fix issue with negative LUA metrics and added cable samples

This commit is contained in:
sberk42
2022-02-14 21:46:41 +01:00
parent 83f5dbf38f
commit c765ded25e
4 changed files with 3824 additions and 4 deletions

View File

@@ -112,11 +112,12 @@ These values are determined by parsing all services from http://fritz.box:49000/
## Customizing metrics
The metrics to collect are no longer hard coded, but have been moved to the [metrics.json](metrics.json) and [metrics-lua.json](metrics-lua.json) files, so just adjust to your needs.
The metrics to collect are no longer hard coded, but have been moved to the [metrics.json](metrics.json) and [metrics-lua.json](metrics-lua.json) files, so just adjust to your needs (for cable version also see [metrics-lua_cable.json](metrics-lua_cable.json)).
For a list of all the available metrics just execute the exporter with -test (username and password are needed for the TR-064 API!)
For lua metrics open UI in browser and check the json files used for the various screens.
For a list of all available metrics, see the dumps below (the format is the same as in the metrics.json file, so it can be used to easily add further metrics to retrieve):
- [FritzBox 6591 v7.29](all_available_metrics_6591_7.29.json)
- [FritzBox 7590 v7.12](all_available_metrics_7590_7.12.json)
- [FritzBox 7590 v7.20](all_available_metrics_7590_7.20.json)
- [FritzBox 7590 v7.25](all_available_metrics_7590_7.25.json)

File diff suppressed because it is too large Load Diff

View File

@@ -78,8 +78,7 @@ type LabelRename struct {
// regex to remove leading/training characters from numbers
var (
regexNonNumberBegin = regexp.MustCompile("^\\D+")
regexNonNumberEnd = regexp.MustCompile("\\D+$")
regexNonNumberEnd = regexp.MustCompile("\\D+$")
)
func (lua *LuaSession) doLogin(response string) error {
@@ -318,7 +317,7 @@ VALUE:
} else {
// convert value to float, but first remove all non numbers from begin or end of value
// needed if value contains unit
sNum := regexNonNumberEnd.ReplaceAllString(regexNonNumberBegin.ReplaceAllString(sVal, ""), "")
sNum := regexNonNumberEnd.ReplaceAllString(sVal, "")
floatVal, err = strconv.ParseFloat(sNum, 64)
if err != nil {

308
metrics-lua_cable.json Normal file
View File

@@ -0,0 +1,308 @@
{
"labelRenames": [
{
"matchRegex": "64QAM",
"renameLabel": "64"
},
{
"matchRegex": "16QAM",
"renameLabel": "16"
},
{
"matchRegex": "(?i)prozessor",
"renameLabel": "CPU"
},
{
"matchRegex": "(?i)system",
"renameLabel": "System"
},
{
"matchRegex": "(?i)DSL",
"renameLabel": "DSL"
},
{
"matchRegex": "(?i)FON",
"renameLabel": "Phone"
},
{
"matchRegex": "(?i)WLAN",
"renameLabel": "WLAN"
},
{
"matchRegex": "(?i)USB",
"renameLabel": "USB"
},
{
"matchRegex": "(?i)Speicher.*FRITZ",
"renameLabel": "Internal eStorage"
}
],
"metrics": [
{
"path": "data.lua",
"params": "page=docInfo",
"resultPath": "data.channelUs.docsis30.*",
"resultKey": "powerLevel",
"promDesc": {
"fqName": "gateway_cable_power_upstream",
"help": "docsis 3.0 power upstream from data.lua?page=docInfo",
"varLabels": [
"gateway", "frequency"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=docInfo",
"resultPath": "data.channelUs.docsis30.*",
"resultKey": "type",
"promDesc": {
"fqName": "gateway_cable_modulation_upstream",
"help": "docsis 3.0 modulation upstream from data.lua?page=docInfo",
"varLabels": [
"gateway", "frequency"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=docInfo",
"resultPath": "data.channelUs.docsis31.*",
"resultKey": "powerLevel",
"promDesc": {
"fqName": "gateway_cable_power_upstream31",
"help": "docsis 3.1 power upstream from data.lua?page=docInfo",
"varLabels": [
"gateway", "frequency"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=docInfo",
"resultPath": "data.channelDs.docsis30.*",
"resultKey": "corrErrors",
"promDesc": {
"fqName": "gateway_cable_correctables_downstream",
"help": "docsis 3.0 correctable errors dpwnstream from data.lua?page=docInfo",
"varLabels": [
"gateway", "frequency"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=docInfo",
"resultPath": "data.channelDs.docsis30.*",
"resultKey": "nonCorrErrors",
"promDesc": {
"fqName": "gateway_cable_uncorrectables_downstream",
"help": "docsis 3.0 uncorrectable errors downstream from data.lua?page=docInfo",
"varLabels": [
"gateway", "frequency"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=docInfo",
"resultPath": "data.channelDs.docsis30.*",
"resultKey": "mse",
"promDesc": {
"fqName": "gateway_cable_mse_downstream",
"help": "docsis 3.0 mse downstream from data.lua?page=docInfo",
"varLabels": [
"gateway", "frequency"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=docInfo",
"resultPath": "data.channelDs.docsis30.*",
"resultKey": "powerLevel",
"promDesc": {
"fqName": "gateway_cable_power_downstream",
"help": "docsis 3.0 powerlevel downstream from data.lua?page=docInfo",
"varLabels": [
"gateway", "frequency"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=docInfo",
"resultPath": "data.channelDs.docsis31.*",
"resultKey": "powerLevel",
"promDesc": {
"fqName": "gateway_cable_power_downstream31",
"help": "docsis 3.1 powerlevel downstream from data.lua?page=docInfo",
"varLabels": [
"gateway", "frequency"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=energy",
"resultPath": "data.drain.*",
"resultKey": "actPerc",
"promDesc": {
"fqName": "gateway_data_energy_consumption",
"help": "percentage of energy consumed from data.lua?page=energy",
"varLabels": [
"gateway", "name"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=energy",
"resultPath": "data.drain.*.lan.*",
"resultKey": "class",
"okValue": "green",
"promDesc": {
"fqName": "gateway_data_energy_lan_status",
"help": "status of LAN connection from data.lua?page=energy (1 = up)",
"varLabels": [
"gateway", "name"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=ecoStat",
"resultPath": "data.cputemp.series.0",
"resultKey": "-1",
"promDesc": {
"fqName": "gateway_data_ecostat_cputemp",
"help": "cpu temperature from data.lua?page=ecoStat",
"varLabels": [
"gateway"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=ecoStat",
"resultPath": "data.cpuutil.series.0",
"resultKey": "-1",
"promDesc": {
"fqName": "gateway_data_ecostat_cpuutil",
"help": "percentage of cpu utilization from data.lua?page=ecoStat",
"varLabels": [
"gateway"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=ecoStat",
"resultPath": "data.ramusage.series.0",
"resultKey": "-1",
"promDesc": {
"fqName": "gateway_data_ecostat_ramusage",
"help": "percentage of RAM utilization from data.lua?page=energy",
"varLabels": [
"gateway"
],
"fixedLabels": {
"ram_type" : "Fixed"
}
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=ecoStat",
"resultPath": "data.ramusage.series.1",
"resultKey": "-1",
"promDesc": {
"fqName": "gateway_data_ecostat_ramusage",
"help": "percentage of RAM utilization from data.lua?page=energy",
"varLabels": [
"gateway"
],
"fixedLabels": {
"ram_type" : "Dynamic"
}
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=ecoStat",
"resultPath": "data.ramusage.series.2",
"resultKey": "-1",
"promDesc": {
"fqName": "gateway_data_ecostat_ramusage",
"help": "percentage of RAM utilization from data.lua?page=energy",
"varLabels": [
"gateway"
],
"fixedLabels": {
"ram_type" : "Free"
}
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=usbOv",
"resultPath": "data.usbOverview.devices.*",
"resultKey": "partitions.0.totalStorageInBytes",
"promDesc": {
"fqName": "gateway_data_usb_storage_total",
"help": "total storage in bytes from data.lua?page=usbOv",
"varLabels": [
"gateway", "deviceType", "deviceName"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
},
{
"path": "data.lua",
"params": "page=usbOv",
"resultPath": "data.usbOverview.devices.*",
"resultKey": "partitions.0.usedStorageInBytes",
"promDesc": {
"fqName": "gateway_data_usb_storage_used",
"help": "used storage in bytes from data.lua?page=usbOv",
"varLabels": [
"gateway", "deviceType", "deviceName"
]
},
"promType": "GaugeValue",
"cacheEntryTTL": 300
}
]
}