Skip to content

Instantly share code, notes, and snippets.

@andreasottosson
Created April 8, 2021 14:40
Show Gist options
  • Save andreasottosson/f81dd15ebc408ae0723c03969ce93ac4 to your computer and use it in GitHub Desktop.
Save andreasottosson/f81dd15ebc408ae0723c03969ce93ac4 to your computer and use it in GitHub Desktop.
Check if server is up or notify via Pushover
#!/bin/bash
api_token=
user_key=
server=10.0.1.3
if nc -z $server 22 2>/dev/null; then
echo "Server ✓"
else
echo "Server ✗"
curl -s \
--form-string "token=$api_token" \
--form-string "user=$user_key" \
--form-string "message=Server is down ✗" \
https://api.pushover.net/1/messages.json
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment