AE-1974 Create a debugging CLI to print logs when enabled during issue time

Review Request #973 — Created July 16, 2025 and updated

mmiriam
APV10
AE-1974
ngurunathan, peteryeh, pradeep, tanya, timlai

AE-1974 Create a debugging CLI to print logs when enabled during issue time. Added CLI which will print logs as below for netstat and lsof output to check if port is used by any other process and pstack output for 10 times to check stack trace of a running snmp process

AN(config)#snmp ?
community Set SNMP community string
contact Set SNMP contact string
debug Set debug logs for SNMP
enable Enable SNMP server
host Set SNMP server IP
ipcontrol Set SNMP access control rules based on source IP
ippermit Add one IP into permit IP permit list in SNMP
location Set SNMP location string
off Disable SNMP agent
on Enable SNMP agent
traps Configure SNMP traps
v3user Add one user into SNMP V3 user database in SNMP

AN(config)#snmp debug ?

off Disable SNMP agent debugging logs
on Enable SNMP agent debugging logs


snmp debug_on

cat /var/crash/snmpdlog.txt

udp 0 0 127.0.0.1:16223 0.0.0.0: 10779/snmpd
udp 0 0 0.0.0.0:161 0.0.0.0:
10774/snmpd
udp6 0 0 :::161 :::* 10774/snmpd
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
snmpd 10774 root 6u IPv4 41135 0t0 UDP :snmp
snmpd 10774 root 12u IPv6 41136 0t0 UDP :snmp
snmpd 10779 root 6u IPv4 40618 0t0 UDP localhost:16223
PSTACK

0 0x00007f18a1d3d210 in __read_nocancel () from /lib64/libpthread.so.0

1 0x00007f1892a65411 in cmd_api (cmd=cmd@entry=0x7f18beb0e5b0, size=size@entry=16, outp=outp@entry=0x7ffc4a839d98, out_size=out_size@entry=0x7ffc4a839d94) at cmd_api.c:119

2 0x00007f1892a2df6a in rts_table_count (arg1=arg1@entry=1) at userWrapper.c:87425

3 0x00007f1892924160 in var_linkRTSTableV6 (vp=0x7ffc4a83a790, name=0x7ffc4a83a390, length=0x7ffc4a839f88, exact=0, var_len=0x7ffc4a839f80, write_method=0x7ffc4a839f78) at llbMIB.c:737

4 0x00007f18a16791c5 in netsnmp_old_api_helper () from /lib64/libnetsnmpagent.so.31

5 0x00007f18a1687d4f in netsnmp_call_handlers () from /lib64/libnetsnmpagent.so.31

6 0x00007f18a1695a89 in handle_var_requests () from /lib64/libnetsnmpagent.so.31

7 0x00007f18a1695ed0 in handle_getnext_loop () from /lib64/libnetsnmpagent.so.31

8 0x00007f18a1696a88 in netsnmp_handle_request () from /lib64/libnetsnmpagent.so.31

9 0x00007f18a1696f42 in handle_snmp_packet () from /lib64/libnetsnmpagent.so.31

10 0x00007f18a0cdfe11 in _sess_process_packet () from /lib64/libnetsnmp.so.31

11 0x00007f18a0ce099e in _sess_read () from /lib64/libnetsnmp.so.31

12 0x00007f18a0ce17e9 in snmp_sess_read2 () from /lib64/libnetsnmp.so.31

13 0x00007f18a0ce183b in snmp_read2 () from /lib64/libnetsnmp.so.31

14 0x00007f18bddd88e8 in main ()

PSTACK

0 0x00007f189f3211dd in send () from /lib64/libc.so.6

1 0x00007f189f31a501 in __vsyslog_chk () from /lib64/libc.so.6

2 0x00007f189f31a7c2 in __syslog_chk () from /lib64/libc.so.6

3 0x00007f18a0cf753d in log_handler_syslog () from /lib64/libnetsnmp.so.31

4 0x00007f18a0cf81b8 in snmp_log_string () from /lib64/libnetsnmp.so.31

…. 10 times

Description From Last Updated

can we also add "top" command to see the CPU usage during issue time. top -b -n 1

pradeeppradeep

in snmp debug command debug should be a menu and on off should be items, no need the underscore. this …

tanyatanya
tanya
  1. 
      
  2. in snmp debug command debug should be a menu and on off should be items, no need the underscore. this will be consistent with our cli style
    snmp debug on|off

  3. 
      
