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
This commit is contained in:
parent
9938275789
commit
5f3c0c15d5
|
@ -1,3 +1,11 @@
|
||||||
|
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
|
||||||
|
|
||||||
2012-05-08 Sancho Lerena <slerena@artica.es>
|
2012-05-08 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
* conf/pandora_server.conf: Better default values.
|
* conf/pandora_server.conf: Better default values.
|
||||||
|
|
|
@ -21,24 +21,33 @@ sub get_param($) {
|
||||||
return $value;
|
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 $host = get_param("h");
|
||||||
my $user = get_param("u");
|
my $user = get_param("u");
|
||||||
my $pass = get_param("p");
|
my $pass = get_param("p");
|
||||||
my $sensor = get_param("s");
|
my $sensor = get_param("s");
|
||||||
|
|
||||||
my $res = `ipmi-sensors -h $host -u $user -p $pass -s $sensor`;
|
my $res = `ipmi-sensors -h $host -u $user -p $pass -s $sensor | tail -1`;
|
||||||
|
|
||||||
my @aux = split(/:/, $res);
|
my @aux = split(/\|/, $res);
|
||||||
|
|
||||||
my $value = $aux[2];
|
my $value = $aux[3];
|
||||||
|
|
||||||
$value =~ s/\n//;
|
$value =~ s/\n//;
|
||||||
|
|
||||||
if ($value =~ / (\S+) .+/) {
|
|
||||||
$value = $1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Clean value
|
|
||||||
$value =~ s/^\s+//;
|
$value =~ s/^\s+//;
|
||||||
$value =~ s/\s+$//;
|
$value =~ s/\s+$//;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ use PandoraFMS::Config;
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Global variables so set behaviour here:
|
# Global variables so set behaviour here:
|
||||||
|
|
||||||
my $target_timeout = 5; # Fixed to 5 secs by default
|
my $pkg_count = 3; #Number of ping pkgs
|
||||||
|
my $pkg_timeout = 3; #Pkg ping timeout wait
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Code begins here, do not touch
|
# Code begins here, do not touch
|
||||||
|
@ -63,22 +64,12 @@ sub show_help {
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Get SNMP response.
|
# Get SNMP response.
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub get_snmp_response ($$$) {
|
sub ipmi_ping ($$$) {
|
||||||
my ($target_timeout, $target_community, $addr) = @_;
|
|
||||||
|
|
||||||
# The OID used is the SysUptime OID
|
|
||||||
my $buffer = `/usr/bin/snmpget -v 1 -r0 -t$target_timeout -OUevqt -c '$target_community' $addr .1.3.6.1.2.1.1.3.0 2>/dev/null`;
|
|
||||||
|
|
||||||
# Remove forbidden caracters
|
|
||||||
$buffer =~ s/\l|\r|\"|\n|\<|\>|\&|\[|\]//g;
|
|
||||||
|
|
||||||
return $buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub ipmi_ping ($) {
|
|
||||||
my $addr = shift;
|
my $addr = shift;
|
||||||
|
my $pkg_count = shift;
|
||||||
|
my $pkg_timeout = shift;
|
||||||
|
|
||||||
my $cmd = "ipmiping $addr -c 3";
|
my $cmd = "ipmiping $addr -c $pkg_count -t $pkg_timeout";
|
||||||
|
|
||||||
my $res = `$cmd`;
|
my $res = `$cmd`;
|
||||||
|
|
||||||
|
@ -101,8 +92,11 @@ sub create_ipmi_modules($$$$$$) {
|
||||||
my $ipmi_plugin_id = get_db_value($dbh, "SELECT id FROM tplugin WHERE name = '".safe_input("IPMI Plugin")."'");
|
my $ipmi_plugin_id = get_db_value($dbh, "SELECT id FROM tplugin WHERE name = '".safe_input("IPMI Plugin")."'");
|
||||||
|
|
||||||
|
|
||||||
foreach my $line (@lines) {
|
for(my $i=1; $i < $#lines; $i++) {
|
||||||
my @aux = split(/:/, $line);
|
|
||||||
|
my $line = $lines[$i];
|
||||||
|
|
||||||
|
my @aux = split(/\|/, $line);
|
||||||
|
|
||||||
my $name = $aux[1];
|
my $name = $aux[1];
|
||||||
|
|
||||||
|
@ -112,7 +106,14 @@ sub create_ipmi_modules($$$$$$) {
|
||||||
|
|
||||||
my $module_type = "generic_data_string";
|
my $module_type = "generic_data_string";
|
||||||
|
|
||||||
if ($aux[2] =~ /.+ (\w) \(/) {
|
my $value_read = $aux[3];
|
||||||
|
|
||||||
|
#Trim name
|
||||||
|
$value_read =~ s/^\s+//;
|
||||||
|
$value_read =~ s/\s+$//;
|
||||||
|
|
||||||
|
#Check if value read is integer or boolean
|
||||||
|
if ($value_read =~ m/^\d+.\d+$/ || $value_read =~ m/^\d+$/) {
|
||||||
$module_type = "generic_data";
|
$module_type = "generic_data";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +161,7 @@ $conf{'pandora_path'} = $pandora_conf;
|
||||||
pandora_load_config (\%conf);
|
pandora_load_config (\%conf);
|
||||||
|
|
||||||
# Connect to the DB
|
# Connect to the DB
|
||||||
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'});
|
my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, '3306', $conf{'dbuser'}, $conf{'dbpass'});
|
||||||
|
|
||||||
|
|
||||||
# Start the network sweep
|
# Start the network sweep
|
||||||
|
@ -199,7 +200,7 @@ for (my $i = 1; $net_addr <= $net_addr->broadcast; $i++, $net_addr++) {
|
||||||
update_recon_task ($dbh, $task_id, ceil ($i / ($total_hosts / 100)));
|
update_recon_task ($dbh, $task_id, ceil ($i / ($total_hosts / 100)));
|
||||||
|
|
||||||
my $alive = 0;
|
my $alive = 0;
|
||||||
if (ipmi_ping ($addr) == 1) {
|
if (ipmi_ping ($addr, $pkg_count, $pkg_timeout) == 1) {
|
||||||
$alive = 1;
|
$alive = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue