this is a Perl script I use to check disk space on a solaris box

#!/usr/bin/perl
#
# --------------------------------------------------------------------
use strict;

use Net::SSH qw(ssh_cmd);
use             Sys::Hostname;
use             Net::SMTP;

sub logmsg { open(O, '>>/var/log/log'); print O scalar localtime, " - $0 -
$$ - @_\n"; close(O); }

my $NOTIFY = ['[EMAIL PROTECTED]', ];
my %disks = (     '/'         => 50,
                '/usr'         => 85,
                '/var'         => 50,
                '/hd1'         => 50,
                '/export' => 50,
                '/opt'         => 85,
        );

my ( $d, @res, @dp, $msg );

logmsg 'start';
$d = ssh_cmd('[EMAIL PROTECTED]', 'df -k');
$d =~ s/%//g;
@res = split(/\n/, $d);
foreach $d (@res) {
    if($d =~ /^\//) {
        @dp = split(/\s+/, $d);
        if(exists($disks{$dp[5]}) and ($disks{$dp[5]} < $dp[4])) {
            $msg = "hostname: $dp[5] disk space is $dp[4], max is
$disks{$dp[5]}";
            ErrorEmail('hostname', \$msg, $NOTIFY);
            logmsg $msg;
            }
        }
    }



- hcir
It always costs more to do nothing, than to do the right thing.

____________________________________________________________________
List archives: 
http://www.mail-archive.com/intermapper-talk%40list.dartware.com/
To unsubscribe: send email to: [EMAIL PROTECTED]

Reply via email to