Sponsored Content
Top Forums Shell Programming and Scripting Disk Monitoring shell script giving incorrect information Post 302549781 by a1_win on Wednesday 24th of August 2011 01:58:08 AM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
DEVNAME(3)						   BSD Library Functions Manual 						DEVNAME(3)

NAME
devname -- get device name LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/stat.h> #include <stdlib.h> char * devname(dev_t dev, mode_t type); char * devname_r(dev_t dev, mode_t type, char *buf, int len); char * fdevname(int fd); char * fdevname_r(int fd, char *buf, int len); DESCRIPTION
The devname() function returns a pointer to the name of the block or character device in /dev with a device number of dev, and a file type matching the one encoded in type which must be one of S_IFBLK or S_IFCHR. To find the right name, devname() asks the kernel via the kern.devname sysctl. If it is unable to come up with a suitable name, it will format the information encapsulated in dev and type in a human-readable format. The fdevname() and fdevname_r() function obtains the device name directly from a file descriptor pointing to a character device. If it is unable to come up with a suitable name, these functions will return a NULL pointer. devname() and fdevname() return the name stored in a static buffer which will be overwritten on subsequent calls. devname_r() and fdevname_r() take a buffer and length as argument to avoid this problem. EXAMPLES
int fd; struct stat buf; char *name; fd = open("/dev/tun"); fstat(fd, &buf); printf("devname is /dev/%s ", devname(buf.st_rdev, S_IFCHR)); printf("fdevname is /dev/%s ", fdevname(fd)); SEE ALSO
stat(2) HISTORY
The devname() function appeared in 4.4BSD. The fdevname() function appeared in FreeBSD 8.0. BSD
February 22, 2005 BSD
All times are GMT -4. The time now is 06:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy