Last active
August 30, 2021 14:08
-
-
Save fisherwei/02494497d382780313dff673bf864e95 to your computer and use it in GitHub Desktop.
zabbix pfsense template: monitor gateway status by API
This file contains hidden or 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
requirements: | |
- zabbix (tested on 5.2) | |
- pfsense api installed (https://github.com/jaredhendrickson13/pfsense-api) | |
usage: | |
- create api token on pfsense(by api plugin) | |
- paste id and token into macros in zabbix host config: {$CLIENT_ID} {$CLIENT_TOKEN} | |
- import and link this template |
This file contains hidden or 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
{ | |
"zabbix_export": { | |
"version": "5.2", | |
"date": "2021-08-30T13:54:05Z", | |
"groups": [ | |
{ | |
"name": "Templates" | |
} | |
], | |
"templates": [ | |
{ | |
"template": "pfsense API", | |
"name": "pfsense API", | |
"groups": [ | |
{ | |
"name": "Templates" | |
} | |
], | |
"discovery_rules": [ | |
{ | |
"name": "status/gateway discovery", | |
"type": "HTTP_AGENT", | |
"key": "status.gateway.discovery", | |
"item_prototypes": [ | |
{ | |
"name": "Gateway: {#NAME} delay", | |
"type": "HTTP_AGENT", | |
"key": "status.gateway.data[\"{#NAME}\",delay]", | |
"value_type": "FLOAT", | |
"preprocessing": [ | |
{ | |
"type": "JSONPATH", | |
"parameters": [ | |
"$.data[?(@.name == '{#NAME}')].delay.first()" | |
] | |
} | |
], | |
"url": "http://{HOST.CONN}/api/v1/status/gateway", | |
"posts": "{\"client-id\": \"{$CLIENT_ID}\", \"client-token\": \"{$CLIENT_TOKEN}\"}", | |
"post_type": "JSON" | |
}, | |
{ | |
"name": "Gateway: {#NAME} loss", | |
"type": "HTTP_AGENT", | |
"key": "status.gateway.data[\"{#NAME}\",loss]", | |
"preprocessing": [ | |
{ | |
"type": "JSONPATH", | |
"parameters": [ | |
"$.data[?(@.name == '{#NAME}')].loss.first()" | |
] | |
} | |
], | |
"url": "http://{HOST.CONN}/api/v1/status/gateway", | |
"posts": "{\"client-id\": \"{$CLIENT_ID}\", \"client-token\": \"{$CLIENT_TOKEN}\"}", | |
"post_type": "JSON", | |
"trigger_prototypes": [ | |
{ | |
"expression": "{last(#5)}>0", | |
"name": "Loss > 0% on {HOST.NAME}->{#NAME}", | |
"priority": "WARNING" | |
} | |
] | |
}, | |
{ | |
"name": "Gateway: {#NAME} status", | |
"type": "HTTP_AGENT", | |
"key": "status.gateway.data[\"{#NAME}\",status]", | |
"trends": "0", | |
"value_type": "TEXT", | |
"preprocessing": [ | |
{ | |
"type": "JSONPATH", | |
"parameters": [ | |
"$.data[?(@.name == '{#NAME}')].status.first()" | |
] | |
} | |
], | |
"url": "http://{HOST.CONN}/api/v1/status/gateway", | |
"posts": "{\"client-id\": \"{$CLIENT_ID}\", \"client-token\": \"{$CLIENT_TOKEN}\"}", | |
"post_type": "JSON", | |
"trigger_prototypes": [ | |
{ | |
"expression": "{last(#5)}<>\"online\"", | |
"name": "Gateway is not ONLINE on {HOST.NAME}->{#NAME}", | |
"priority": "HIGH" | |
} | |
] | |
}, | |
{ | |
"name": "Gateway: {#NAME} stddev", | |
"type": "HTTP_AGENT", | |
"key": "status.gateway.data[\"{#NAME}\",stddev]", | |
"value_type": "FLOAT", | |
"preprocessing": [ | |
{ | |
"type": "JSONPATH", | |
"parameters": [ | |
"$.data[?(@.name == '{#NAME}')].stddev.first()" | |
] | |
} | |
], | |
"url": "http://{HOST.CONN}/api/v1/status/gateway", | |
"posts": "{\"client-id\": \"{$CLIENT_ID}\", \"client-token\": \"{$CLIENT_TOKEN}\"}", | |
"post_type": "JSON" | |
} | |
], | |
"url": "http://{HOST.CONN}/api/v1/status/gateway", | |
"posts": "{\"client-id\": \"{$CLIENT_ID}\", \"client-token\": \"{$CLIENT_TOKEN}\"}", | |
"post_type": "JSON", | |
"headers": [ | |
{ | |
"name": "Content-Type", | |
"value": "application/json" | |
} | |
], | |
"lld_macro_paths": [ | |
{ | |
"lld_macro": "{#NAME}", | |
"path": "$.name" | |
} | |
], | |
"preprocessing": [ | |
{ | |
"type": "JSONPATH", | |
"parameters": [ | |
"$.data" | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment