Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

snmptrapd not working

645 views
Skip to first unread message

pandit jignesh

unread,
Apr 29, 2012, 7:10:26 AM4/29/12
to
Hi


I have few question regarding my net-snmp configuration files although its working fine.
(1).i need logging option for both snmpd and snmptrapd to a different location (user specified ie /var/log/snmpd.log and /var/log/snmptrapd.log) rather then syslog(it is logging in syslog).

i have following line in /etc/default/snmpd file
SNMPDRUN=yes

# snmpd options (use syslog, close stdin/out/err).
#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'

# snmptrapd control (yes means start daemon).  As of net-snmp version
# 5.0, master agentx support must be enabled in snmpd before snmptrapd
# can be run.  See snmpd.conf(5) for how to do this.
TRAPDRUN=yes

# snmptrapd options (use syslog).
TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'

# create symlink on Debian legacy location to official RFC path
SNMPDCOMPAT=yes
 
(2). when i mention agentaddress udp:161 or udp:127.0.0.1:161 in snmpd.conf file i got error opening specified endpoint 161 and snmpd can not start, if i do not mention above token it is working.
(3). what token should be provide for traphandler in snmptrapd.conf file ?. i have downloaded a sample handler which is a perl file from debian website and is located under /usr/local/bin/Mytrapfile.pl . snmptrapd.conf file has followig line.

traphandle  default /usr/local/bin/Mytrapfile.pl

i can not restart snmptrapd service after i stop it(on boot up no problem). i got following err.
 * Restarting network management services:                                    

Unknown logging option passed to -L: ".
Unknown logging option passed to -L: ".
Unknown output option passed to -O: -
sh: /usr/local/bin/Mytrapfile.pl: Permission denied
sh: /usr/local/bin/Mytrapfile.pl: Permission denied
^Cjbpandit@jbpandit-desktop:~$ service snmpd status
 * snmpd is running
 * snmptrapd is not running
this is log option in snmptrapd.conf file

logoption  "-Lf FILE"
logoption  "-Lf /var/log/snmptrapd.log"
snmpd.conf file has following trap destinations value
trapsink 127.0.0.1 public
trap2sink 127.0.0.1 public
informsink 127.0.0.1 public
trapcommunity public
authtrapenable 1


there is no trap in syslog from snmptrapd.

what is wrong here
help please.............jbpandit

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-users mailing list
Net-snm...@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Dave Shield

unread,
Apr 29, 2012, 11:22:19 AM4/29/12
to
On 29 April 2012 12:10, pandit jignesh <jign...@yahoo.com> wrote:
> (1).i need logging option for both snmpd and snmptrapd to a different
> location

See the section 'LOGGING OPTIONS' in the snmpcmd(1) man page

> (2). when i mention agentaddress udp:161 or udp:127.0.0.1:161 in
> snmpd.conf file i got error opening specified endpoint 161 and
> snmpd can not start, if i do not mention above token it is working.

What is the exact command you are using to start the agent?
Are you running this as root, or some other user?
What happens if you specify a different port number, other than 161?
What version of the agent are you working with?

> (3). what token should be provide for traphandler in snmptrapd.conf file ?

Either the OID of the trap that you wish to pass to this particular script,
or the token "default" to handle all incoming traps


> traphandle  default /usr/local/bin/Mytrapfile.pl

What is the first line of the file Mytrapfile.pl?
What are the permissions on it?

What happens if you invoke
/usr/local/bin/Mytrapfile.pl
from the command line?


> i can not restart snmptrapd service after i stop it(on boot up no problem). i got following err.
>  * Restarting network management services:
>
> Unknown logging option passed to -L: ".
> Unknown logging option passed to -L: ".
> Unknown output option passed to -O: -

What are the options being used to invoke snmptrapd?
How exactly are you restarting this services?

> sh: /usr/local/bin/Mytrapfile.pl: Permission denied
> sh: /usr/local/bin/Mytrapfile.pl: Permission denied

That definitely looks like issues with the permissions on the script.



> this is log option in snmptrapd.conf file
>
> logoption  "-Lf FILE"

That looks like a template entry, where you are expected to
replace 'FILE' with the name of the file that you wish to log to
Try deleting this (or commenting it out)

> logoption  "-Lf /var/log/snmptrapd.log"


> snmpd.conf file has following trap destinations value
> trapsink 127.0.0.1 public
> trap2sink 127.0.0.1 public
> informsink 127.0.0.1 public

Why are you sending three copies of every trap?
Choose *one* of these entries, and delete the other two.


dave

pandit jignesh

unread,
Apr 29, 2012, 4:15:54 PM4/29/12
to
hi thanks for reply

my net-snmp virsion is 5.4.3. i start it as a sudo service snmpd start (restart or stop). when service snmpd status command execute show that

* snmpd is running

* snmptrapd is running
i am not manually starting snmptrapd, when snmpd started snmptrapd also start.
on execute Mytrapefile.pl from commandline following output:
-bash: /usr/local/bin/Mytrapfile.pl: Permission denied
Mytrapfile code:
#!/usr/bin/perl
# A simple trap handler
my $TRAP_FILE = "/var/log/snmptrapd.log";   

my $host = <STDIN>;    # Read the Hostname - First line of input from STDIN
 chomp($host);
my $ip = <STDIN>;    # Read the IP - Second line of input
 chomp($ip);

while(<STDIN>) {
        chomp($_);
        push(@vars,$_);
}

open(TRAPFILE, ">> $TRAP_FILE");
$date = `date`;
chomp($date);
print(TRAPFILE "New trap received: $date for $OID\n\nHOST: $host\nIP: $ip\n");
foreach(@vars) {
        print(TRAPFILE "TRAP: $_\n");
}
print(TRAPFILE "\n----------\n");
close(TRAPFILE);#!/usr/bin/perl
# A simple trap handler
my $TRAP_FILE = "/var/log/snmptrapd.log";   

my $host = <STDIN>;    # Read the Hostname - First line of input from STDIN
 chomp($host);
my $ip = <STDIN>;    # Read the IP - Second line of input
 chomp($ip);

while(<STDIN>) {
        chomp($_);
        push(@vars,$_);
}

open(TRAPFILE, ">> $TRAP_FILE");
$date = `date`;
chomp($date);
print(TRAPFILE "New trap received: $date for $OID\n\nHOST: $host\nIP: $ip\n");
foreach(@vars) {
        print(TRAPFILE "TRAP: $_\n");
}
print(TRAPFILE "\n----------\n");
close(TRAPFILE);

read-write permission for this file is jbpandit as a user and not as a root user.
on restart snmpd got 2 err related to snmptrapd.conf file
Unknown logging option passed to -L: ".

Unknown output option passed to -O: -
*snmpd is running.
*snmptrapd is not running.

what wrong here?  help please.....jbpandit
0 new messages