Monitoring Sript giving random end result


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Monitoring Sript giving random end result
# 1  
Old 04-27-2012
Debian Monitoring Sript giving random end result

Hi Guys,

I am developing a script to monitor GUI based FileNet Component "Component Manager" which logs it's running status in a log file.

Log file is a huge file so in script I put last 300 lines of log file in seperate file and run script every 5 minutes.
I am searching the string "Component Manager stopped" in the below shown log file output.

My requirement is -
If string "Component Manager stopped" is found in log file, a simple file should generate which will be taken by the tivoli alert as tivoli alert input and alert will generate.

Problem faced by me -
I am finding it difficult to handle multiple entries of string "component manager stopped" also I just want the latest entry to be monitored and if once monitored the same alert should not be alerted again .


Log file shows following error message when the component manager stops .
-----------------------------------------------------------------
Code:
pe.txt.2012-03-28:2012/03/28 00:57:48 [RMI TCP Connection(536)-10.87.130.42] INFO  filenet.vw.ComponentIntegrator  Component Manager stopped.
pe.txt.2012-03-28:2012/03/28 00:57:48 [RMI TCP Connection(536)-10.87.130.42] INFO  filenet.vw.ComponentIntegrator  Component Manager stopped.

------------------------------------------------------------------

Script Description -
In my script , I am searching for string from bottom to top in log file to get latest alert only and if entry found take it's time stamp save it in text file , compare the time stamp with current time stamp ..if it matches then do not generate alert but if it does not match , generate alert ..

Script code -
Code:
#!/bin/ksh
tail -300 pe_1.txt > msgtime.txt
head -1 newfile.txt | sed 's/://g' | read temp
tac msgtime.txt | grep "Component Manager stopped" msgtime.txt | while read line
                                                  do
                                                  awk '{ print $2}' | sed 's/://g' | read msgtime
                                                  done
   
test $temp -eq $msgtime
if [ $? -eq 0 ]; then
   echo "tivoli already generated"
else
   echo "$msgtime" > newfile.txt
   touch $msgtime.txt ComponentManagerDown_on_`hostname`.txt
fi


kindly help for any modifications required as the script does not give the result intended .

Last edited by Franklin52; 04-27-2012 at 05:40 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 04-27-2012
Please post what Operating System and version you are running.

Quote:
Log file is a huge file so in script I put last 300 lines of log file in seperate file
What size is a typical log file and how many records in a typical log file?
Code:
ls -lad pe_1.txt
wc -l pe_1.txt

And how many "Component Manager stopped" lines:
Code:
grep "Component Manager stopped" pe_1.txt | wc -l

Most versions of tail have a limited buffer. What do you get for:
Code:
tail -300 pe_1.txt | wc -l

# 3  
Old 04-28-2012
Please note that my code is following and not the previously posted -

Code:
#!/bin/ksh
tail -300 pe_1.txt > msgtime_1.txt

tail -r msgtime_1.txt > msgtime.txt

head -1 newfile.txt | sed 's/://g' | read temp

grep "Component Manager stopped" msgtime.txt | while read line
                                                 do
                                                     awk '{ print $2}' | sed 's/://g' | read msgtime
                                                done

test $temp -eq $msgtime
if [ $? -eq 0 ]; then
   echo "tivoli already generated"
else
   echo "$msgtime" > newfile.txt
   touch $msgtime.txt ComponentManagerDown_on_`hostname`.txt
fi

Methyl,
answers to your queries -
# AIX OS -> 5.3.12.1 .
# Log file size varies from 30 KB to 0.13 GB daily.
# The number of times , we would try to start the component manager and stop it ,
we get the entry "component manager stopped" string in log file.

Please let me know any queries , looking fwd to your reply .

Moderator's Comments:
Mod Comment Welcome to the UNIX and Linux Forums. Please use [code][/code] tags. Video tutorial on how to use them

Last edited by Scrutinizer; 04-28-2012 at 09:54 AM.. Reason: code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

