pandorafms/pandora_server/util/compaq_chassis_trap_manager2.pl
slerena 24dd478a46 2010-10-07 Sancho Lerena <slerena@artica.es>
* conf/pandora_server.conf: Removed multicast options

    * Makefile.PL: Removed need for dependencies on Mail::Sendmail
    and Traceroute::PurePerl, now are included in the Pandora FMS
    distribution.

    * lib/PandoraFMS/Config.pm: Removed options for multicast

    * lib/PandoraFMS/Traceroute.pm,
      lib/PandoraFMS/Sendmail.pm,
      lib/PandoraFMS/Traceroute/PurePerl.pm: Now included on Pandora FMS
    distribution, this will help to do easier installs of Pandora, because
    that packages was difficult to build/install in different distros.

    * lib/PandoraFMS/Core.pm: Removed the old multicast-on change enterprise
    feature, not used/supported anymore.

    * lib/PandoraFMS/ReconServer.pm: Now uses the internal Traceroute Pureperl
    implementation.

    * lib/PandoraFMS/Tools.pm: Now uses the internal Mail::Sendmail copy.

    * bin/pandora_server: Removed the multicast option from main loop.

    * FreeBSD/pandora_server.conf: Removed multicast from options.

    * util/mcast_client.pl: Deleted sample client for multicast.

    * util/pandora_logrotate: Updated the rotate options for SNMP logfile.

    * util/compaq_chassis_trap_manager2.pl: Added sample of SNMP Trap           
    postprocessor.

    * pandora_server.redhat.spec,
      pandora_server.spec,
      DEBIAN/control: Updated packages deps and other minor changes (xprobe2 is not
      mandatory now).



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3365 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-10-07 15:09:04 +00:00

91 lines
2.2 KiB
Perl
Executable File

#!/usr/bin/perl
# (c) Sancho Lerena 2010 <slerena@artica.es>
# Specific Pandora FMS trap collector for Compaq Hardware
# Parameter list: list_event, code with TRAP VALUES to match
# module_name: Name of the module generated.
my @list_event = ('22013', '22042', '22039');
my $module_name = "evento_enclosure";
use POSIX qw(setsid strftime);
sub show_help {
print "\nSpecific Pandora FMS trap collector for compaq Hardware\n";
print "(c) Sancho Lerena 2010 <slerena@artica.es>\n";
print "Usage:\n\n";
print " compaq_chassis_trap_manager.pl <destination_agent_name> <TRAP DATA>\n\n";
exit;
}
sub writexml {
my ($hostname, $xmlmessage ) = @_;
my $file = "/var/spool/pandora/data_in/$hostname.".rand(1000).".data";
# my $file = "/tmp/compaq.debug";
open (FILE, ">> $file") or die "[FATAL] Cannot write to XML '$file'";
print FILE $xmlmessage;
close (FILE);
}
if ($#ARGV == -1){
show_help();
}
$chunk = "";
# First parameter is always destination host for virtual server
$target_host = $ARGV[0];
foreach $argnum (1 .. $#ARGV) {
if ($chunk ne ""){
$chunk .= " ";
}
$chunk .= $ARGV[$argnum];
}
my $hostname = "";
my $now = strftime ("%Y-%m-%d %H:%M:%S", localtime());
my $xmldata = "<agent_data agent_name='$target_host' timestamp='$now' version='1.0' os='Other' os_version='N/A' interval='9999999999'>";
my $blade = "N/A";
my $index_pos = 1;
my $enclosure = "N/A";
my $rack = "N/A";
# Get position
if ($chunk =~ m/.1.3.6.1.4.1.232.22.2.4.1.1.1.8.([0-9])*\s/){
$index_pos = $1;
}
# Get blade
if ($chunk =~ m/.1.3.6.1.4.1.232.22.2.4.1.1.1.4.$index_pos \= STRING\: ([A-Za-z0-9\-\.]*)\s/){
$blade = $1;
}
# Get enclosure
if ($chunk =~ m/.1.3.6.1.4.1.232.22.2.4.1.1.1.5.$index_pos \= STRING\: ([A-Za-z0-9\-\.]*)\s/){
$enclosure = $1;
}
# Get rack
if ($chunk =~ m/1.3.6.1.4.1.232.22.2.2.1.1.2.1 \= STRING\: ([A-Za-z0-9\-\.]*)\s\.1/){
$rack = $1;
}
my $event_code = "";
foreach $argnum (0 .. $#list_event) {
if ($chunk =~ m/\s\.($list_event[$argnum])\s/){
$text = chunk;
$event_code = $1;
}
}
$xmldata .=
"<module><name>$module_name_$event_code</name><type>async_string</type><data><![CDATA[$text]]></data></module>\n";
$xmldata .= "</agent_data>\n";
writexml ($target_host, $xmldata);