Print the diag_loadavg output as plain json to the output file
hosts: "{{hostname}}"
period: "all"
on-success: "d_state_processes"
- on-failure: "email_escalation"
-
name: "d_state_processes"
ref: "linux.check_processes"
criteria: "D"
args: "pidlist"
on-success: "r_state_processes"
- on-failure: "email_escalation"
-
name: "r_state_processes"
ref: "linux.check_processes"
criteria: "R"
args: "pidlist"
on-success: "netstat"
- on-failure: "email_escalation"
-
name: "netstat"
ref: "linux.netstat_grep"
hosts: "{{hostname}}"
pids: "{{d_state_processes[hostname].stderr}} {{r_state_processes[hostname].stderr}}"
on-success: "lsof"
- on-failure: "email_escalation"
-
name: "lsof"
ref: "linux.lsof_pids"
name: "dump_results"
ref: "core.local"
parameters:
- cmd: "echo \"ST2 Workflow\tdiag_loadavg:\t{{__results}}\" >> /tmp/diag_loadavg && echo 'Output written to file /tmp/diag_loadavg'"
+ cmd: "echo \"{{__results}}\" | python2 -c \"import json; import sys; from datetime import datetime; diag_data=eval(sys.stdin.read()); diag_data['timestamp'] = str(datetime.now()); print(json.dumps(diag_data))\" >> /tmp/diag_loadavg.json && echo 'Output written to file /tmp/diag_loadavg.json'"
default: "check_load"
