monitor: Use USR1 signal to dump debug data

Similar to what fan control is already doing, this commit adds a handler
for the USR1 signal to write debug data to /tmp/fan_monitor_dump.json.
The data being written is the same data saved in an event log - the
current sensor status plus any of the Logger class's logs.

Example output, which shows fan0 recovering from previous faults:
{
    "logs": [
        ...
        [
            "Aug 26 17:04:47",
            "Setting tach sensor /xyz/openbmc_project/sensors/fan_tach/fan0_0 functional state to false. [target = 18000, input = 3446, allowed range = (10600 - NoMax) owned = true]"
        ],
        [
            "Aug 26 17:04:47",
            "Starting shutdown action 'EPOW Power Off: 60s/60s' due to cause '2 Nonfunctional Fan Rotors'"
        ],
        [
            "Aug 26 17:04:47",
            "Action EPOW Power Off: 60s/60s: Starting service mode timer"
        ],
        [
            "Aug 26 17:04:47",
            "Creating event log for faulted fan /xyz/openbmc_project/inventory/system/chassis/motherboard/fan0 sensor /xyz/openbmc_project/sensors/fan_tach/fan0_0"
        ]
    ],
    "sensors": {
        "sensors": {
            "/xyz/openbmc_project/sensors/fan_tach/fan0_0": {
                "functional": false,
                "in_range": true,
                "present": true,
                "prev_tachs": "[11829,11867,11829,11867,11829,11867,11718,11467]",
                "prev_targets": "[18000,9000,9040,10320,0,0,0,0]",
                "tach": 11829.0,
                "target": 18000,
                "ticks": 18
            },
            "/xyz/openbmc_project/sensors/fan_tach/fan0_1": {
                "functional": false,
                "in_range": true,
                "present": true,
                "prev_tachs": "[17857,17772,17857,17772,17201,17045,16741,16375]",
                "tach": 17857.0,
                "ticks": 20
            },
            "/xyz/openbmc_project/sensors/fan_tach/fan1_0": {
                "functional": true,
                "in_range": true,
                "present": true,
                "prev_tachs": "[11755,11792,11755,11792,11755,11792,11755,11792]",
                "prev_targets": "[18000,9000,9040,10320,0,0,0,0]",
                "tach": 11755.0,
                "target": 18000,
                "ticks": 0
            },
            ...
        }
    }
}

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I84179f78ec83ca6bab788052d0bebe677c1fd29f
3 files changed