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):

#!/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)