2008-07-22 Sancho Lerena <slerena@gmail.com>
* pandora_network: Minimal style changes. Added status change in tserver table on controlled shutdown. * pandora_server: Added status change in tserver table on controlled shutdown. Minimal changes and optimizations. Recheck for bad XML is adjusted to 3 instead 10.Fixed problem with "blank" agent names. Added support for async types (data, proc and string). * config.pm: Added support for new config token: max_log_size. This stablish a max log filesize. * DB.pm: Added support for postprocess (as simple multiplier value). Fixed problem with continuous update of laststart in server keepalive. Updated also several logger priorities (raise them). * Config.pm: pandora_get_os() fixed for void OSes. Logger() implements a file-rotation system with a maximum in bytes for PandoraFMS log file. * pandora_server.conf: Updated with new options and removed some from 1.3.1 * pandora_export: Deleted skeleton file por export server. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@967 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
bfedfd0106
commit
41588772b0
|
@ -1,3 +1,27 @@
|
|||
2008-07-22 Sancho Lerena <slerena@gmail.com>
|
||||
|
||||
* pandora_network: Minimal style changes. Added status change in
|
||||
tserver table on controlled shutdown.
|
||||
|
||||
* pandora_server: Added status change in tserver table on controlled
|
||||
shutdown. Minimal changes and optimizations. Recheck for bad XML is
|
||||
adjusted to 3 instead 10.Fixed problem with "blank" agent names. Added
|
||||
support for async types (data, proc and string).
|
||||
|
||||
* config.pm: Added support for new config token: max_log_size. This
|
||||
stablish a max log filesize.
|
||||
|
||||
* DB.pm: Added support for postprocess (as simple multiplier value).
|
||||
Fixed problem with continuous update of laststart in server keepalive.
|
||||
Updated also several logger priorities (raise them).
|
||||
|
||||
* Config.pm: pandora_get_os() fixed for void OSes. Logger() implements
|
||||
a file-rotation system with a maximum in bytes for PandoraFMS log file.
|
||||
|
||||
* pandora_server.conf: Updated with new options and removed some from 1.3.1
|
||||
|
||||
* pandora_export: Deleted skeleton file por export server.
|
||||
|
||||
2008-07-11 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||
|
||||
* pandora_server/pandora_network
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
##########################################################################
|
||||
# Pandora FMS Export Server
|
||||
##########################################################################
|
||||
# Copyright (c) 2008 Sancho Lerena, slerena@gmail.com
|
||||
# (c) 2008 Artica Soluciones Tecnologicas S.L
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 (only).
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##########################################################################
|
||||
|
||||
# Includes list
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Date::Manip; # Needed to manipulate DateTime formats of
|
||||
# input, output and compare
|
||||
use Time::Local; # DateTime basic manipulation
|
||||
use XML::Simple; # Useful XML functions
|
||||
use Time::Local; # DateTime basic manipulation
|
||||
use DBI;
|
||||
|
||||
# Pandora Modules
|
||||
use PandoraFMS::Config;
|
||||
use PandoraFMS::Tools;
|
||||
use PandoraFMS::DB;
|
||||
|
||||
# FLUSH in each IO (only for debug, very slooow)
|
||||
# ENABLED in DEBUGMODE
|
||||
# DISABLE FOR PRODUCTION
|
||||
$| = 0;
|
||||
|
||||
my %pa_config;
|
||||
|
||||
$SIG{'TERM'} = 'pandora_shutdown';
|
||||
$SIG{'INT'} = 'pandora_shutdown';
|
||||
|
||||
# Inicio del bucle principal de programa
|
||||
pandora_init(\%pa_config, "Pandora FMS Export Server");
|
||||
|
||||
# Read config file for Global variables
|
||||
pandora_loadconfig (\%pa_config, 7);
|
||||
|
||||
# Audit server starting
|
||||
pandora_audit (\%pa_config, "Pandora FMS Export server starting", "SYSTEM", "System");
|
||||
|
||||
# Daemonize and put in background
|
||||
if ( $pa_config{"daemon"} eq "1" ){
|
||||
if ($pa_config{"quiet"} eq "0"){
|
||||
print " [*] Backgrounding Pandora FMS Export Server process.\n\n";
|
||||
}
|
||||
&pandora_daemonize ( \%pa_config);
|
||||
}
|
||||
|
||||
die ("There is no more program yet! :-)");
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
|
||||
if 0; # not running under some shell
|
||||
##########################################################################
|
||||
# Pandora FMS Network Server
|
||||
##########################################################################
|
||||
|
@ -28,7 +25,7 @@ use Time::Local; # DateTime basic manipulation
|
|||
use Net::Ping; # For ICMP latency
|
||||
use Time::HiRes; # For high precission timedate functions (Net::Ping)
|
||||
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::shared;
|
||||
|
||||
|
@ -379,7 +376,7 @@ sub pandora_query_tcp (%$$$$$$$) {
|
|||
if (defined($handle)){
|
||||
# Multi request patch, submitted by Glen Eustace (new zealand)
|
||||
my @tcp_send = split( /\|/, $tcp_send );
|
||||
my @tcp_rcv = split( /\|/, $tcp_rcv );
|
||||
my @tcp_rcv = split( /\|/, $tcp_rcv );
|
||||
|
||||
next_pair:
|
||||
$tcp_send = shift( @tcp_send );
|
||||
|
@ -696,6 +693,7 @@ sub exec_network_module {
|
|||
########################################################################################
|
||||
sub pandora_shutdown {
|
||||
logger (\%pa_config,"Pandora FMS Server '".$pa_config{'servername'}.$pa_config{"servermode"}."' Shutdown by signal ",0);
|
||||
pandora_updateserver (\%pa_config, $pa_config{'servername'}, 0, 1, $dbh);
|
||||
print " [*] Shutting down ".$pa_config{'servername'}.$pa_config{"servermode"} ."(received signal)...\n";
|
||||
pandora_event (\%pa_config, $pa_config{'servername'}.$pa_config{"servermode"}." going Down", 0,
|
||||
0, 4, 0, 0, "system", $dbh);
|
||||
|
|
|
@ -86,9 +86,9 @@ pandora_startlog (\%pa_config);
|
|||
my $dbhost = $pa_config{'dbhost'};
|
||||
my $dbname = $pa_config{'dbname'};
|
||||
my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost:3306",
|
||||
$pa_config{'dbuser'},
|
||||
$pa_config{'dbpass'},
|
||||
{ RaiseError => 1, AutoCommit => 1 });
|
||||
$pa_config{'dbuser'},
|
||||
$pa_config{'dbpass'},
|
||||
{ RaiseError => 1, AutoCommit => 1 });
|
||||
|
||||
# KeepAlive checks for Agents, only for master servers, in separate thread
|
||||
while (1) {
|
||||
|
@ -103,11 +103,12 @@ while (1) {
|
|||
# Close system
|
||||
########################################################################################
|
||||
sub pandora_shutdown {
|
||||
logger (\%pa_config,"Pandora FMS Server '".$pa_config{'servername'}.$pa_config{"servermode"}."' Shutdown by signal ",0);
|
||||
print " [*] Shutting down ".$pa_config{'servername'}.$pa_config{"servermode"} ."(received signal)...\n";
|
||||
pandora_event (\%pa_config, $pa_config{'servername'}.$pa_config{"servermode"}." going Down", 0,
|
||||
0, 4, 0, 0, "system", $dbh);
|
||||
exit;
|
||||
logger (\%pa_config,"Pandora FMS Server '".$pa_config{'servername'}.$pa_config{"servermode"}."' Shutdown by signal ",0);
|
||||
pandora_updateserver (\%pa_config, $pa_config{'servername'}, 0, 0, $dbh);
|
||||
print " [*] Shutting down ".$pa_config{'servername'}.$pa_config{"servermode"} ."(received signal)...\n";
|
||||
pandora_event (\%pa_config, $pa_config{'servername'}.$pa_config{"servermode"}." going Down", 0,
|
||||
0, 4, 0, 0, "system", $dbh);
|
||||
exit;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
@ -155,7 +156,6 @@ sub pandora_data_producer {
|
|||
$incomplete_task_hash{$file_name} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
threads->yield;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,6 @@ sub pandora_data_producer {
|
|||
sub pandora_data_consumer ($$) {
|
||||
my $pa_config = $_[0];
|
||||
my $thread_id = $_[1];
|
||||
|
||||
my $file_name;
|
||||
my $counter =0;
|
||||
|
||||
|
@ -212,6 +211,7 @@ sub pandora_data_consumer ($$) {
|
|||
# Check file really exists to avoid race conditions
|
||||
if (! -e "$file") {
|
||||
$counter++;
|
||||
delete($active_task_hash{$file_name});
|
||||
next LOOP;
|
||||
}
|
||||
|
||||
|
@ -219,15 +219,14 @@ sub pandora_data_consumer ($$) {
|
|||
|
||||
# Parse the XML file
|
||||
eval {
|
||||
logger ($pa_config, "Ready to parse $file_name",4);
|
||||
threads->yield;
|
||||
$data = XMLin($file, forcearray=>'module');
|
||||
};
|
||||
|
||||
# Invalid MXL
|
||||
if ($@) {
|
||||
|
||||
# Retry
|
||||
if ($incomplete_task_hash{$file_name} < 10) {
|
||||
# Retry 3 times this XML
|
||||
if ($incomplete_task_hash{$file_name} < 3) {
|
||||
{
|
||||
lock $queue_lock;
|
||||
delete($active_task_hash{$file_name});
|
||||
|
@ -237,22 +236,22 @@ sub pandora_data_consumer ($$) {
|
|||
# Discard
|
||||
else {
|
||||
{
|
||||
logger ($pa_config, "$file_name is a BAD XML. Removing", 3);
|
||||
lock $queue_lock;
|
||||
delete($active_task_hash{$file_name});
|
||||
delete($incomplete_task_hash{$file_name});
|
||||
rename($file, $file . "_BADXML");
|
||||
|
||||
# Create event
|
||||
pandora_event ($pa_config, "Unable to process XML data file ($file)", 0, 0, 0, 0, 0, 'error', $dbh);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$counter = 0;
|
||||
threads->yield;
|
||||
next LOOP;
|
||||
}
|
||||
|
||||
procesa_datos ($pa_config, $data, $dbh);
|
||||
process_datafile ($pa_config, $data, $dbh);
|
||||
|
||||
{
|
||||
lock $queue_lock;
|
||||
|
@ -260,7 +259,7 @@ sub pandora_data_consumer ($$) {
|
|||
delete($incomplete_task_hash{$file_name});
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
threads->yield;
|
||||
$counter = 0;
|
||||
}
|
||||
}
|
||||
|
@ -274,45 +273,47 @@ sub keep_alive_check {
|
|||
my $pa_config = $_[0];
|
||||
my $dbh = $_[1];
|
||||
my $timestamp = &UnixDate ("today", "%Y-%m-%d %H:%M:%S");
|
||||
my $utimestamp = &UnixDate ("today", "%s");
|
||||
my $query_idag = "SELECT tagente_modulo.id_agente_modulo, tagente_estado.utimestamp, tagente_estado.id_agente, tagente.intervalo, tagente.nombre, tagente_modulo.nombre FROM tagente_modulo, talerta_agente_modulo, tagente_estado, tagente WHERE tagente_modulo.id_agente_modulo = talerta_agente_modulo.id_agente_modulo AND talerta_agente_modulo.disable = 0 AND tagente_modulo.id_tipo_modulo = 100 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.datos != 0";
|
||||
my $s_idag = $dbh->prepare($query_idag);
|
||||
$s_idag ->execute;
|
||||
my $utimestamp = &UnixDate ("today", "%s");
|
||||
my $query_idag = "SELECT tagente_modulo.id_agente_modulo, tagente_estado.utimestamp, tagente_estado.id_agente, tagente.intervalo, tagente.nombre, tagente_modulo.nombre FROM tagente_modulo, talerta_agente_modulo, tagente_estado, tagente WHERE tagente_modulo.id_agente_modulo = talerta_agente_modulo.id_agente_modulo AND talerta_agente_modulo.disable = 0 AND tagente_modulo.id_tipo_modulo = 100 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.datos != 0";
|
||||
my $s_idag = $dbh->prepare($query_idag);
|
||||
$s_idag ->execute;
|
||||
|
||||
my $id_agent_module;
|
||||
my $module_utimestamp;
|
||||
my $id_agent;
|
||||
my $interval;
|
||||
my $agent_name;
|
||||
my $module_name;
|
||||
my $id_agent_module;
|
||||
my $module_utimestamp;
|
||||
my $id_agent;
|
||||
my $interval;
|
||||
my $agent_name;
|
||||
my $module_name;
|
||||
|
||||
# data needed in loop (we'll reuse it)
|
||||
my @data;
|
||||
my @data;
|
||||
if ($s_idag->rows != 0) {
|
||||
while (@data = $s_idag->fetchrow_array()) {
|
||||
threads->yield;
|
||||
$id_agent_module = $data[0];
|
||||
$module_utimestamp = $data[1];
|
||||
$id_agent = $data[2];
|
||||
$interval = $data[3];
|
||||
$agent_name = $data[4];
|
||||
$module_name = $data[5];
|
||||
# Agent down - Keepalive utimestamp too low (2x)
|
||||
if (($module_utimestamp + ($interval * 2)) < $utimestamp){
|
||||
pandora_writestate ($pa_config, $agent_name, "keep_alive", $module_name, 0, 1, $dbh, 1);
|
||||
}
|
||||
$module_utimestamp = $data[1];
|
||||
$id_agent = $data[2];
|
||||
$interval = $data[3];
|
||||
$agent_name = $data[4];
|
||||
$module_name = $data[5];
|
||||
# Agent down - Keepalive utimestamp too low (2x)
|
||||
if (($module_utimestamp + ($interval * 2)) < $utimestamp){
|
||||
pandora_writestate ($pa_config, $agent_name, "keep_alive", $module_name, 0, 1, $dbh, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
$s_idag->finish();
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
## SUB procesa_datos (param_1)
|
||||
## SUB process_datafile (param_1, param_2, param_3)
|
||||
## Process data packet (XML file)
|
||||
##########################################################################
|
||||
## param_1 : XML datafile name
|
||||
## param_1 : pandora_config hash
|
||||
## param_2 : XML Hash structure reference
|
||||
## param_3
|
||||
|
||||
sub procesa_datos {
|
||||
sub process_datafile {
|
||||
my $pa_config = $_[0];
|
||||
my $datos = $_[1];
|
||||
my $dbh = $_[2];
|
||||
|
@ -347,7 +348,7 @@ sub procesa_datos {
|
|||
}
|
||||
|
||||
|
||||
if (defined $agent_name){
|
||||
if ((defined $agent_name) && ($agent_name ne "")){
|
||||
$id_agente = dame_agente_id($pa_config,$agent_name,$dbh);
|
||||
|
||||
if ($id_agente == -1){
|
||||
|
@ -357,7 +358,7 @@ sub procesa_datos {
|
|||
# Always create event about this detected IP
|
||||
|
||||
} else {
|
||||
logger($pa_config, "ERROR: There is no agent defined with name $agent_name", 2);
|
||||
logger($pa_config, "ERROR: There is no agent defined with name $agent_name", 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,7 +402,7 @@ sub procesa_datos {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
logger($pa_config, "ERROR: Received data from an unknown agent", 1);
|
||||
logger($pa_config, "ERROR: Received data from an unknown agent", 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,17 +420,17 @@ sub process_module_data {
|
|||
my $module = $_[4];
|
||||
my $dbh = $_[5];
|
||||
|
||||
if ($tipo_modulo eq 'generic_data') {
|
||||
module_generic_data ($pa_config, $module, $timestamp, $agent_name, "generic_data", $dbh);
|
||||
if (($tipo_modulo eq 'generic_data') || ($tipo_modulo eq 'async_data')) {
|
||||
module_generic_data ($pa_config, $module, $timestamp, $agent_name, $tipo_modulo, $dbh);
|
||||
}
|
||||
elsif ($tipo_modulo eq 'generic_data_inc') {
|
||||
module_generic_data_inc ($pa_config, $module, $timestamp, $agent_name,"generic_data_inc", $dbh);
|
||||
}
|
||||
elsif ($tipo_modulo eq 'generic_data_string') {
|
||||
module_generic_data_string ($pa_config, $module, $timestamp, $agent_name,"generic_data_string", $dbh);
|
||||
elsif (($tipo_modulo eq 'generic_data_string') || ($tipo_modulo eq 'async_string')) {
|
||||
module_generic_data_string ($pa_config, $module, $timestamp, $agent_name,$tipo_modulo, $dbh);
|
||||
}
|
||||
elsif ($tipo_modulo eq 'generic_proc') {
|
||||
module_generic_proc ($pa_config, $module, $timestamp, $agent_name, "generic_proc", $dbh);
|
||||
elsif (($tipo_modulo eq 'generic_proc') || ($tipo_modulo eq 'async_data')) {
|
||||
module_generic_proc ($pa_config, $module, $timestamp, $agent_name, $tipo_modulo, $dbh);
|
||||
}
|
||||
else {
|
||||
logger($pa_config, "ERROR: Received data from an unknown module ($tipo_modulo)", 2);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#############################################################################
|
||||
# Pandora Server Parameters, please change it for your setup needs
|
||||
# Pandora FMS Server Parameters
|
||||
# Pandora FMS, the Flexible Monitoring System.
|
||||
# http://www.pandorafms.com
|
||||
# Please change it for your setup needs
|
||||
#############################################################################
|
||||
|
||||
# Servername: Name of this server
|
||||
|
@ -82,56 +85,6 @@ dataserver 1
|
|||
|
||||
reconserver 1
|
||||
|
||||
# Network timeout (in seconds) for timeout in network connections for Network agents
|
||||
|
||||
network_timeout 5
|
||||
|
||||
# Server keepalive (in seconds)
|
||||
|
||||
server_keepalive 50
|
||||
|
||||
# Server Threshold: defines number of seconds of main loop (in sec)
|
||||
|
||||
server_threshold 15
|
||||
|
||||
network_threads 5
|
||||
|
||||
# icmp_checks x : defines number of pings for each icmp_proc module type. at least one of that ping should be 1 to report 1
|
||||
icmp_checks 2
|
||||
|
||||
# alert_recovery 1 | 0 : Defines if Pandora FMS launch another alert when alert condition is recovered. It
|
||||
# has the same field1, but adds "[RECOVER]" to field2 and field3. Is disabled by default.
|
||||
|
||||
alert_recovery 1
|
||||
|
||||
# tcp specific options :
|
||||
# tcp_checks: number of tcp retries if first attempt fails.
|
||||
# tcp_timeout: specific timeout for tcp connections
|
||||
|
||||
tcp_checks 2
|
||||
tcp_timeout 30
|
||||
|
||||
# snmp specific options :
|
||||
# snmp_checks: number of snmp request retries if first attempt fails.
|
||||
# snmp_timeout: specific timeout for snmp request.
|
||||
|
||||
snmp_checks 4
|
||||
snmp_timeout 10
|
||||
|
||||
# snmp_proc_deadresponse 1 (default): Return DOWN if cannot contact
|
||||
# or receive NULL from a SNMP PROC module.
|
||||
|
||||
snmp_proc_deadresponse 1
|
||||
|
||||
# plugin_threads: Specify number of plugin server threads for processing plugin calls
|
||||
|
||||
plugin_threads 5
|
||||
|
||||
# plugin_timeout: Specify number of seconds calling plugin exec waiting for response
|
||||
# after this time, call is aborted and result is "unknown".
|
||||
|
||||
plugin_timeout 5
|
||||
|
||||
# pluginserver : 1 or 0. Set to 1 to activate plugin server with this setup
|
||||
|
||||
pluginserver 1
|
||||
|
@ -144,13 +97,70 @@ predictionserver 1
|
|||
|
||||
wmiserver 1
|
||||
|
||||
# Network timeout (in seconds) for timeout in network connections for Network agents
|
||||
|
||||
network_timeout 3
|
||||
|
||||
# Server keepalive (in seconds)
|
||||
|
||||
server_keepalive 45
|
||||
|
||||
# Server Threshold: defines number of seconds of main loop (in sec)
|
||||
|
||||
server_threshold 5
|
||||
|
||||
# Network threads: Do not set too high (~40). Each threads make a network module check.
|
||||
|
||||
network_threads 5
|
||||
|
||||
# icmp_checks x : defines number of pings for each icmp_proc module type. at least one of
|
||||
# that ping should be 1 to report 1
|
||||
|
||||
icmp_checks 2
|
||||
|
||||
# tcp specific options :
|
||||
# tcp_checks: number of tcp retries if first attempt fails.
|
||||
# tcp_timeout: specific timeout for tcp connections
|
||||
|
||||
tcp_checks 1
|
||||
tcp_timeout 30
|
||||
|
||||
# snmp specific options :
|
||||
# snmp_checks: number of snmp request retries if first attempt fails.
|
||||
# snmp_timeout: specific timeout for snmp request.
|
||||
|
||||
snmp_checks 1
|
||||
snmp_timeout 3
|
||||
|
||||
# snmp_proc_deadresponse 1 (default): Return DOWN if cannot contact
|
||||
# or receive NULL from a SNMP PROC module.
|
||||
|
||||
snmp_proc_deadresponse 1
|
||||
|
||||
# plugin_threads: Specify number of plugin server threads for processing plugin calls
|
||||
|
||||
plugin_threads 3
|
||||
|
||||
# plugin_timeout: Specify number of seconds calling plugin exec waiting for response
|
||||
# after this time, call is aborted and result is "unknown".
|
||||
|
||||
plugin_timeout 5
|
||||
|
||||
# wmi_timeout : specific timeout for wmi request.
|
||||
|
||||
wmi_timeout 10
|
||||
|
||||
# wmi_threads: Specify number of WMI server threads for processing WMI remote calls
|
||||
|
||||
wmi_threads 3
|
||||
wmi_threads 2
|
||||
|
||||
# recon_threads. Each thread will scan a different scantask.
|
||||
|
||||
recon_threads 2
|
||||
|
||||
# dataserver_threads: Number of threads for data server (XML processing threads)
|
||||
|
||||
dataserver_threads 2
|
||||
|
||||
# mta_address: External Mailer (MTA) IP Address to be used by Pandora FMS internal email capabilities
|
||||
# mta_address 192.168.50.1
|
||||
|
@ -177,6 +187,8 @@ autocreate_group 2
|
|||
|
||||
autocreate 1
|
||||
|
||||
# recon_threads (3 by default)
|
||||
# max_log_size: Specify max size of Pandora FMS server log file (1MB by default). If
|
||||
# log file grows above this limit, is renamed to "pandora_server.log.old".
|
||||
|
||||
max_log_size 65536
|
||||
|
||||
recon_threads 3
|
|
@ -1,6 +1,7 @@
|
|||
package PandoraFMS::Config;
|
||||
##########################################################################
|
||||
# Pandora Config package
|
||||
# Configuration Package
|
||||
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||
##########################################################################
|
||||
# Copyright (c) 2004-2008 Sancho Lerena, slerena@gmail.com
|
||||
# Copyright (c) 2005-2008 Artica Soluciones Tecnologicas S.L
|
||||
|
@ -195,7 +196,10 @@ sub pandora_loadconfig {
|
|||
$pa_config->{"xprobe2"} = "/usr/bin/xprobe2";
|
||||
$pa_config->{'autocreate_group'} = 2;
|
||||
$pa_config->{'autocreate'} = 1;
|
||||
$pa_config{'recon_threads'} = 3;
|
||||
$pa_config->{'recon_threads'} = 3;
|
||||
|
||||
# max log size (bytes)
|
||||
$pa_config->{'max_log_size'} = 1048576; # 1MB by default
|
||||
|
||||
# Check for UID0
|
||||
if ($pa_config->{"quiet"} != 0){
|
||||
|
@ -402,7 +406,9 @@ sub pandora_loadconfig {
|
|||
elsif ($parametro =~ m/^recon_threads\s([0-9]*)/i) {
|
||||
$pa_config->{'recon_threads'}= clean_blank($1);
|
||||
}
|
||||
|
||||
elsif ($parametro =~ m/^max_log_size\s([0-9]*)/i) {
|
||||
$pa_config->{'max_log_size'}= clean_blank($1);
|
||||
}
|
||||
} # end of loop for parameter #
|
||||
|
||||
|
||||
|
@ -510,7 +516,7 @@ sub pandora_loadconfig {
|
|||
# Check valid Database variables and update server status
|
||||
eval {
|
||||
$dbh = DBI->connect("DBI:mysql:$pa_config->{'dbname'}:$pa_config->{'dbhost'}:3306", $pa_config->{'dbuser'}, $pa_config->{'dbpass'}, { RaiseError => 1, AutoCommit => 1 });
|
||||
pandora_updateserver ($pa_config, $pa_config->{'servername'},1, $opmode, $dbh); # Alive status
|
||||
pandora_updateserver ($pa_config, $pa_config->{'servername'}, 1, $opmode, $dbh); # Alive status
|
||||
};
|
||||
if ($@) {
|
||||
logger ($pa_config, "Error connecting database in init Phase. Aborting startup.",0);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package PandoraFMS::DB;
|
||||
##########################################################################
|
||||
# Pandora FMS Database Package
|
||||
# Database Package
|
||||
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||
##########################################################################
|
||||
# Copyright (c) 2004-2008 Sancho Lerena, slerena@gmail.com
|
||||
# Copyright (c) 2005-2008 Artica Soluciones Tecnologicas S.L
|
||||
|
@ -599,7 +600,6 @@ sub pandora_writestate (%$$$$$$$) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
my $id_grupo = dame_grupo_agente($pa_config, $id_agente,$dbh);
|
||||
|
||||
# Seek for agent_interval or module_interval
|
||||
|
@ -609,6 +609,7 @@ sub pandora_writestate (%$$$$$$$) {
|
|||
if ($s_idag->rows == 0) {
|
||||
logger( $pa_config, "ERROR Cannot find agenteModulo $id_agente_modulo",4);
|
||||
logger( $pa_config, "ERROR: SQL Query is $query_idag ",10);
|
||||
return 0;
|
||||
} else {
|
||||
@data = $s_idag->fetchrow_array();
|
||||
}
|
||||
|
@ -619,6 +620,7 @@ sub pandora_writestate (%$$$$$$$) {
|
|||
$module_interval = dame_intervalo ($pa_config, $id_agente, $dbh);
|
||||
}
|
||||
$s_idag->finish();
|
||||
|
||||
# Check alert subroutine
|
||||
eval {
|
||||
pandora_generate_alerts ($pa_config, $timestamp, $nombre_agente, $id_agente, $id_agente_modulo, $id_module_type, $id_grupo, $datos, $dbh);
|
||||
|
@ -633,6 +635,14 @@ sub pandora_writestate (%$$$$$$$) {
|
|||
my $idages = "SELECT * from tagente_estado WHERE id_agente_modulo = $id_agente_modulo";
|
||||
my $s_idages = $dbh->prepare($idages);
|
||||
$s_idages ->execute;
|
||||
|
||||
# Postprocess
|
||||
if (($data[23] != 0) && (is_numeric($data[23]))){
|
||||
if (($id_modulo == 1) || ($id_modulo == 7) || ($id_modulo == 15) || ($id_modulo == 22) || ($id_modulo == 4) || ($id_modulo == 8) || ($id_modulo == 16) ){
|
||||
$datos = $datos * $data[23];
|
||||
}
|
||||
}
|
||||
|
||||
$datos = $dbh->quote($datos); # Parse data entry for adecuate SQL representation.
|
||||
|
||||
my $query_act; # OJO que dentro de una llave solo tiene existencia en esa llave !!
|
||||
|
@ -815,7 +825,7 @@ sub module_generic_proc (%$$$$$) {
|
|||
## param_1 : XML name
|
||||
## paran_2 : Timestamp
|
||||
## param_3 : Agent name
|
||||
## param_4 : Module type
|
||||
## param_4 : Module type (generic_data, async_data or network data)
|
||||
|
||||
sub module_generic_data (%$$$$$) {
|
||||
my $pa_config = $_[0];
|
||||
|
@ -830,10 +840,19 @@ sub module_generic_data (%$$$$$) {
|
|||
my $a_desc = $datos->{description}->[0];
|
||||
my $m_data = $datos->{data}->[0];
|
||||
|
||||
# Notes to improve module_generic_* functions.
|
||||
#
|
||||
# #1 checking for correct data should be made before calling writedata or writestate
|
||||
# #2 a new procedure called return modulehash should detect if exists that module,
|
||||
# create them, and always return a hash with agent needed information and module needed information
|
||||
# #3 this hash should be used as parameter in writedata and writestate in order to have all needed
|
||||
# information and don't need to ask again for the same data. At this time this code is very low and bad
|
||||
# written, need to be optimized.
|
||||
|
||||
my $bUpdateDatos = 0; # added, patch submitted by Dassing
|
||||
if (ref($m_data) ne "HASH"){
|
||||
if (!is_numeric($m_data)){
|
||||
logger($pa_config, "(data) Invalid data (non-numeric) received from $agent_name, module $m_name", 1);
|
||||
logger($pa_config, "(data) Invalid data (non-numeric) received from $agent_name, module $m_name", 3);
|
||||
return -1;
|
||||
}
|
||||
if ($m_data =~ /[0-9]*/){
|
||||
|
@ -856,7 +875,7 @@ sub module_generic_data (%$$$$$) {
|
|||
# Numeric data has status N/A (100) always
|
||||
pandora_writestate ($pa_config, $agent_name, $module_type, $m_name, $m_data, 100, $dbh, $bUpdateDatos);
|
||||
} else {
|
||||
logger($pa_config, "(data) Invalid data value received from $agent_name, module $m_name", 2);
|
||||
logger($pa_config, "(data) Invalid data value received from $agent_name, module $m_name", 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -921,6 +940,9 @@ sub module_generic_data_inc (%$$$$$) {
|
|||
my $timestamp_anterior = 0;
|
||||
my $m_utimestamp = &UnixDate ($m_timestamp, "%s");
|
||||
|
||||
# tagente_datos_inc do not store real data (if real data has any post-process, data is compared and
|
||||
# stored in tagente_datos_inc with its original value).
|
||||
|
||||
if (($id_agente_modulo == -1) && (dame_learnagente($pa_config, $id_agente, $dbh) eq "1" )) {
|
||||
$id_agente_modulo = crea_agente_modulo ($pa_config, $agent_name, $module_type, $m_name, $a_max, $a_min, $a_desc, $dbh);
|
||||
$no_existe = 1;
|
||||
|
@ -1037,6 +1059,7 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||
my $descripcion = $_[8];
|
||||
my $dbh = $_[9];
|
||||
my $Ref_bUpdateDatos = $_[10];
|
||||
|
||||
my @data;
|
||||
|
||||
if (!defined($max)){
|
||||
|
@ -1070,9 +1093,19 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||
if ($s_idag->rows == 0) {
|
||||
logger( $pa_config, "ERROR Cannot find agenteModulo $id_agente_modulo",6);
|
||||
logger( $pa_config, "ERROR: SQL Query is $query_idag ",10);
|
||||
} else { @data = $s_idag->fetchrow_array(); }
|
||||
} else {
|
||||
@data = $s_idag->fetchrow_array();
|
||||
}
|
||||
$max = $data[5];
|
||||
$min = $data[6];
|
||||
|
||||
# Postprocess
|
||||
if (($data[23] != 0) && (is_numeric($data[23]))){
|
||||
if (($id_modulo == 1) || ($id_modulo == 7) || ($id_modulo == 15) || ($id_modulo == 22) || ($id_modulo == 4) || ($id_modulo == 8) || ($id_modulo == 16) ){
|
||||
$datos = $datos * $data[23];
|
||||
}
|
||||
}
|
||||
|
||||
$s_idag->finish();
|
||||
} else { # Id AgenteModulo DOESNT exist, it could need to be created...
|
||||
if (dame_learnagente($pa_config, $id_agente, $dbh) eq "1" ){
|
||||
|
@ -1092,13 +1125,13 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||
my $needsupdate =0;
|
||||
|
||||
$query = "SELECT * FROM tagente_estado WHERE id_agente_modulo = $id_agente_modulo";
|
||||
my $sql_oldvalue = $dbh->prepare($query);
|
||||
$sql_oldvalue->execute;
|
||||
@data = $sql_oldvalue->fetchrow_array();
|
||||
$sql_oldvalue = $dbh->prepare($query);
|
||||
$sql_oldvalue->execute;
|
||||
if ($sql_oldvalue->rows != 0) {
|
||||
@data = $sql_oldvalue->fetchrow_array();
|
||||
my $sql_oldvalue = $dbh->prepare($query);
|
||||
$sql_oldvalue->execute;
|
||||
@data = $sql_oldvalue->fetchrow_array();
|
||||
$sql_oldvalue = $dbh->prepare($query);
|
||||
$sql_oldvalue->execute;
|
||||
if ($sql_oldvalue->rows != 0) {
|
||||
@data = $sql_oldvalue->fetchrow_array();
|
||||
#$data[2] contains data
|
||||
# Transform data (numeric types only)
|
||||
if ($tipo_modulo =~ /string/){
|
||||
|
@ -1115,8 +1148,7 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||
}
|
||||
# Detect changes between stored data and adquired data.
|
||||
if ($data[2] ne $datos){
|
||||
$needsupdate=1;
|
||||
logger( $pa_config, "Updating data for $nombre_modulo after compare with tagente_data: new($datos) ne old($data[2])",5);
|
||||
$needsupdate = 1;
|
||||
} else {
|
||||
# Data in DB is the same, but could be older (more than 1
|
||||
# day ). Should check this against last_try field, who is
|
||||
|
@ -1124,7 +1156,8 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||
my $fecha_datos = $data[7]; # last_try
|
||||
my $fecha_mysql = &UnixDate("today","%Y-%m-%d %H:%M:%S");
|
||||
my $fecha_actual = ParseDate( $fecha_mysql );
|
||||
my $fecha_flag; my $err;
|
||||
my $fecha_flag;
|
||||
my $err;
|
||||
my $fecha_limite = DateCalc($fecha_actual,"- 1 days",\$err);
|
||||
$fecha_flag = Date_Cmp ($fecha_limite, $fecha_datos);
|
||||
if ($fecha_flag >= 0) { # write data,
|
||||
|
@ -1132,10 +1165,11 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||
$needsupdate = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$needsupdate=1; # There aren't data
|
||||
} else {
|
||||
$needsupdate = 1; # There aren't data
|
||||
logger( $pa_config, "Updating data for $nombre_modulo, because there are not data in DB ",10);
|
||||
}
|
||||
|
||||
$sql_oldvalue->finish();
|
||||
if (($needscreate == 1) || ($needsupdate == 1)){
|
||||
my $outlimit = 0;
|
||||
|
@ -1165,11 +1199,13 @@ sub pandora_writedata (%$$$$$$$$$$){
|
|||
$timestamp = $dbh->quote($timestamp);
|
||||
# Parse data entry for adecuate SQL representation.
|
||||
$query = "INSERT INTO tagente_datos (id_agente_modulo, datos, timestamp, utimestamp, id_agente) VALUES ($id_agente_modulo, $datos, $timestamp, $utimestamp, $id_agente)";
|
||||
} # If data is out of limits, do not insert into database
|
||||
if ($outlimit == 0){
|
||||
logger($pa_config, "DEBUG: pandora_insertdata Calculado id_agente_modulo a $id_agente_modulo",6);
|
||||
logger($pa_config, "DEBUG: pandora_insertdata SQL : $query",10);
|
||||
$dbh->do($query); # Makes insertion in database
|
||||
|
||||
# If data is out of limits, do not insert into database
|
||||
if ($outlimit == 0){
|
||||
logger($pa_config, "DEBUG: pandora_insertdata Calculado id_agente_modulo a $id_agente_modulo",6);
|
||||
logger($pa_config, "DEBUG: pandora_insertdata SQL : $query",10);
|
||||
$dbh->do($query); # Makes insertion in database
|
||||
}
|
||||
}
|
||||
}
|
||||
fin_DB_insert_datos:
|
||||
|
@ -1239,6 +1275,7 @@ sub pandora_updateserver (%$$$) {
|
|||
|
||||
|
||||
my $sql_update;
|
||||
my $sql_update_post;
|
||||
my $pandorasuffix;
|
||||
my $version_data;
|
||||
|
||||
|
@ -1262,6 +1299,8 @@ sub pandora_updateserver (%$$$) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$sql_update_post = "";
|
||||
|
||||
my $id_server = dame_server_id($pa_config, $servername.$pandorasuffix, $dbh);
|
||||
if ($id_server == -1){
|
||||
# Must create a server entry
|
||||
|
@ -1276,27 +1315,38 @@ sub pandora_updateserver (%$$$) {
|
|||
$s_idag ->execute;
|
||||
if ($s_idag->rows != 0) {
|
||||
if (@data = $s_idag->fetchrow_array()){
|
||||
if ($data[3] == 0){ # If down, update to get up the server
|
||||
logger( $pa_config, "Server ".$data[1]." going UP ",1);
|
||||
}
|
||||
# Update server data
|
||||
my $timestamp = &UnixDate("today","%Y-%m-%d %H:%M:%S");
|
||||
# Update server data
|
||||
$version_data = $pa_config->{"version"}." (P) ".$pa_config->{"build"};
|
||||
|
||||
# Some fields of tserver should be updated ONLY when server is going up
|
||||
if ($data[3] == 0){ # If down, update to get up the server
|
||||
|
||||
logger( $pa_config, "Server ".$data[1]." going UP ",1);
|
||||
$sql_update_post = ", laststart = '$timestamp', version = '$version_data'";
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($opmode == 0){
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', recon_server = 0, snmp_server = 0, network_server = 0, data_server = 1, master = $pa_config->{'pandora_master'}, checksum = $pa_config->{'pandora_check'} where id_server = $id_server";
|
||||
$sql_update = "data_server = 1";
|
||||
} elsif ($opmode == 1){
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', recon_server = 0, snmp_server = 0, network_server = 1, data_server = 0, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
$sql_update = "network_server = 1";
|
||||
} elsif ($opmode == 2) {
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', recon_server = 0, snmp_server = 1, network_server = 0, data_server = 0, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
$sql_update = "snmp_server = 1";
|
||||
} elsif ($opmode == 3) {
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', recon_server = 1, snmp_server = 0, network_server = 0, data_server = 0, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
$sql_update = "recon_server = 1";
|
||||
} elsif ($opmode == 4) {
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', plugin_server = 1, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
$sql_update = "plugin_server = 1";
|
||||
} elsif ($opmode == 5) {
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', prediction_server = 1, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
$sql_update = "prediction_server = 1";
|
||||
} elsif ($opmode == 6) {
|
||||
$sql_update = "update tserver set version = '$version_data', status = 1, laststart = '$timestamp', keepalive = '$timestamp', wmi_server = 1, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
$sql_update = "wmi_server = 1";
|
||||
# $sql_update = "update tserver set version = '$version_data', status = $status, laststart = '$timestamp', keepalive = '$timestamp', wmi_server = 1, master = $pa_config->{'pandora_master'}, checksum = 0 where id_server = $id_server";
|
||||
}
|
||||
|
||||
$sql_update = "UPDATE tserver SET $sql_update $sql_update_post , status = $status, keepalive = '$timestamp', master = $pa_config->{'pandora_master'} WHERE id_server = $id_server";
|
||||
|
||||
$dbh->do($sql_update);
|
||||
}
|
||||
$s_idag->finish();
|
||||
|
@ -1382,7 +1432,7 @@ sub pandora_audit (%$$$$) {
|
|||
};
|
||||
if ($@){
|
||||
logger ($pa_config,"FATAL: pandora_audit() cannot connect with database",0);
|
||||
logger ($pa_config,"FATAL: Error code $@",2);
|
||||
logger ($pa_config,"FATAL: Error code $@", 0);
|
||||
}
|
||||
if ($local_dbh == 1){
|
||||
$dbh->disconnect();
|
||||
|
@ -1407,8 +1457,8 @@ sub dame_agente_id (%$$) {
|
|||
my $s_idag = $dbh->prepare($query_idag);
|
||||
$s_idag ->execute;
|
||||
if ($s_idag->rows == 0) {
|
||||
logger ($pa_config, "ERROR dame_agente_id(): Cannot find agent called $agent_name. Returning -1", 1);
|
||||
logger ($pa_config, "ERROR: SQL Query is $query_idag ",2);
|
||||
logger ($pa_config, "ERROR dame_agente_id(): Cannot find agent called $agent_name. Returning -1", 5);
|
||||
logger ($pa_config, "ERROR: SQL Query is $query_idag ",10);
|
||||
$id_agente = -1;
|
||||
} else {
|
||||
@data = $s_idag->fetchrow_array();
|
||||
|
@ -1427,22 +1477,28 @@ sub dame_agente_id (%$$) {
|
|||
##########################################################################
|
||||
sub dame_server_id (%$$) {
|
||||
my $pa_config = $_[0];
|
||||
my $name = $_[1];
|
||||
my $name = $_[1];
|
||||
my $dbh = $_[2];
|
||||
|
||||
my $id_server;
|
||||
my @data;
|
||||
|
||||
my $id_server;my @data;
|
||||
# Get serverid
|
||||
my $query_idag = "SELECT * FROM tserver WHERE name = '$name' ";
|
||||
my $s_idag = $dbh->prepare($query_idag);
|
||||
$s_idag ->execute;
|
||||
if ($s_idag->rows == 0) {
|
||||
logger ($pa_config, "ERROR dame_server_id(): Cannot find server called $name. Returning -1",4);
|
||||
logger ($pa_config, "ERROR: SQL Query is $query_idag ",10);
|
||||
# Get serverid
|
||||
my $query_idag = "SELECT * FROM tserver WHERE name = '$name' ";
|
||||
my $s_idag = $dbh->prepare($query_idag);
|
||||
$s_idag ->execute;
|
||||
|
||||
if ($s_idag->rows == 0) {
|
||||
logger ($pa_config, "ERROR dame_server_id(): Cannot find server called $name. Returning -1", 5);
|
||||
logger ($pa_config, "ERROR: SQL Query is $query_idag ",10);
|
||||
$data[0]=-1;
|
||||
} else { @data = $s_idag->fetchrow_array(); }
|
||||
$id_server = $data[0];
|
||||
$s_idag->finish();
|
||||
return $id_server;
|
||||
} else {
|
||||
@data = $s_idag->fetchrow_array();
|
||||
}
|
||||
|
||||
$id_server = $data[0];
|
||||
$s_idag->finish();
|
||||
return $id_server;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
@ -1487,8 +1543,8 @@ sub dame_grupo_agente (%$$) {
|
|||
my $s_idag = $dbh->prepare($query_idag);
|
||||
$s_idag ->execute;
|
||||
if ($s_idag->rows == 0) {
|
||||
logger ($pa_config, "ERROR dame_grupo_agente(): Cannot find agent with id $id_agente",1);
|
||||
logger ($pa_config, "ERROR: SQL Query is $query_idag ",2);
|
||||
logger ($pa_config, "ERROR dame_grupo_agente(): Cannot find agent with id $id_agente", 5);
|
||||
logger ($pa_config, "ERROR: SQL Query is $query_idag ",10);
|
||||
} else { @data = $s_idag->fetchrow_array(); }
|
||||
$id_grupo = $data[0];
|
||||
$s_idag->finish();
|
||||
|
@ -1511,8 +1567,8 @@ sub dame_comando_alerta (%$$) {
|
|||
my $comando = "";
|
||||
$s_idag ->execute;
|
||||
if ($s_idag->rows == 0) {
|
||||
logger ($pa_config, "ERROR dame_comando_alerta(): Cannot find alert $id_alerta",1);
|
||||
logger ($pa_config, "ERROR: SQL Query is $query_idag ",2);
|
||||
logger ($pa_config, "ERROR dame_comando_alerta(): Cannot find alert $id_alerta", 5);
|
||||
logger ($pa_config, "ERROR: SQL Query is $query_idag ", 10);
|
||||
} else {
|
||||
@data = $s_idag->fetchrow_array();
|
||||
$comando = $data[2];
|
||||
|
@ -1626,8 +1682,8 @@ sub dame_agente_modulo_id (%$$$$) {
|
|||
my $s_idag = $dbh->prepare($query_idag);
|
||||
$s_idag ->execute;
|
||||
if ($s_idag->rows == 0) {
|
||||
logger($pa_config, "ERROR dame_agente_modulo_id(): Cannot find a module called $name", 2);
|
||||
logger($pa_config, "ERROR: SQL Query is $query_idag ",10);
|
||||
logger ($pa_config, "ERROR dame_agente_modulo_id(): Cannot find a module called $name", 5);
|
||||
logger ($pa_config, "ERROR: SQL Query is $query_idag ", 10);
|
||||
$id_agentemodulo = -1;
|
||||
} else {
|
||||
@data = $s_idag->fetchrow_array();
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package PandoraFMS::Tools;
|
||||
##########################################################################
|
||||
# Pandora Tools Package
|
||||
# Tools Package
|
||||
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||
##########################################################################
|
||||
# Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
|
||||
# Copyright (c) 2005-2007 Artica Soluciones Tecnologicas S.L
|
||||
# Copyright (c) 2004-2008 Sancho Lerena, slerena@gmail.com
|
||||
# Copyright (c) 2005-2008 Artica Soluciones Tecnologicas S.L
|
||||
#
|
||||
#This program is free software; you can redistribute it and/or
|
||||
#modify it under the terms of the GNU General Public License
|
||||
|
@ -95,35 +96,37 @@ sub pandora_event (%$$$$$$$$) {
|
|||
|
||||
sub pandora_get_os ($) {
|
||||
$command = $_[0];
|
||||
|
||||
if ($command =~ m/Windows/i){
|
||||
return 9;
|
||||
if (defined($command) && $command ne ""){
|
||||
if ($command =~ m/Windows/i){
|
||||
return 9;
|
||||
}
|
||||
elsif ($command =~ m/Linux/i){
|
||||
return 1;
|
||||
}
|
||||
elsif ($command =~ m/BSD/i){
|
||||
return 4;
|
||||
}
|
||||
elsif ($command =~ m/Cisco/i){
|
||||
return 7;
|
||||
}
|
||||
elsif ($command =~ m/SunOS/i){
|
||||
return 2;
|
||||
}
|
||||
elsif ($command =~ m/Solaris/i){
|
||||
return 2;
|
||||
}
|
||||
elsif ($command =~ m/AIX/i){
|
||||
return 3;
|
||||
}
|
||||
elsif ($command =~ m/HP-UX/i){
|
||||
return 5;
|
||||
}
|
||||
else {
|
||||
return 10; # Unknown / Other
|
||||
}
|
||||
} else {
|
||||
return 10;
|
||||
}
|
||||
elsif ($command =~ m/Linux/i){
|
||||
return 1;
|
||||
}
|
||||
elsif ($command =~ m/BSD/i){
|
||||
return 4;
|
||||
}
|
||||
elsif ($command =~ m/Cisco/i){
|
||||
return 7;
|
||||
}
|
||||
elsif ($command =~ m/SunOS/i){
|
||||
return 2;
|
||||
}
|
||||
elsif ($command =~ m/Solaris/i){
|
||||
return 2;
|
||||
}
|
||||
elsif ($command =~ m/AIX/i){
|
||||
return 3;
|
||||
}
|
||||
elsif ($command =~ m/HP-UX/i){
|
||||
return 5;
|
||||
}
|
||||
else {
|
||||
return 10; # Unknown / Other
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
@ -294,8 +297,9 @@ sub logger {
|
|||
my $pa_config = $_[0];
|
||||
my $fichero = $pa_config->{"logfile"};
|
||||
my $datos = $_[1];
|
||||
my $verbose_level = 2; # if parameter not passed, verbosity is 5 (DEBUG)
|
||||
my $param2= $_[2];
|
||||
my $verbose_level = 2; # if parameter not passed, verbosity is 2
|
||||
|
||||
if (defined $param2){
|
||||
if (is_numeric($param2)){
|
||||
$verbose_level = $param2;
|
||||
|
@ -308,6 +312,12 @@ sub logger {
|
|||
}
|
||||
|
||||
my $time_now = &UnixDate("today","%Y/%m/%d %H:%M:%S");
|
||||
if (-e $fichero){
|
||||
my $filesize = (stat($fichero))[7];
|
||||
if ( $filesize > $pa_config->{'max_log_size'}) {
|
||||
rename ($fichero, $fichero.".old");
|
||||
}
|
||||
}
|
||||
open (FILE, ">> $fichero") or die "[FATAL] Cannot open logfile at $fichero";
|
||||
my $server_name = $pa_config->{'servername'}.$pa_config->{"servermode"};
|
||||
print FILE "$time_now $server_name $datos \n";
|
||||
|
|
Loading…
Reference in New Issue