ESensors Advanced Environmental Monitor EM32-Xe
ESensors Advanced Environmental Monitor EM32-Xe
When will Nagios support the Advanced Environmental Monitor EM32-Xe? I asked about this last year and was told it was coming.
Re: ESensors Advanced Environmental Monitor EM32-Xe
You can try this one:
https://support.nagios.com/forum/viewto ... 13#p199513
Please post the FULL output of these commands from your XI server:
- Note: Make sure to change ESENSORIP to the IP of your ESENSOR.
https://support.nagios.com/forum/viewto ... 13#p199513
Please post the FULL output of these commands from your XI server:
- Note: Make sure to change ESENSORIP to the IP of your ESENSOR.
Code: Select all
curl -k -L 'http://ESENSORIP/index.html?em345678' -v
curl -k -L 'http://ESENSORIP/status.xml' -v
curl -k -L 'https://ESENSORIP/index.html?em345678' -v
curl -k -L 'https://ESENSORIP/status.xml' -vRe: ESensors Advanced Environmental Monitor EM32-Xe
Here is the output.
[root@kensnagios ~]# curl -k -L 'http://192.168.1.4/index.html?em345678' -v
* About to connect() to 192.168.1.4 port 80 (#0)
* Trying 192.168.1.4... connected
* Connected to 192.168.1.4 (192.168.1.4) port 80 (#0)
> GET /index.html?em345678 HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.1.4
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: text/html
< Connection: close
<
* Closing connection #0
<html><head></head><body>/N 12153TF: 75.8HU:22.8%IL:62.96</body></html>[root@kensnagios ~]# curl -k -L 'http://192.168.1.4/status.xml' -v
* About to connect() to 192.168.1.4 port 80 (#0)
* Trying 192.168.1.4... connected
* Connected to 192.168.1.4 (192.168.1.4) port 80 (#0)
> GET /status.xml HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.1.4
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/xml
< Connection: close
<
* Closing connection #0
<?xml version="1.0"?><sensorsSW><dvc>TBD</dvc><sht>inline</sht><ilum>inline</ilum><evin>inline</evin><ethm>none</ethm><ecin>inline</ecin><efld>none</efld><epir>none</epir><egas>none</egas><ght>1</ght><gsn>1</gsn><eDL>none</eDL><ecam>none</ecam><ephc>none</ephc><sid0>12153</sid0><stu0>OK</stu0><tm0>75.76</tm0><hu0>21.99</hu0><il0>62.71</il0><tun0>F</tun0><cin>0</cin><fin>1</fin><pin>0</pin><vin>120.25</vin><thm>0.00</thm><phcv>0</phcv></sensorsSW>[root@kensnagios ~]#
[root@kensnagios ~]# curl -k -L 'https://192.168.1.4/index.html?em345678' -v
* About to connect() to 192.168.1.4 port 443 (#0)
* Trying 192.168.1.4... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
[root@kensnagios ~]# curl -k -L 'https://192.168.1.4/status.xml' -v
* About to connect() to 192.168.1.4 port 443 (#0)
* Trying 192.168.1.4... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
[root@kensnagios ~]#
[root@kensnagios ~]# curl -k -L 'http://192.168.1.4/index.html?em345678' -v
* About to connect() to 192.168.1.4 port 80 (#0)
* Trying 192.168.1.4... connected
* Connected to 192.168.1.4 (192.168.1.4) port 80 (#0)
> GET /index.html?em345678 HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.1.4
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: text/html
< Connection: close
<
* Closing connection #0
<html><head></head><body>/N 12153TF: 75.8HU:22.8%IL:62.96</body></html>[root@kensnagios ~]# curl -k -L 'http://192.168.1.4/status.xml' -v
* About to connect() to 192.168.1.4 port 80 (#0)
* Trying 192.168.1.4... connected
* Connected to 192.168.1.4 (192.168.1.4) port 80 (#0)
> GET /status.xml HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.1.4
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/xml
< Connection: close
<
* Closing connection #0
<?xml version="1.0"?><sensorsSW><dvc>TBD</dvc><sht>inline</sht><ilum>inline</ilum><evin>inline</evin><ethm>none</ethm><ecin>inline</ecin><efld>none</efld><epir>none</epir><egas>none</egas><ght>1</ght><gsn>1</gsn><eDL>none</eDL><ecam>none</ecam><ephc>none</ephc><sid0>12153</sid0><stu0>OK</stu0><tm0>75.76</tm0><hu0>21.99</hu0><il0>62.71</il0><tun0>F</tun0><cin>0</cin><fin>1</fin><pin>0</pin><vin>120.25</vin><thm>0.00</thm><phcv>0</phcv></sensorsSW>[root@kensnagios ~]#
[root@kensnagios ~]# curl -k -L 'https://192.168.1.4/index.html?em345678' -v
* About to connect() to 192.168.1.4 port 443 (#0)
* Trying 192.168.1.4... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
[root@kensnagios ~]# curl -k -L 'https://192.168.1.4/status.xml' -v
* About to connect() to 192.168.1.4 port 443 (#0)
* Trying 192.168.1.4... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
[root@kensnagios ~]#
Re: ESensors Advanced Environmental Monitor EM32-Xe
Looks like they should both work technically.
What is the output of these commands:
Please take this code and put it in /usr/local/nagios/libexec/check_em.pl.
Then run these commands and send me the full output:
What is the output of these commands:
Please take this code and put it in /usr/local/nagios/libexec/check_em.pl.
Code: Select all
#!/usr/bin/perl
#
# License to use per the terms of the GNU Public License (GPL)
#
# CHANGES:
# Modified by Nagios Enterprises January 2010 to return performance data
#
#$Id$
# configure nagios utils
use lib "/usr/local/nagios/libexec";
use utils qw($TIMEOUT %ERRORS);
use strict;
use Getopt::Long;
use Data::Dumper;
use LWP;
use XML::Simple;
Getopt::Long::Configure('bundling');
my $opt_debug = 0;
my $opt_ver = 0;
my $opt_help = 0;
my $opt_typ = '';
my $opt_temp = 'x/x,x/x';
my $opt_hum = 'x/x,x/x';
my $opt_illum = 'x/x,x/x';
my $opt_timeout = $TIMEOUT;
GetOptions
( "version|v" => \$opt_ver,
"debug|d" => \$opt_debug,
"help|h" => \$opt_help,
"type=s" => \$opt_typ,
"temp|temperature=s" => \$opt_temp,
"hum|humidity=s" => \$opt_hum,
"illum|illumination=s" => \$opt_illum,
);
my $sensor = $ARGV[0] || &syntax();
if ($opt_help) {
&syntax();
}
#############################################
my @temp = split(/[\/,]/, $opt_temp);
my @hum = split(/[\/,]/, $opt_hum);
my @illum = split(/[\/,]/, $opt_illum);
my $vals = &read_sensor($sensor, $opt_timeout);
my @msgs = ();
my $condition = $ERRORS{'OK'};
&check_value('temperature', $vals, @temp);
&check_value('humidity', $vals, @hum);
&check_value('illumination', $vals, @illum);
if ($#msgs > -1) {
print join("; ", @msgs);
}
if ($opt_typ eq '') {
#print "[";
print "Temp: $vals->{'temperature'} $vals->{'temp-unit'}, ";
print "Humidity: $vals->{'humidity'}, ";
print "Illum: $vals->{'illumination'}\n";
#print "]\n";
} else {
#print "[";
if ($opt_typ eq "temp") {
print "Temp: $vals->{'temperature'} $vals->{'temp-unit'}";
print "|";
print "temperature=$vals->{'temperature'}$vals->{'temp-unit'};;;; ";
} elsif ($opt_typ eq "hum") {
print "Humidity: $vals->{'humidity'}";
print "|";
print "humidity=$vals->{'humidity'};;;; ";
} elsif ($opt_typ eq "illum") {
print "Illum: $vals->{'illumination'}";
print "|";
print "illumination=$vals->{'illumination'};;;; ";
}
print "\n";
}
exit($condition);
#############################################
sub check_value {
my ($type, $vals, $w_lo, $w_hi, $c_lo, $c_hi) = @_;
my $current = $vals->{$type};
my $uctype = ucfirst $type;
if ($c_lo ne 'x' && $current < $c_lo) {
push(@msgs, "CRITICAL LOW $uctype (<$c_lo) - ");
$condition = $ERRORS{'CRITICAL'};
} elsif ($c_hi ne 'x' && $current > $c_hi) {
push(@msgs, "CRITICAL HIGH $uctype (>$c_hi) - ");
$condition = $ERRORS{'CRITICAL'};
} elsif ($w_lo ne 'x' && $current < $w_lo) {
push(@msgs, "WARNING LOW $uctype (<$w_lo) - ");
$condition = $ERRORS{'WARNING'};
} elsif ($w_hi ne 'x' && $current > $w_hi) {
push(@msgs, "WARNING HIGH $uctype (>$w_hi) - ");
$condition = $ERRORS{'WARNING'};
}
};
sub syntax {
print <<END;
Syntax: $0 [options] {sensor}
{sensor} is the address of sensor on network (name or IP)
--debug
print debug messages to stdout
--timeout=x
how long to wait before failing. Default=$opt_timeout
--type={all|temp|hum|illum}
which sensor data you want to retrieve.
If you did not specify this option, then this plugin will return all
sensor data.
--{temp|hum|illum}=warnlow/warnhi,critlow/crithi
four values are required. 'x' is used to specify no value.
Example:
check_em01.pl --type=temp --temp=65/75,60/80
check_em01.pl --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80
END
exit($ERRORS{'UNKNOWN'});
}
sub read_sensor {
my ($host,$timeout) = @_;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => "http://$host/status.xml");
my $remote = $ua->request($req);
if (!$remote) {
&debug("connect error: $!\n");
print "failed to connect\n";
exit($ERRORS{'UNKNOWN'});
}
&debug("connected to $host:80\n");
my $xml = new XML::Simple;
my $data = XMLin($remote->content);
&debug(Dumper($data)."\n");
my $didalarm = 0;
my $hdrs = {};
my $read = {};
eval {
local $SIG{'ALRM'} = sub { $didalarm=1; die "alarm\n"; };
alarm($timeout);
$read->{'temp-unit'} = "$data->{tun0}";
$read->{'temperature'} = "$data->{tm0}";
$read->{'humidity'} = "$data->{hu0}";
$read->{'illumination'} = "$data->{il0}";
alarm(0);
};
if ($@) {
die if $didalarm != 1;
&debug("timeout(alarm) during sensor read\n");
print "Unable to read sensor\n";
exit($ERRORS{'UNKNOWN'});
}
return $read;
};
sub debug {
my ($msg) = @_;
if ($opt_debug) {
print STDERR $msg;
}
};
Code: Select all
yum install perl-XML-Simple -y
chown apache.nagios /usr/local/nagios/libexec/check_em.pl
chmod +x /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all
/usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80Re: ESensors Advanced Environmental Monitor EM32-Xe
[root@kensnagios ~]# yum install perl-XML-Simple -y
chown apache.nagios /usr/local/nagios/libexec/check_em.pl
chmod +x /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all
/usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80Loaded plugins: fastestmirror, refresh-packagekit
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: ftpmirror.your.org
* epel: mirrors.liquidweb.com
* extras: ftpmirror.your.org
* updates: ftpmirror.your.org
Package perl-XML-Simple-2.18-6.el6.noarch already installed and latest version
Nothing to do
[root@kensnagios ~]# chown apache.nagios /usr/local/nagios/libexec/check_em.pl
[root@kensnagios ~]# chmod +x /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all
chmod: unrecognized option '--type=all'
Try `chmod --help' for more information.
[root@kensnagios ~]# /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80
-bash: /usr/local/nagios/libexec/check_em.pl: Permission denied
[root@kensnagios ~]#
chown apache.nagios /usr/local/nagios/libexec/check_em.pl
chmod +x /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all
/usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80Loaded plugins: fastestmirror, refresh-packagekit
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: ftpmirror.your.org
* epel: mirrors.liquidweb.com
* extras: ftpmirror.your.org
* updates: ftpmirror.your.org
Package perl-XML-Simple-2.18-6.el6.noarch already installed and latest version
Nothing to do
[root@kensnagios ~]# chown apache.nagios /usr/local/nagios/libexec/check_em.pl
[root@kensnagios ~]# chmod +x /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all
chmod: unrecognized option '--type=all'
Try `chmod --help' for more information.
[root@kensnagios ~]# /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80
-bash: /usr/local/nagios/libexec/check_em.pl: Permission denied
[root@kensnagios ~]#
Re: ESensors Advanced Environmental Monitor EM32-Xe
Sorry, please run these instead:
Code: Select all
chown apache.nagios /usr/local/nagios/libexec/check_em.pl
chmod +x /usr/local/nagios/libexec/check_em.pl
/usr/local/nagios/libexec/check_em.pl 192.168.1.4
/usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80Re: ESensors Advanced Environmental Monitor EM32-Xe
[root@kensnagios ~]# chown apache.nagios /usr/local/nagios/libexec/check_em.pl
[root@kensnagios ~]# chmod +x /usr/local/nagios/libexec/check_em.pl
[root@kensnagios ~]# /usr/local/nagios/libexec/check_em.pl 192.168.1.4
-bash: /usr/local/nagios/libexec/check_em.pl: /usr/bin/perl^M: bad interpreter: No such file or directory
[root@kensnagios ~]# /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80
-bash: /usr/local/nagios/libexec/check_em.pl: /usr/bin/perl^M: bad interpreter: No such file or directory
[root@kensnagios ~]#
[root@kensnagios ~]# chmod +x /usr/local/nagios/libexec/check_em.pl
[root@kensnagios ~]# /usr/local/nagios/libexec/check_em.pl 192.168.1.4
-bash: /usr/local/nagios/libexec/check_em.pl: /usr/bin/perl^M: bad interpreter: No such file or directory
[root@kensnagios ~]# /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80
-bash: /usr/local/nagios/libexec/check_em.pl: /usr/bin/perl^M: bad interpreter: No such file or directory
[root@kensnagios ~]#
Re: ESensors Advanced Environmental Monitor EM32-Xe
Open the "/usr/local/nagios/libexec/check_em.pl" plugin in vi.
Type:
and hit "Enter" to view the file format. Does it say "unix"?
It it says "dos", you will need to change the format by typing:
save, exit, and test your plugin again.
Let us know if this helped. Thank you!
Code: Select all
vi /usr/local/nagios/libexec/check_em.plCode: Select all
:set ff?It it says "dos", you will need to change the format by typing:
Code: Select all
:set ff=unixLet us know if this helped. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: ESensors Advanced Environmental Monitor EM32-Xe
Here is the output.
[root@kensnagios ~]# chown apache.nagios /usr/local/nagios/libexec/check_em.pl
[root@kensnagios ~]# chmod +x /usr/local/nagios/libexec/check_em.pl
[root@kensnagios ~]# /usr/local/nagios/libexec/check_em.pl 192.168.1.4
/usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80
Temp: 74.80 F, Humidity: 18.43, Illum: 73.30
[root@kensnagios ~]# /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80
CRITICAL LOW Humidity (<25) - ; WARNING HIGH Illumination (>70) -
[root@kensnagios ~]#
[root@kensnagios ~]# chown apache.nagios /usr/local/nagios/libexec/check_em.pl
[root@kensnagios ~]# chmod +x /usr/local/nagios/libexec/check_em.pl
[root@kensnagios ~]# /usr/local/nagios/libexec/check_em.pl 192.168.1.4
/usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80
Temp: 74.80 F, Humidity: 18.43, Illum: 73.30
[root@kensnagios ~]# /usr/local/nagios/libexec/check_em.pl 192.168.1.4 --type=all --temp=65/75,60/80 --hum=30/40,25/50 --illum=40/70,30/80
CRITICAL LOW Humidity (<25) - ; WARNING HIGH Illumination (>70) -
[root@kensnagios ~]#
Re: ESensors Advanced Environmental Monitor EM32-Xe
It seems like the plugin is working now... You are no longer getting the "-bash: /usr/local/nagios/libexec/check_em.pl: /usr/bin/perl^M: bad interpreter: No such file or directory" error.
Do you have any further questions or we can lock this topic?
Do you have any further questions or we can lock this topic?
Be sure to check out our Knowledgebase for helpful articles and solutions!