Nagios Exchange Nagios Exchange
  • Home
  • Directory
  • Library
  • Support
  • About

Advanced Search

Build precise queries to find exactly what you need

Search Logic

Select compatible versions

Press ESC to close

Sign In Sign Up

Nagios World Conference 2026: Sept. 14-17 in St. Paul, MN | Learn More

  • Home
  • Directory
  • Library
  • Support
  • About
Plugins4401Themes and Skins13Add-ons756Graphics and Logos36View All Categories
LinuxSecuritySNMPFile SystemCloud
New Listings Recently Updated Listings Most Favored Listings Most Popular Listings Most Rated Listings Most Reviewed Listings
Random Project
Nagios XI Tutorials Understanding And Using XI Views
0.0 (0)
98.1K
RSS Feed
Newest Listings Updated Listings
Top Contributors
Yoann LAMY (7)Julien DESMAREST (6)Davide Lemma (4)deskwork_itunes142 (4)Sam N (3)
See More
Newest Contributors
signalgrid (1)Sanna Glue (2)fisherrs (1)smolinux (1)juanfertor (1)
See More

Copyright © 2009-2026 Nagios Enterprises, LLC. All rights reserved.

Privacy PolicyTerms of UseTrademarks
Home > Rado
R

Rado

@RadoS

User Stats

Member Since: February 2, 2015

Favorites0

Views

Projects0

No Projects Found
UPS Checks

OK, but fails with embedded Perl-for-Nagios

I use the ups_acp.pl Script. a) it provides some useful info, thanks b) some parts may be incorrect (don't know enough about SNMP/UPS-APC, guessing from code where it checks the same SNMP value twice) c) code fails to operate with embedded perl when enabled in nagios (which is by default on ubuntu 14/04) I changed quite a bit for what I think is correct for b) and definitely is necessary for c). If I did wrong, then correct my corrections as needed. ;-) Enjoy ====== *** check_ups_apc.pl 2014-03-20 16:58:31.000000000 +0100 --- jjj.pl 2015-02-02 18:34:43.000000000 +0100 *************** *** 39,99 **** # After: CRIT - Smart-UPS RT 10000 XL - CRIT BATTERY CAPACITY 50% - STATUS NORMAL - OUTPUT LOAD 31% - TEMPERATURE 23 C # - Added multiline output for firmware,manufacture date and serial number use Net::SNMP; use Getopt::Std; # DEBUGGING PURPOSE use Data::Dumper; ! $script = "check_ups_apc.pl"; ! $script_version = "1.2"; ! $metric = 1; ! $version = "1"; # SNMP version ! $timeout = 2; # SNMP query timeout # $warning = 100; # $critical = 150; ! $status = 0; ! $returnstring = ""; ! $perfdata = ""; ! ! $community = "public"; # Default community string ! ! $oid_sysDescr = ".1.3.6.1.2.1.1.1.0"; ! $oid_serial_number = ".1.3.6.1.4.1.318.1.1.1.1.2.3.0"; ! $oid_firmware = ".1.3.6.1.4.1.318.1.1.1.1.2.1.0"; ! $oid_manufacture_date = ".1.3.6.1.4.1.318.1.1.1.1.2.2.0"; ! $oid_upstype = ".1.3.6.1.4.1.318.1.1.1.1.1.1.0"; ! $oid_battery_capacity = ".1.3.6.1.4.1.318.1.1.1.2.2.1.0"; ! $oid_output_status = ".1.3.6.1.4.1.318.1.1.1.4.1.1.0"; ! $oid_output_current = ".1.3.6.1.4.1.318.1.1.1.4.2.4.0"; ! $oid_output_load = ".1.3.6.1.4.1.318.1.1.1.4.2.3.0"; ! $oid_battemperature = ".1.3.6.1.4.1.318.1.1.1.2.2.2.0"; ! $oid_exttemperature = ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1"; ! $oid_remaining_time = ".1.3.6.1.4.1.318.1.1.1.2.2.3.0"; # optional, Smart-UPS 2200 support this ! $oid_current_load_wh = ".1.3.6.1.4.1.318.1.1.1.4.3.6.0"; ! $oid_battery_replacment = ".1.3.6.1.4.1.318.1.1.1.2.2.4.0"; ! $upstype = ""; ! $battery_capacity = 0; ! $output_status = 0; ! $output_current = 0; ! $output_load = 0; ! $battemperature = 0; ! $exttemperature = 0; # crit / warn values ! $remaining_time_crit = 5; ! $output_load_crit = 80; ! $output_load_warn = 70; ! $battemperature_crit = 33; ! $battemperature_warn = 31; ! $exttemperature_crit = 30; ! $exttemperature_warn = 26; ! $battery_capacity_crit = 35; ! $battery_capacity_warn = 65; # Do we have enough information? if (@ARGV var_bind_names()) { *************** *** 233,249 **** --- 243,262 ---- } } + my $firmware; # some useful stuff if (defined($s->get_request($oid_firmware))) { foreach ($s->var_bind_names()) { $firmware = $s->var_bind_list()->{$_}; } } + my $serial_number; if ( defined ( $s->get_request($oid_serial_number))) { foreach ($s->var_bind_names()) { $serial_number = $s->var_bind_list()->{$_}; } } + my $manufacture_date; if ( defined ( $s->get_request($oid_manufacture_date))) { foreach ($s->var_bind_names()) { $manufacture_date = $s->var_bind_list()->{$_}; *************** *** 279,285 **** ####################################################### if (!defined($s->get_request($oid_battery_replacment))) { ! if (!defined($s->get_request($oid_battery_replacement))) { $returnstring = "SNMP agent not responding"; $status = 1; return 1; --- 292,298 ---- ####################################################### if (!defined($s->get_request($oid_battery_replacment))) { ! if (!defined($s->get_request($oid_sysDescr))) { $returnstring = "SNMP agent not responding"; $status = 1; return 1; *************** *** 290,295 **** --- 303,309 ---- return 1; } } + my $battery_replacement; foreach ($s->var_bind_names()) { $battery_replacement = $s->var_bind_list()->{$_}; } *************** *** 308,313 **** --- 322,328 ---- return 1; } } + my $remaining_time; foreach ($s->var_bind_names()) { $remaining_time = $s->var_bind_list()->{$_}; # returns (days),(hours),(minutes),seconds } *************** *** 453,469 **** if ( defined ( $remaining_time ) ) { # convert time to minutes my @a = split(/ /,$remaining_time); ! my $timeUnit = @a[1]; my $minutes = 0; if ( $timeUnit =~ /hour/ ) { # hours returned ! my @minutesArray = split(/:/,@a[2]); ! $minutes = @a[0] * 60; ! $minutes = $minutes + @minutesArray[0]; } elsif ( $timeUnit =~ /minute/ ) { # minutes returned ! $minutes = @a[0]; } else { # seconds returned? $minutes = 0; --- 468,484 ---- if ( defined ( $remaining_time ) ) { # convert time to minutes my @a = split(/ /,$remaining_time); ! my $timeUnit = $a[1]; my $minutes = 0; if ( $timeUnit =~ /hour/ ) { # hours returned ! my @minutesArray = split(/:/,$a[2]); ! $minutes = $a[0] * 60; ! $minutes = $minutes + $minutesArray[0]; } elsif ( $timeUnit =~ /minute/ ) { # minutes returned ! $minutes = $a[0]; } else { # seconds returned? $minutes = 0;

Reviewed 11 years ago

No Favorites Found

Copyright © 2009-2026 Nagios Enterprises, LLC. All rights reserved.

Privacy PolicyTerms of UseTrademarks
Home Browse Submit Profile