smartmontools

Dan Urist durist at euler.cr.usgs.gov
Thu Jul 1 00:29:44 CEST 2004


On Wednesday 30 June 2004 14:02, Neil wrote:

> This is cool. What if we want to monitor on Solaris?

Here you go-- note that the version of smartmontools I'm running on Solaris 
(v. 5.30) has different args than the linux version that ships with redhat; 
also, does anybody know if smartmontools will work for FCAL disks on the 
v880?

==================
#!/usr/local/bin/perl -w

my $SMARTCTL = "/usr/local/smartmontools/sbin/smartctl";

open(CFGADM,"/usr/sbin/cfgadm -al|")
  or die "$0: Could not open pipe to cfgadm";

my @disks;
my $disk;
my @baddisks;
while( my $line = <CFGADM> ){
  if( $line =~ /dsk\/(\S+)\s+disk/ ){
    system("$SMARTCTL -Hq silent /dev/rdsk/" . $1 . "s2");
    push(@baddisks, $1) if $?;
  }
}

if( scalar(@baddisks) ){
  print "Bad Disks: ", join(",", at baddisks), "\n";;
  exit 1;
}
==================

Actually, because I'm lazy and want to have a single directory of scripts to 
distribute, I have all my linux-specific scripts named e.g.  "chksmart.linux" 
and the solaris-specific scripts named e.g. "chksmart.solaris", and then I 
have a script called "launch" that is symlinked to "chksmart" (or any other 
scriptname that has an OS-specfic version, but without the extension); launch 
figures out what OS it's running on and calls the appropriate script. Here's 
launch:

==================
#!/bin/sh

case `uname` in
        Linux)
                exec $0.linux $@
                ;;
        SunOS)
                exec $0.solaris $@
                ;;
        *)
                echo "Unknown operating system!"
                exit 1
                ;;
esac
==================

--
Dan Urist
durist at euler.cr.usgs.gov



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list