Mountpoint monitoring script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mountpoint monitoring script
# 1  
Old 05-13-2014
Mountpoint monitoring script

Hi,

I am new to shell scripting. I prepared a very simple script to monitor mount points but not geting desired output.

Code:
df -h|awk -F' ' '{ if ($5 >= 80) print "CRITICAL\n" $NF " mount point has reached " $5;}'|sed -n '3,$p'

When I run above script in Sun solaris box it is executing perfectly fine.
But when I am running this script in Linux box i am not getting desired output.

Can you help please.

Many thanks in advance
# 2  
Old 05-13-2014
Please post the output of the command df -h and the desired output.
# 3  
Old 05-13-2014
output of
Code:
df -h

Code:
Filesystem             size   used  avail capacity  Mounted on
/dev/vx/dsk/rootvol    4.3G   3.6G   684M    85%    /
/proc                    0K     0K     0K     0%    /proc
mnttab                   0K     0K     0K     0%    /etc/mnttab
fd                       0K     0K     0K     0%    /dev/fd
/dev/vx/dsk/var        2.0G   1.5G   392M    80%    /var
swap                   2.8G   112K   2.8G     1%    /var/run
swap                   3.8G  1021M   2.8G    27%    /tmp

desired output of
Code:
df -h|awk -F' ' '{ if ($5 >= 80) print "CRITICAL\n" $NF " mount point has reached " $5;}'|sed -n '3,$p'

Code:
CRITICAL
/ mount point has reached 85%
CRITICAL
/var mount point has reached 80%

# 4  
Old 05-13-2014
And how is the output of df -h on the linux system?
# 5  
Old 05-13-2014
output on linux

Code:
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-root
                      4.0G  627M  3.2G  17% /
tmpfs                 7.9G  624M  7.3G   8% /dev/shm
/dev/sda1             485M   77M  383M  17% /boot
/dev/mapper/rootvg-home
                      248M   70M  166M  30% /home
/dev/mapper/rootvg-opt
                      4.0G  1.4G  2.4G  38% /opt
/dev/mapper/rootvg-osmf
                      4.0G  582M  3.2G  16% /osmf/mgmt
/dev/mapper/rootvg-scheduler
                      217M  6.1M  200M   3% /osmf/mgmt/scheduler
/dev/mapper/rootvg-usr
                      5.0G  1.1G  3.7G  23% /usr
/dev/mapper/rootvg-var
                      4.0G  1.1G  2.7G  30% /var
none                  1.0G  430M  595M  42% /tmp

when i run script
Code:
df -h|awk -F' ' '{ if ($5 >= 10) print "CRITICAL\n" $NF " mount point has reached " $5;}'|sed -n '3,$p'

getting below output

Code:
CRITICAL
/dev/shm mount point has reached 8%
CRITICAL
/boot mount point has reached 17%
CRITICAL
/tmp mount point has reached 42%

# 6  
Old 05-13-2014
You may have to remove the "%" symbol form the %Use.
Try:
Code:
df -h |awk '{gsub("%","",$5);} $5 >= 10  print "CRITICAL\n" $NF " mount point has reached " $5;}'|sed -n '3,$p'

# 7  
Old 05-13-2014
Try this:
Code:
df -h | awk 'NF==1{f=$1;getline;$0=f FS $0} int($5) >=80 {print "CRITICAL\n" $1 " has reach " $5}' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Creating mountpoint in Linux from rawdevices without lv's

Hello, I need to create mountpoint in linux from rawdevices without using lv's. Please help me with the steps to do this. Best regards, Vishal (2 Replies)
Discussion started by: admin_db
2 Replies

2. AIX

Space not getting released on the mountpoint

root@atldc-oragrid-ux01:/oragrid_01> du -sg * 0.58 11gR2gridBase 47.31 Grid_11203 4.17 app 0.00 lost+found 0.01 oraInventory root@atldc-oragrid-ux01:/oragrid_01> cd Grid_11203 root@atldc-oragrid-ux01:/oragrid_01/Grid_11203> du -sg *|sort 0.00 JRE 0.00 OPatch_old 0.00 ... (11 Replies)
Discussion started by: Vishal_dba
11 Replies

3. UNIX for Advanced & Expert Users

Unable to format new mountpoint

Can some one help me i try to mkfs new mountpoint from storageIBM but give some problem # mkfs -t ext3 /dev/sdd1 mke2fs 1.39 (29-May-2006) /dev/sdd1 is apparently in use by the system; will not make a filesystem here! my os is redhat 5.3 using fdisk # fdisk -l Disk /dev/sda: 298.9... (4 Replies)
Discussion started by: vickyid04
4 Replies

4. Solaris

Mountpoint 100% but no data inside

One of our mountpoint shows 100% but we have less data on that mountpoint. Pls help me to find which data/process holds the space. bash-3.00$ cd /oracle/server_software/oracle10 bash-3.00$ du -sh * 0K admin 260M app 0K flash_recovery_area 0K lost+found 0K oradata ... (6 Replies)
Discussion started by: rock123
6 Replies

5. AIX

read lv mountpoint information directly from disk

Hello, I need to get the lv mountpoint from the hdisk directly (from vgda i guess) and not from odm or /etc/filesystems I knew the command, but unfortunately I forgot it ;) cheers funksen (5 Replies)
Discussion started by: funksen
5 Replies

6. UNIX for Advanced & Expert Users

Filesystem and partition, mountpoint

Hello All, I am new to System/plat-form administration work. Right now I am facing some issues while creating the filesystem and mounpoint. I am using Linux 6.0 SuSE 11. Last time I was used one command to partition the given space along with filesystem in SuSE 9 and it was done in GUI mode but... (0 Replies)
Discussion started by: nvkuriseti
0 Replies

7. UNIX for Dummies Questions & Answers

Testing NAS /mountpoint accessible

Hello. What's the best way to ensure that a NFS filesystem mounted from a disk-cabine (NAS) is accessible? My proposal: 1. ping to the ip of the cabine 2. verify filesystem is mounted 3. touch a file inside the /mountpoint Any other suggestions? Thank you! (2 Replies)
Discussion started by: asanchez
2 Replies

8. Shell Programming and Scripting

Get mountpoint from filename

Dear Guru's Given a full filename /a/b/c/d/file.txt how do i determine what part is the mount point ( say /a/b). Cheers, Karel (6 Replies)
Discussion started by: karelb
6 Replies

9. Solaris

problem in restoring mountpoint in Solaris

Hi, I am restoring the existing mount point on Solaris and getting below mentioned error mount: /dev/dsk/c0t2d0s6 is already mounted or /billing is busy I uses truss command to see the output and snapshot is below. Please help me to restore the mount point, # truss -fa mount -F... (3 Replies)
Discussion started by: helplineinc
3 Replies

10. UNIX for Advanced & Expert Users

HPUX : identify NFS mountpoint

Is there a way to identify a directory as the start of an NFS mountpoint in HPUX 11.0? Using existing utilities & without root priv. If you stat the directory and use the S_ISNWK macro you can find network special files that way. The requirement will have to go through other channels if I need... (5 Replies)
Discussion started by: jim mcnamara
5 Replies
Login or Register to Ask a Question