Nagging while the pizza burns

Written by

in

,

I’ve always had a vague fascination with how people can take data and make huge leaps into the darkness with them, carrying a light they’ve somehow fashioned out of the madness.

Okay, it’s a bit of a tortured metaphor, and an overworked title, but it doesn’t make it any the less true.

My first recollection of encountering this phenomenon was the famous (initially counter-intuitive) example of Survivorship Bias – whereby if you look at the damage suffered by Allied planes in WW2 and plot them out you end up with a point diagram that looks somewhat like this:

Illustration of hypothetical damage pattern on a WW2 bomber. Loosely based on data from an unillustrated report by Abraham Wald (1943), showing that a similar plane survived a single hit to the engine 60% of the time, but a hit to the fuselage or fuel system closer to 95% of the time. Picture is based on US Air Force "hit plots", such as this F-4 hit plot published in 1991. New version by McGeddon based on a Lockheed PV-1 Ventura drawing (2016), vector file by Martin Grandjean (2021).

Asking where to put more armour plating to increase the chances of the plane coming back home, most people respond with where the red dots are – but of course that’s where the planes that did make it home were already hit. The planes that got hit in the cockpit, the engines, or the fuel tanks were less likely to make it back – so put the additional armour there and more will make it home.

Not long after, I heard about The Monty Hall Problem and then swiftly after that, The German Tank Problem. (I’ll let you read up on those yourself if you’re not already familiar with them rather than continue to rack up the wordcount).

I’m not good at maths, or statistics, but these stories always tweaked my imagination as to how someone else could look at these seemingly innocuous (to me) things and intuit a whole other level of meaning that I was completely blind to.

And then I heard about Acoustic Kitty – the CIA’s attempt to literally bug a cat – which opened up a whole new world of spy craft and madness. Which eventually led me to The Pentagon Pizza Theory – the idea that you could hazard a guess that the US was going to be involved in some international incident based on a sudden late night spike in pizza orders at places near the Pentagon & the Whitehouse.

These were things of academic interest only really – a kind of “look at these mathematicians in tin-foil hats!” sort of view – until Trump took his second term and started kicking over everyone elses’ sandcastles so that he could try to turn around his polling numbers and make a huge amount of cash on the stock markets on the side. And then suddenly caring about whether the Pentagon were having late night meetings started heavily affecting my pension value as he started abducting foreign leaders – and making it unaffordable to attend graduation because petrol prices doubled almost overnight when he started bombing the Middle East.

And someone (no doubt one of the aforementioned tin-foil-hat-wearing-mathematicians) put together a dashboard – https://www.pizzint.watch using Google’s “busyness” indicator for fast food joints around the Pentagon and the Whitehouse to keep an eye on it all. Originally it only did pizza joints (staying true to the cause), but over time it has grown to include a number of other OSINT sources.

I don’t know about you, but I don’t have the time or inclination to have their dashboard up on screen at all hours of the day to review constantly – so I wanted to build an automated monitor for the service instead, to actively alert me to changes.

And so, finally, we get to the point of this post. I wrote myself a bash file, designed to be run as a Nagios plugin (to make use of my existing setup to send out the alerts whenever things changed). It’s not deep or complicated – I just wanted a quick scrape of the site & receive a nudge when things looked like they might be going sideways.

#!/usr/bin/env bash

