Skip to content

Instantly share code, notes, and snippets.

@christianchristensen
Created November 11, 2013 02:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianchristensen/7406950 to your computer and use it in GitHub Desktop.
Save christianchristensen/7406950 to your computer and use it in GitHub Desktop.

Output:

$ ./cpu-load-hist.get.sh 
Zabbix.org: Processor load
▂▄▇█▄▆▄▃▂▂▁▁▁▁▂▄▂▃▂▂▂▁▁▁▂▂▁▂▁▁▂▁▃▂▃▃▂▁▁▁▂▂▆▅▄▂▂▂▂▂▂▂▁▁▁▄▄▄▃▁

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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment