LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-28-2007, 11:22 AM   #1
nautilus
Member
 
Registered: Jun 2007
Location: London, Athens
Distribution: Debian, Ubuntu
Posts: 36

Rep: Reputation: 15
SNMP_Session problem


Hello All,

I've got the following script that sends SNMP packets using SNMP_Session perl module (I know it is not the best script you have ever seen, I just found it and using it, later on I will improve it):

Quote:
#!/usr/bin/perl
# use warnings;
# use strict;
my $version=1;
#use lib '/usr/lib/mrtg2'; # location of SNMP_Session.pm and BER.pm;
use SNMP_Session;
use BER;

my $trap_receiver = "xxx.xxx.xxx.xxx";
my $myIpAddress = "yyy.yyy.yyy.yyy";
my $trap_community = "public";
my $trap_session = $version eq '1'
? SNMP_Session->open ($trap_receiver, $trap_community, 162)
: SNMPv2c_Session->open ($trap_receiver, $trap_community, 162);
my $start_time = time;

link_down_trap 1, $ARGV[0], $version;

sub link_down_trap ($$$) {
my ($if_index, $message, $version) = @_;
my $genericTrap = 6;
my $specificTrap = 1;
my @ifIndex_OID = ( 1,3,6,1,4,1,666,2,2 );
my @ifDescr_OID = ( 1,3,6,1,4,1,666,2,2 );
my $upTime = int ((time - $start_time) * 100.0);
my @myOID = ( 1,3,6,1,4,1,666,2,2 );

warn "Sending trap failed"
unless ($version eq '1')
? $trap_session->trap_request_send (encode_oid (@myOID),
encode_ip_address ($myIpAddress),
encode_int ($genericTrap),
encode_int ($specificTrap),
encode_timeticks ($upTime),
[encode_oid (@ifIndex_OID,$if_index),encode_int ($if_index)],
[encode_oid (@ifDescr_OID,$if_index),encode_string ($message)])
: $trap_session->v2_trap_request_send (\@linkDown_OID, $upTime,
[encode_oid (@ifIndex_OID,$if_index),
encode_int ($if_index)],
[encode_oid (@ifDescr_OID,$if_index),encode_string ($message)]);
}
When I've installed it on 5 different Debian machines (all Sarge), in 2 of them it worked perfectly ok, in 2 of them I get an "Operation not permitted" error message although I am running it as root, and in 1 of them the scripts executes with no error messages but no snmp packet makes its way to the receiver (OpenNMS).

About the last case I am pretty sure it is not a network issue... When I am using a little Java program that sends an snmp packet it goes with no problems!

Any ideas??? I am only using SNMP v1 (for the moment)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration