Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
sdk:status-values-via-snmp [2015/05/06 12:50]
127.0.0.1 external edit
sdk:status-values-via-snmp [2015/07/07 11:16]
fachet [Extended example]
Line 30: Line 30:
 ===== Access via SNMP ===== ===== Access via SNMP =====
  
 +Using SNMP v1/2c there are two communities. The "​read"​ community only allows to read data. The "​write"​ or "​admin"​ gives read and write access. With "​allowed hosts" you can restrict the SNMP access to the router via an IP range. "​0.0.0.0"​ can be used for any access.
 +
 +You can also use SNMP v3 for accessing the router. ​
 +Attention must be paid to the fact that SNMP passwords have to be more than 8 characters long. Shorter passwords have to be doubled for SNMP (e.g. admin01 becomes admin01admin01). ​
 +Only the user "​admin"​ can be used 
 To see the values run on linux: \\ To see the values run on linux: \\
 **snmpwalk -v 3 -u <​user>​ -n ""​ -l authNoPriv -a MD5 -x DES -A <​password>​[<​password>​] <​IPaddress> ​ 1.3.6.1.4.1.31496.10.90** **snmpwalk -v 3 -u <​user>​ -n ""​ -l authNoPriv -a MD5 -x DES -A <​password>​[<​password>​] <​IPaddress> ​ 1.3.6.1.4.1.31496.10.90**
- 
-Attention must be paid to the fact that SNMP passwords have to be more than 8 characters long. Shorter passwords will be doubled for SNMP (e.g. admin01 becomes admin01admin01). 
  
 For example: For example:
 <code bash> <code bash>
-snmpwalk -v 3 -u admin -n ""​ -l authNoPriv -a MD5 -x DES -A admin01admin01 ​192.168.1.140 ​ 1.3.6.1.4.1.31496.10.90 ​+snmpwalk -v 3 -u snmp -n ""​ -l authNoPriv -a MD5 -x DES -A snmp01password ​192.168.1.140 ​ 1.3.6.1.4.1.31496.10.90 ​
  
 iso.3.6.1.4.1.31496.10.90.1.0 = STRING: "​47.3"​ iso.3.6.1.4.1.31496.10.90.1.0 = STRING: "​47.3"​
Line 44: Line 47:
  
 Or use a windows tool: Or use a windows tool:
 +
 +{{:​sdk:​mibbroswersettings.jpg|}}
 +
 {{:​sdk:​snmp.jpg |}} {{:​sdk:​snmp.jpg |}}
 +
 +*if you use SNMP v1/2c with the MibBrowser please set either the "​Community"​ (=read only) or the "Write Commuinity"​ (=read-write),​ but not both at the same time.
 +
  
 ===== Useful ===== ===== Useful =====
Line 92: Line 101:
 </​code>​ </​code>​
  
 +===== Extended example =====
 +<code c status_snmp2.are>​
 +/* DESC: This script extends MIB entries of the SNMP agent 
 + * with values from nb_status for temperature,​ signal level, ​
 + * transferred data on mobile network and
 + * reset of transferred data counter
 + * Copyright (coffee) 2014 NetModule AG, Switzerland
 + */
 +if (nb_snmp_register("​TEMPERATURE",​ 1, "​s",​ "​ro"​) == -1) exit(1);
 +if (nb_snmp_register("​RSRQ",​ 2, "​s",​ "​ro"​) == -1) exit(2);
 +if (nb_snmp_register("​DOWNLOADED",​ 3, "​s",​ "​ro"​) == -1)exit(3);
 +if (nb_snmp_register("​UPLOADED",​ 4, "​s",​ "​ro"​) == -1)exit(4);
 +if (nb_snmp_register("​RESET_DATA",​ 5, "​s",​ "​rw"​) == -1)exit(5);
 + 
 +if (nb_snmp_link() == -1)exit(6);
 + 
 +for(;;) {
 +   wwan = nb_status("​wwan"​);​
 +   wan = nb_status("​wan"​);​
 +   if (nb_snmp_update("​TEMPERATURE",​ struct_get(wwan,​ "​MOBILE1_MODULE_TEMPERATURE"​)) == -1) exit(7);
 +   if (nb_snmp_update("​RSRQ",​ struct_get(wwan,​ "​MOBILE1_RSRQ"​)) == -1) exit(8);
 +   if (nb_snmp_update("​DOWNLOADED",​ struct_get(wan,​ "​WANLINK1_DATA_DOWNLOADED"​)) == -1) exit(9);
 +   if (nb_snmp_update("​UPLOADED",​ struct_get(wan,​ "​WANLINK1_DATA_UPLOADED"​)) == -1) exit(10);
 +   
 +   if (s = nb_snmp_listen(5))
 +      if (s.name == "​RESET_DATA"​ && s.value == "​reset"​) {
 +          nb_reset_statistics("​wanlink0"​);​
 +          if (nb_snmp_update("​RESET_DATA",​ strftime("​%d.%m.%Y %H:​%M:​%S",​ localtime(time()))) == -1) exit(11);
 +      }
 +} </​code>​
 +
 +Please extend the NetModule router MIB (VENODR-MIB.txt before "trap objects"​ with:
 +<​code>​
 +-- ****************************************************************************
 +-- NBSdkTable
 +-- ****************************************************************************
 +sdkTemperature OBJECT-TYPE
 +    SYNTAX ​ DisplayString
 +    MAX-ACCESS ​ read-only
 +    STATUS ​ current
 +    DESCRIPTION
 +        "The temperature of the WWAN Module 1"
 +    ::= { sdk 1 }
 +    ​
 +sdkRSRQ OBJECT-TYPE
 +    SYNTAX ​ DisplayString
 +    MAX-ACCESS ​ read-only
 +    STATUS ​ current
 +    DESCRIPTION
 +        "The RSRQ of the WWAN Module 1"
 +    ::= { sdk 2 }
 +    ​
 +sdkDataDownloaded OBJECT-TYPE
 +    SYNTAX ​ DisplayString
 +    MAX-ACCESS ​ read-only
 +    STATUS ​ current
 +    DESCRIPTION
 +        "The data downloaded on the WAN interface"​
 +    ::= { sdk 3 }
 +    ​
 +sdkDataUploaded OBJECT-TYPE
 +    SYNTAX ​ DisplayString
 +    MAX-ACCESS ​ read-only
 +    STATUS ​ current
 +    DESCRIPTION
 +        "The data uploaded on the WAN interface"​
 +    ::= { sdk 4 }   
 +
 +sdkDataReset OBJECT-TYPE
 +    SYNTAX ​ DisplayString ​
 +    MAX-ACCESS ​ read-write
 +    STATUS ​ current
 +    DESCRIPTION
 +        "Write '​reset'​ to reset the up- and download counters for the WAN interface."​
 +    ::= { sdk 5 }   
 +</​code>​
 +
 +{{:​sdk:​mibbrowser_status_snmp2.jpg|}}