mirror of
https://dev.iopsys.eu/system/sysmngr.git
synced 2025-12-10 00:06:19 +01:00
temperature: show optical transceiver temperature
This commit is contained in:
parent
70ca07fbc2
commit
9e5cbc3c00
1 changed files with 32 additions and 0 deletions
|
|
@ -373,6 +373,35 @@ static void scan_thermal_zones(json_object *sensors_array)
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void scan_xpon_sensors(json_object *sensors_array)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
char output[256];
|
||||||
|
int temp_value = 0;
|
||||||
|
|
||||||
|
fp = popen("ubus -t 1 call xpon status 2>/dev/null | jsonfilter -e '@.ONU[0].ANI[0].Transceiver[0].Temperature'", "r"); // flawfinder: ignore
|
||||||
|
if (!fp)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fgets(output, sizeof(output), fp) != NULL) {
|
||||||
|
char *endptr;
|
||||||
|
long val = strtol(output, &endptr, 10);
|
||||||
|
if (endptr != output && val >= INT_MIN && val <= INT_MAX) {
|
||||||
|
temp_value = (int)val;
|
||||||
|
|
||||||
|
/* Create JSON object for optical transceiver sensor */
|
||||||
|
json_object *sensor = json_object_new_object();
|
||||||
|
json_object_object_add(sensor, "name", json_object_new_string("optical_transceiver"));
|
||||||
|
json_object_object_add(sensor, "sysfs_path", json_object_new_string(""));
|
||||||
|
json_object_object_add(sensor, "temperature", json_object_new_int(temp_value));
|
||||||
|
json_object_object_add(sensor, "source", json_object_new_string("xpon"));
|
||||||
|
json_object_array_add(sensors_array, sensor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
static void discover_sensors(json_object **sensors_data)
|
static void discover_sensors(json_object **sensors_data)
|
||||||
{
|
{
|
||||||
*sensors_data = json_object_new_array();
|
*sensors_data = json_object_new_array();
|
||||||
|
|
@ -388,6 +417,9 @@ static void discover_sensors(json_object **sensors_data)
|
||||||
|
|
||||||
/* Scan WiFi sensors via wlctl (Broadcom) */
|
/* Scan WiFi sensors via wlctl (Broadcom) */
|
||||||
scan_wlctl_sensors(*sensors_data);
|
scan_wlctl_sensors(*sensors_data);
|
||||||
|
|
||||||
|
/* Scan optical transceiver sensors via xpon */
|
||||||
|
scan_xpon_sensors(*sensors_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int browseTemperatureSensor(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
static int browseTemperatureSensor(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue