Hi, I have created a python script to return data to PRTG. The scripts reads a json string containing upload and download bandwith values. In my Python script I use the following settings to send them to PRTG: ... csr.add_primary_channel(name="Download", value=d_b, unit=ValueUnit.SPEEDNET, speed_size=ValueSize.MEGABIT, is_float=False) csr.add_channel(name="Upload", value=u_b, unit=ValueUnit.SPEEDNET, speed_size=ValueSize.MEGABIT, is_float=False) ...

When I use the above code, the values in PRTG always show as "nnn /s" although I set the ValuSize in my script to MEGABIT. Also on the sensor Channel settings in PRTG I have no option to change that to Mbps.

When I use the ValueUnit.BYTESBANDWITH, with the same ValueSize.MEGABIT, the values show up as Kbit/s in PRTG, but I do have the option in PRTG to change them to Mbit/s

1) is this a bug in the Python PRTG module that it doesn't use the correct ValueSize?
2) What's the difference between SpeedNet and BytesBandwith unit options?
3) What is best used to keep track of up- and downloadspeeds of a connection?

Thanks a lot for your input.


Article Comments

What's the actual output of your script when run manually? SpeedNet and BytesBandwidth are measuring speed and throughput. The latter also allows for reporting on throughput over a certain timespan. The first one is best for what you're intending to do. iirc, the right value to use would be bytes for this in order for PRTG to calculate correctly :)


Apr, 2021 - Permalink

Stephan,

When I use SpeedNet as ValueUnit, it always shows up in bytes and I can't use the ValueSize option (actually I can but it doesn't change anything). I can also not change it using the PRTG channel settings When I use BytesBandwidth as ValueUnit, I can also set the ValueSize option and the values show as MBit/s in PRTG in stead of in bytes/s.

I'm actually running the speedtest.net cli program and parse the output in the python script to get an (hourly) update of my internet connection speed. That's why I also thought SpeedNet was the one to use, but then I only get values in bytes/s and I actually wont the see it in a more human-readable format (the times of 56k modem connections are long behind us already, we're measuring in Mbps now :-))


Apr, 2021 - Permalink

Well speednet would work for that, you can configure the channel unit configuration in the device settings, have you tried that one? :)


May, 2021 - Permalink

On the device settings, it says: No configurable channels...


May, 2021 - Permalink

But your sensor clearly has channels, right? Could you post a screenshot of the device settings, at the very bottom where it states that? I have yet to see this message :)


May, 2021 - Permalink

See screenshot. Sensor is currently paused, so no live data visible. Channels Download en Upload are setup with SpeedNet unit.


May, 2021 - Permalink

Still the same when resuming it?


May, 2021 - Permalink

Yes. Just started the sensor again, values are updated correctly, but only showing in bits /s and no way to change it to Mbps.


May, 2021 - Permalink

When you're in the Sensor, open up its settings tab. At the bottom, there should be a section "Channel Unit Configuration" where you can set this - is that not the case here?


May, 2021 - Permalink

No. It says: no configurable channels. On the other senor, using the BytesBandwidth as Unit, I do have an option to change it to Kbps/Mbps/...


May, 2021 - Permalink

What happens if you click in the gear icon of the Channels? Can you send me a screenshot of that?


May, 2021 - Permalink


May, 2021 - Permalink

Hi,

Have you tried changing the Channel Unit directly from the device? Please review the following document: https://www.paessler.com/manuals/prtg/device_settings#channel

Another option is to change the script so that it reports BytesBandwidth (unit) without a customunit, SpeedSize or VolumeSize.

Hope this helps.


May, 2021 - Permalink

Hi,

When using the BytesBandwidth type I can change it to KB/MB/GB without any problem. It's when using SpeedNet as unit that I always get it in bytes/s and there's no way to change it to mega- or gigabytes/s. I just created a new sensor with the script only specifying SPEEDNET as Unit and no other options, but in PRTG I have no way to change it to MB/GB/... Not in the settings, nor in the channel configuration.


May, 2021 - Permalink

Hi,

I believe the best option is to open up a ticket with us and if needed gather logs for analysis. To open up a ticket you can do it directly from the Contact Support option in the Core Server web interface.


May, 2021 - Permalink

Hello Mickeybyte. Did you get any support?

I am experiencing the same issue with a similar sensor. The whole sensor is in the code snippet below.

I would expect that simple SpeedNet unit with SpeedSize Byte will show it as simple as in Byte/s and allow me to change it in the channel unit configuration. But there is nothing about the SpeedNet in channel unit sensor settings. I tried byte, bit, in VolumeSize, SpeedSize, SpeedTime, nothing lead to success.

So question to the Paessler:

How does this work? What is expected result? How we can reach the state when we can configure the Bytes/s to be Megabytes/s (or alternative) from the UI same as for Bandwidth?

Sensor

Sensor Settings > Channel units

Also from help from speedtest cmd: Machine readable formats (csv, tsv, json, jsonl, json-pretty) use bytes as the unit of measure with max precision

So the $cosi.download.bandwitdth is Byte/s

#!/usr/bin/env pwsh
param([Switch] $Push)

$cosi = '{ "server": { "name": "ahoj", "location": "loc" }, "result": { "url": "url" } }'
#$cosi2 = '{"type":"result","timestamp":"2022-01-02T15:27:25Z","ping":{"jitter":0.71499999999999997,"latency":26.661000000000001},"download":{"bandwidth":1129525,"bytes":14619008,"elapsed":15011},"upload":{"bandwidth":1129272,"bytes":10069392,"elapsed":9003},"packetLoss":0.67796610169491522,"isp":"K-net Technical International Group, s.r.o.","interface":{"internalIp":"....","name":"eth0","macAddr":"DC:A6:32:74:F0:9F","isVpn":false,"externalIp":"...."},"server":{"id":29593,"host":"speed2.brno.master.profihost.cloud","port":8080,"name":"PROFI CLOUD SERVICES s.r.o.","location":"Brno","country":"Czech Republic","ip":"77.93.201.229"},"result":{"id":"57f71161-a25e-4a25-a782-563ed2ec4fde","url":"https://www.speedtest.net/result/c/57f71161-a25e-4a25-a782-563ed2ec4fde","persisted":true}}'
# $cosi = & speedtest --format="json" --accept-license --accept-gdpr
$cosi = $cosi | ConvertFrom-Json

$server = $cosi.server
$server = $server.name + ' - ' + $server.location
$resultURL = $cosi.result.url

$result = @{
	'prtg' = @{
		'text'   = "$server ($resultURL)"
		'result' = @(
			@{
				'Channel'         = 'Download Speed'
				'Value'           = 2125027
				# 'Value'           = ($cosi.download.bandwidth ?? 0)
				'Float'           = 1
				'DecimalMode'     = 'All'
				'Unit'            = 'SpeedNet'
				'VolumeSize'      = 'Byte'
				'SpeedSize'       = 'Byte'
				'LimitMode'       = 1
				'LimitMinWarning' = 1
			},
			@{
				'Channel'     = 'Downloaded Data'
				'Value'       = ($cosi.download.bytes ?? 0)
				'Float'       = 1
				'DecimalMode' = 'All'
				'Unit'        = 'BytesBandwidth'
			},
			@{
				'Channel'     = 'Upload Speed'
				'Value'       = 2167276
				# 'Value'       = ($cosi.upload.bandwidth ?? 0)
				'Float'       = 1
				'DecimalMode' = 'All'
				'Unit'        = 'SpeedNet'
				'VolumeSize'  = 'Bit'
				'SpeedSize'   = 'Bit'
			},
			@{
				'Channel'     = 'Uploaded Data'
				'Value'       = ($cosi.upload.bytes ?? 0)
				'Float'       = 1
				'DecimalMode' = 'All'
				'Unit'        = 'BytesBandwidth'
			},
			@{
				'Channel'     = 'Latency'
				'Value'       = $cosi.ping.latency ?? 0
				'Float'       = 1
				'DecimalMode' = 'All'
				'Unit'        = 'TimeResponse'
			},
			@{
				'Channel'     = 'Latency Jitter'
				'Value'       = $cosi.ping.jitter ?? 0
				'Float'       = 1
				'DecimalMode' = 'All'
				'Unit'        = 'TimeResponse'
			},
			@{
				'Channel'         = 'Packet Loss'
				'Value'           = ($cosi.packetloss ?? 0)
				'Float'           = 1
				'DecimalMode'     = 'All'
				'Unit'            = 'Percent'
				'LimitMode'       = 1
				'LimitMaxError'   = 60
				'LimitMaxWarning' = 30
			}
		)
	}

} | ConvertTo-Json -Depth 20 -Compress

if ($Push) {
	$ProgressPreference = 'SilentlyContinue'
	Invoke-WebRequest '<Redacted>' -Method 'Post' -Body $result -Headers @{
		'Content-Type' = 'application/json'
	} | Out-Null
} else {
	return $result
}


Jan, 2022 - Permalink

This issue has been in the freezer for some time now. Never opened a support ticket for it. Sorry.


Feb, 2022 - Permalink