[INUG-Users] Net::SNMP to send snmptrap

Raj Bhimireddy bheemireddi at gmail.com
Tue Feb 2 19:00:05 EST 2010


Hi,

I tried to execute the  script modified by you.

When we put the commas inside the sq brackets it returns me the error
"syntax error at ./send_snmptrap1.pl line 24, near "[""

I just moved the comma outside sq bracket, then I don't get the syntax
error, Still  getting the runtime error

"ERROR SENDING TRAP: The argument "ARRAY(0x96983a8)" is unknown."

Thanks,
Raji.

On Tue, Feb 2, 2010 at 3:31 PM, <douglasstvnsn at aol.com> wrote:

>
> Ok Raj,
>
> Lemme see what I can do... I changed the commas in the trap definition to
> inside the sq brackets like the perldoc has it...  See if that runs...
>
> Dougie!!!
>
>
>
> #! /usr/bin/perl
>
>   use warnings;   use Net::SNMP;
> $seconds = 100;
> $oid = ".1.2.3.4.5.6";
> $ipaddress = "0.0.0.0";
> $generic = 6;
> $specific = 1;
> $timeticks = 12345;
> @VBlist = "";
>
>   my ($session, $error) = Net::SNMP->session(
>      -hostname  => shift || 'localhost',
>      -community => shift || 'public',
>   );
>
>   if (!defined $session) {
>      print "SESSION CREATION ERROR: %s.\n", $error;
>      exit 1;
>   }
>
>   $result = $session->trap(
>                          [-delay      => $seconds,]
>                          [-enterprise      => $oid,]
>                          [-agentaddr       => $ipaddress,]
>                          [-generictrap     => $generic,]
>                          [-specifictrap    => $specific,]
>                           [-timestamp       => $timeticks,]
>                           -varbindlist        => \@VBlist,
>                        );
>
>
>
>   if (!defined $result) {
>      printf "ERROR SENDING TRAP: %s.\n", $session->error();
>      $session->close();
>      exit 1;
>   }
>
>
>
>
> -----Original Message-----
> From: Raj Bhimireddy <bheemireddi at gmail.com>
> To: users at netcoolusers.org
> Sent: Tue, Feb 2, 2010 4:59 pm
> Subject: Re: [INUG-Users] Net::SNMP to send snmptrap
>
>
> Thanks to all,
> Here is the script I am using to send a simple snmptrap. The rules are not
> oing to parse this trap, But I just wanted to see whether I can send a
> rap. using Net::SNMP.
> #! /usr/bin/perl
>   use warnings;
>   use Net::SNMP;
> $seconds = 100;
> oid = ".1.2.3.4.5.6";
> ipaddress = "0.0.0.0";
> generic = 6;
> specific = 1;
> timeticks = 12345;
>   my ($session, $error) = Net::SNMP->session(
>     -hostname  => shift || 'localhost',
>     -community => shift || 'public',
>  );
>   if (!defined $session) {
>     print "SESSION CREATION ERROR: %s.\n", $error;
>     exit 1;
>  }
>   $result = $session->trap(
>                         [-delay      => $seconds],
>                         [-enterprise      => $oid],
>                         [-agentaddr       => $ipaddress],
>                         [-generictrap     => $generic],
>                         [-specifictrap    => $specific],
>                         [-timestamp       => $timeticks],
>                      );
>
>   if (!defined $result) {
>     printf "ERROR SENDING TRAP: %s.\n", $session->error();
>     $session->close();
>     exit 1;
>  }
>
>
> On Tue, Feb 2, 2010 at 2:29 PM, <douglasstvnsn at aol.com> wrote:
> >
>  It looks like the command is looking for an Array argument and its being
>  presented as something else.
>
>  If you have an array with one element you can present it as such as
>  [element1_of_the_array] - The square brackets tell it that it is to be
>  treated as an array.  Or you can spec it as @Array =
>  "element1_of_the_array";
>
>  or you could push it as push @Array, list;
>
>  Send over your line and I will see what I can do to help...
>
>  Dougie!!!
>
>
>
>
>
>  -----Original Message-----
>  From: Raj Bhimireddy <bheemireddi at gmail.com>
>  To: users at netcoolusers.org
>  Sent: Tue, Feb 2, 2010 3:53 pm
>  Subject: [INUG-Users] Net::SNMP to send snmptrap
>
>
>  Hello users,
>  Has anybody used Net::SNMP perl module to send snmptrap on Linux.
>  I am using it to send a simple trap, but getting the error message
>  "ERROR SENDING TRAP: The argument "ARRAY(0x9792760)" is unknown."
>  Any Idea?
>  Thanks,
>  aji.
>  ______________________________________________
>  ent by the netcoolusers.org "users" mailing list
>  ost: users at netcoolusers.org
>  nsubscribe: users-unsubscribe at netcoolusers.org
>  earch: http://netcoolusers.org/Search
>
>  _______________________________________________
>  Sent by the netcoolusers.org "users" mailing list
>  Post: users at netcoolusers.org
>  Unsubscribe: users-unsubscribe at netcoolusers.org
>  Search: http://netcoolusers.org/Search
>
> ______________________________________________
> ent by the netcoolusers.org "users" mailing list
> ost: users at netcoolusers.org
> nsubscribe: users-unsubscribe at netcoolusers.org
> earch: http://netcoolusers.org/Search
>
> _______________________________________________
> Sent by the netcoolusers.org "users" mailing list
> Post: users at netcoolusers.org
> Unsubscribe: users-unsubscribe at netcoolusers.org
> Search: http://netcoolusers.org/Search
>



More information about the Users mailing list