Output:
$ ./cpu-load-hist.get.sh
Zabbix.org: Processor load
▂▄▇█▄▆▄▃▂▂▁▁▁▁▂▄▂▃▂▂▂▁▁▁▂▂▁▂▁▁▂▁▃▂▃▃▂▁▁▁▂▂▆▅▄▂▂▂▂▂▂▂▁▁▁▄▄▄▃▁
#!/bin/sh | |
# CLI Visual Zabbix perf | |
# Dependencies (NB) | |
# * spark: https://raw.github.com/holman/spark/master/spark | |
auth='ac905749516dd173668f3dbf7b0cac0a' | |
getjson() | |
{ | |
# $1 == itemid | |
# returns JSON string | |
start=$(date +%s --date='- 1 hour') | |
stop=$(date +%s --date='+ 10 sec') | |
json=$(cat <<EOF | |
{ | |
"jsonrpc": "2.0", | |
"method": "history.get", | |
"params":{ | |
"output":"extend", | |
"history":0, | |
"time_from":"${start}", | |
"time_till":"${stop}", | |
"itemids":["$1"] | |
}, | |
"id": 123,"auth":"${auth}" | |
} | |
EOF | |
) | |
echo $json | |
} | |
showdata() | |
{ | |
# $1 == itemid | |
json=$(getjson $1) | |
curl -s -H "Content-type: application/json" "https://www.zabbix.org/zabbix/api_jsonrpc.php" -d "${json}" \ | |
| grep -o "\"value\":\"[0-9\.]*\"," \ | |
| awk -F\" '{print $4*100}' \ | |
| spark | |
} | |
echo "Zabbix.org: Processor load" | |
showdata '16' |
https://github.com/holman/spark/wiki/Wicked-Cool-Usage#zabbix-api-history-graph-results-christianchristensen