This is a discussion on Shell script to check the disk space on remote systems within the Shell scripting forums, part of the Development/Scripting category; Hi, I would like to write an shell script on linux(bash), which would check the disk space on remote systems ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
Hi,
I would like to write an shell script on linux(bash), which would check the disk space on remote systems and allow to build if the free space is more than 70%. can any one wirte a script for the same. |
| Sponsored Links | ||
|
|
|
||||
|
Pretty simple if remote server runs ssh server all you have to do is ssh into box and login using SSH keys and run df command:
Code:
ssh user@remote-server.ip.com df Second step is modify script - Shell script to watch the disk space | nixCraft Here is modified script, make sure you setup ssh username and IP/hostname: Code:
#!/bin/bash
ADMIN="me@somewher.com"
ALERT=70
ssh user@ip-address.com df -H > /tmp/df.out
cat /tmp/df.out | 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 $ALERT ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $usep" $ADMIN
fi
done
|
|
|||
|
Vivek,
Thanks for the script, it was perfect,but now my boss reliased that he want the processes running on remote systems and not the disk free space. Actually I wanted to use dmake on remote systems,so when i execute the script it need to check the processes running and the cpu occupied. so that the dmake can be performed. Currently the dmake is failing on some of the remote systems if the cpu occupied is crossing certian limit. please do help me on this too. |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linux check disk error | raj | Linux hardware | 3 | 12-07-2007 11:00 AM |
| Shell script to perform operation on remote server | vivekv | Shell scripting | 3 | 10-24-2007 01:10 AM |
| Linux Shell script to mount remote windows share | angelus_kit | Shell scripting | 2 | 09-06-2007 08:18 PM |
| Shell script to monitor remote local http or port 80 | amigo28 | Shell scripting | 1 | 02-12-2007 10:58 PM |
| shell script to open log files and check for faults | trueman82 | Shell scripting | 1 | 11-23-2006 03:35 AM |