CUT command not giving correct result inside loop

Hi, i have a source file and have 3 columns and separated by "|" .i want to split this 3 columns in different variable.When i am executing this values indivisually giving correct result but when the same execute inside a for loop,it's giving issues. Src file(jjj.txt) -------... (8 Replies)
Discussion started by: raju2016
8 Replies

2. Shell Programming and Scripting

Grep command giving different result for different users for same command

Hello, I am running below command as root user #nodetool cfstats tests | grep "Memtable switch count" Memtable switch count: 12 Where as when I try to run same command as another user it gives different result. #su -l zabbix -s /bin/bash -c "nodetool cfstats tests | grep "Memtable switch... (10 Replies)
Discussion started by: Pushpraj
10 Replies

3. UNIX for Dummies Questions & Answers

VxWorks RTC time giving wrong value at random times

I am seeing a scenario where in if the TIMEZONE environment variable value is set to nothing i.e. putenv "TIMEZONE=" the hardware clock is +1 to software clock.Pasted below the results displayed: -> envShow (global environment) 0: TSC_TIME_FROM_RESET=420150.971529 seconds 1:... (0 Replies)
Discussion started by: snehavb
0 Replies

4. Shell Programming and Scripting

Remove 3rd character from the end of a random-length string

Hi, I hope someone can share there scripting fu on my problem, I would like to delete the 3rd character from a random length of string starting from the end Example Output Hope you can help me.. Thanks in advance.. (3 Replies)
Discussion started by: jao_madn
3 Replies

5. Shell Programming and Scripting

Disk Monitoring shell script giving incorrect information

Hi All, OS: Linux 86x64 bits Red Hat Linux I get the email alert for the following when Alert condition is set for 30: /dev/sda1 99M 21M 74M 22% /boot -> Below 30%(Should not get the email alert) Expected output as per E-Mail alert: /dev/sda3 20G ... (2 Replies)
Discussion started by: a1_win
2 Replies

6. AIX

errpt not giving a result

my system get rebooted by its self after its came up i try to check the error log P690/>errpt | more Cannot open error message catalog /usr/lib/nls/msg/en_US/codepoint.cat. The error report will still run, but it will not have explanatory messages P690/>ls -lrt... (1 Reply)
Discussion started by: thecobra151
1 Replies

7. Programming

Test program not giving expected result

I have five classes. 2 composition classes,1 aggregation class and 1 dependency class.I have coded all the classes but one of my test program is not giving me the expected result.I have the following classes: TimeStamp Interval (composition of 2 TimeStamps) TimeSheet ( aggregation of many... (3 Replies)
Discussion started by: moraks007
3 Replies

8. Shell Programming and Scripting

My script is not giving result for 2 or more arguments

Hi, I am new to shell scripting and my below script is not giving result for 2 or more arguments. Can anyone help pls. #!/bin/sh sname=$(basename $(readlink -nf $0)) echo "This is $sname, running at $(date)" echo "It is running on $(hostname)" echo "Script being run by" echo " User... (3 Replies)
Discussion started by: baigmd
3 Replies

9. UNIX for Dummies Questions & Answers

Script giving different result on Linux compared to Unix

Hi I have a script executing fine in Unix but in linux I am getting different result. I have three files under /local/home/temp/Gen test.sh list.txt shst.txt Contents of test.sh -------------------------- #!/bin/ksh K=0; SCRIPT_DIR=/local/home/temp/Gen cat... (2 Replies)
Discussion started by: malavm
2 Replies

10. UNIX for Advanced & Expert Users

Sript need, please respond

Hi I am looking for the script which can move 1month old data from a TXT file.actully in this file data is appended on daily basis.pleasehalp me out. Here is the file content : $head abc.txt. 20070301130052,xxz. 20070307132111,cvasjchgjhcg gacg chjbgasjkchjk.... (3 Replies)
Discussion started by: vpandey
3 Replies
Login or Register to Ask a Question