Daily health check script


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Daily health check script
# 1  
Daily health check script

Hi

I am still learning how to write shell scripts, so I started to write a script like this:
Code:
#!/bin/sh
date 
echo
outputOK () {
  echo $1 "[ ok ]"
}

outputOK () {
  echo $1 "[ warning ]"
}

for vol in `/usr/bin/grep -E 'hfs|vxfs|nfs|cifs' /etc/fstab | egrep -v '^#' | awk '{ print $3 }'`
do
if bdf    $vol | grep $vol > /dev/null
then
 outputOK "Filesystem: $vol    mounted"
 else    outputW  "Filesystem: $vol    NOT MOUNTED"
fi
done

But when I run, I got the following:

Code:
bdf: vxfs: No such file or directory
Filesystem: vxfs NOT MOUNTED [ Warning ]

Can you help

FR
# 2  
Hi,

You are aware that bdf is a HPUX command, are you sure that that is the platform? Also it would seem that the output is expecting to see a Veritas volume.

Regards

Dave
# 3  
Plaase post what Operating System and version and what Shell this is.

If this is HP-UX, the 3rd field in /etc/fstab is the filesystem type (e.g. vxfs). The second field is the filesystem mountpoint.

If I wanted to know which filesystems were mounted, I'd use the mount command (without any parameters).
# 4  
Daily health check script

The O.S. is hp-ux, that is why I use bdf:

Code:
#uname -a
HP-UX prep03 B.11.31 U ia64 3933449231 unlimited-user license

---------- Post updated 16-08-12 at 08:44 AM ---------- Previous update was 15-08-12 at 10:18 AM ----------

Any ideas on this?

Please help
# 5  
Then main fault in your script is that the awk is extracting field 3 not field 2 from /etc/vfstab .
This User Gave Thanks to methyl For This Post:
# 6  
Hi

Thanks a lot, it worked now:

Code:
#./daily_check
Fri Aug 17 17:46:08 SAST 2012

Filesystem: / mounted [ OK ]
Filesystem: /stand mounted [ OK ]
Filesystem: /tmp mounted [ OK ]
Filesystem: /home mounted [ OK ]
Filesystem: /opt mounted [ OK ]
Filesystem: /usr mounted [ OK ]
Filesystem: /var mounted [ OK ]
prep03[171]/tmp/fr #

I will try and add more commands
# 7  
Hi

I am trying to use a modified code to check for lan, disk but with no success, please can you give me some hints:
Code:
#check if NIC cards are OK

if [ `ioscan -fnC lan |wc -l` != 1 ]
then
 if [ `ioscan -fnC lan  |grep CLAIMED|wc -l` != `ioscan -fnC lan |grep NO_HW|wc -l` ]
then
 outputW "Ethernet: Offline NICs detected."
else
 outputOK "Ethernet: All NICs are online"
fi
else
 outputOK "Ethernet: No NICs found."
fi

# check if Disks are OK

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

and the output I am getting is:

Code:
Ethernet: Offline NICs detected. [ Warning ]


SAN: Offline HBAs detected. [ Warning ]


Disks: Not CLAIMED disks detected. [ Warning ]

and if I do ioscan:
Code:
prep03[133]/tmp/fr #ioscan -fnC lan
Class     I  H/W Path  Driver S/W State   H/W Type     Description
===================================================================
lan       0  0/1/1/0   igelan   CLAIMED     INTERFACE    HP PCI-X 1000Mbps Dual-port Built-in
lan       1  0/1/1/1   igelan   CLAIMED     INTERFACE    HP PCI-X 1000Mbps Dual-port Built-in
lan       2  0/2/2/0   igelan   CLAIMED     INTERFACE    HP PCI-X 1000Mbps Dual-port Built-in
lan       3  0/2/2/1   igelan   CLAIMED     INTERFACE    HP PCI-X 1000Mbps Dual-port Built-in
prep03[134]/tmp/fr #nwmgr

Name/          Interface Station          Sub-   Interface      Related
ClassInstance  State     Address        system   Type           Interface
============== ========= ============== ======== ============== =========
lan2           UP        0x78E7D1723F0E igelan   1000Base-SX
lan0           DOWN      0x78E7D1723F0C igelan   1000Base-SX
lan1           DOWN      0x78E7D1723F0D igelan   1000Base-SX
lan3           UP        0x78E7D1723F0F igelan   1000Base-SX
lan900         DOWN      0x000000000000 hp_apa   hp_apa
lan901         DOWN      0x000000000000 hp_apa   hp_apa
lan902         DOWN      0x000000000000 hp_apa   hp_apa
lan903         DOWN      0x000000000000 hp_apa   hp_apa
lan904         DOWN      0x000000000000 hp_apa   hp_apa
prep03[135]/tmp/fr #ioscan -fnC fc
Class     I  H/W Path     Driver S/W State   H/W Type     Description
====================================================================
fc        0  0/3/0/0/0/0  fclp   CLAIMED     INTERFACE    HP 403621-B21 4Gb PCIe 2-port LPe1105 FC Mezzanine Adapter
                         /dev/fclp0
fc        1  0/3/0/0/0/1  fclp   CLAIMED     INTERFACE    HP 403621-B21 4Gb PCIe 2-port LPe1105 FC Mezzanine Adapter
                         /dev/fclp1
prep03[136]/tmp/fr #ioscan -fnC disk
Class     I  H/W Path  Driver S/W State   H/W Type     Description
==================================================================
disk      0  0/2/1/0.0.0.0.0  sdisk   CLAIMED     DEVICE       HP      IR Volume
                      /dev/dsk/c0t0d0     /dev/dsk/c0t0d0s2   /dev/rdsk/c0t0d0    /dev/rdsk/c0t0d0s2
                      /dev/dsk/c0t0d0s1   /dev/dsk/c0t0d0s3   /dev/rdsk/c0t0d0s1  /dev/rdsk/c0t0d0s3
prep03[137]/tmp/fr #

Please can you help
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #321
Difficulty: Medium
DHCP stands for Dynamic Host Configuration Port.
True or False?

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