-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(input.mikrotik): Add Mikrotik plugin (#16080)
- Loading branch information
1 parent
bed5e3d
commit 5b9119b
Showing
24 changed files
with
1,545 additions
and
0 deletions.
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,5 @@ | ||
//go:build !custom || inputs || inputs.mikrotik | ||
|
||
package all | ||
|
||
import _ "github.com/influxdata/telegraf/plugins/inputs/mikrotik" // register plugin |
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,110 @@ | ||
# Mikrotik Input Plugin | ||
|
||
This plugin gathers Mikrotik's (not only) interface statistics such as bytes, | ||
packets, run count, uptime etc | ||
|
||
## Global configuration options <!-- @/docs/includes/plugin_config.md --> | ||
|
||
In addition to the plugin-specific configuration settings, plugins support | ||
additional global and plugin configuration settings. These settings are used to | ||
modify metrics, tags, and field or create aliases and configure ordering, etc. | ||
See the [CONFIGURATION.md][CONFIGURATION.md] for more details. | ||
|
||
[CONFIGURATION.md]: ../../../docs/CONFIGURATION.md#plugins | ||
|
||
## Configuration | ||
|
||
```toml @sample.conf | ||
[[inputs.mikrotik]] | ||
# Mikrotik's address to query. Make sure that REST API is enabled: https://help.mikrotik.com/docs/spaces/ROS/pages/47579162/REST+API | ||
agent = "https://192.168.88.1" | ||
|
||
# User to use. Read access rights will be enough | ||
username = "admin" | ||
password = "password" | ||
|
||
# Mikrotik's entities whose comments contain this strings will be ignored | ||
ignore_comments = [ | ||
"Facebook", | ||
"block", | ||
"doNotGatherMetricsFromThis" | ||
] | ||
|
||
# Modules available to use. At least one shall be chosen | ||
include_modules = [ | ||
"interface", | ||
"interface_wireguard_peers", | ||
"interface_wireless_registration", | ||
"ip_dhcp_server_lease", | ||
"ip_firewall_connection", | ||
"ip_firewall_filter", | ||
"ip_firewall_nat", | ||
"ip_firewall_mangle", | ||
"ipv6_firewall_connection", | ||
"ipv6_firewall_filter", | ||
"ipv6_firewall_nat", | ||
"ipv6_firewall_mangle", | ||
"system_script", | ||
"system_resourses" | ||
] | ||
|
||
## Optional TLS Config | ||
# tls_ca = "/etc/telegraf/ca.pem" | ||
# tls_cert = "/etc/telegraf/cert.pem" | ||
# tls_key = "/etc/telegraf/key.pem" | ||
## Use TLS but skip chain & host verification | ||
# insecure_skip_verify = false | ||
|
||
## HTTP response timeout (default: 5s) | ||
response_timeout = "5s" | ||
``` | ||
|
||
## Metrics | ||
|
||
For each exact module there will be different set of modules and tags based on | ||
the JSON structure that is returned from the exact REST endpoint. You can take | ||
a look at structure `CommonData` in `types.go`. There are mikrotik tag in that | ||
structure marking field as tag or value. Only fields and tags that are | ||
available via each endpoint will be passed into the accumulator. Disabled | ||
entities will not be taken into account. | ||
|
||
## Example Output | ||
|
||
Using this configuration: | ||
|
||
```toml | ||
[[inputs.mikrotik]] | ||
agent = "https://192.168.88.1" | ||
|
||
username = "admin" | ||
password = "password" | ||
|
||
include_modules = [ | ||
"interface", | ||
"system_resourses" | ||
] | ||
``` | ||
|
||
When run with: | ||
|
||
```sh | ||
./telegraf --config telegraf.conf --input-filter nginx --test | ||
``` | ||
|
||
Will produce something similar to this: | ||
|
||
```text | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,DefaultName=ether1,Disabled=false,ID=*1,MacAddress=00:11:22:33:44:B6,Name=ether1,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=true,Type=ether,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=204555898022i,FpRxPacket=151821725i,FpTxByte=0i,FpTxPacket=0i,LinkDowns=0i,RxByte=205163168867i,RxDrop=0i,RxError=0i,RxPacket=151821670i,TxByte=16146845989i,TxDrop=0i,TxError=0i,TxPacket=60029156i,TxQueueDrop=0i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,DefaultName=ether2,Disabled=false,ID=*2,MacAddress=00:11:22:33:44:B7,Name=ether2,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=false,Slave=true,Type=ether,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=0i,FpRxPacket=0i,FpTxByte=0i,FpTxPacket=0i,LinkDowns=0i,RxByte=0i,RxDrop=0i,RxError=0i,RxPacket=0i,TxByte=0i,TxDrop=0i,TxError=0i,TxPacket=0i,TxQueueDrop=0i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,DefaultName=ether3,Disabled=false,ID=*3,MacAddress=00:11:22:33:44:B8,Name=ether3,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=true,Slave=true,Type=ether,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=14289795840i,FpRxPacket=15388528i,FpTxByte=24893573990i,FpTxPacket=16958932i,LinkDowns=34i,RxByte=14351349952i,RxDrop=0i,RxError=0i,RxPacket=15388528i,TxByte=25737561612i,TxDrop=0i,TxError=0i,TxPacket=17651724i,TxQueueDrop=0i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,DefaultName=ether4,Disabled=false,ID=*4,MacAddress=00:11:22:33:44:B9,Name=ether4,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=false,Slave=true,Type=ether,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=0i,FpRxPacket=0i,FpTxByte=0i,FpTxPacket=0i,LinkDowns=0i,RxByte=0i,RxDrop=0i,RxError=0i,RxPacket=0i,TxByte=0i,TxDrop=0i,TxError=0i,TxPacket=0i,TxQueueDrop=0i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,DefaultName=ether5,Disabled=false,ID=*5,MacAddress=00:11:22:33:44:BA,Name=ether5,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=false,Slave=true,Type=ether,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=0i,FpRxPacket=0i,FpTxByte=0i,FpTxPacket=0i,LinkDowns=0i,RxByte=0i,RxDrop=0i,RxError=0i,RxPacket=0i,TxByte=0i,TxDrop=0i,TxError=0i,TxPacket=0i,TxQueueDrop=0i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,Disabled=true,ID=*13,MacAddress=11:22:33:44:55:666,Name=SomethingHidden,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=false,Type=wlan,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=0i,FpRxPacket=0i,FpTxByte=0i,FpTxPacket=0i,LinkDowns=0i,RxByte=0i,RxDrop=0i,RxError=0i,RxPacket=0i,TxByte=0i,TxDrop=0i,TxError=0i,TxPacket=0i,TxQueueDrop=0i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,DefaultName=wlan1,Disabled=false,ID=*6,MacAddress=00:11:22:33:44:BB,Name=wlan1,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=false,Slave=true,Type=wlan,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=306495714i,FpRxPacket=3415113i,FpTxByte=70507553i,FpTxPacket=48467i,LinkDowns=69i,RxByte=306495714i,RxDrop=0i,RxError=0i,RxPacket=3415113i,TxByte=7401961434i,TxDrop=0i,TxError=0i,TxPacket=5705917i,TxQueueDrop=82i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,DefaultName=wlan2,Disabled=false,ID=*7,MacAddress=00:11:22:33:44:BC,Name=wlan2,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=true,Slave=true,Type=wlan,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=40649889743i,FpRxPacket=74186211i,FpTxByte=14103365713i,FpTxPacket=14965617i,LinkDowns=4i,RxByte=40649889743i,RxDrop=0i,RxError=0i,RxPacket=74186211i,TxByte=210494811217i,TxDrop=2i,TxError=0i,TxPacket=161243464i,TxQueueDrop=346119i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Comment=VPN,Cpu=ARM,Disabled=true,ID=*18,Name=VPN,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=false,Type=wg,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=0i,FpRxPacket=0i,FpTxByte=0i,FpTxPacket=0i,LinkDowns=0i,RxByte=0i,RxDrop=0i,RxError=0i,RxPacket=0i,TxByte=0i,TxDrop=0i,TxError=0i,TxPacket=0i,TxQueueDrop=0i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,Disabled=false,ID=*8,MacAddress=00:11:22:33:44:BB,Name=lan,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=true,Type=bridge,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=15941754904i,FpRxPacket=60288063i,FpTxByte=0i,FpTxPacket=0i,LinkDowns=0i,RxByte=16088294995i,RxDrop=0i,RxError=0i,RxPacket=60903697i,TxByte=204668863217i,TxDrop=0i,TxError=0i,TxPacket=151995468i,TxQueueDrop=0i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,Disabled=false,ID=*14,MacAddress=00:00:00:00:00:00,Name=lo,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=true,Type=loopback,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=0i,FpRxPacket=0i,FpTxByte=0i,FpTxPacket=0i,LinkDowns=0i,RxByte=3818476i,RxDrop=0i,RxError=0i,RxPacket=22101i,TxByte=3818476i,TxDrop=0i,TxError=0i,TxPacket=22101i,TxQueueDrop=0i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,Disabled=true,ID=*17,MacAddress=00:11:22:33:44:55,Name=ovpn-out1,Platform=MikroTik,RouterOsVersion=7.16\ (stable),Running=false,Type=ovpn-out,currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER FpRxByte=0i,FpRxPacket=0i,FpTxByte=0i,FpTxPacket=0i,LinkDowns=0i,RxByte=0i,RxDrop=0i,RxError=0i,RxPacket=0i,TxByte=0i,TxDrop=0i,TxError=0i,TxPacket=0i,TxQueueDrop=0i 1730024835000000000 | ||
mikrotik,ArchitectureName=arm,BoardName=hAP\ ac^2,Cpu=ARM,Platform=MikroTik,RouterOsVersion=7.16\ (stable),currentFirmware=7.15.3,firmwareType=ipq4000L,host=82xv,model=ROUTERBOARDMODEL,serialNumber=YOURSERIALNUMBER CPUFrequency=896i,CPULoad=0i,FreeHddSpace=1478656i,FreeMemory=46735360i,WriteSectSinceReboot=20576i,WriteSectTotal=48545i 1730024835000000000 | ||
``` |
Oops, something went wrong.