2008-10-10 Sancho Lerena <slerena@artica.es>
* bin/pandora_snmpconsole: Added support to get custom value, custom type and custom OID. Code for trap2agent forward feature not fully implemented, don't work yet, need finish. * util/pandora_db.pl: Now delete also events and session information. String data is using utimestamp to purge (faster!). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1137 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
273f4d1b54
commit
d138ceece8
|
@ -1,3 +1,12 @@
|
|||
2008-10-10 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* bin/pandora_snmpconsole: Added support to get custom value,
|
||||
custom type and custom OID. Code for trap2agent forward feature
|
||||
not fully implemented, don't work yet, need finish.
|
||||
|
||||
* util/pandora_db.pl: Now delete also events and session information.
|
||||
String data is using utimestamp to purge (faster!).
|
||||
|
||||
2008-10-02 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* bin/pandora_network: Added support for multiple SNMP versions.
|
||||
|
|
|
@ -117,6 +117,8 @@ sub pandora_snmptrapd {
|
|||
# open database, only ONCE. We pass reference to DBI handler ($dbh) to all subprocess
|
||||
my $dbh = DBI->connect("DBI:mysql:$pa_config->{'dbname'}:$pa_config->{'dbhost'}:3306",$pa_config->{'dbuser'}, $pa_config->{'dbpass'}, { RaiseError => 1, AutoCommit => 1 });
|
||||
|
||||
my $trap2agent = get_db_value ("value", "tconfig", "token", "trap2agent", $dbh);
|
||||
|
||||
# Main loop for reading file
|
||||
while ( 1 ){
|
||||
while ($datos = <SNMPLOGFILE>) {
|
||||
|
@ -155,8 +157,8 @@ sub pandora_snmptrapd {
|
|||
$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', '', '', '')";
|
||||
logger ($pa_config,"Received SNMP Trap from $source", 5);
|
||||
$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", 4);
|
||||
eval {
|
||||
$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
|
||||
|
@ -164,7 +166,19 @@ sub pandora_snmptrapd {
|
|||
};
|
||||
if ($@) {
|
||||
logger ($pa_config, "[ERROR] Cannot access to database while updating SNMP Trap data",0);
|
||||
logger ($pa_config, "[ERROR] SQL Errorcode: $@",2);
|
||||
logger ($pa_config, "[ERROR] SQL Errorcode: $@", 2);
|
||||
}
|
||||
|
||||
if ( $trap2agent eq "1"){
|
||||
# Forward trap to agent into module "SNMPTrap";
|
||||
# Exist an agent with this IP ?
|
||||
if (pandora_check_ip ($pa_config, $dbh, $source) == 1){
|
||||
# TODO: Falta la ultima parte (coger el nombre del agente e insertar el dato, comprobar que el codigo que hay aqui funciona OK).
|
||||
my $agent_name = ''; #DAME NOMBRE DEL AGENTE A PARTIR DE LA IP;
|
||||
my $mydata = "$oid $value $custom_oid $custom_value";
|
||||
# Insert string data
|
||||
module_generic_data_string ($pa_config, $mydata, $timestamp, $agent_name, 'SNMPTrap', $dbh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,10 +146,19 @@ sub pandora_purgedb {
|
|||
}
|
||||
$idag->finish();
|
||||
if ($verbosity > 0){
|
||||
print "[PURGE] Deleting static data until $limit_timestamp \n";
|
||||
print "\n[PURGE] Deleting string data until $limit_timestamp \n";
|
||||
}
|
||||
$dbh->do ("delete from tagente_datos_string where timestamp < '$limit_timestamp'");
|
||||
$dbh->disconnect();
|
||||
my $limit_utimestamp = &UnixDate($limit_timestamp, "%s");
|
||||
|
||||
# Deleting string data
|
||||
$dbh->do ("DELETE FROM tagente_datos_string WHERE utimestamp < $limit_utimestamp");
|
||||
|
||||
# Deleting session data
|
||||
$dbh->do ("DELETE FROM tsesion WHERE utimestamp < $limit_utimestamp");
|
||||
|
||||
# Deleting SNMP data
|
||||
$dbh->do ("DELETE FROM ttrap WHERE timestamp < '$limit_timestamp'");
|
||||
$dbh->disconnect();
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
|
Loading…
Reference in New Issue