12V DC Ammo Can Power Box v1.0

IMG_5260

I wanted to build a custom rugged battery box on a budget for amateur radio communications and emergency charging. The ammo can was found in poor condition at an army surplus and was restored by sanding to remove rust, re-painting, and lubricating the rubber seal. I’m not yet satisfied with the internal fabrication and will continue to improve upon its design later. Future improvements to include: led switch, solar charge controller, improved mounting panel, volt/amp meter.

more photos below and materials list below…

Continue reading “12V DC Ammo Can Power Box v1.0”

Nagios Plugin – Juice Box Midspan XP POE

This script checks the status of a SEI Juice Box XP Midspan power-over-ethernet (POE) injector via SNMP.

It provides information on Voltage, Temperature, Power Delivered, Power Allocated, and Power Available.

[EXPAND Click here to look at the code]#!/usr/bin/perl -w
###########################################################################################################
##
## Filename: check_snmp_poe_juicebox_xp.pl
## Description: This script checks the status of a Juice Box XP mid-span power-over-ethernet (POE) injector.
## Author: Brandon Fiquett ([email protected])
## Date: 2011-06-18
## Version: 1.0
##
############################################################################################################

## —————————————————————————————-(Includes)-START

use strict;
use Getopt::Long;
use Net::SNMP;
use lib “/usr/local/nagios/libexec”;

## —————————————————————————————-(Includes)-END

## —————————————————————————————-(Declarations)-START

## OIDs
my $juiceBoxMainSystemVoltage = “1.3.6.1.4.1.20364.3.1.2.1.0”; ## juiceBoxMainSystemVoltage (millivolts)
my $juiceBoxMainTemperature = “1.3.6.1.4.1.20364.3.1.2.2.0”; ## juiceBoxMainTemperature (Celsius)
my $juiceBoxMainPowerAvailable = “1.3.6.1.4.1.20364.3.1.2.3.0”; ## juiceBoxMainPowerAvailable
my $juiceBoxMainPowerDelivered = “1.3.6.1.4.1.20364.3.1.2.4.0”; ## juiceBoxMainPowerDelivered
my $juiceBoxMainAllocatedPower = “1.3.6.1.4.1.20364.3.1.2.5.0”; ## juiceBoxMainAllocatedPower
my $juiceBoxMainNetworkControllerFirmware = “1.3.6.1.4.1.20364.3.1.2.11.0”; ## juiceBoxMainNetworkControllerFirmware
my $juiceBoxMainSystemControllerFirmware = “1.3.6.1.4.1.20364.3.1.2.12.0”; ## juiceBoxMainSystemControllerFirmware

## ARGS
my $host = “”;
my $timeout = 15;
my $community = “public”;
my $type = “”;
my $min_warning = -1;
my $max_warning = -1;
my $min_critical = -1;
my $max_critical = -1;
my $verbose = undef;
my $celsius = undef;

## Result Strings
my $result = “”;
my $status = “”;
my $snmp_result = undef;
my $exit_level = 0; ## OK
my $exit_code = “”;
my $value = “”;

