+++ /dev/null
-[ $# != 2 ] && echo "Wrong number of arguments to $(basename $0)" && exit 1
-HOST="$1"
-PORT="$2"
-
-if nmap "$HOST" -p "$PORT" -oN - 2>/dev/null | grep -q open
-then
- echo "Port $PORT open on $HOST"
-else
- echo "Port $PORT not open on $HOST"
- exit 1
-fi
+++ /dev/null
-COMCAST_USERNAME=bob
-COMCAST_PASSWORD=hope
+++ /dev/null
-#!/usr/bin/python3
-from __future__ import print_function
-# Source: https://github.com/lachesis/comcast
-
-import json
-import logging
-import os
-import re
-import requests
-import time
-
-logger = logging.getLogger(__name__)
-logging.basicConfig(level=logging.DEBUG)
-logging.getLogger('requests').setLevel(logging.ERROR)
-
-session = requests.Session()
-
-username = os.environ['COMCAST_USERNAME']
-password = os.environ['COMCAST_PASSWORD']
-
-logger.debug("Finding req_id for login...")
-res = session.post('https://login.comcast.net/login?r=comcast.net&s=oauth&continue=https%3A%2F%2Flogin.comcast.net%2Foauth%2Fauthorize%3Fclient_id%3Dmy-account-web%26redirect_uri%3Dhttps%253A%252F%252Fcustomer.xfinity.com%252Foauth%252Fcallback%26response_type%3Dcode%26state%3D%2523%252Fdevices%26response%3D1&client_id=my-account-web')
-assert res.status_code == 200
-m = re.search(r'<input type="hidden" name="reqId" value="(.*?)">', res.text)
-req_id = m.group(1)
-logger.debug("Found req_id = %r", req_id)
-
-data = {
- 'user': username,
- 'passwd': password,
- 'reqId': req_id,
- 'deviceAuthn': 'false',
- 's': 'oauth',
- 'forceAuthn': '0',
- 'r': 'comcast.net',
- 'ipAddrAuthn': 'false',
- 'continue': 'https://login.comcast.net/oauth/authorize?client_id=my-account-web&redirect_uri=https%3A%2F%2Fcustomer.xfinity.com%2Foauth%2Fcallback&response_type=code&state=%23%2Fdevices&response=1',
- 'passive': 'false',
- 'client_id': 'my-account-web',
- 'lang': 'en',
-}
-
-logger.debug("Posting to login...")
-res = session.post('https://login.comcast.net/login', data=data, allow_redirects=False)
-assert res.status_code == 302
-
-#logger.debug("Preloader HTML...")
-#res = session.get('https://customer.xfinity.com/Secure/Preloading/?backTo=%2fMyServices%2fInternet%2fUsageMeter%2f')
-#assert res.status_code == 200
-
-logger.debug("Preloader AJAX...")
-res = session.get('https://customer.xfinity.com/Secure/Preloader.aspx')
-assert res.status_code == 200
-
-#logger.debug("Waiting 5 seconds for preloading to complete...")
-#time.sleep(5)
-
-logger.debug("Fetching internet usage HTML...")
-res = session.get('https://customer.xfinity.com/MyServices/Internet/UsageMeter/')
-assert res.status_code == 200
-html = res.text
-
-# Example HTML:
-# <div class="cui-panel-body">
-# <!-- data-options:
-# unit (string) - fills in labels; example: GB, MB, miles;
-# max (number, optional) - the 100% number of the bar
-# increment (number, optional) - the number between grid lines
-# -->
-# <span class="cui-usage-label"><p>Home Internet Usage</p></span>
-# <div data-component="usage-meter"
-# data-options="hideMax:true;divisions:4;
-# unit:GB;
-# max:1024;
-# increment:50
-# ">
-# <div class="cui-usage-bar" data-plan="1024">
-# <span data-used="222" data-courtesy="false">
-# <span class="accessibly-hidden">222GB of 1024GB</span>
-# </span>
-# </div>
-# <div class="cui-usage-label">
-# <span>
-# 222GB of 1024GB
-# </span>
-# <!--<p><a href="#">View details</a></p>-->
-# <span class="marker"></span>
-# </div>
-# </div>
-
-used = None
-m = re.search(r'<span data-used="(\d+)"', html)
-if m:
- used = int(m.group(1))
-
-total = None
-m = re.search(r'<div class="cui-usage-bar" data-plan="(\d+)">', html)
-if m:
- total = int(m.group(1))
-
-unit = None
-m = re.search(r'<div data-component="usage-meter"\s*data-options="([^"]*)"', html)
-if m:
- opts = m.group(1)
- opts = re.sub(r'\s+', '', opts) # remove whitespace
- m = re.search(r'unit:(\w+);', opts)
- if m:
- unit = m.group(1)
-
-print("{used} {unit} of {total} {unit} used".format(used=used,total=total,unit=unit))
-if used > total:
- exit(1)
-else:
- exit(0)
+++ /dev/null
-FILE="$1"
-SECONDS="${2-$((7 * 24 * 60 * 60))}"
-UPDATED="$(date -r "$FILE" "+%b %d, %Y")"
-TIMESTAMP="$(date -r "$FILE" +%s)"
-NOW="$(date +%s)"
-CUTOFF=$((NOW - SECONDS))
-echo "${FILE} was last updated ${UPDATED}"
-[ "$TIMESTAMP" -gt "$CUTOFF" ]
+++ /dev/null
-#!/bin/bash
-DIR="$1"
-find "$DIR" -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "
+++ /dev/null
-host "$1"
-ping -c 1 -w 3 -q "$1" >/dev/null || ping6 -c 1 -w 3 -q "$1" >/dev/null
+++ /dev/null
-AVALANCHE=$(ssh -i /var/www/status/backup_check -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no backup_status@germinate.za3k.com | grep avalanche)
-echo $AVALANCHE
-EXPECTED=$(date +"avalanche.%Y%m%d")
-[ "${AVALANCHE}" = "${EXPECTED}" ] && exit 0
-EXPECTED=$(date --date="yesterday" +"avalanche.%Y%m%d")
-[ "${AVALANCHE}" = "${EXPECTED}" ] && exit 0
-EXPECTED=$(date --date="2 days ago" +"avalanche.%Y%m%d")
-[ "${AVALANCHE}" = "${EXPECTED}" ] && exit 0
+++ /dev/null
-./ping? avalanche.za3k.com
+++ /dev/null
-./check-port? minecraft.za3k.com 25566
+++ /dev/null
-./up? "http://blog.za3k.com" || exit 1
-./up? "https://blog.za3k.com" || exit 1
+++ /dev/null
-CORRUPT=$(ssh -i /var/www/status/backup_check -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no backup_status@germinate.za3k.com | grep corrupt)
-echo $CORRUPT
-EXPECTED=$(date +"corrupt.%Y%m%d")
-[ "${CORRUPT}" = "${EXPECTED}" ] && exit 0
-EXPECTED=$(date --date="yesterday" +"corrupt.%Y%m%d")
-[ "${CORRUPT}" = "${EXPECTED}" ] && exit 0
-EXPECTED=$(date --date="2 days ago" +"corrupt.%Y%m%d")
-[ "${CORRUPT}" = "${EXPECTED}" ] && exit 0
+++ /dev/null
-IP="$(curl -q icanhazip.com 2>/dev/null)"
-host deadtree.moreorcs.com ns.za3k.com | grep "has"
-host deadtree.moreorcs.com ns.za3k.com | grep "has" | grep "${IP}" >/dev/null
+++ /dev/null
-./up? "https://ddns.za3k.com"
+++ /dev/null
-DEADTREE=$(ssh -i /var/www/status/backup_check -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no backup_status@germinate.za3k.com | grep deadtree)
-echo $DEADTREE
-EXPECTED=$(date +"deadtree.%Y%m%d")
-[ "${DEADTREE}" = "${EXPECTED}" ] && exit 0
-EXPECTED=$(date --date="yesterday" +"deadtree.%Y%m%d")
-[ "${DEADTREE}" = "${EXPECTED}" ] && exit 0
-EXPECTED=$(date --date="2 days ago" +"deadtree.%Y%m%d")
-[ "${DEADTREE}" = "${EXPECTED}" ] && exit 0
+++ /dev/null
-./ping? deadtree.xen.prgmr.com
+++ /dev/null
-./up? "http://etherpad.za3k.com/" || exit 1
-./up? "https://etherpad.za3k.com/" || exit 1
+++ /dev/null
-./ping? germinate.za3k.com
+++ /dev/null
-DOWNLOAD=$(rsync -l burn.za3k.com::ghtorrent | awk '{print $3}' | sort | tail -n1)
-echo "Last file downloaded: $DOWNLOAD"
-EXPECTED=$(date +"%Y/%m/%d")
-[ "${DOWNLOAD}" = "${EXPECTED}" ] && exit 0
-EXPECTED=$(date --date="yesterday" +"%Y/%m/%d")
-[ "${DOWNLOAD}" = "${EXPECTED}" ] && exit 0
-EXPECTED=$(date --date="2 days ago" +"%Y/%m/%d")
-[ "${DOWNLOAD}" = "${EXPECTED}" ] && exit 0
+++ /dev/null
-ssh -i /var/www/status/backup_check -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no backup_status@germinate.za3k.com | grep giant-ant
+++ /dev/null
-FILE=$(./last-updated-in-dir /home/github/za3k)
-ONE_WEEK=$((7 * 24 * 60 * 60))
-./file-updated? "${FILE}" "${ONE_WEEK}"
+++ /dev/null
-./up? "http://za3k.com/github/" || exit 1
-./up? "https://za3k.com/github/" || exit 1
+++ /dev/null
-FILE=/var/www/github/repos.json.gz
-ONE_WEEK=$((7 * 24 * 60 * 60))
-./file-updated? "${FILE}" "${ONE_WEEK}"
+++ /dev/null
-./check-port? minecraft.za3k.com 25565
+++ /dev/null
-./up? "http://jsfail.com" || exit 1
+++ /dev/null
-./up? "https://library.za3k.com/" || exit 1
-curl "https://library.za3k.com/" | grep -q "reading list"
+++ /dev/null
-./up? "https://library.za3k.com/qr.png?text=Test" || exit 1
+++ /dev/null
-URL="https://za3k.com/~logs/analog.html"
-./up? "${URL}" || exit 1
-SIZE=$(curl -s "${URL}" | wc -c)
-TARGET_SIZE=20000
-if [ "${SIZE}" -lt "${TARGET_SIZE}" ]; then
- echo "${URL} is too short (<${TARGET_SIZE} bytes), probably failing"
- exit 1
-fi
+++ /dev/null
-TESTSITE="https://za3k.com/archive/test.md"
-echo "Markdown testing at ${TESTSITE}"
-curl "${TESTSITE}" 2>/dev/null | grep -q "<h1>"
+++ /dev/null
-./up? "http://minecraft.za3k.com/"
+++ /dev/null
-./up? "http://moreorcs.com/"
+++ /dev/null
-TESTSITE="https://za3k.com/archive/test.md"
-timeout 3 curl -k "${TESTSITE}" >/dev/null 2>/dev/null
-SUCCESS=$?
-
-if [ "$SUCCESS" -eq 0 ]; then
- echo "Success"
- exit 0
-elif [ "$SUCCESS" -eq 124 ]; then
- echo "Timed out -- only one CGI script is running at a time"
- exit 1
-else
- echo "Markdown testing at ${TESTSITE} is failing"
- exit 2
-fi
+++ /dev/null
-./up? "http://nanowrimo.za3k.com/" || exit 1
-./up? "https://nanowrimo.za3k.com/" || exit 1
+++ /dev/null
-./up? "http://petchat.za3k.com"
+++ /dev/null
-if curl https://za3k.com/stylish.view 2>/dev/null | grep -q "style"
-then
- echo "Database appears to work"
-else
- echo "Unknown problem"
- exit 1
-fi
+++ /dev/null
-ssh -i /var/www/status/backup_check -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no backup_status@germinate.za3k.com | grep tarragon
+++ /dev/null
-./supervisor-up? thisisashell || {
- echo "KNOWN DOWN"
- exit 0
-}
+++ /dev/null
-#!/bin/bash
-ALL=$(curl -ILs "http://transmission.moreorcs.com:9091")
-HEADER=$(echo "$ALL" | head -1)
-echo "${HEADER}"
-echo "${ALL}" | grep -q "401 Unauthorized"
+++ /dev/null
-./ping? tron.alloscomp.com
+++ /dev/null
-./up? "http://za3k.com/~twitter_archive/" || exit 1
-./up? "https://za3k.com/~twitter_archive/" || exit 1
-FILE=$(./last-updated-in-dir /home/twitter_archive)
-ONE_WEEK=$((7 * 24 * 60 * 60))
-./file-updated? "${FILE}" "${ONE_WEEK}" || exit 1
+++ /dev/null
-./ping? xenu.za3k.com
+++ /dev/null
-./up? "http://za3k.com" || exit 1
-./up? "https://za3k.com" || exit 1
+++ /dev/null
-./check-port? znc.za3k.com 10000
+++ /dev/null
-#!/bin/bash
-TEMP=$(mktemp)
-SECONDS=5
-if [ $# -eq 2 ]; then SECONDS="$1"; shift; fi
-timeout "${SECONDS}" bash "$@" >"$TEMP" 2>/dev/null
-SUCCESS=$?
-
-if [ "$SUCCESS" -eq 0 ]; then
- RESULT="success"
-elif [ "$SUCCESS" -eq 124 ]; then
- RESULT="timeout"
-else
- RESULT="failure"
-fi
-
-echo "<tr class=\"${RESULT}\">"
-
-echo "<td>$(basename "$1")</td>"
-echo "<td>${RESULT}</td>"
-
-echo -n "<td>"
-cat "$TEMP"
-rm "$TEMP"
-echo -n "</td>"
-
-echo "</tr>"
-exit $SUCCESS
+++ /dev/null
-#!/bin/bash
-echo "Content-type: text/html"
-echo
-
-STATUS="$(basename "$PATH_TRANSLATED")"
-FOLDER="/var/www/za3k/cgi-bin/${STATUS}.d"
-SECONDS=5
-if [[ "${QUERY_STRING}" =~ ^t=[0-9]+$ ]]
-then
- SECONDS="${QUERY_STRING#t=}"
-fi
-if [ "$SECONDS" -gt 30 ]; then SECONDS=5; fi
-export SECONDS
-
-echo "<html>"
-echo "<head>"
-echo " <title>${PATH_TRANSLATED}</title>"
-echo ' <link rel="stylesheet" type="text/css" href="/service.css"'
-echo "</head>"
-echo "<body>"
-echo "<table>"
-echo " <thead>"
-echo " <th>Service</td>"
-echo " <th>Status</td>"
-echo " <th>Details</td>"
-echo " </thead>"
-find "${FOLDER}" -type f -print0 | sort -z | SHELL=/bin/sh parallel -0 -j 0 --keep-order -n1 -- ./status-simple "${SECONDS}"
-echo "</table>"
-echo "<a href=\"https://github.com/za3k/za3k.com/tree/master/cgi-bin/service.status.d\">[Source]</a>"
-echo "</body>"
-echo "</html>"
+++ /dev/null
-#!/bin/bash
-sudo supervisorctl status | grep "$1"
-STATUS=$(sudo supervisorctl status | grep "$1" | awk '{print $2}')
-echo "$STATUS" | grep -q "RUNNING"
+++ /dev/null
-#!/bin/bash
-ALL=$(curl -ILs "$1")
-HEADER=$(echo "$ALL" | head -1)
-echo "${HEADER}"
-echo "${ALL}" | grep -q "200 OK"