I am writing a script to check several servers and to report id the filesystem is over 90 % full.
Im server does not like the @i = $i +1 it returns a syntax error. I have tried to modify the scrip using i = `expr $i + 1 ' in place of the @i line . the system does not like this either .
Below is a copy of script with current output and what the end product should look like.
Any insight would be appreciated.
below copy of script.
******************************
#!/bin/csh
set limit = 90
set comp_list = 'box1 box2 box3'
touch /tmp/comp
rm /tmp/comp
foreach comp ( $comp_list )
set df = `rsh $comp df -lk |grep -v 'capa' |awk '{print $5}' |sed -e s/\%//`
set mnt = `rsh $comp df -lk |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
mailx -s "disk Capasity Alert" adm < /tmp/comp
endif
*******************
Current Output
91% on box1
92% on box1
95% on box1
95% on box2
99% on box3
Desired Output
91% on box1 /usr
92% on box1 /name
95% on box1 /name
95% on box2 /name
99% on box3 /name
Im server does not like the @i = $i +1 it returns a syntax error. I have tried to modify the scrip using i = `expr $i + 1 ' in place of the @i line . the system does not like this either .
Below is a copy of script with current output and what the end product should look like.
Any insight would be appreciated.
below copy of script.
******************************
#!/bin/csh
set limit = 90
set comp_list = 'box1 box2 box3'
touch /tmp/comp
rm /tmp/comp
foreach comp ( $comp_list )
set df = `rsh $comp df -lk |grep -v 'capa' |awk '{print $5}' |sed -e s/\%//`
set mnt = `rsh $comp df -lk |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
mailx -s "disk Capasity Alert" adm < /tmp/comp
endif
*******************
Current Output
91% on box1
92% on box1
95% on box1
95% on box2
99% on box3
Desired Output
91% on box1 /usr
92% on box1 /name
95% on box1 /name
95% on box2 /name
99% on box3 /name