Outils pour utilisateurs

Outils du site


bash:kimsufi-availability-alarm

This script checks for the availability of Kimsufi dedicated servers, and plays alarm sound when there is. Requires jq, vlc and a file called “alarm.mp3”

kimsufi-alarm.sh
#!/bin/bash
while [ TRUE ]; do
data=$(wget -qO - "https://ws.ovh.com/dedicated/r2/ws.dispatcher/getAvailability2?callback=Request.JSONP.request_map.request_0" | sed 's/Request.JSONP.request_map.request_0(//' | head -c-2);
 
serverType = 177; # set here the ID of the server type. "177" is for KS-3
 
zone1=$(echo $data | jq ".answer.availability[$serverType].metaZones[].availability")
zone2=$(echo $data | jq ".answer.availability[$serverType].zones[].availability")
 
date
 
if [[ $zone1 == *"H"* ]]; then
   echo "ALERTE"
   vlc alarm.mp3
else
   echo "no-avail"
fi
 
if [[ $zone2 == *"H"* ]]; then
   echo "ALERTE"
   vlc alarm.mp3
else
   echo "no-avail"
fi
 
echo "*******************"
sleep 30
done
bash/kimsufi-availability-alarm.txt · Dernière modification: 2015/06/30 14:32 par mitsu