#!/bin/bash
#
# This script is called when a status report has been produced.
#
# The first parameter passed is the path to the status file.  Subsequent parameters,
# if any, are passed from the statusReport.runExtraParams in the nsm_conf.json file.
#
# NOTE: This script should execute as quickly as possible as it is called on
# NSM's execution thread.  If the script does not return in a timely fashion
# (less than 5 seconds), NSM's watchdog will declare a hung process and abort
# operation.


# This example shows how the contents of the status report is sent via a cURL POST
# to a URL
function example_send_status_to_url() {
     STATUS_JSON=$(cat "${1}")
     ID=$(echo ${STATUS_JSON} | jq -r .id)
     SERVER_URL="${2}"

     curl -s -X POST "$SERVER_URL/api/status/$ID" \
          -H "Content-Type: application/json" \
          -d "$STATUS_JSON" \
          --max-time 3
}

exit 0
