Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.51 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # simple script to check to see if our NOAA streaming server is working correctly.
  4.  
  5. FAILTITLE="NOAA STREAMING FAILURE"
  6. FAILMESSAGE="NOAA Streaming has failed!"
  7. OKTITLE="NOAA STREAMING OK"
  8. OKMESSAGE="NOAA streaming has been restarted!"
  9. ACCESSTOKEN=put_your_access_token_here
  10. CHANNEL="internal-noaa"
  11.  
  12.  
  13. STREAMING_STATUS=`ps aux | grep arecord | wc -l`
  14. EXPECTED_STATUS=2
  15.  
  16.     if [ "$STREAMING_STATUS" = "$EXPECTED_STATUS" ]; then
  17.          echo "NOAA Streaming - Normal"
  18.          if [ -e /root/noaa_alert_sent ]; then
  19.             /usr/bin/curl --header "Access-Token: ${ACCESSTOKEN}" --header 'Content-Type: application/json' --data-binary "{\"body\":\"${OKMESSAGE}\",\"title\":\"${OKTITLE}\",\"type\":\"note\",\"channel_tag\":\"${CHANNEL}\"}" --request POST https://api.pushbullet.com/v2/pushes >> /dev/null
  20.             rm /root/noaa_alert_sent
  21.             exit
  22.          else
  23.            exit
  24.          fi
  25.     else
  26.          echo "Houston, we have a problem"
  27.          if [ -e /root/noaa_alert_sent ]; then
  28.             exit
  29.          else
  30.             /usr/bin/curl --header "Access-Token: ${ACCESSTOKEN}" --header 'Content-Type: application/json' --data-binary "{\"body\":\"${FAILMESSAGE}\",\"title\":\"${FAILTITLE}\",\"type\":\"note\",\"channel_tag\":\"${CHANNEL}\"}" --request POST https://api.pushbullet.com/v2/pushes >> /dev/null
  31.            touch /root/noaa_alert_sent
  32.            /root/noaa.sh  >/dev/null 2>&1
  33.            echo "NOAA Streaming Restored - Please check!"
  34.            exit
  35.          fi
  36.     fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement