Useful Scripts for Overworked Administrators
By Mark Prager, May 13, 2004
I work for a startup company, which means we face the usual problems of financing. Because many automated system tools are very expensive, I have written several scripts to help automate some of my daily tasks that monitor our system. I write these scripts in ksh and csh, and, where necessary, a few small C programs because these seem to be the least complicated. The C programs were compiled with gcc. Similarly, the scripts usually come out self-documenting, which means I can leave them running and return to them several months later and still understand what I was trying to do. Also, the scripts run under Solaris 2.5.1-7.0, and can easily be used on other UNIX operating systems.
Listing 1 df_limit.csh
#!/bin/csh -f
set limit = 90
set comp_list = 'barracuda medusa stingray tuna dolphin sword seal salmon octopus'
touch /tmp/comp
rm /tmp/comp
foreach comp ( $comp_list )
set df = `rsh $comp df -F ufs -k | grep -v 'capa' | awk '{print $5}' | sed \
-e s/\%// `
set mnt = `rsh $comp df -F ufs -k | grep -v 'capa' | awk '{print $6}'`
set i = 0
foreach use ( $df )
@ i = $i + 1
if ( "$use" > "$limit" ) then
echo " $use% on $comp : $mnt[$i]" >> /tmp/comp
endif
end
end
if (-f /tmp/comp) then
/usr/ucb/Mail [email protected] < /tmp/comp
endif