Skip to content

Instantly share code, notes, and snippets.

@diyfr
Last active July 26, 2022 17:47
Show Gist options
  • Save diyfr/2d0502d504ca6132dcfef037a06f60c9 to your computer and use it in GitHub Desktop.
Save diyfr/2d0502d504ca6132dcfef037a06f60c9 to your computer and use it in GitHub Desktop.
Vérifier dispo serveur OVH et notif sur pushbullet
#!/bin/bash
# Pour ne pas avoir trop de notif dès la dispo
DONT_SPAM=/tmp/ovh.exist
#https://www.pushbullet.com/#settings/account to retrieve your API key/access
TOKEN=<VOTRE_TOKEN PUSHBULLET>
# remplacer planCode, server dans l'url à votre convenance et le datacenter recherché dans le filtre jq contains (ici= fr)
if [ ! -f "${DONT_SPAM}" ]; then
RESULT=$(curl -s 'https://www.ovh.com/engine/apiv6/dedicated/server/datacenter/availabilities?excludeDatacenters=false&planCode=22sk080&server=22sk080' | jq -r '.[0].datacenters[] | select (.datacenter |contains ("ca")).availability')
if [ $RESULT != "unavailable" ]; then
curl -u $TOKEN: https://api.pushbullet.com/v2/pushes -d type=note --data-urlencode "title=OVH Server" --data-urlencode "body=Serveur 22sk080 Dispo" > /dev/null 2>&1 &
touch $DONT_SPAM
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment