Created
June 14, 2017 10:18
-
-
Save bsingr/f229b753c3082b2c7137b591daef4456 to your computer and use it in GitHub Desktop.
Zabbix Scripts
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
#!/bin/bash | |
$USERNAME="" | |
$PASSWORD="" | |
$HOSTGROUP="Production" | |
$zabbixApiUrl="https://zabbix/api_jsonrpc.php" | |
login=$(cat <<EOF | |
{ | |
"jsonrpc": "2.0", | |
"method": "user.login", | |
"params": { | |
"user": "$USERNAME", | |
"password": "$PASSWORD" | |
}, | |
"id": 1, | |
"auth": null | |
} | |
EOF) | |
authentication=$(curl -H "Content-Type: application/json-rpc" -X POST -k -d "$login" $zabbixApiUrl | jq .result) | |
trigger=$(cat <<EOF | |
{ | |
"jsonrpc": "2.0", | |
"method": "trigger.get", | |
"params": { | |
"filter": { | |
"value": 1 | |
}, | |
"sortfield": "priority", | |
"sortorder": "DESC", | |
"active": 1, | |
"only_true": true, | |
"withLastEventUnacknowledged": true, | |
"min_severity": 3, | |
"group": "$hostgroup", | |
"countOutput": true | |
}, | |
"auth": $authentication, | |
"id": 1 | |
} | |
EOF) | |
noOfProblems=$(curl -H "Content-Type: application/json-rpc" -X POST -k -d "$trigger" $zabbixApiUrl | jq .result) | |
echo $noOfProblems |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment