Shell Scripting

Hi I have a script that Checks

  • DiskSpace
  • Few Daemons status
  • Few FileAgent Status

I need to have a summary of the results on the top like this
DiskSpace:Ok/Not OK
Few Daemons status:Ok/Not OK
Few FileAgent Status:Ok/Not OK

The actual Script like the if conditions should be followed by the above summary. The requirement is if someone open the output they should have the metadata information like DiskSpace is ok or not ok.
The detailed information should be followed by the summary.

How do i go about it?

Thanks,
Siva

What have you tried so far?
Where are you stuck?

It would also help if you showed us your current script that checks disk space, daemon status, and file agent status. And, since system administration commands can vary from system to system (even on various Linux systems), telling us which Linux system and which version of that system) may help. If you don't know, show us the output from the command:

uname -a

Ok

diskSpace

df -g|grep "path name"|awk '{ print$field "" NF}'|While read output

---------- Post updated at 01:00 PM ---------- Previous update was at 12:55 PM ----------

I have the script in place.
say for Disk check
i have

df -g|grep "$pathanme|awk '{ print $field "" NF }'|while read ouput
do
Variable1=Pathname
Variable2=filesystem
If [ variable 1 -ge Limit];then
   echo "File system space is more"
else
   echo "file system is in permissable limit"
fi
done

This is the format of the script
Likewise i have other scripts in place.

My requirement is for diskspace let us say the filesystem is ok.
So only that information i needed it on the top of the display when i execute the script.

Create script and name it as diskAlert :
-------------------------

#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
  echo $output
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
  if [ $usep -ge 90 ]; then
    echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
     mail -s "Alert: Almost out of disk space $usep%" you@somewhere.com
  fi
done

--

Also do the following to schedule this script to run on regular basis:

# cp diskAlert /etc/cron.daily/
# chmod +x /etc/cron.daily/diskAlert

And modify crontab as follows:

crontab �e

10 0 * * * /path/to/diskAlert

Hello Siva,

Following may help you in same. I have tested it in BASH.

 cat Diskspace_check.ksh
thd=70
Disk_space_value=`df -hP | awk -vTHD="$thd" '(NR>1 && $5 + 0 >= THD){print $NF " has Disk Space more than " THD}'`
if [[ -n $Disk_space_value ]]
then
      echo $Disk_space_value | mailx -s"Disk space report" chumma@Singh.com
fi
 

Just want to add here if you want you can take output of variable named Disk_space_value into a file and send it to email or so.

Thanks,
R. Singh