Nagios + APC UPSsssss

Lionel Ostric lionel.ostric at arm.com
Mon May 12 16:54:34 CEST 2003


Yes you can monitor it  by SNMP.
I've written a plugin for that but it would need some clean up :

#!/usr/local/bin/perl -wT
# check_lsf
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# you should have received a copy of the GNU General Public License
# along with this program (or with Nagios);  if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA
####################################
# checks for status of platform LSF cluster
# Returns:
#  OK if lsf is running
#  Critical if lsf is not running
#
####################################

use Net::SNMP;
use Getopt::Long;
&Getopt::Long::config('auto_abbrev');

my $status;
my $response = "";
my $TIMEOUT = 240;
my $community = "public";
my $port = 161;

my $status_string = "";

my %OIDLIST = (
  upsload  =>  '.1.3.6.1.4.1.318.1.1.1.4.2.3.0',
  upsstatus  =>  '.1.3.6.1.4.1.318.1.1.1.4.1.1.0'
       );

my %STATUSCODE = (  'UNKNOWN' => '-1',
                    'OK' => '0',
                    'WARNING' => '1',
                    'CRITICAL' => '2');

my $state = "UNKNOWN";

$SIG{'ALRM'} = sub {
    print "ERROR: No snmp response from $hostname (sigALRM)\n";
    exit($STATUSCODE{"UNKNOWN"});
};

alarm($TIMEOUT);

sub show_help {
    printf("\nPerl Powernet UPS plugin for APC UPS\n");
    printf("Usage:\n");
    printf("
  check_ups [options] <nb_critical> <nb_down>
  Options:
    -c snmp-community
    -p snmp-port
");
    printf("check_ups comes with absolutely NO WARRANTY either implied or
explicit\n");
    printf("This program is licensed under the terms of the\n");
    printf("GNU General Public License\n(check source code for
details)\n\n\n");
    exit($STATUSCODE{"UNKNOWN"});
}

sub SNMPGET {
    $OID = shift;
    ($session,$error) = Net::SNMP->session(
        Hostname        =>      $hostname,
        Community       =>      $community,
        Port            =>      $port,
 Timeout  => 60
        );
    if(!defined($session)) {
 return "";
    }
    if(!defined($response = $session->get_request($OID))) {
        $session->close();
        printf("$state %s\n", $session->error());
 return "";
        #exit($STATUSCODE{$state});
    }
    $session->close();
    return($response->{$OID});
}
$status = GetOptions( "community=s", \$community,
                      "port=i",      \$port,
   "maxi=i", \$max,
   "warning=i", \$warn );
if($status == 0) {
    &show_help;
}

$hostname = shift || &show_help;
 $upsstatus=&SNMPGET($OIDLIST{upsstatus});
 if ($upsstatus eq "")
 {
  print "No SNMP response\n";
  exit($STATUSCODE{"UNKNOWN"});
 }
 if ($upsstatus==2)
 {
  $upsload=&SNMPGET($OIDLIST{upsload});
  print "Load : $upsload|$upsload\n";
  exit($STATUSCODE{'OK'});
 }
 elsif ($upsstatus==1) {print "Unknown\n" ; exit(1)}
 elsif ($upsstatus==3) {print "On Battery\n" ; exit(2)}
 elsif ($upsstatus==4) {print "On SmartBoost\n" ; exit(1)}
 elsif ($upsstatus==5) {print "TimedSleeping\n" ; exit(2)}
 elsif ($upsstatus==6) {print "SoftwareBypass\n" ; exit(2)}
 elsif ($upsstatus==7) {print "off\n" ; exit(2)}
 elsif ($upsstatus==8) {print "Rebooting\n" ; exit(2)}
 elsif ($upsstatus==9) {print "SwitchedBypass\n" ; exit(2)}
 elsif ($upsstatus==10) {print "HardwareFailureBypass\n" ; exit(2)}
 elsif ($upsstatus==11) {print "Sleeping until power return\n" ; exit(2)}
 elsif ($upsstatus==12) {print "On Smart Trim\n" ; exit(2)}


----- Original Message -----
From: "Leonard Miller" <Leonard_Miller at udlp.com>
To: <nagios-users at lists.sourceforge.net>
Sent: Monday, May 12, 2003 3:25 PM
Subject: [Nagios-users] Nagios + APC UPSsssss


> Hi,
> I started using Nagios a few weeks ago and things are
> running great.
>
> From what I have seen on the list so far, Nagios has the
> ability to monitor anything in some way or another.
> Has anybody monitored APC UPS's with it?  I am currently
> checking some with PING but that is about it.  I would like
> the ability to monitor runtime, battery capacity and things
> like that.  I have about 75 UPS, 150 printers, and other devices
> that I would like to do some monitoring on.
>
> It is currently in a test environment until I can get it tweaked and
> have a base config setup.
>
> Thanks
> Leonard
>
>
>
> --
> Leonard W. Miller, CCNA
> United Defense, L.P.
>
> Learn to survive until you can gain control
>
>
>
> -------------------------------------------------------
> Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
> The only event dedicated to issues related to Linux enterprise solutions
> www.enterpriselinuxforum.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
>



-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.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