Thank you. I set up a local Salt on a server using salt-call, using your script in crontab, so for anyone else who might want to do the same thing:
In order to run salt-call every 20 minutes from crontab and get mail when something gets changed, comment out line 13 and 14, the ones that print minion_id and "=" signs, and add this line to /etc/crontab: */20 * * * * root salt-call --local state.highstate --out=json -l quiet | /path/to/filter.py
Thanks for the post, useful!
I changed a little bit to have the parsing when a new line gets in (for long term operations) instead to wait for the end stream and then parse the data.
BTW: I used the raw output.
r = { "True" : "true", "False" : "false", "\"" : "\\\"", "\'" : "\"" } for l in fileinput.input(): for k in r: l = l.replace(k,r[k]) j = loads(l) print j