2008-08-22 Sancho Lerena <slerena@gmail.com>
* Makefile.PL: Added WMI and fixed lot of small things. * pandora_server_installer: Fixed several things. * pandora_wmi: Launcher script added. * lib/PandoraFMS/Config.pm: Update version. * lib/PandoraFMS/DB.pm * lib/PandoraFMS/Tools.pm: Added defined check in limpia_cadena(). This should fix warning message on some calls. * bin/pandora_snmpconsole: Fixed code for SNMP TRAP alerts. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1024 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
404e43c9fc
commit
dc7c2b1f91
|
@ -1,3 +1,20 @@
|
||||||
|
2008-08-22 Sancho Lerena <slerena@gmail.com>
|
||||||
|
|
||||||
|
* Makefile.PL: Added WMI and fixed lot of small things.
|
||||||
|
|
||||||
|
* pandora_server_installer: Fixed several things.
|
||||||
|
|
||||||
|
* pandora_wmi: Launcher script added.
|
||||||
|
|
||||||
|
* lib/PandoraFMS/Config.pm: Update version.
|
||||||
|
|
||||||
|
* lib/PandoraFMS/DB.pm
|
||||||
|
|
||||||
|
* lib/PandoraFMS/Tools.pm: Added defined check in limpia_cadena().
|
||||||
|
This should fix warning message on some calls.
|
||||||
|
|
||||||
|
* bin/pandora_snmpconsole: Fixed code for SNMP TRAP alerts.
|
||||||
|
|
||||||
2008-08-21 Sancho Lerena <slerena@gmail.com>
|
2008-08-21 Sancho Lerena <slerena@gmail.com>
|
||||||
|
|
||||||
* lib/PandoraFMS/DB.pm, bin/pandora_server: Enabled again
|
* lib/PandoraFMS/DB.pm, bin/pandora_server: Enabled again
|
||||||
|
|
|
@ -22,8 +22,7 @@ WriteMakefile(
|
||||||
HTML::Entities => 0,
|
HTML::Entities => 0,
|
||||||
SNMP => 0
|
SNMP => 0
|
||||||
},
|
},
|
||||||
EXE_FILES =>
|
EXE_FILES => [ 'bin/pandora_server', 'bin/pandora_network', 'bin/pandora_wmi', 'bin/pandora_recon', 'bin/pandora_snmpconsole' , 'bin/pandora_plugin', 'bin/pandora_prediction', 'util/pandora_exec'],
|
||||||
[ 'bin/pandora_server', 'bin/pandora_network', 'bin/pandora_recon', 'bin/pandora_snmpconsole' , 'bin/pandora_plugin', 'bin/pandora_prediction', 'util/pandora_exec'],
|
|
||||||
PMLIBDIRS => [ 'lib' ],
|
PMLIBDIRS => [ 'lib' ],
|
||||||
'dist' => { 'TAR' => 'tar', 'TARFLAGS' => 'cvfz', 'SUFFIX'
|
'dist' => { 'TAR' => 'tar', 'TARFLAGS' => 'cvfz', 'SUFFIX'
|
||||||
=> '.gz', 'COMPRESS' => 'gzip'}
|
=> '.gz', 'COMPRESS' => 'gzip'}
|
||||||
|
|
|
@ -154,12 +154,13 @@ sub pandora_snmptrapd {
|
||||||
$custom_type="";
|
$custom_type="";
|
||||||
$custom_value=$type_desc; # Bug fixed, 080108 by anonymous
|
$custom_value=$type_desc; # Bug fixed, 080108 by anonymous
|
||||||
}
|
}
|
||||||
$sql_insert = "insert into ttrap (timestamp, source, oid, type, value, oid_custom, value_custom, type_custom) values ('$timestamp', '$source', '$oid', $type, '$value', '$custom_oid', '$custom_value', '$custom_type')";
|
|
||||||
logger ($pa_config,"Received SNMP Trap from $source",2);
|
$sql_insert = "insert into ttrap (timestamp, source, oid, type, value, oid_custom, value_custom, type_custom) values ('$timestamp', '$source', '$oid', $type, '$value', '', '', '')";
|
||||||
|
logger ($pa_config,"Received SNMP Trap from $source", 5);
|
||||||
eval {
|
eval {
|
||||||
$dbh->do($sql_insert) || logger ($pa_config, "Cannot write to database while updating SNMP Trap data (error in INSERT)",0);
|
$dbh->do($sql_insert) || logger ($pa_config, "Cannot write to database while updating SNMP Trap data (error in INSERT)",0);
|
||||||
# Evaluate TRAP Alerts for this trap
|
# Evaluate TRAP Alerts for this trap
|
||||||
calcula_alerta_snmp($pa_config, $source,$oid,$custom_value,$timestamp,$dbh);
|
calcula_alerta_snmp ($pa_config, $source, $oid, $custom_value, $timestamp, $dbh);
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
logger ($pa_config, "[ERROR] Cannot access to database while updating SNMP Trap data",0);
|
logger ($pa_config, "[ERROR] Cannot access to database while updating SNMP Trap data",0);
|
||||||
|
@ -182,38 +183,41 @@ sub pandora_snmptrapd {
|
||||||
sub calcula_alerta_snmp {
|
sub calcula_alerta_snmp {
|
||||||
# Parameters passed as arguments
|
# Parameters passed as arguments
|
||||||
my $pa_config = $_[0];
|
my $pa_config = $_[0];
|
||||||
my $trap_agente = $_[1];
|
my $trap_agente = $_[1];
|
||||||
my $trap_oid = $_[2];
|
my $trap_oid = $_[2];
|
||||||
my $trap_custom_value = $_[3];
|
my $trap_custom_value = $_[3];
|
||||||
my $timestamp = $_[4];
|
my $timestamp = $_[4];
|
||||||
my $dbh = $_[5];
|
my $dbh = $_[5];
|
||||||
my $alert_fired = 0;
|
my $alert_fired = 0;
|
||||||
|
|
||||||
my $query_idag = "select * from talert_snmp";
|
my $query_idag = "select * from talert_snmp";
|
||||||
my $s_idag = $dbh->prepare($query_idag);
|
my $s_idag = $dbh->prepare($query_idag);
|
||||||
$s_idag ->execute;
|
$s_idag ->execute;
|
||||||
my @data;
|
my @data;
|
||||||
# Read all alerts and apply to this incoming trap
|
# Read all alerts and apply to this incoming trap
|
||||||
if ($s_idag->rows != 0) {
|
if ($s_idag->rows != 0) {
|
||||||
while (@data = $s_idag->fetchrow_array()) {
|
while (@data = $s_idag->fetchrow_array()) {
|
||||||
$alert_fired = 0;
|
$alert_fired = 0;
|
||||||
my $id_as = $data[0];
|
my $id_as = $data[0];
|
||||||
my $id_alert = $data[1];
|
my $id_alert = $data[1];
|
||||||
my $field1 = $data[2];
|
my $field1 = $data[2];
|
||||||
my $field2 = $data[3];
|
my $field2 = $data[3];
|
||||||
my $field3 = $data[4];
|
my $field3 = $data[4];
|
||||||
my $description = $data[5];
|
my $description = $data[5];
|
||||||
my $alert_type = $data[6];
|
my $alert_type = $data[6];
|
||||||
my $agent = $data[7];
|
my $agent = $data[7];
|
||||||
my $custom_oid = $data[8];
|
my $custom_oid = $data[8];
|
||||||
my $oid = $data[9];
|
my $oid = $data[9];
|
||||||
my $time_threshold = $data[10];
|
my $time_threshold = $data[10];
|
||||||
my $times_fired = $data[11];
|
my $times_fired = $data[11];
|
||||||
my $last_fired = $data[12]; # The real fired alarms
|
my $last_fired = $data[12]; # The real fired alarms
|
||||||
my $max_alerts = $data[13];
|
my $max_alerts = $data[13];
|
||||||
my $min_alerts = $data[14]; # The real triggered alarms (not really fired, only triggered)
|
my $min_alerts = $data[14]; # The real triggered alarms (not really fired, only triggered)
|
||||||
my $internal_counter = $data[15];
|
my $internal_counter = $data[15];
|
||||||
|
my $alert_priority = $data[16];
|
||||||
|
|
||||||
my $alert_data = "";
|
my $alert_data = "";
|
||||||
|
|
||||||
if ($alert_type == 0){ # type 0 is OID only
|
if ($alert_type == 0){ # type 0 is OID only
|
||||||
if ( $trap_oid =~ m/$oid/i ){
|
if ( $trap_oid =~ m/$oid/i ){
|
||||||
$alert_fired = 1;
|
$alert_fired = 1;
|
||||||
|
@ -270,9 +274,10 @@ sub calcula_alerta_snmp {
|
||||||
$data_alert{'al_campo2'} = $field2;
|
$data_alert{'al_campo2'} = $field2;
|
||||||
$data_alert{'al_campo3'} = $field3;
|
$data_alert{'al_campo3'} = $field3;
|
||||||
$data_alert{'descripcion'} = $description;
|
$data_alert{'descripcion'} = $description;
|
||||||
|
$data_alert{'priority'} = $alert_priority;
|
||||||
|
|
||||||
# Execute alert
|
# Execute alert
|
||||||
execute_alert ($pa_config, \%data_alert, $agent, 0, $agent, $trap_agente, 1, $dbh);
|
execute_alert ($pa_config, \%data_alert, 0, 0, $agent, $trap_agente, 1, $dbh);
|
||||||
|
|
||||||
# Now update the new value for times_fired, alert_fired, internal_counter and last_fired for this alert.
|
# Now update the new value for times_fired, alert_fired, internal_counter and last_fired for this alert.
|
||||||
my $query_idag2 = "update talert_snmp set times_fired = $times_fired, last_fired = '$ahora_mysql', internal_counter = $internal_counter where id_as = $id_as ";
|
my $query_idag2 = "update talert_snmp set times_fired = $times_fired, last_fired = '$ahora_mysql', internal_counter = $internal_counter where id_as = $id_as ";
|
||||||
|
|
|
@ -38,8 +38,8 @@ our @EXPORT = qw(
|
||||||
# There is no global vars, all variables (setup) passed as hash reference
|
# There is no global vars, all variables (setup) passed as hash reference
|
||||||
|
|
||||||
# version: Defines actual version of Pandora Server for this module only
|
# version: Defines actual version of Pandora Server for this module only
|
||||||
my $pandora_version = "2.0-dev";
|
my $pandora_version = "2.0Beta1";
|
||||||
my $pandora_build="PS080422";
|
my $pandora_build="PS080822";
|
||||||
our $VERSION = $pandora_version." ".$pandora_build;
|
our $VERSION = $pandora_version." ".$pandora_build;
|
||||||
|
|
||||||
# Setup hash
|
# Setup hash
|
||||||
|
|
|
@ -271,9 +271,13 @@ sub logger {
|
||||||
sub limpia_cadena {
|
sub limpia_cadena {
|
||||||
my $micadena;
|
my $micadena;
|
||||||
$micadena = $_[0];
|
$micadena = $_[0];
|
||||||
$micadena =~ s/[^\-\:\;\.\,\_\s\a\*\=\(\)a-zA-Z0-9]/ /g;
|
if (defined($micadena)){
|
||||||
$micadena =~ s/[\n\l\f]/ /g;
|
$micadena =~ s/[^\-\:\;\.\,\_\s\a\*\=\(\)a-zA-Z0-9]/ /g;
|
||||||
return $micadena;
|
$micadena =~ s/[\n\l\f]/ /g;
|
||||||
|
return $micadena;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -22,7 +22,7 @@ then
|
||||||
echo "The complete installation guide is at: "http://www.openideas.info/wiki/index.php?title=Pandora_1.3:Server:QIG#Installing_from_sources" "
|
echo "The complete installation guide is at: "http://www.openideas.info/wiki/index.php?title=Pandora_1.3:Server:QIG#Installing_from_sources" "
|
||||||
echo " "
|
echo " "
|
||||||
echo "Debian-based distribution do:"
|
echo "Debian-based distribution do:"
|
||||||
echo " $ apt-get install libdate-manip-perl snmp snmpd libsnmp-perl libtime-format-perl libxml-simple-perl libnetaddr-ip-perl libdbi-perl libxml-simple-perl libnetaddr-ip-perl"
|
echo " $ apt-get install libdate-manip-perl snmp snmpd libsnmp-perl libtime-format-perl libxml-simple-perl libnetaddr-ip-perl libdbi-perl libxml-simple-perl libnetaddr-ip-perl wmi-client xprobe2"
|
||||||
echo " "
|
echo " "
|
||||||
echo "RedHat-based distribution do"
|
echo "RedHat-based distribution do"
|
||||||
echo " "
|
echo " "
|
||||||
|
@ -72,6 +72,7 @@ else
|
||||||
ln -s /etc/init.d/pandora_snmpconsole /etc/rc2.d/S90pandora_snmpconsole
|
ln -s /etc/init.d/pandora_snmpconsole /etc/rc2.d/S90pandora_snmpconsole
|
||||||
ln -s /etc/init.d/pandora_plugin /etc/rc2.d/S90pandora_plugin
|
ln -s /etc/init.d/pandora_plugin /etc/rc2.d/S90pandora_plugin
|
||||||
ln -s /etc/init.d/pandora_prediction /etc/rc2.d/S90pandora_prediction
|
ln -s /etc/init.d/pandora_prediction /etc/rc2.d/S90pandora_prediction
|
||||||
|
ln -s /etc/init.d/pandora_wmi /etc/rc2.d/S90pandora_wmi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e /usr/local/bin/pandora_server ]
|
if [ -e /usr/local/bin/pandora_server ]
|
||||||
|
@ -82,6 +83,7 @@ else
|
||||||
ln -s /usr/local/bin/pandora_network /usr/bin/pandora_network
|
ln -s /usr/local/bin/pandora_network /usr/bin/pandora_network
|
||||||
ln -s /usr/local/bin/pandora_prediction /usr/bin/pandora_prediction
|
ln -s /usr/local/bin/pandora_prediction /usr/bin/pandora_prediction
|
||||||
ln -s /usr/local/bin/pandora_plugin /usr/bin/pandora_plugin
|
ln -s /usr/local/bin/pandora_plugin /usr/bin/pandora_plugin
|
||||||
|
ln -s /usr/local/bin/pandora_wmi /usr/bin/pandora_wmi
|
||||||
else
|
else
|
||||||
ln -s /usr/bin/pandora_server /usr/local/bin/pandora_server
|
ln -s /usr/bin/pandora_server /usr/local/bin/pandora_server
|
||||||
ln -s /usr/bin/pandora_network /usr/local/bin/pandora_network
|
ln -s /usr/bin/pandora_network /usr/local/bin/pandora_network
|
||||||
|
@ -89,6 +91,7 @@ else
|
||||||
ln -s /usr/bin/pandora_plugin /usr/local/bin/pandora_plugin
|
ln -s /usr/bin/pandora_plugin /usr/local/bin/pandora_plugin
|
||||||
ln -s /usr/bin/pandora_prediction /usr/local/bin/pandora_prediction
|
ln -s /usr/bin/pandora_prediction /usr/local/bin/pandora_prediction
|
||||||
ln -s /usr/bin/pandora_snmpconsole /usr/local/bin/pandora_snmpconsole
|
ln -s /usr/bin/pandora_snmpconsole /usr/local/bin/pandora_snmpconsole
|
||||||
|
ln -s /usr/bin/pandora_wmi /usr/local/bin/pandora_wmi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir /usr/share/pandora
|
mkdir /usr/share/pandora
|
||||||
|
@ -119,27 +122,41 @@ uninstall () {
|
||||||
## Just to clarify here. Some people (like me) are using the pandora user for other purposes and/or using an LDAP-based user management
|
## Just to clarify here. Some people (like me) are using the pandora user for other purposes and/or using an LDAP-based user management
|
||||||
## I would hate to have a script clear out this users' information without any notification
|
## I would hate to have a script clear out this users' information without any notification
|
||||||
|
|
||||||
rm -Rf /var/log/pandora/
|
rm -Rf /var/log/pandora/ 2> /dev/null
|
||||||
rm -Rf /etc/pandora/pandora_server.conf
|
rm -Rf /etc/pandora/pandora_server.conf 2> /dev/null
|
||||||
rm -Rf /etc/init.d/pandora_server
|
|
||||||
rm -Rf /etc/init.d/pandora_network
|
rm -Rf /etc/init.d/pandora_server 2> /dev/null
|
||||||
rm -Rf /etc/init.d/pandora_recon
|
rm -Rf /etc/init.d/pandora_network 2> /dev/null
|
||||||
rm -Rf /etc/init.d/pandora_snmpconsole
|
rm -Rf /etc/init.d/pandora_recon 2> /dev/null
|
||||||
rm -Rf /etc/rc2.d/S90pandora_server
|
rm -Rf /etc/init.d/pandora_snmpconsole 2> /dev/null
|
||||||
rm -Rf /etc/rc2.d/S90pandora_recon
|
rm -Rf /etc/init.d/pandora_prediction 2> /dev/null
|
||||||
rm -Rf /etc/rc2.d/S90pandora_network
|
rm -Rf /etc/init.d/pandora_wmi 2> /dev/null
|
||||||
rm -Rf /etc/rc2.d/S90pandora_snmpconsole
|
rm -Rf /etc/init.d/pandora_plugin 2> /dev/null
|
||||||
rm -Rf /usr/local/bin/pandora_server
|
|
||||||
rm -Rf /usr/local/bin/pandora_snmpconsole
|
rm -Rf /etc/rc2.d/S90pandora_server 2> /dev/null
|
||||||
rm -Rf /usr/local/bin/pandora_recon
|
rm -Rf /etc/rc2.d/S90pandora_recon 2> /dev/null
|
||||||
rm -Rf /usr/local/bin/pandora_network
|
rm -Rf /etc/rc2.d/S90pandora_network 2> /dev/null
|
||||||
rm -Rf /usr/bin/pandora_server
|
rm -Rf /etc/rc2.d/S90pandora_snmpconsole 2> /dev/null
|
||||||
rm -Rf /usr/bin/pandora_snmpconsole
|
rm -Rf /etc/rc2.d/S90pandora_wmi 2> /dev/null
|
||||||
rm -Rf /usr/bin/pandora_recon
|
rm -Rf /etc/rc2.d/S90pandora_prediction 2> /dev/null
|
||||||
rm -Rf /usr/bin/pandora_network
|
rm -Rf /etc/rc2.d/S90pandora_plugin 2> /dev/null
|
||||||
|
|
||||||
|
rm -Rf /usr/local/bin/pandora_server 2> /dev/null
|
||||||
|
rm -Rf /usr/local/bin/pandora_snmpconsole 2> /dev/null
|
||||||
|
rm -Rf /usr/local/bin/pandora_recon 2> /dev/null
|
||||||
|
rm -Rf /usr/local/bin/pandora_network 2> /dev/null
|
||||||
|
rm -Rf /usr/local/bin/pandora_wmi 2> /dev/null
|
||||||
|
rm -Rf /usr/local/bin/pandora_prediction 2> /dev/null
|
||||||
|
rm -Rf /usr/local/bin/pandora_plugin 2> /dev/null
|
||||||
|
|
||||||
|
rm -Rf /usr/bin/pandora_wmi 2> /dev/null
|
||||||
|
rm -Rf /usr/bin/pandora_server 2> /dev/null
|
||||||
|
rm -Rf /usr/bin/pandora_snmpconsole 2> /dev/null
|
||||||
|
rm -Rf /usr/bin/pandora_recon 2> /dev/null
|
||||||
|
rm -Rf /usr/bin/pandora_network 2> /dev/null
|
||||||
rm -Rf /usr/bin/pandora_prediction 2> /dev/null
|
rm -Rf /usr/bin/pandora_prediction 2> /dev/null
|
||||||
rm -Rf /usr/bin/pandora_plugin 2> /dev/null
|
rm -Rf /usr/bin/pandora_plugin 2> /dev/null
|
||||||
rm -Rf /usr/bin/pandora_export 2> /dev/null
|
|
||||||
rm -Rf /usr/share/pandora
|
rm -Rf /usr/share/pandora
|
||||||
rm -Rf /etc/cron.daily/pandora_purge_db
|
rm -Rf /etc/cron.daily/pandora_purge_db
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Pandora FMS WMI Server, startup script
|
||||||
|
# Sancho Lerena, <slerena@gmail.com>
|
||||||
|
# Linux Version (generic)
|
||||||
|
# 2.0 Build 080620
|
||||||
|
|
||||||
|
# Configurable path and filenames
|
||||||
|
PANDORA_HOME="/etc/pandora/pandora_server.conf"
|
||||||
|
PANDORA_PID_PATH="/var/run"
|
||||||
|
PANDORA_PID=$PANDORA_PID_PATH/pandora_wmi.pid
|
||||||
|
PANDORA_DAEMON=/usr/bin/pandora_wmi
|
||||||
|
|
||||||
|
# Main script
|
||||||
|
|
||||||
|
if [ ! -d "$PANDORA_PID_PATH" ]
|
||||||
|
then
|
||||||
|
echo "Pandora FMS WMI Server cannot write it's PID file in $PANDORA_PID_PATH. Please create that directory"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f $PANDORA_DAEMON ]
|
||||||
|
then
|
||||||
|
echo "Pandora FMS WMI Server not found, please check setup and read manual"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
OLD_PATH="`pwd`"
|
||||||
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
||||||
|
if [ ! -z $PANDORA_PID ]
|
||||||
|
then
|
||||||
|
echo "Pandora FMS WMI Server is currently running on this machine with PID ($PANDORA_PID). Aborting now..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
$PANDORA_DAEMON $PANDORA_HOME -D
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
||||||
|
if [ ! -z "$PANDORA_PID" ]
|
||||||
|
then
|
||||||
|
echo "Pandora FMS WMI Server is now running with PID $PANDORA_PID"
|
||||||
|
else
|
||||||
|
echo "Cannot start Pandora FMS WMI Server. Aborted."
|
||||||
|
fi
|
||||||
|
cd "$OLD_PATH"
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
PANDORA_PID=$(pidof -x $PANDORA_DAEMON)
|
||||||
|
if [ -z $PANDORA_PID ]
|
||||||
|
then
|
||||||
|
echo "Pandora FMS WMI Server is not running, cannot stop it."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Stopping Pandora FMS WMI Server"
|
||||||
|
kill $PANDORA_PID > /dev/null 2>&1
|
||||||
|
rm -f $PANDORA_PID
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
force-reload|restart)
|
||||||
|
$0 stop
|
||||||
|
$0 start
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: pandora_plugin {start|stop|restart}"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
Loading…
Reference in New Issue