Skip to content

Instantly share code, notes, and snippets.

@bsingr
Created June 14, 2017 10:18
Show Gist options
  • Save bsingr/f229b753c3082b2c7137b591daef4456 to your computer and use it in GitHub Desktop.
Save bsingr/f229b753c3082b2c7137b591daef4456 to your computer and use it in GitHub Desktop.
Zabbix Scripts
#!/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