Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sdk:scripts:snmp-trap [2015/05/05 17:04] (current)
Line 1: Line 1:
 +====== SDK Script snmp-trap.are ======
 +<code c snmp-trap.are>​
 +/* DESC: This script can be used to send SNMP traps
 + * Copyright (C) 2014 NetModule AG, Switzerland
 + */
 +
 +/* use SNMPv1 */
 +rc = nb_snmp_traphost("​192.168.1.254",​ 162, 1, "​public"​);​
 +
 +if (rc != 0) {
 +    printf("​unable to set traphost\n"​);​
 +    exit(1);
 +}
 +
 +/* send null trap */
 +if (nb_snmp_trap("​.1.2.3.4.5",​ "​n",​ ""​) != 0) {
 +    printf("​unable to send null trap"​);​
 +}
 +
 +/* send an integer trap */
 +if (nb_snmp_trap("​.1.2.3.4.5",​ "​i",​ 1) != 0) {
 +    printf("​unable to send integer trap"​);​
 +}
 +
 +/* send an octet string trap */
 +if (nb_snmp_trap("​.1.2.3.4.5",​ "​s",​ "​test"​) != 0) {
 +    printf("​unable to send octet string trap"​);​
 +}
 +
 +
 +exit(0);
 +
 +</​code>​