# check_pizza_watch.sh - Monitor PizzaInt.Watch for changes to Doughcon
#
# -----------------------------------------------------------------------------
# Description:
#   This script checks the PizzaInt.Watch website to see what the current
#   "DOUGHCON"[sic] level is. Default is to return CRITICAL if it is at
#   DOUGHCON 1, WARNING if it is at DOUGHCON 2, or OK at any other level.
#
# Example usage:
#   ./check_pizza_watch.sh
# #
# -----------------------------------------------------------------------------
# Requirements:
#   • bash 4.x or later (uses associative arrays)
#   • curl (or wget)
#
# -----------------------------------------------------------------------------
# Author:		Phil Tanner <phil@philtanner.com>
# Created:		2026-08-29
# Last updated:		2026-08-29
#
# Licence: (MIT licence: https://mit-license.org/)
# Copyright © 2026 Phil Tanner
#
# Permission is hereby granted, free of charge,  to any person obtaining a copy
# of this software and associated documentation files (the “Software”), to deal
# in the Software without restriction,  including without limitation the rights
# to use, copy,  modify, merge,  publish, distribute,  sublicense,  and/or sell 
# copies of  the  Software,  and to  permit  persons to  whom  the  Software is
# furnished to do so, subject to the following conditions:
#
# The above  copyright notice  and this permission notice shall  be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”,  WITHOUT  WARRANTY OF ANY KIND,  EXPRESS OR
# IMPLIED,  INCLUDING  BUT NOT  LIMITED TO THE  WARRANTIES OF  MERCHANTABILITY,
# FITNESS FOR  A PARTICULAR PURPOSE  AND NONINFRINGEMENT.  IN  NO  EVENT  SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE  FOR ANY  CLAIM,  DAMAGES OR OTHER
# LIABILITY,  WHETHER IN  AN ACTION  OF CONTRACT,  TORT  OR OTHERWISE,  ARISING
# FROM,  OUT  OF  OR  IN  CONNECTION  WITH  THE  SOFTWARE OR THE  USE  OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# -----------------------------------------------------------------------------
# Version: 1.0.0
# -----------------------------------------------------------------------------

# Nagios exit codes
NAGIOS_OK=0
NAGIOS_WARNING=1
NAGIOS_CRITICAL=2
NAGIOS_UNKNOWN=3

# Default values
WARNING_VAL=2
CRITICAL_VAL=1
TIMEOUT=10
URL="https://www.pizzint.watch/api/dashboard-data"

# Review arguments
while getopts "w:c:t:" opt; do
  case $opt in
    w) WARNING_VAL="$OPTARG" ;;
    c) CRITICAL_VAL="$OPTARG" ;;
    t) TIMEOUT="$OPTARG" ;;
    *) echo "Usage: $0 -w <warning> -c <critical> -t <timeout>"; exit $NAGIOS_UNKNOWN ;;
  esac
done

# Fetch JSON (curl preferred, wget fallback)
if command -v curl >/dev/null 2>&1; then
    JSON=$(curl -fsS --max-time "$TIMEOUT" "$URL")
    RC=$?
elif command -v wget >/dev/null 2>&1; then
    JSON=$(wget -q -T "$TIMEOUT" -O - "$URL")
    RC=$?
else
    echo "UNKNOWN - neither curl nor wget is available"
    exit $NAGIOS_UNKNOWN
fi

if [ $RC -ne 0 ] || [ -z "$JSON" ]; then
    echo "UNKNOWN - failed to fetch JSON from $URL"
    exit $NAGIOS_UNKNOWN
fi

# Extract defcon_level (assumes a numeric value)
DEFCON=$(echo "$JSON" \
    | grep -o '"defcon_level"[[:space:]]*:[[:space:]]*[0-9]\+' \
    | sed 's/[^0-9]//g')

# Check if our DEFCON value is empty
if [ -z "$DEFCON" ]; then
    echo "UNKNOWN - defcon_level not found in JSON"
    exit $NAGIOS_UNKNOWN
fi

if [[ "$DEFCON" -le "$CRITICAL_VAL" ]]; then 
    echo "CRITICAL - DOUGHCON level is $DEFCON"
    exit $NAGIOS_CRITICAL
elif [[ "$DEFCON" -le "$WARNING_VAL" ]]; then
    echo "WARNING - DOUGHCON level is $DEFCON"
    exit $NAGIOS_WARNING
else
    echo "OK - DOUGHCON level is $DEFCON"
    exit $NAGIOS_OK
fi

I have zero idea if this script will be useful to anyone else or not, but as I have a nasty habit of losing my useful scripts, at least I’ll now have this one documented somewhere (thanks Archive.org!)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *