Skip to content

[Net-SNMP] Attach gdb to snmpd agent on x86

Attach gdb to snmpd agent on x86
Attach gdb to snmpd agent on x86

This post will explain how to attach gdb to net-snmp agent which is loaded by net-snmp using shared library method.


Base condition

You need to check net-snmp is runing properly or not with agent using shared library method.

Please check snmpd.conf and service status.

# check snmpd.conf whether it' shared library mode or not
vim ~/.snmp/snmpd.conf

# check snmpd control
sudo service snmpd status
sudo service snmpd restart 


Run on x86

Kill running net-snmp then run snmpd by gdb. once gdb shell entered, input options to run snmpd properly. Actually, you can catch that options by result of “sudo service snmpd status” which described running command with options.

# kill running snmpd & check twice after kill
ps -ef | grep snmpd
sudo kill <pid of snmpd>

# run gdb with snmpd
sudo gdb /usr/local/sbin/snmpd
# put below in gdb shell , below is same as "/etc/init.d/snmpd" described
(gdb) run -Ls0-7d -a -f -c /home/surplsdev/.snmp/snmpd.conf -p /run/snmpd.pid


Run on some embeded linux(arm64)

# kill running snmpd & check twice after kill
ps -ef | grep snmpd
kill <pid of snmpd>

# run gdb with snmpd
gdb /usr/sbin/snmpd
(gdb) run -Ls0-6d -a -f -p /run/snmpd.pid

Leave a Reply

Your email address will not be published. Required fields are marked *