Tuesday, 17 March 2009

IBM RSA - The Perl script

So, here is some perl code that can help getting informations from IBM RSA.

Based on Net::SNMP module and on the oid I provided below.


sub get_status

{
my $rsa_status = "unknown";

#Define SNMP Session
my ($session, $error) = Net::SNMP->session( -hostname => $_[0], -community => $_[1], -port => 161 );

#Error Check
if (!defined($session))

{
$rsa_status = "SNMP_Error";
}
else
{
#SNMP Get
my $sysStatus = "$_[2]";
my $result = $session->get_request(-varbindlist => [$sysStatus]);

#Error check
if (!defined($result))
{
$rsa_status = "SNMP_Error";
}

else

{
if ($result->{$sysStatus} == 0)
{$rsa_status = "Critical";}
elsif ($result->{$sysStatus} == 2)
{$rsa_status = "Warning";}
elsif ($result->{$sysStatus} == 4)
{$rsa_status = "System";}
elsif ($result->{$sysStatus} == 255)
{$rsa_status = "Normal";}
}
$session->close;

return $rsa_status;
}

1 comment:

  1. Jonathan,

    Do you have any stuff that helps me to develop scripts to get information from IBM RSA?
    Do I have to use Perl or can I use other scripting languages?

    Thanks!

    Carlos Felipe

    ReplyDelete