*/ 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);