1833569 Members
3643 Online
110061 Solutions
New Discussion

checklist script

 
SOLVED
Go to solution
kacou
Regular Advisor

checklist script

How are you guys doing ? ..

Coming to the question ..

I am looking for a script which will will allow me to make a checklist on a hp-ux server B11.23 every morning
5 REPLIES 5
Jeeshan
Honored Contributor
Solution

Re: checklist script

this is very much simple. but can get an idea

#!/usr/bin/sh

echo "Server name: `hostname` OS: `uname -s` ";
echo "Date: `date` ";
echo "Currently logged users:" ; who -a |grep 172.16.* ;
#echo "Files in `pwd`" ; ls -l ;
echo "last 25 lines of syslog file:" ; tail -25 /var/log/messages;
echo "Used Disk Space" ;df -h ;
#echo "Total No# of oracle process:" ; ps -fu oracle |wc -l ;
echo "Total No# of root process:" ; ps -fu root |wc -l ;
echo "Please wait command is running need 25 second to finish" ; sar -u 5 5 ;
#echo "Plase wait script is runining, need 45 second to finish" ;./system.sh ;
echo "wait for a while"; sar -d 1 1;
echo "wait for a while"; sar -q 5 5 ;
echo "wait for some times"; sar -w 5 5 ;
echo "Currently Logged: ";w ;
#exit 0 ;
#sleep 300
echo " "
echo "Process Finished:";date;
a warrior never quits
SUDHAKAR_18
Trusted Contributor

Re: checklist script

Write a script named dailyscript which includes,

grep -i full /var/adm/syslog/syslog.log
grep -i fail /var/adm/syslog/syslog.log
grep -i fault /var/adm/syslog/syslog.log
grep -i error /var/adm/syslog/syslog.log
grep -i scsi /var/adm/syslog/syslog.log
grep -i lbolt /var/adm/syslog/syslog.log
grep -i ems /var/adm/syslog/syslog.log
grep -i lpmc /var/adm/syslog/syslog.log
grep -i critical /var/adm/syslog/syslog.log
grep -i Recovered /var/adm/syslog/syslog.log
grep -i Restored /var/adm/syslog/syslog.log
grep -i incorr /var/adm/syslog/syslog.log
grep -i su: /var/adm/syslog/syslog.log
grep -i cmcld /var/adm/syslog/syslog.log
tail -30 /var/adm/sulog
netstat -in |pg
netstat -nvr |pg
netstat -an |grep "ESTABLISHED" |wc -l |pg
cat /var/adm/syslog/syslog.log
grep -i "connection logging"
grep -i LVM /var/adm/syslog/syslog.log
grep -i scsi /var/adm/syslog/syslog.log
ll /var/opt/resmon/log

Regards,
Sudhakar
Hein van den Heuvel
Honored Contributor

Re: checklist script

Sudhakar,

Thanks for the inputs, but you are not actually running that every day I hope??

- Why grep syslog over and over? Let grep look for all 'intersting' lines in one command? But what about new, unlisted problem signatures? It may be better to let grep exclude lines which are deemed 'not so interesting' for the application such that you will also catch those 'new' errors.

- If you do want to grep for problems in 'zones' (error, fail, ...) then don't you want to identify those zones with a seperator (a few empties, a line of dashes, whatever).

- By doing the known potential issues in chunks, you'll loose easy access to time context.

- Do you really want to see last weeks errors highlighted again and again?

Imho you need either a marker file with the last record looked at last time (tail 1 syslog > last_syslog_looked_at :-),
or you need to pre-filter for yesterday (and today ?!)

For example:

$ yesterday=$(TZ=$TZ+24 date +"%b %e")
$ today=$(date +"%b %e")
$ echo $yesterday $today
Jun 30 Jul 1
$ grep -E "^$yesterday|^$today" /var/adm/syslog/syslog.log | grep -iE "error|fail"

To 'analyze' syslog properly I suspect that you quickly need a real script instead of a buch of greps.

Here is a starting point in the shape of a perl scripts which goes over an input file (syslog) just once and examines each line for a list of matches.
On match it pushed that line into an array for those matches.
At end of input report for each match type:

$ cat syslog_filter.pl
use warnings;
use strict;
my @targets = qw ( error fail hein fault );
my @AoA; # Array of Arrays
my $i;
while (<>) {
foreach $i ( 0 .. @targets - 1 ) {
if (/$targets[$i]/i) {push @{$AoA[$i]}, $_};
}
}
foreach $i ( 0 .. @targets - 1 ) {
print "----- $targets[$i] -----\n";
print @{$AoA[$i]} if $AoA[$i];
}

Run as:

#perl syslog_filter.pl /var/adm/syslog/syslog.log


Enjoy folks,
Hein.
Torsten.
Acclaimed Contributor

Re: checklist script

BTW, every message sent by EMS to syslog is also sent to root by mail - consider to check roots email.
Should be enough for most cases.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Bill Thorsteinson
Honored Contributor

Re: checklist script

Consider using logcheck run as a cron job. It can classify the level of concern for various messages.