I have an attached program w/ text file, if anyone cares to look at...
It is a small perl pgm that checks filesystem(s) which have a soft/hard
limit.
It mails the recipient when a limit is exceeded.
I have just ported to a differnet linux box.
The perl version on the linux box I'm trying to compile/run on now
is newer!
So, I get some warnings w/ the "-w" option.
Here is the chunk or snip of code that fails:
62
if( $Limit{$mpnt} eq undef ){
63
&undefined_mpnt( $mpnt );
64
} else {
65
($soft, $hard) = split(' ',$Limit{$mpnt});
The interpreter/compiler reports:
Name "main::min_free" used only once: possible typo at ./softfs line
84.
Name "main::time" used only once: possible typo at ./softfs line 42.
Name "main::iused" used only once: possible typo at ./softfs line 52.
Name "main::ifree" used only once: possible typo at ./softfs line 52.
Name "main::iper" used only once: possible typo at ./softfs line 52.
Use of uninitialized value at ./softfs line 62, <DF> chunk 2.
Use of uninitialized value at ./softfs line 62, <DF> chunk 3.
Use of uninitialized value at ./softfs line 62, <DF> chunk 4.
Use of uninitialized value at ./softfs line 62, <DF> chunk 5.
Use of uninitialized value at ./softfs line 62, <DF> chunk 6.
Please let me know if anyone can help or you need more info!
-TIA
Scott
#!/usr/bin/perl -w # # [hard|soft]fs - check for "full" disks # # "full" is defined as having more than the soft or hard limit # mentioned in the $LIMITS file, which should consist of lines of # filesystems, softfree, and hardfree values. # # In the event a filesystem hits its soft limit, the sysadmin should # receive mail. If a filesystem hits its hard limit, crisis gets # notified. Filesystems mounted via NFS are ignored. # # based on dfbitch by tom christiansen, 9-sep-90 # # Version Date Author Comments # 1.0 01/11/94 gwh Initial release # 1.01 02/27/96 jas Modified for Verona # 1.1 09/21/96 jas The War of OS Independence Won, also # seperated crisis (hard) from sysadmin (soft) # $ENV{"PATH"} = "/bin:/usr/bin:/usr/local/bin:/usr/lpp/X11/bin"; $SOFTFS = "/repository/scripts/softfs"; $HARDFS = "/repository/scripts/hardfs"; $LIMITS = '/repository/scripts/capacities'; $HOST = `/bin/hostname`; chop( $HOST ); $OPMSG = "Low on disk space. Call System Administrator."; $SYSADMIN = '[EMAIL PROTECTED]'; $CRISIS = '[EMAIL PROTECTED]'; $SHOULD_WALL = "ok"; # Comment this line if we shouldn't wall $OS = `uname`; # No path specified 'cause uname is located elsewhere # on Linux than on AIX chop( $OS ); if( $OS ne 'Linux' && $OS ne 'AIX' ){ print STDERR "[soft|hard]fs: can't identify your OS\n"; exit; } @n=localtime(time()); @mon=("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); $time=sprintf("%s %2.2d %2.2d:%2.2d:%2.2d",@mon[$n[4]],$n[3],$n[2],$n[1],$n[0]); &read_exceptions; open(DF, "df -v|"); $_ = <DF>; # skip header while ( <DF> ) { chop; if( $OS eq 'AIX' ){ ($fs,$tot,$kused,$kfree,$kper,$iused,$ifree,$iper,$mpnt) = split; } elsif( $OS eq 'Linux' ){ ($fs,$tot,$kused,$kfree,$kper,$mpnt) = split; } # Skip NFS-mounted filesystems - their sysadmin should worry, not us if( /:/ || !($fs =~/\//) ){ next; } $kper =~ s/%//; if( $Limit{$mpnt} eq undef ){ print STDOUT "$Limit"; &undefined_mpnt( $mpnt ); } else { ($soft, $hard) = split(' ',$Limit{$mpnt}); if ( $kper > $soft && $0 eq $SOFTFS ){ &soft_alert($mpnt, $kused, $kper); } if ( $kper > $hard && $0 eq $HARDFS ){ &hard_alert($mpnt, $kused, $kper); } } } close DF; exit; # --------------------------------------------------------------------------- sub read_exceptions { local($mpnt, $min_free); if (-e $LIMITS) { open (LIMITS) || die "can't open $LIMITS: $!"; while ( <LIMITS> ) { next if /^\s*#/ || /^\s*$/; chop; ($mpnt, $soft_free, $hard_free) = split(' '); $Limit{$mpnt} = $soft_free ." " . $hard_free; } close LIMITS; } } # --------------------------------------------------------------------------- sub soft_alert { local($mpnt, $kused, $kper) = @_; open (MAIL, "| /usr/lib/sendmail -oi -t"); select(MAIL); print <<EOM; From: Disk Monitor Daemon <daemon> To: $SYSADMIN Cc: Subject: $mpnt on $HOST is $kper% full Please check into this situation as soon as possible. Your friendly Disk Monitor Daemon EOM close MAIL; select(STDOUT); } # --------------------------------------------------------------------------- sub hard_alert { local($mpnt, $kused, $kper) = @_; open( MAIL, "| /usr/lib/sendmail -oi -t" ); select( MAIL ); print <<EOM; From: Disk Monitor Daemon <daemon> To: $CRISIS Cc: Subject: $mpnt on $HOST is $kper% full Please check into this situation as soon as possible. The logs will be rotated in order to save space! Your friendly Disk Monitor Daemon EOM if( $SHOULD_WALL ne undef ){ system("echo \"$OPMSG\" | wall"); } #------- # rotate the log file to save space #------- system("/www/bin/rotatewnlogs -g -r wn"); } # --------------------------------------------------------------------------- sub undefined_mpnt { local( $mpnt ) = @_; open( MAIL, "| /usr/lib/sendmail -oi -t" ); select( MAIL ); print <<EOM; From: Disk Monitor Daemon <daemon> To: $SYSADMIN Cc: Subject: Tisk, Tisk! Please add the mountpoint $mpnt to $LIMITS so that monitoring may be performed on this filesystem. Your friendly Disk Monitor Daemon EOM close MAIL; select(STDOUT); }
# Disk limits data file for the [hard|soft]fs scripts # # Filesystem Soft limit Hard limit / 80 90 /home 30 90 /var 80 90 /usr 85 95 /usr 85 95 /boot 85 95 /cdrom 101 101
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]