=====Telegram Notify===== notify_telegram.sh -123456789 "Title" "Message" 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 #!/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 #!/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/ #!/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) =====Slack Notification===== #!/bin/bash url='https://hooks.slack.com/services/xxxxxxxx/xxxxxxx/xxxxxxxxxxxx' username='Zabbix' to="$1" subject="$2" message="$3" recoversub='^RECOVER(Y|ED)?$|^OK$|^Resolved.*' problemsub='^PROBLEM.*|^Problem.*' if [[ "$subject" =~ $recoversub ]]; then emoji=':white_check_mark:' color='#00ff40' elif [[ "$subject" =~ $problemsub ]]; then emoji=':exclamation:' color='#ff0a0a' else emoji=':question:' color='#0ac2ff' fi payload="payload={\"channel\": \"${to}\", \"username\": \"${username}\", \"attachments\": [{\"fallback\": \"${subject}\", \"title\": \"${subject}\", \"text\": \"${message}\", \"color\": \"${color}\"}], \"icon_emoji\": \"${emoji}\"}" return=$(curl -s -m 5 --data-urlencode "${payload}" "$url") if [[ "$return" != 'ok' ]]; then >&2 echo "$return" exit 1 fi ==Message Templates== Problem: {EVENT.NAME} Host: {HOST.NAME}\nTime: {EVENT.TIME} on {EVENT.DATE}\n{EVENT.OPDATA} Resolved: {EVENT.NAME} Host: {HOST.NAME}\nDuration: {EVENT.DURATION}\n{EVENT.OPDATA}