darode 5f3c0c15d5 2012-05-09 Dario Rodriguez <dario.rodriguez@artica.es>
* util/plugin/ipmi-plugin.pl,
	util/recon_scripts/ipmi-recon.pl: Fixed some bugs of plugin and
	recon

	MERGED FROM 4.0.2



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6275 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-05-09 07:40:24 +00:00

56 lines
1006 B
Perl

#!/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++) {
if ($ARGV[$i] eq $param) {
$value = $ARGV[$i+1];
last;
}
}
return $value;
}
##########################################################################
# 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();
}
my $host = get_param("h");
my $user = get_param("u");
my $pass = get_param("p");
my $sensor = get_param("s");
my $res = `ipmi-sensors -h $host -u $user -p $pass -s $sensor | tail -1`;
my @aux = split(/\|/, $res);
my $value = $aux[3];
$value =~ s/\n//;
$value =~ s/^\s+//;
$value =~ s/\s+$//;
#Output the value
print $value;