Status to InfluxDB

This Wiki Page describes how to use our SDK functionality to monitor current status value into external Database(influxdb). It allows you to get more connectivtiy into you network infrastructor. This can be used for all netmodule routers.

Prerequierments

  • NetModule Wireless Router with any WAN connection
  • NRSW 4.8.0.101 or newer
  • Not available for legacy products NB1600, NB2700, NB3700, NB3710

Concept

Netmodule routers provide several service status values via cli. We are going to send those informations to the external influxdb. For this usecase we want to use the REST-API and the line protocol by influxdb. Our SDK functionality has different kind of netmodule specific functions to do HTTP request. The status value can attached to the HEADER of the HTTP request and going to get send via TLS/SSL connection to the database.

SDK scripting

All information about SDK can be found here

InfluxDB

InfluxDB is an opensource database software, which gives you multiple opperunitys to visual, monitoring, retrieval of time series data, recording performance metrics, analytics or simplely storage data for any other applications. It has different kind of state of the art interfaces and is fully integrated into python for example. You can easily register at https://www.influxdata.com/get-influxdb/ to get a free userspace/cloud for your needs. It is required for this HowTo to have a account. This contains no additional cost at all.

Configuration

All guiding pictures are .gif and will show you the following steps. You need to click them twice to start the .gif

InfluxDB

1. Bucket

Once you have created an account login and created a new data bucket

2. API Access Token

Generate a “all access api token” to write data to the bucket. Once you have seen the API token, you have option to see the token again. Please save the token may in your password manager.

3. API URL

For the last step you need your Organisation ID and bring all other information into a specific URL. https://eu-central-1-1.aws.cloud2.influxdata.com/api/v2/write?org=orgID&bucket=bucketName&precision=ns

You can find your OrgID here:

Netmodule router

1. Allow https connections

To send the data via TLS/SSL we need to add the domian certifcate to the netmodule router. Therefor you need to upload the Root CA R3 chain from the influxdb SSL Certificate. You can easily download the cert chain with the following steps:

Then login to your netmodule router WEB UI and upload the cert chain under SYSTEM –> Keys & Certificates –> Authorities.

2. SDK job

For the final step you need to define the SDK Job as followed:

Timebased trigger periodically every 1min.

upload the the script below with you URL and API

Select trigger and script and define the sdk job.

status2influx script

status2influx.are
*/ DESC: This script is sendinf the current cli WWAN infos to a external InfluxDB
*  created by [TD] 24.9.2023
*  Copyright (C) (2013-2024) NetModule AG, Switzerland
*/
 
url = "https://eu-central-1-1.aws.cloud2.influxdata.com/api/v2/write?org=01ad2d78e27c0e0d&bucket=netmodule&precision=ns";
usr = "";
pwd = "";
pp = "";
resp = "response.txt";
 
status = nb_status("wwan");
stinfo = struct_fields(status);
sn = struct_get(nb_status("system"), "SERIAL_NUMBER");
host = nb_config_get("network.hostname");
data = sprintf("host=%s,sn=%s ", host, sn);
 
 
//define header with valid influx API Token
header = "Authorization: Token XansFOeVPLFvPkfGiboGW7RvXwaio1WmjodVklcbtOJPumgqH5KGhIQyHQuMlflL72bWk27liAybzE2EhA3ksQ==";
 
for (i = 0; i < length(stinfo); i++) {
 
   // if value is digit
   if (isdigit(struct_get(status, stinfo[i]))) {
      data = strcat(data, sprintf("%s=%s,", stinfo[i], struct_get(status, stinfo[i])));
 
   } else {
      data = strcat(data, sprintf('%s="%s",', stinfo[i], struct_get(status, stinfo[i])));
   }
}
 
len = strlen(data);
data = left(data, len - 1);
 
// POST request
response = nb_transfer_post(usr, pwd, url, "", data, resp, header, 1);
printf("Exited script with response %d", response);
exit(0);

InfluxDB Dashboard

This section will show you how to create a simple dashboard to monitor the cpu temperature of a the router.