mmiriam
pradeep
  1. 
      
  2. can we also add "top" command to see the CPU usage during issue time.

    top -b -n 1

  3. 
      
mmiriam
Review request changed

Testing Done:

~  

AN(config)#snmp ?

  ~

AN(config)#snmp ?

  + community Set SNMP community string
  + contact Set SNMP contact string
  + debug Set debug logs for SNMP
  + enable Enable SNMP server
  + host Set SNMP server IP
  + ipcontrol Set SNMP access control rules based on source IP
  + ippermit Add one IP into permit IP permit list in SNMP
  + location Set SNMP location string
  + off Disable SNMP agent
  + on Enable SNMP agent
  + traps Configure SNMP traps
  + v3user Add one user into SNMP V3 user database in SNMP

   
~  

debug_off Disable SNMP agent debugging off

~   debug_on Enable SNMP agent debugging on

  ~

AN(config)#snmp debug ?

  ~
  +

off Disable SNMP agent debugging logs

  + on Enable SNMP agent debugging logs

   
   
   
   

snmp debug_on

   
   

cat /var/crash/snmpdlog.txt

   
   

   
   

udp 0 0 127.0.0.1:16223 0.0.0.0: 10779/snmpd

    udp 0 0 0.0.0.0:161 0.0.0.0: 10774/snmpd
    udp6 0 0 :::161 :::* 10774/snmpd
    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    snmpd 10774 root 6u IPv4 41135 0t0 UDP :snmp
    snmpd 10774 root 12u IPv6 41136 0t0 UDP :snmp
    snmpd 10779 root 6u IPv4 40618 0t0 UDP localhost:16223
    PSTACK

   
   

0 0x00007f18a1d3d210 in __read_nocancel () from /lib64/libpthread.so.0

   
   

1 0x00007f1892a65411 in cmd_api (cmd=cmd@entry=0x7f18beb0e5b0, size=size@entry=16, outp=outp@entry=0x7ffc4a839d98, out_size=out_size@entry=0x7ffc4a839d94) at cmd_api.c:119

   
   

2 0x00007f1892a2df6a in rts_table_count (arg1=arg1@entry=1) at userWrapper.c:87425

   
   

3 0x00007f1892924160 in var_linkRTSTableV6 (vp=0x7ffc4a83a790, name=0x7ffc4a83a390, length=0x7ffc4a839f88, exact=0, var_len=0x7ffc4a839f80, write_method=0x7ffc4a839f78) at llbMIB.c:737

   
   

4 0x00007f18a16791c5 in netsnmp_old_api_helper () from /lib64/libnetsnmpagent.so.31

   
   

5 0x00007f18a1687d4f in netsnmp_call_handlers () from /lib64/libnetsnmpagent.so.31

   
   

6 0x00007f18a1695a89 in handle_var_requests () from /lib64/libnetsnmpagent.so.31

   
   

7 0x00007f18a1695ed0 in handle_getnext_loop () from /lib64/libnetsnmpagent.so.31

   
   

8 0x00007f18a1696a88 in netsnmp_handle_request () from /lib64/libnetsnmpagent.so.31

   
   

9 0x00007f18a1696f42 in handle_snmp_packet () from /lib64/libnetsnmpagent.so.31

   
   

10 0x00007f18a0cdfe11 in _sess_process_packet () from /lib64/libnetsnmp.so.31

   
   

11 0x00007f18a0ce099e in _sess_read () from /lib64/libnetsnmp.so.31

   
   

12 0x00007f18a0ce17e9 in snmp_sess_read2 () from /lib64/libnetsnmp.so.31

   
   

13 0x00007f18a0ce183b in snmp_read2 () from /lib64/libnetsnmp.so.31

   
   

14 0x00007f18bddd88e8 in main ()

   
   

PSTACK

   
   

0 0x00007f189f3211dd in send () from /lib64/libc.so.6

   
   

1 0x00007f189f31a501 in __vsyslog_chk () from /lib64/libc.so.6

   
   

2 0x00007f189f31a7c2 in __syslog_chk () from /lib64/libc.so.6

   
   

3 0x00007f18a0cf753d in log_handler_syslog () from /lib64/libnetsnmp.so.31

   
   

4 0x00007f18a0cf81b8 in snmp_log_string () from /lib64/libnetsnmp.so.31

   
   

…. 10 times

Diff:

Revision 2 (+72)

Show changes

Loading...