snmpwalk
snmpwalk -Ci -v 2c -c <community_string> <hostname> <optional_mib>
snmpget
snmpget -v 2c -c <community_string> <hostname> <required_oid>
snmptrap
snmptrap -v 2c -c community_string snmptrapd_host "" MIB OID value_type (e.g. i=integer, s=string) value
snmptrap -v 2c -c public my_server.com "" NET-SNMP-EXAMPLES-MIB::netSnmpExampleNotification netSnmpExampleString s 'This is my test'
To debug this the other end run snmptrapd in debug mode as follows
/usr/sbin/snmptrapd -Lsd -Lo -p /var/run/snmptrapd.pid -Dsess_process_packet,netsnmp_udp,dumpH_recv,dumpv_recv,snmp_api -f &
[root@be1 ~]# /usr/sbin/snmptrapd -Lsd -Lo -p /var/run/snmptrapd.pid -Dsess_process_packet,netsnmp_udp,dumpH_recv,dumpv_recv,snmp_api -f & [1] 13641 [root@be1 ~]# registered debug token sess_process_packet, 1 registered debug token netsnmp_udp, 1 registered debug token dumpH_recv, 1 registered debug token dumpv_recv, 1 registered debug token snmp_api, 1 netsnmp_udp_parse_security: <"public", 0x00000000/0x00000000> => "comm1" netsnmp_udp_parse_security: <"PUBLIC", 0x00000000/0x00000000> => "comm2" netsnmp_udp: open local UDP: [0.0.0.0]:162->[0.0.0.0] netsnmp_udp: set IP_PKTINFO NET-SNMP version 5.5 [root@be1 ~]# snmptrap -v 2c -c public snmptrapd.example.com "" NET-SNMP-EXAMPLES-MIB::netSnmpExampleNotification netSnmpExampleString s 'This is my test' netsnmp_udp: got source addr: 172.16.0.193 netsnmp_udp: got destination (local) addr 172.16.0.193, iface 1 netsnmp_udp: recvfrom fd 8 got 104 bytes (from UDP: [172.16.0.193]:35048->[172.16.0.193]) sess_process_packet: session 0x7f7328c8d3b0 fd 8 pkt 0x7f7328ca3850 length 104 Integer: 1 (0x01) snmp_api: Parsing SNMPv2 message... Integer: 1 (0x01) String: public dumpv_recv: Command TRAP2 Integer: 1533359473 (0x5B653571) Integer: 0 (0x00) Integer: 0 (0x00) ObjID: DISMAN-EVENT-MIB::sysUpTimeInstance UInteger: 945424395 (0x385A080B) ObjID: SNMPv2-MIB::snmpTrapOID.0 ObjID: NET-SNMP-EXAMPLES-MIB::netSnmpExampleNotification ObjID: NET-SNMP-EXAMPLES-MIB::netSnmpExampleString String: This is my test sess_process_packet: received message id#0 reqid#1533359473 netsnmp_udp_getSecName: opaque = 0x7f7328c9e3e0 (len = 24), sizeof = 24, family = 2 (2) netsnmp_udp_getSecName: resolve <"public", 0xc10010ac> netsnmp_udp_getSecName: compare <"public", 0x00000000/0x00000000>... SUCCESS netsnmp_udp_getSecName: opaque = 0x7f7328c9e3e0 (len = 24), sizeof = 24, family = 2 (2) netsnmp_udp_getSecName: resolve <"public", 0xc10010ac> netsnmp_udp_getSecName: compare <"public", 0x00000000/0x00000000>... SUCCESS netsnmp_udp_getSecName: opaque = 0x7f7328c9e3e0 (len = 24), sizeof = 24, family = 2 (2) netsnmp_udp_getSecName: resolve <"public", 0xc10010ac> netsnmp_udp_getSecName: compare <"public", 0x00000000/0x00000000>... SUCCESS netsnmp_udp_getSecName: opaque = 0x7f7328c9e3e0 (len = 24), sizeof = 24, family = 2 (2) netsnmp_udp_getSecName: resolve <"public", 0xc10010ac> netsnmp_udp_getSecName: compare <"public", 0x00000000/0x00000000>... SUCCESS netsnmp_udp_getSecName: opaque = 0x7f7328c9e3e0 (len = 24), sizeof = 24, family = 2 (2) netsnmp_udp_getSecName: resolve <"public", 0xc10010ac> netsnmp_udp_getSecName: compare <"public", 0x00000000/0x00000000>... SUCCESS netsnmp_udp_getSecName: opaque = 0x7f7328c9e3e0 (len = 24), sizeof = 24, family = 2 (2) netsnmp_udp_getSecName: resolve <"public", 0xc10010ac> netsnmp_udp_getSecName: compare <"public", 0x00000000/0x00000000>... SUCCESS netsnmp_udp_getSecName: opaque = 0x7f7328c9e3e0 (len = 24), sizeof = 24, family = 2 (2) netsnmp_udp_getSecName: resolve <"public", 0xc10010ac> netsnmp_udp_getSecName: compare <"public", 0x00000000/0x00000000>... SUCCESS netsnmp_udp_getSecName: opaque = 0x7f7328c9e3e0 (len = 24), sizeof = 24, family = 2 (2) netsnmp_udp_getSecName: resolve <"public", 0xc10010ac> netsnmp_udp_getSecName: compare <"public", 0x00000000/0x00000000>... SUCCESS [root@be1 ~]# /usr/local/zabbix/scripts/snmptrap.sh: line 52: /usr/local/zabbix/bin/zabbix_sender: No such file or directory