Daily health check script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Daily health check script
# 8  
Old 08-24-2012
Let's pick one of the tests and assume that OutputW and OutputOK are other scripts or local functions.

Quote:
if [ `ioscan -fnC disk |wc -l` != 1 ]
then
if [ `ioscan -fnC disk |grep CLAIMED|wc -l` != `ioscan -fnC disk |grep NO_HW|wc -l` ]
then
outputW "Disks: Not CLAIMED disks detected."
else
outputOK "Disks: All Disks are CLAIMED"
fi
else
outputOK "Disks: No Disks found."
fi
There is a basic logic error here. The main condition does not work unless perhaps there is only ever one disk on a HP-UX system! Not sure about the syntax either.
We should run ioscan only once because it is a very powerful program and can cause the view to change. Be aware that running ioscan can cause dead hardware to completely disappear from the inventory (and therefore not show as NO_HW).
Let's try something lke this (untested and purely to demonstrate logic and not recommended).

Code:
ioscan -fnC disk > /tmp/ioscan_fnC_disk # Store output from ioscan
total_count=$(egrep "CLAIMED|NO_HW" ioscan_fnC_disk|wc -l)
dead_count=$(grep "NO_HW" ioscan_fnC_disk|wc -l)
if [ ${total_count} -eq  0 ]
then
        outputW "Disks: No Disks found."
else
        if [ ${dead_count} -gt 0 ]
        then
              outputW "Disks: Not CLAIMED disks detected."
        else
              outputOK "Disks: All Disks are CLAIMED"
        fi
fi
rm -f ioscan_fnC_disk # Clean up workfile

On my systems I run ioscan -fn (i.e. all hardware) daily and compare this output with the output from the same command yesterday. No attempt to predict every possible error output from ioscan. If there are differences, this is reported as a major error. Obviously if you detect a failure and repair it you will get one false alert for the broken hardware re-appearing.
I started doing this after discovering that a major hardware failure can cause a crash and reboot during which the dead hardware can completely and silently disappear from the ioscan inventory.
That reminds me. Don't forget to have a script to read the syslog and identify anything abnormal (and I don't mean broken printers).

Last edited by methyl; 08-24-2012 at 07:44 PM.. Reason: minor typos
This User Gave Thanks to methyl For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX Health Check

Hi everyone, I am new to the Unix admin position, needed some help. My management wants to report how their over all AIX servers / environment is doing so far. I've been researching and found multiple commands to run on each LPAR, well I have few questions and also wanted to share the commands Im... (12 Replies)
Discussion started by: Adnans2k
12 Replies

2. Shell Programming and Scripting

Health check report

Hi Team, I am writing a small script in that I want collect all servers of /opt and /stage. Below is my small script #!/bin/ksh #checking Media server opt_Disk_Space_logs myclient=`cat media_server.txt` > opt_logs.txt printf " Server Name\tsize\tused\tavail\tcapacity\tMounted... (12 Replies)
Discussion started by: bashi77
12 Replies

3. Shell Programming and Scripting

Script to check the health of a database

need a script to check the health of a session server database. It must read the data base and send an alert if the database is unavailable. If its unavailable, we will want to bring down the database listener to force failover. can u guyz help me in doing this. what information do i need... (1 Reply)
Discussion started by: remo999
1 Replies

4. HP-UX

HP-UX Health Check

Hi Experts, I want to check health of hp-ux box. Basically I want to check if there are possibilities of network/memory/cpu bottleneck? Are there are any commands available other than glance in hp-ux for the same? (11 Replies)
Discussion started by: sai_2507
11 Replies

5. Shell Programming and Scripting

Health check script

There are 3 servers . I want to fire commands df -kh and mpstat -P ALL on those individual servers and retrieve particular values to genrate reports. This part is almost done. But i am facing issue when i need to compile the reports from all three servers on to one server in order to generate a... (1 Reply)
Discussion started by: pratikm23
1 Replies

6. AIX

AIX Health Check script

Hi Everyone, Can you please help me put together a aix health check script that will check the status of CPU,Memory,Adapter, Filesystems (threshold 80%) and Disks.Im thinking of deploying a script to gather the required data in all the 22 servers and probably send out a mail if anything needs... (3 Replies)
Discussion started by: R!C
3 Replies

7. Shell Programming and Scripting

Health check script

Hi, I have a server type(A group of AIX,HP-UX and Linux servers running with different appn) in which i need to do health check(memory,cpu,h/w etc). I am planning to automate the same. Please help me out in writing the same. Thanks Renjesh Raju (9 Replies)
Discussion started by: Renjesh
9 Replies

8. AIX

AIX Health Check

Hi All, I would like to know if there is a downloadable AIX health check script available from IBM that would print a report of a servers health status. I've been working on a number of Sun Solaris servers and Sun provide a sun checkup script which can give you an ORI figure as well as a list... (3 Replies)
Discussion started by: backslash
3 Replies

9. Shell Programming and Scripting

need help to write script to check the process health and automatically restart it

I am working on a project, which need to constantly watch the process, and check its status, if it was dead, it should be restart automatically. Please kindly refer me to URL which teach how to write this kind of script, or service. Thanks. (1 Reply)
Discussion started by: dragondad
1 Replies

10. HP-UX

check health

Dear Gentelmen I need command for display to me the following statement: -battery state -The application if working or not -The cpu is working or not -The power supply is working or not -The Data base is workig or not (2 Replies)
Discussion started by: magasem
2 Replies
Login or Register to Ask a Question