Disk Monitoring shell script giving incorrect information


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Disk Monitoring shell script giving incorrect information
# 1  
Old 08-24-2011
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:
Code:
/dev/sda1              99M   21M   74M  22% /boot

-> Below 30%(Should not get the email alert)

Expected output as per E-Mail alert:

Code:
/dev/sda3              20G   13G  6.2G  68% /

(Not receiving any e-mail alert for this which is incorrect as the sapce is more than 30)


df -h output for:
Code:
df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              20G   13G  6.2G  68% /
/dev/sda1              99M   21M   74M  22% /boot

Script:
Code:
cat diskspace1.sh

#!/bin/bash

export DBALIST="xyz@abc.com"

devnames="/dev/sda3 /dev/sda1 /oradata  /orabkup  /software /backup /patches"

for devname in $devnames
do
   p=`df -h $devname | grep -v ^File | awk '{printf ("%i", $4); }'`
   if [ $p -ge 30 ]
   then
      df -h $devname | mail -s "$devname is low on space" $DBALIST
   fi
done

Could someone please let me know what's wrong here?

Thanks for your time and help.

Regards,
a1_win

Moderator's Comments:
Mod Comment Please use [code] and [/code] tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks. You got a PM with a guide.

Last edited by zaxxon; 08-24-2011 at 03:11 AM.. Reason: code tags
# 2  
Old 08-24-2011
Code:
$ df -h | grep % | sed 's,%,,g' | awk ' { if ($5>=30) {print $0} } ' > disk_chk_out
$ mailx -s "Disk Check > 30%" abc@xyz.com < disk_chk_out

# 3  
Old 08-24-2011
You already have 2 threads going about the same script, just with a little difference in progress. Please refrain from opening a new thread for every new problem in the script, thanks.

Continue here
https://www.unix.com/shell-programmin...ll-script.html
or there
https://www.unix.com/shell-programmin...t-issue-2.html

- closed -
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

wc -L giving incorrect length of longest line

Running below line gives 3957 as length of longest line in file 20121119_SRMNotes_init.dat awk ' { if ( length > 3950 ) { x = length } }END{ print x }' 20121119_SRMNotes_init.dat While wc -L 20121119_SRMNotes_init.dat gives output as 4329. Why is there a difference between these two commands.... (2 Replies)
Discussion started by: Satish Mantha
2 Replies

2. Shell Programming and Scripting

awk sum giving incorrect value

cat T|awk -v format=$format '{ SUM += $1} END { printf format,SUM}' the file T has below data usghrt45tf:hrguat:/home/hrguat $ cat T -1363000.00123456789 -95000.00789456123 -986000.0045612378 -594000.0015978 -368939.54159753258415 -310259.0578945612 -133197.37123456789... (4 Replies)
Discussion started by: zulfi123786
4 Replies

3. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: dhirajdsharma
2 Replies

4. Shell Programming and Scripting

Script for monitoring disk failures

Hi , Does anyone have a script for monitoring disk failures on a Solaris 10/11 box? Need one today ASAP, thnks in advance. (2 Replies)
Discussion started by: walnutpony123
2 Replies

5. Shell Programming and Scripting

Disk Space Monitoring Script - OLD and NEW

It's the old thread "Disk Space Monitoring Script", modified for UNIX This is the new code: df -k | awk ' { if ( int($4) > 90) {subject = $1 " More than 90% disk usage. Used: " $4 email = "email@test.com" print subject cmd = "mailx -s \"" subject "\" " email cmd | getline... (4 Replies)
Discussion started by: dungureanu
4 Replies

6. Solaris

iSCSI disk showing incorrect size

Hi, I have a very frustrating issue! I hope you guys can assist When a disk is presented out the iSCSI target display a lower disk capacity SOLARIS VERSION is SOLARIS 10 05/09 Kernel Patch 139555-31 ISCSI Patch 119090-31, 141878-11 Unix Commands To discover Target bash-3.00# i... (0 Replies)
Discussion started by: capitalexall
0 Replies

7. UNIX for Advanced & Expert Users

xbindkeys giving wrong mapping information

Hello, I'm having a problem with xbindkeys giving the wrong mapping information, hence I can't get it work at all when trying new mappings from this machine. From another computer, I have some definitions for xbindkeys (made with xbindkeys-config). These key codes work correctly on this... (0 Replies)
Discussion started by: Narnie
0 Replies

8. SCO

Incorrect Disk Partition - New Install SCO 6.0

New IBM x3400 machine with a raid 5 configuration. Go through the early setup routine to the point where I answer the questions for time zone, machine name. Enter continue and get a message stating : "Incorrect disk partitioning cannot continue" This is a sco message, refers to the installation... (1 Reply)
Discussion started by: wjbtms
1 Replies

9. Shell Programming and Scripting

mv command is giving error in shell script

Hi, In my shell script when I am using mv command using shell variables it is giving me error of syntax. Following is the shell script: file_edifice="*.txt" fquote="'" fdquote=\" for file in $file_edifice do file_name=$fquote$file$fquote tofile_name=`date... (5 Replies)
Discussion started by: gammit
5 Replies

10. Shell Programming and Scripting

Disk Space Monitoring Script

#!/bin/bash # Disk Space Monitoring for more than 95 % # and Sending Alerts by Mail if ; then `df -k |awk '$5 > 95 {print $1 " ----------- " $5}' |mailx -s "More than 95% disk usage in DEV" email@test.com'; else exit 0 fi I get the... (8 Replies)
Discussion started by: sriram003
8 Replies
Login or Register to Ask a Question