2007-05-21 Sancho Lerena <slerena@artica.es>

* pandora_network: Version banner update.

        * pandora_db.pm: Fixed problem in function
        module_generic_data_inc() that doesn't create record on new
        data_inc modules, only updates if already exists. Fixed and
        tested.

        * pandora_network.pm: pandora_query_snmp() function return 0 if
        cannot stablish connection. Also, snmp_data_proc value of 2 (down)
        is turned to 0 for Pandora FMS. Also, now when cannot connect,
        ONLY UPDATE last_try field, not timestamp field in tagente_estado
        table. I don't know why was in that way until this moment ¿?




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@460 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2007-05-21 09:12:21 +00:00
parent 32d96a89a0
commit a822da5d02
5 changed files with 72 additions and 39 deletions

View File

@ -1,12 +1,29 @@
2007-05-21 Sancho Lerena <slerena@artica.es>
* pandora_network: Version banner update.
* pandora_db.pm: Fixed problem in function
module_generic_data_inc() that doesn't create record on new
data_inc modules, only updates if already exists. Fixed and
tested.
* pandora_network.pm: pandora_query_snmp() function return 0 if
cannot stablish connection. Also, snmp_data_proc value of 2 (down)
is turned to 0 for Pandora FMS. Also, now when cannot connect,
ONLY UPDATE last_try field, not timestamp field in tagente_estado
table. I don't know why was in that way until this moment ¿?
2007-05-07 Sancho Lerena <slerena@artica.es> 2007-05-07 Sancho Lerena <slerena@artica.es>
* bin/pandora_db.pm: Fixed some problems with quotes and other aditional * bin/pandora_db.pm: Fixed some problems with quotes and other
checks. aditional checks.
* bin/pandora_network.pl: Fixed some problems with quotes and other * bin/pandora_network.pl: Fixed some problems with quotes and
aditional checks. Detected a serious BUG in snmplib for Ubuntu Freeze other aditional checks. Detected a serious BUG in snmplib for
(already submitted as detected BUG with veryhigh priority). This makes Ubuntu Freeze
pandora network server unusable on feisty until fixed :(. Bug item is in (already submitted as detected BUG with veryhigh priority). This
makes pandora network server unusable on feisty until fixed
:(. Bug item is in
https://bugs.launchpad.net/ubuntu/+source/net-snmp/+bug/65047 https://bugs.launchpad.net/ubuntu/+source/net-snmp/+bug/65047
2007-05-07 Sancho Lerena <slerena@artica.es> 2007-05-07 Sancho Lerena <slerena@artica.es>

View File

@ -642,32 +642,32 @@ sub module_generic_data_inc (%$$$$$) {
my $m_utimestamp = &UnixDate ($m_timestamp, "%s"); my $m_utimestamp = &UnixDate ($m_timestamp, "%s");
if ($id_agente_modulo == -1) { if ($id_agente_modulo == -1) {
$no_existe = 1;
$id_agente_modulo = crea_agente_modulo ($pa_config, $agent_name, $module_type, $m_name, $a_max, $a_min, $a_desc, $dbh); $id_agente_modulo = crea_agente_modulo ($pa_config, $agent_name, $module_type, $m_name, $a_max, $a_min, $a_desc, $dbh);
$no_existe = 1;
} else { } else {
my $query_idag = "SELECT * FROM tagente_datos_inc WHERE id_agente_modulo = $id_agente_modulo"; my $query_idag = "SELECT * FROM tagente_datos_inc WHERE id_agente_modulo = $id_agente_modulo";
my $s_idag = $dbh->prepare($query_idag); my $s_idag = $dbh->prepare($query_idag);
$s_idag->execute; $s_idag->execute;
my @data_row = $s_idag->fetchrow_array(); if ($s_idag->rows == 0) {
if (is_numeric($data_row[2])){ # Does not exists entry in tagente_datos_inc yet
$data_anterior = $data_row[2]; $no_existe = 1;
} else { } else {
$data_anterior = 0; my @data_row = $s_idag->fetchrow_array();
} if (is_numeric($data_row[2])){
if (is_numeric($data_row[4])){ $data_anterior = $data_row[2];
$timestamp_anterior = $data_row[4]; }
} else { if (is_numeric($data_row[4])){
$timestamp_anterior = 0; $timestamp_anterior = $data_row[4];
} }
$diferencia = $m_data - $data_anterior;
$diferencia = $m_data - $data_anterior; $timestamp_diferencia = $m_utimestamp - $timestamp_anterior;
$timestamp_diferencia = $m_utimestamp - $timestamp_anterior; # get seconds between last data and this data
# get seconds between last data and this data if (($timestamp_diferencia > 0) && ($diferencia > 0)) {
if (($timestamp_diferencia > 0) && ($diferencia > 0)) { $diferencia = $diferencia / $timestamp_diferencia;
$diferencia = $diferencia / $timestamp_diferencia; }
} if ($diferencia < 0 ){
if ($diferencia < 0 ){ $need_reset = 1;
$need_reset = 1; }
} }
$s_idag -> finish(); $s_idag -> finish();
} }

View File

@ -25,7 +25,7 @@ use Time::Local; # DateTime basic manipulation
use Net::Ping; # For ICMP latency use Net::Ping; # For ICMP latency
use Time::HiRes; # For high precission timedate functions (Net::Ping) use Time::HiRes; # For high precission timedate functions (Net::Ping)
use IO::Socket; # For TCP/UDP access use IO::Socket; # For TCP/UDP access
use SNMP; # For SNMP access (libsnmp-perl PACKAGE!) use SNMP; # For SNMP access (libsnmp-perl PACKAGE!)
use threads; use threads;
# Pandora Modules # Pandora Modules
@ -45,10 +45,13 @@ $SIG{'INT'} = 'pandora_shutdown';
# Inicio del bucle principal de programa # Inicio del bucle principal de programa
pandora_init(\%pa_config, "Pandora FMS Network Server"); pandora_init(\%pa_config, "Pandora FMS Network Server");
# Read config file for Global variables # Read config file for Global variables
pandora_loadconfig (\%pa_config,1); pandora_loadconfig (\%pa_config,1);
# Audit server starting # Audit server starting
pandora_audit (\%pa_config, "Pandora FMS Network Daemon starting", "SYSTEM", "System"); pandora_audit (\%pa_config, "Pandora FMS Network Daemon starting", "SYSTEM", "System");
print " [*] Starting up network threads\n"; print " [*] Starting up network threads\n";
if ( $pa_config{"daemon"} eq "1" ) { if ( $pa_config{"daemon"} eq "1" ) {
@ -350,7 +353,7 @@ sub pandora_ping_icmp {
########################################################################## ##########################################################################
# SUB pandora_query_tcp (pa_config, tcp_port. ip_target, result, data, tcp_send, # SUB pandora_query_tcp (pa_config, tcp_port. ip_target, result, data, tcp_send,
# tcp_rcv, id_tipo_module, dbh) # tcp_rcv, id_tipo_module, dbh)
# Makes a call to TCP modules to get a value. # Makes a call to TCP modules to get a value.
########################################################################## ##########################################################################
sub pandora_query_tcp (%$$$$$$$$) { sub pandora_query_tcp (%$$$$$$$$) {
@ -453,7 +456,7 @@ sub pandora_query_snmp {
Version => 1); Version => 1);
if ((!defined($SESSION))&& ($snmp_community != "") && ($snmp_oid != "")) { if ((!defined($SESSION))&& ($snmp_community != "") && ($snmp_oid != "")) {
logger($pa_config, "SNMP ERROR SESSION for Target $snmp_target ", 4); logger($pa_config, "SNMP ERROR SESSION for Target $snmp_target ", 4);
$_[4]="1"; $_[4] = "1";
} else { } else {
# Perl uses different OID syntax than SNMPWALK or PHP's SNMP # Perl uses different OID syntax than SNMPWALK or PHP's SNMP
# for example: # for example:
@ -476,9 +479,10 @@ sub pandora_query_snmp {
my @OIDINFO = $SESSION->getnext($OIDLIST); my @OIDINFO = $SESSION->getnext($OIDLIST);
$output = $OIDINFO[0]; $output = $OIDINFO[0];
if ((!defined($output)) || ($output eq "")){ if ((!defined($output)) || ($output eq "")){
$_[4]="1"; $_[4] = "1";
return 0;
} else { } else {
$_[4]="0"; $_[4] = "0";
} }
} }
return $output; return $output;
@ -549,7 +553,7 @@ sub exec_network_module {
$module_result = 0; # Done but, with zero value $module_result = 0; # Done but, with zero value
$module_data = 0; $module_data = 0;
} }
# SNMP Modules (Proc, inc, data, string) # SNMP Modules (Proc=18, inc, data, string)
# ------------ # ------------
} elsif (($id_tipo_modulo == 15) || ($id_tipo_modulo == 18) || ($id_tipo_modulo == 16) || ($id_tipo_modulo == 17)) { # SNMP module } elsif (($id_tipo_modulo == 15) || ($id_tipo_modulo == 18) || ($id_tipo_modulo == 16) || ($id_tipo_modulo == 17)) { # SNMP module
if ($mysnmp_oid ne ""){ if ($mysnmp_oid ne ""){
@ -561,9 +565,18 @@ sub exec_network_module {
# SUB pandora_query_snmp (pa_config, oid, community, target, error, dbh) # SUB pandora_query_snmp (pa_config, oid, community, target, error, dbh)
if ($error == 0) { # A correct SNMP Query if ($error == 0) { # A correct SNMP Query
$module_result = 0; $module_result = 0;
if (($id_tipo_modulo == 15) || ($id_tipo_modulo == 18) || ($id_tipo_modulo == 16) ){ # Numeric SNMP modules and PROC # SNMP_DATA_PROC
if ($id_tipo_modulo == 18){ #snmp_data_proc
if ($temp2 != 1){ # up state is 1, down state in SNMP is 2 ....
$temp2 = 0;
}
$module_data = $temp2;
$module_result = 0; # Successful
}
# SNMP_DATA and SNMP_DATA_INC
elsif (($id_tipo_modulo == 15) || ($id_tipo_modulo == 16) ){
if ($temp2 =~ /[A-Za-z\.\,\-\/\\\(\)\[\]]/){ if ($temp2 =~ /[A-Za-z\.\,\-\/\\\(\)\[\]]/){
$module_result = 1; # Alphanumeric dada, not numeric $module_result = 1; # Alphanumeric data, not numeric
} else { } else {
$module_data = int($temp2); $module_data = int($temp2);
$module_result = 0; # Successful $module_result = 0; # Successful
@ -573,6 +586,7 @@ sub exec_network_module {
$module_result=0; $module_result=0;
} }
} else { # Failed SNMP-GET } else { # Failed SNMP-GET
$module_data = 0;
$module_result = 1; # No data, cannot connect $module_result = 1; # No data, cannot connect
} }
# TCP Module # TCP Module
@ -621,7 +635,8 @@ sub exec_network_module {
logger ($pa_config, "Cannot obtain exec Network Module $nombre from agent $agent_name", 4); logger ($pa_config, "Cannot obtain exec Network Module $nombre from agent $agent_name", 4);
my $timestamp = &UnixDate("today","%Y-%m-%d %H:%M:%S"); my $timestamp = &UnixDate("today","%Y-%m-%d %H:%M:%S");
my $utimestamp = &UnixDate("today","%s"); my $utimestamp = &UnixDate("today","%s");
my $query_act = "UPDATE tagente_estado SET utimestamp = $utimestamp, timestamp = '$timestamp', last_try = '$timestamp' WHERE id_agente_estado = $id_agente_estado "; #my $query_act = "UPDATE tagente_estado SET utimestamp = $utimestamp, timestamp = '$timestamp', last_try = '$timestamp' WHERE id_agente_estado = $id_agente_estado ";
my $query_act = "UPDATE tagente_estado SET last_try = '$timestamp' WHERE id_agente_estado = $id_agente_estado ";
my $a_idages = $dbh->prepare($query_act); my $a_idages = $dbh->prepare($query_act);
$a_idages->execute; $a_idages->execute;
$a_idages->finish(); $a_idages->finish();

View File

@ -1,8 +1,9 @@
#!/bin/sh #!/bin/bash
# Pandora Network Server, startup script # Pandora Network Server, startup script
# Sancho Lerena, <slerena@gmail.com> # Sancho Lerena, <slerena@gmail.com>
# Linux Version (generico) # Linux Version (generico)
# v1.2 (Ene/2006) # v1.3
# Configurable path and filenames # Configurable path and filenames
PANDORA_HOME="/usr/share/pandora_server" PANDORA_HOME="/usr/share/pandora_server"

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# Pandora Data Server startup script # Pandora Data Server startup script
# Sancho Lerena, <slerena@gmail.com> # Sancho Lerena, <slerena@gmail.com>
# Linux Version (generic) # Linux Version (generic)