sub CtoF { my $c = shift; $c =~ s/[^\d\.]//g; return (((9/5)*$c)+32); }

## —————————————————————————————-(Declarations)-END

## —————————————————————————————-(Main)-START

## —————————————————————————————-(Get Args)-START

Getopt::Long::Configure (‘no_ignore_case’);
$result = GetOptions (‘host|h=s’ => \$host,
‘timeout|t=i’ => \$timeout,
‘community|c=s’ => \$community,
‘type=s’ => \$type,
‘min_warning=i’ => \$min_warning,
‘max_warning=i’ => \$max_warning,
‘min_critical=i’ => \$min_critical,
‘max_critical=i’ => \$max_critical,
‘celsius’ => \$celsius,
‘verbose|v’ => \$verbose);
sub usage {
my $ret = “USAGE $0 [options]\n”;
$ret .= “-h –host\t\tNagios Macro: \$HOSTADDRESS\$\n”;
$ret .= “-c –community\t\tSNMP Community String (Default: $community)\n”;
$ret .= “-t –timeout\t\tTime out (Default: $timeout)\n”;
$ret .= “–type\t\t\tType (voltage,temp,pwr_available,pwr_delivered,pwr_allocated)\n”;
$ret .= “–celsius\t\tTemperature in Celsius\n”;
$ret .= “–min_warning\t\tMin Warning\n”;
$ret .= “–max_warning\t\tMax Warning\n”;
$ret .= “–min_critical\t\tMin Critical\n”;
$ret .= “–max_critical\t\tMax Critical\n”;
$ret .= “\n”;
return $ret;
}

## Verbose subroutine
sub verb { my $t=shift; print $t,”\n” if defined($verbose) ; }

alarm ($timeout + 1);

$SIG{‘ALRM’} = sub {
print (“WARNING: Check Timed-out\n”);
exit(3); ## UNKNOWN
};
if(not $result ) {
print “ERROR: Missing Need Parameters\n\n” . usage();
exit(3); ## UNKNOWN
}
if( $host eq “”) {
die “ERROR: No host given\n\n” . usage();
exit(3); ## UNKNOWN
}

if( $type eq “”) {
die “ERROR: No type given\n\n” . usage();
exit(3); ## UNKNOWN
}
## —————————————————————————————-(Get Args)-END

## —————————————————————————————-(Create new SNMP-session-object)-START

my($snmp_session, $error) = Net::SNMP->session( -hostname => $host,
-community => $community,
-timeout => $timeout,
);

if( ! defined $snmp_session) {
print “ERROR: Couldn’t create snmp session: $error\n”;
exit(3); ## UNKNOWN
}

## Set Timeout
$snmp_session->timeout($timeout);

## —————————————————————————————-(Create new SNMP-session-object)-END

## —————————————————————————————-(Request the actual values)-START

$snmp_result = $snmp_session->get_request( -varbindlist => [ $juiceBoxMainSystemVoltage,$juiceBoxMainTemperature,$juiceBoxMainPowerAvailable,$juiceBoxMainPowerDelivered,$juiceBoxMainAllocatedPower,$juiceBoxMainNetworkControllerFirmware,$juiceBoxMainSystemControllerFirmware]);
$snmp_session->close;

verb(“Juice Box POE Midspan Power Hub Information\n##########################################################”);
my $MainSystemVoltage = $snmp_result->{$juiceBoxMainSystemVoltage};
$MainSystemVoltage = $MainSystemVoltage / 1000;
verb(“System Voltage (volts): $MainSystemVoltage”);
my $MainTemperature = $snmp_result->{$juiceBoxMainTemperature};
$MainTemperature = CtoF($MainTemperature) if (! defined $celsius);
verb(“Temperature (” . ((defined $celsius)?”°C”:”°F”) . “): $MainTemperature”);
my $MainPowerAvailable = $snmp_result->{$juiceBoxMainPowerAvailable};
verb(“Power Available (Watts): $MainPowerAvailable”);
my $MainPowerDelivered = $snmp_result->{$juiceBoxMainPowerDelivered};
verb(“Power Delivered (Watts): $MainPowerDelivered”);
my $MainAllocatedPower = $snmp_result->{$juiceBoxMainAllocatedPower};
verb(“Allocated Power (Watts): $MainAllocatedPower”);
my $MainNetworkControllerFirmware = $snmp_result->{$juiceBoxMainNetworkControllerFirmware};
verb(“Network Controller Firmware: $MainNetworkControllerFirmware”);
my $MainSystemControllerFirmware = $snmp_result->{$juiceBoxMainSystemControllerFirmware};
verb(“System Controller Firmware: $MainSystemControllerFirmware”);
verb(“##########################################################”);

## Verifty no SNMP problems
if( (! defined $MainSystemVoltage) or ( ! defined $MainTemperature) or ( ! defined $MainPowerAvailable) or ( ! defined $MainPowerDelivered) or ( ! defined $MainAllocatedPower) or ( ! defined $MainNetworkControllerFirmware) or ( ! defined $MainSystemControllerFirmware)) {
print “SNMP ERROR in get-request: “.$snmp_session->error();
exit(3); ## UNKNOWN
}

## —————————————————————————————-(Request the actual values)-END

## —————————————————————————————-(Build the results)-START

if ($type eq “voltage”){
$value = $MainSystemVoltage;
$status = “Voltage ($MainSystemVoltage volts)”;
}elsif($type eq “temp”){
$value = $MainTemperature;
$status = “Temperature ($MainTemperature ” . ((defined $celsius)?”degrees C”:”degrees F”) . “)”;
}elsif($type eq “pwr_available”){
$value = $MainPowerAvailable;
$status = “Power Available ($MainPowerAvailable Watts)”;
}elsif($type eq “pwr_delivered”){
$value = $MainPowerDelivered;
$status = “Power Delivered ($MainPowerDelivered Watts)”;
}elsif($type eq “pwr_allocated”){
$value = $MainAllocatedPower;
$status = “Power Allocated ($MainAllocatedPower Watts)”;
}else{
$status = “ERROR: Not a valid type. (voltage,temp,pwr_available,pwr_delivered,pwr_allocated)”;
exit(3); ## UNKNOWN
}
if (( $min_warning eq -1 && $min_critical eq -1) | ($max_warning eq -1 && $max_critical eq -1)){
$status = “ERROR: Missing threshold(s)”;
$exit_level = 3; ## UNKNOWN
}else{
if (($min_critical ne -1 && $max_critical ne -1) && ($value = $max_critical)){
$exit_code = “CRITICAL ” . (($value $exit_level = 2; ## CRITICAL
}elsif (($min_warning ne -1 && $max_warning ne -1) && ($value = $max_warning)){
$exit_code = “WARNING ” . (($value $exit_level = 1; ## WARNING
}else{
$exit_code .= “OK”;
}
}
## —————————————————————————————-(Build the results)-END

## —————————————————————————————-(Main)-END

## —————————————————————————————-(Exit)-START

print “$status: $exit_code \n”;
exit($exit_level);

## —————————————————————————————-(Exit)-END[/EXPAND]

Click here to download