版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hjj651471519/article/details/80107093
一、修改:/net-snmp-5.6.1.1/include/net-snmp/Net-snmp-config.h文件中
Net-snmp-config.h文件中,必须注释掉NETSNMP_NO_DEBUGGING的宏定义,并把NETSNMP_ALWAYS_DEBUG改为0,才能是-Dtoken生效。
/* debugging stuff */
/* if defined, we optimize the code to exclude all debugging calls. */
//#define NETSNMP_NO_DEBUGGING 1
/* ignore the -D flag and always print debugging information */
#define NETSNMP_ALWAYS_DEBUG 0
举例,DEBUGMSGTL(("trap", "sending trap %ld\n",count));
上面这句的调试token就是第一个“trap”,则./snmp -f -Dtrap就可以只输出token为trap的所有调试信息了。
snmpd启动时默认会fork一个进程执行,因此,shell中是看不到任何输出的,可以加 -f,表示do not fork from the shell,这样,才会看到snmpd的输出信息。snmpd -h 可以查看所有的选项,-f是这些当中比较实用的。
二、注意事项:
//编包时,使能debugging ./configure --enable-debugging
三、使用启动方法:
DEBUGMSGTL(("xxx", "sending trap %ld\n",count));
snmpd -c /etc/snmp/snmp.conf -d -f -L -Dxxx
-d 打印数据包
-L 打印指定xxx
Net-snmp-config.h文件中,必须注释掉NETSNMP_NO_DEBUGGING的宏定义,并把NETSNMP_ALWAYS_DEBUG改为0,才能是-Dtoken生效。
/* debugging stuff */
/* if defined, we optimize the code to exclude all debugging calls. */
//#define NETSNMP_NO_DEBUGGING 1
/* ignore the -D flag and always print debugging information */
#define NETSNMP_ALWAYS_DEBUG 0
举例,DEBUGMSGTL(("trap", "sending trap %ld\n",count));
上面这句的调试token就是第一个“trap”,则./snmp -f -Dtrap就可以只输出token为trap的所有调试信息了。
snmpd启动时默认会fork一个进程执行,因此,shell中是看不到任何输出的,可以加 -f,表示do not fork from the shell,这样,才会看到snmpd的输出信息。snmpd -h 可以查看所有的选项,-f是这些当中比较实用的。
二、注意事项:
//编包时,使能debugging ./configure --enable-debugging
三、使用启动方法:
DEBUGMSGTL(("xxx", "sending trap %ld\n",count));
snmpd -c /etc/snmp/snmp.conf -d -f -L -Dxxx
-d 打印数据包
-L 打印指定xxx