This is an old revision of the document!


Telegram Notify

notify_telegram.sh -123456789 "Title" "Message"
notify_telegram.sh
TELEGRAM_TOKEN="12345:ABCDEFGH"
CHAT_ID="$1"
TITLE="$2"
MESSAGE="$3"
 
curl -X POST -H "Content-Type: application/json" -d "{\"chat_id\":\"${CHAT_ID}\",\"title\":\"${TITLE}\",\"text\":\"${MESSAGE}\"}" "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage"

Domain Expiration

check_domain.sh example.com
check_domain.sh
#!/bin/bash
 
which whois >/dev/null || { echo "whois - not installed"; exit 1; }
[ -z "${1}" ] && { echo "domain - not spicified"; exit 1; }
now=$(date '+%s')
expiration_date=$(date -d "$(whois "${1}" | grep 'Registry Expiry Date'|awk -F ': ' '{print $2}')" '+%s')
echo $(( ( expiration_date - now )/(60*60*24) ))

Certificate Expiration

check_certificate.sh example.com
check_certificate.sh
#!/bin/bash
 
[ -z "${1}" ] && { echo "domain - not spicified"; exit 1; }
now=$(date '+%s')
expiration_date=$(date -d "$(openssl s_client -connect ${1}:443 < /dev/null 2>/dev/null| openssl x509 -noout -dates|grep 'notAfter'|awk -F '=' '{print $2}')" '+%s')
echo $(( ( expiration_date - now )/(60*60*24) ))

WebSocket Check

check_ws.py wss://example.com:8080/public/
check_ws.py
#!/usr/bin/python3
 
import sys
from websocket import create_connection
 
host = sys.argv[1]
 
try:
    ws = create_connection(host)
    ws.close()
    connectionState = 1
except Exception:
    connectionState = 0
print(connectionState)
Navigation
Print/export
QR Code
QR Code wiki:zabbix (generated for current page)