JSON Parsing Nagios Script

Parsing JSON in Bash is never usually the best idea but sometimes it may be necessary or preferred. Here’s a nice easy script which uses the ‘jq’ command to perform JSON parsing in Bash.

imgres

Let’s imagine you have the following JSON which is outputted by a stats gathering process:

{"web_rate":1,"db_rate":2,"php_rate":2}

Parsing that in Bash by writing some regex’s etc is perfecting possible but there’s an infinitely easier way. Welcome to ‘jq’. Let’s see it in action.

Read More »