-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
7.0 updates. All the same as 6.4 really, except I re-exported the tem…
…plate yml file
- Loading branch information
Todd Blake
committed
Aug 21, 2024
1 parent
a69d983
commit 5d844dd
Showing
5 changed files
with
1,047 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Template_App_Speedtest_Wan | ||
To store information from the ookla speedtest cli command into Zabbix. | ||
# Author | ||
Todd Blake | ||
# Requirements: | ||
* Zabbix version 6.4 or later | ||
* the speedtest cli app from speedtest.net - https://www.speedtest.net/apps/cli (NOT the one from pypi) | ||
* the timeout command to timeout a hanging speedtest command | ||
* the zabbix_sender command for sending the data to zabbix | ||
# Installation: | ||
1. Import the Template_App_Speedtest_Wan.yaml template into your Zabbix instance (Configuration --> Templates --> Import), and apply the template to a host | ||
2. Copy the record_speedtest.sh script to somewhere on your system, e.g. /usr/local/bin/record_speedtest.sh | ||
3. Set the script to be executable, e.g. `chmod +x /usr/local/bin/record_speedtest.sh` | ||
4. Edit the record_speedtest.sh script: | ||
- Set the SPDHOST variable to the name of the host you've applied the template too within Zabbix | ||
- Set the ZABSRV variable to the name/IP of your Zabbix server or proxy that the host is reporting too | ||
- Optionally, set the PSKID and PSKFILE variables if you're using encryption in your Zabbix environment. | ||
- Optionally, set the SPEEDTESTPARAMS variable to any additional needed speedtest parameters | ||
5. Set the {$NO_SPDTST_DATA_SECS} macro to 300 seconds (5 minutes) more than the frequency of execution, in seconds. i.e. If you run it every 6 hours, set the macro to 21900 (6 hours * 60 minutes per hour * 60 seconds per minute, then add 300 seconds to that.) | ||
6. Install a crontab entry to run this script on a schedule: | ||
|
||
`0 */6 * * * /usr/local/bin/record_speedtest.sh # feed speedtest info into zabbix every 6 hours` | ||
|
||
# Example Dashboard | ||
![Example Dashboard](dashboard.png?raw=true "Example Dashboard") | ||
|
||
## Macros used | ||
|
||
|Macro|Default Value|Description| | ||
|-----|-------------|-----------| | ||
|{$NO_SPDTST_DATA_SECS}|21900 (6 hours and 5 minutes)|The number of seconds that Zabbix will alert when it's received no new speedtest data| | ||
|{$BWIDTH_DL_ALERT}|209715200 (200Mbps)|The threshold for alerting if download bandwidth drops below this value| | ||
|{$BWIDTH_UL_ALERT}|10485760 (10Mbps)|The threshold for alerting if upload bandwidth drops below this value| | ||
|
||
## Template links | ||
|
||
There are no template links in this template. | ||
|
||
## Discovery rules | ||
|
||
There are no discovery rules in this template. | ||
|
||
## Items collected | ||
|
||
|Name|Description|Type|Key and additional info| | ||
|----|-----------|----|----| | ||
|Speedtest - Download Bandwidth|The measured bandwidth in bits per second.|Dependent item|speedtest[download.bandwidth]| | ||
|Speedtest - Download Bytes|The number of bytes downloaded in the test.|Dependent item|speedtest[download.bytes]| | ||
|Speedtest - Download Latency (High)|The highest recorded latency during the download portion of the test.|Dependent item|speedtest[download.latency.high]| | ||
|Speedtest - Download Latency (IQM)|The IQM (interquartile mean) of the latency recorded during the download portion of the test.|Dependent item|speedtest[download.latency.iqm]| | ||
|Speedtest - Download Latency (Jitter)|The jitter recorded during the download portion of the test.|Dependent item|speedtest[download.latency.jitter]| | ||
|Speedtest - Download Latency (Low)|The lowest recorded latency during the download portion of the test.|Dependent item|speedtest[download.latency.low]| | ||
|Speedtest - Download Time Elapsed|The time to execute the download test.|Dependent item|speedtest[download.elapsed]| | ||
|Speedtest - External IP|The external (internet) IP address of the system executing the test.|Dependent item|speedtest[interface.externalIp]| | ||
|Speedtest - ISP|The ISP of the system executing the test.|Dependent item|speedtest[isp]| | ||
|Speedtest - Internal IP|The internal (local) IP address of the system executing the test.|Dependent item|speedtest[interface.internalIp]| | ||
|Speedtest - Is VPN?|Are we on a VPN while executing the test?|Dependent item|speedtest[interface.isVpn]| | ||
|Speedtest - JSON|The raw JSON from the speedtest command. It's parsed out for all of the other fields except the run time.|Zabbix trapper|custom.speedtest[json]| | ||
|Speedtest - MAC Address|The MAC address of the interface used when executing the test|Dependent item|speedtest[interface.macAddr]| | ||
|Speedtest - Network Interface|The network interface used to execute the test|Dependent item|speedtest[interface.name]| | ||
|Speedtest - Packet Loss|Packets lost during the test.|Dependent item|speedtest[packetLoss]| | ||
|Speedtest - Ping Latency (Average)|The average recorded latency during the ping portion of the test.|Dependent item|speedtest[ping.latency]| | ||
|Speedtest - Ping Latency (High)|The highest recorded latency during the ping portion of the test.|Dependent item|speedtest[ping.high]| | ||
|Speedtest - Ping Latency (Jitter)|The recorded jitter during the ping portion of the test.|Dependent item|speedtest[ping.jitter]| | ||
|Speedtest - Ping Latency (Low)|The lowest recorded latency during the ping portion of the test.|Dependent item|speedtest[ping.low]| | ||
|Speedtest - Result ID|The ID at speedtest.net of the results.|Dependent item|speedtest[result.id]| | ||
|Speedtest - Result URL|The URL at speedtest.net of the results.|Dependent item|speedtest[result.url]| | ||
|Speedtest - Run time|The time the record_speedtest.sh script was executed.|Zabbix trapper|custom.speedtest[runtime]| | ||
|Speedtest - Server Country|The country of the selected speedtest server.|Dependent item|speedtest[server.country]| | ||
|Speedtest - Server Host|The hostname of the selected speedtest server.|Dependent item|speedtest[server.host]| | ||
|Speedtest - Server ID|The speedtest ID of the selected speedtest server.|Dependent item|speedtest[server.id]| | ||
|Speedtest - Server IP|The IP address of the selected speedtest server.|Dependent item|speedtest[server.ip]| | ||
|Speedtest - Server Location|The geographical location (City, State in the US for example) of the selected speedtest server.|Dependent item|speedtest[server.location]| | ||
|Speedtest - Server Name|The human readable speedtest.net name of the selected speedtest server.|Dependent item|speedtest[server.name]| | ||
|Speedtest - Server Port|The TCP port used of the selected speedtest server.|Dependent item|speedtest[server.port]| | ||
|Speedtest - Timestamp|The timestamp of the test recorded from speedtest.net.|Dependent item|speedtest[timestamp]| | ||
|Speedtest - Upload Bandwidth|The measured bandwidth in bits per second.|Dependent item|speedtest[upload.bandwidth]| | ||
|Speedtest - Upload Bytes|The number of bytes uploaded in the test.|Dependent item|speedtest[upload.bytes]| | ||
|Speedtest - Upload Latency (High)|The highest recorded latency during the upload portion of the test.|Dependent item|speedtest[upload.latency.high]| | ||
|Speedtest - Upload Latency (IQM)|The IQM (interquartile mean) of the latency recorded during the upload portion of the test.|Dependent item|speedtest[upload.latency.iqm]| | ||
|Speedtest - Upload Latency (Jitter)|The jitter recorded during the upload portion of the test.|Dependent item|speedtest[upload.latency.jitter]| | ||
|Speedtest - Upload Latency (Low)|The lowest recorded latency during the upload portion of the test.|Dependent item|speedtest[upload.latency.low]| | ||
|Speedtest - Upload Time Elapsed|The time to execute the upload test.|Dependent item|speedtest[upload.elapsed]| | ||
|
||
## Triggers | ||
|
||
|Name|Description|Expression|Priority| | ||
|----|-----------|----------|--------| | ||
|No new speed test data received in the last {$NO_SPDTST_DATA_SECS} seconds|We haven't received any new JSON data from speedtest in the last {$NO_SPDTST_DATA_SECS} seconds.|nodata(/Template_App_Speedtest/custom.speedtest[json],{$NO_SPDTST_DATA_SECS})=1|High| | ||
|Download bandwidth is less than {$BWIDTH_DL_ALERT}|The measured download bandwidth has dropped below {$BWIDTH_DL_ALERT}bps.|max(/Template_App_Speedtest_Wan/speedtest[download.bandwidth],#3)<{$BWIDTH_DL_ALERT}|Warning| | ||
|Upload bandwidth is less than {$BWIDTH_UL_ALERT}|The measured upload bandwidth has dropped below {$BWIDTH_UL_ALERT}bps.|max(/Template_App_Speedtest_Wan/speedtest[upload.bandwidth],#3)<{$BWIDTH_UL_ALERT}|Warning| |
Oops, something went wrong.
This comment was marked as resolved.
Sorry, something went wrong.
5d844dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like (guessing) that the variables near the top of the script weren't filled in?
At a minimum,
ZABSRV
andSPDHOST
need to be assigned.If you did, can you paste the output of "
bash -x /path/to/record_speedtest.sh
"This comment was marked as resolved.
Sorry, something went wrong.
5d844dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you paste the output of:
bash -x /path/to/record_speedtest.sh
and
/snap/bin/speedtest -v
5d844dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, I was rushing and thought that bash command is not giving anything else than couple of lines. Waiting a bit longer gives this, but stucks after cat
`+ PSKID=
PSKFILE=
ZABSRV=172.22.54.44
SPDHOST=Zabbix
SPEEDTESTPARAMS=
++ /snap/bin/speedtest
SPEEDTEST='
Speedtest by Ookla
Idle Latency: 7.59 ms (jitter: 0.08ms, low: 7.53ms, high: 7.64ms)
Download: 588.98 Mbps (data used: 280.6 MB)
14.93 ms (jitter: 0.52ms, low: 9.99ms, high: 15.96ms)
Upload: 291.08 Mbps (data used: 134.8 MB)
7.62 ms (jitter: 6.19ms, low: 7.42ms, high: 229.88ms)
Packet Loss: 0.0%
Result URL: OMITTED LINK HERE'
++ /usr/bin/timeout
Try '/usr/bin/timeout --help' for more information.
++ /usr/bin/zabbix_sender
zabbix_sender [161505]: either '-c' or '-z' option must be specified
zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] -s host
-k key -o value
zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] [-s host]
[-T] [-N] [-r] [-b] -i input-file
zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
[-t timeout] [-s host] -k key -o value
zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
[-t timeout] [-s host] [-T] [-N] [-r] -b] -i input-file
zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] -s host
--tls-connect cert --tls-ca-file CA-file
[--tls-crl-file CRL-file]
[--tls-server-cert-issuer cert-issuer]
[--tls-server-cert-subject cert-subject]
--tls-cert-file cert-file --tls-key-file key-file
[--tls-cipher13 cipher-string] [--tls-cipher cipher-string]
-k key -o value
zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] [-s host]
--tls-connect cert --tls-ca-file CA-file
[--tls-crl-file CRL-file]
[--tls-server-cert-issuer cert-issuer]
[--tls-server-cert-subject cert-subject]
--tls-cert-file cert-file --tls-key-file key-file
[--tls-cipher13] cipher-string [--tls-cipher cipher-string]
[-T] [-N] [-r] [-b] -i input-file
zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
[-t timeout] [-s host] --tls-connect cert --tls-ca-file CA-file
[--tls-crl-file CRL-file]
[--tls-server-cert-issuer cert-issuer]
[--tls-server-cert-subject cert-subject]
--tls-cert-file cert-file --tls-key-file key-file
[--tls-cipher13 cipher-string] [--tls-cipher cipher-string]
-k key -o value
zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
[-t timeout] [-s host] --tls-connect cert --tls-ca-file CA-file
[--tls-crl-file CRL-file]
[--tls-server-cert-issuer cert-issuer]
[--tls-server-cert-subject cert-subject]
--tls-cert-file cert-file --tls-key-file key-file
[--tls-cipher13 cipher-string] [--tls-cipher cipher-string]
[-T] [-N] [-r] [-b] -i input-file
zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] -s host
--tls-connect psk --tls-psk-identity PSK-identity
--tls-psk-file PSK-file [--tls-cipher13 cipher-string]
[--tls-cipher cipher-string] -k key -o value
zabbix_sender [-v] -z server [-p port] [-I IP-address] [-t timeout] [-s host]
--tls-connect psk --tls-psk-identity PSK-identity
--tls-psk-file PSK-file [--tls-cipher13 cipher-string]
[--tls-cipher cipher-string] [-T] [-N] [-r] [-b] -i input-file
zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
[-t timeout] [-s host] --tls-connect psk
--tls-psk-identity PSK-identity --tls-psk-file PSK-file
[--tls-cipher13 cipher-string] [--tls-cipher cipher-string]
-k key -o value
zabbix_sender [-v] -c config-file [-z server] [-p port] [-I IP-address]
[-t timeout] [-s host] --tls-connect psk
--tls-psk-identity PSK-identity --tls-psk-file PSK-file
[--tls-cipher13 cipher-string] [--tls-cipher cipher-string]
[-T] [-N] [-r] [-b] -i input-file
zabbix_sender -h
zabbix_sender -V
Try '''zabbix_sender --help''' for more information.'
++ /usr/bin/date
++ /usr/bin/mktemp
++ /usr/bin/stat
/usr/bin/stat: missing operand
Try '/usr/bin/stat --help' for more information.
++ /usr/bin/cat
`
This is below /snap/bin/speedtest -v
`
Speedtest by Ookla
Idle Latency: 7.63 ms (jitter: 0.05ms, low: 7.54ms, high: 7.66ms)
Download: 587.20 Mbps (data used: 280.7 MB)
14.83 ms (jitter: 6.43ms, low: 7.93ms, high: 237.61ms)
[warning] Loaded latency: cannot read response.: [11] Resource temporarily unavailable
[warning] Loaded latency: cannot read response.: [0] Cannot read from uninitialized socket.
Upload: 290.66 Mbps (data used: 134.3 MB)
7.64 ms (jitter: 0.15ms, low: 7.42ms, high: 8.58ms)
[warning] No libz support available, not compressing data.
Packet Loss: 0.0%
OMITTED https link
5d844dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed and overlooked this:
Where you edited all of those variables, previously they were:
Which is incorrect, they should be the lines with "which" in them, which searches your PATH for the binaries. I'd bet speedtest isn't being found since /snaps/bin often isn't in your PATH so you can try changing JUST that one line to:
5d844dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, shame on me, reading your instructions and still making my own modifications to the working code. Corrected as you suggested, only this needs to be snap without s in the end
SPEEDTEST="/snap/bin/speedtest"
This works perfectly now, thank you so much.5d844dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad to help and hear!