added some examples
This commit is contained in:
@@ -53,3 +53,33 @@ telegraf::metrics:
|
||||
```
|
||||
This will only work if you have deployed the necessary script (in the example `/your/script/location/script.sh`) and the necessary sudo rule(s) beforehand. For this you might wanna use techniques described in [Distribute Files](distribute_files) and/or [Custom sudo Rules](sudo).
|
||||
|
||||
## Examples
|
||||
|
||||
### Custom Script
|
||||
|
||||
A custom telegraf collector can look something like this:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
CONNECTED=$(/usr/NX/bin/nxserver --history | awk '$7 == "Connected" {print}' | wc -l)
|
||||
DISCONNECTED=$(/usr/NX/bin/nxserver --history | awk '$7 == "Disconnected" {print}' | wc -l)
|
||||
FINISHED=$(/usr/NX/bin/nxserver --history | awk '$7 == "Finished" {print}' | wc -l)
|
||||
|
||||
# Provide data to telegraf
|
||||
echo "nxserver open_sockets=$(lsof -i -n -P | wc -l),connected_sessions=${CONNECTED},disconnected_sessions=${DISCONNECTED},finished_sessions=${FINISHED}"
|
||||
```
|
||||
|
||||
The first string of the echo command is the name of the series the data is written into. This name can be overwritten in the metric config via `name_override = "nxserver_report"`
|
||||
|
||||
### Custom Config File
|
||||
|
||||
A custom config file in /etc/telegraf/telegraf.d could look like this:
|
||||
|
||||
```
|
||||
[[inputs.exec]]
|
||||
name_override = "remacc_report"
|
||||
timeout = "30s"
|
||||
interval = "5m"
|
||||
data_format = "influx"
|
||||
commands = ["sudo /usr/lib/telegraf/scripts/remacc_report.sh"]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user