2011-10-10 16:21:00 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
sub get_param($) {
|
|
|
|
my $param = shift;
|
|
|
|
my $value = undef;
|
|
|
|
|
|
|
|
$param = "-".$param;
|
|
|
|
|
|
|
|
for(my $i=0; $i<$#ARGV; $i++) {
|
|
|
|
|
2015-05-26 20:01:17 +02:00
|
|
|
if ($ARGV[$i] eq "--") {
|
|
|
|
if ($param eq "--") {
|
|
|
|
$value = join(' ', @ARGV[$i+1..$#ARGV]);
|
|
|
|
}
|
|
|
|
last;
|
|
|
|
} elsif ($ARGV[$i] eq $param) {
|
2011-10-10 16:21:00 +02:00
|
|
|
$value = $ARGV[$i+1];
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
2012-05-09 09:40:24 +02:00
|
|
|
##########################################################################
|
|
|
|
# Show help
|
|
|
|
##########################################################################
|
|
|
|
sub show_help {
|
|
|
|
print "\nSpecific Pandora FMS Intel DCM Discovery\n";
|
|
|
|
print "(c) Artica ST 2011 <info\@artica.es>\n\n";
|
|
|
|
print "Usage:\n\n";
|
|
|
|
print " $0 -h <host> -u <username> -p <password> -s <sensor_id>\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($#ARGV == -1){
|
|
|
|
show_help();
|
|
|
|
}
|
|
|
|
|
2011-10-10 16:21:00 +02:00
|
|
|
my $host = get_param("h");
|
|
|
|
my $user = get_param("u");
|
|
|
|
my $pass = get_param("p");
|
|
|
|
my $sensor = get_param("s");
|
2015-05-26 20:01:17 +02:00
|
|
|
my $extraopts = get_param("-");
|
2011-10-10 16:21:00 +02:00
|
|
|
|
2015-05-27 01:28:00 +02:00
|
|
|
my $res = `ipmi-sensors -h $host -u $user -p $pass -s $sensor $extraopts --ignore-not-available-sensors --no-header-output --comma-separated-output --output-event-bitmask`;
|
2011-10-10 16:21:00 +02:00
|
|
|
|
2015-05-27 01:28:00 +02:00
|
|
|
my ($sensor_id, $name, $type, $value, $units, $eventmask) = split(/,/, $res);
|
2011-10-10 16:21:00 +02:00
|
|
|
|
|
|
|
#Output the value
|
2015-05-27 01:28:00 +02:00
|
|
|
if ($value eq 'N/A') {
|
|
|
|
if ($eventmask =~ /([0-9A-Fa-f]+)h/) {
|
2015-05-27 07:07:32 +02:00
|
|
|
print hex $1;
|
2015-05-27 01:28:00 +02:00
|
|
|
} else {
|
|
|
|
print $eventmask;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print $value;
|
|
|
|
}
|