A software defined Wattbox cousin - but not really like a Wattbox at all.
Quick Deployment (script) • Uninstall Nottbox (script) • Manual Deployment
Nottbox is a Wattbox-like bash script (that can run as a service) that will reboot a Unifi device if it cannot ping an IP address or hostname for longer than 2.5 minutes (default - 150 seconds). Some devices in my Unifi environment will go offline while remaining physically powered on for no apparent reason. Some days/weeks/months are better than others, but today it happened 3 times - and now there is Nottbox.
Since Nottbox is just a few bash scripts and a couple of config files, the entire project directory has a very small footprint at under 30KB.
If Nottbox proves to be useful to you, it probably means you need to:
- check to ensure you're running on the latest firmware version on all devices within your Unifi environment, including the network controller
- get Unifi support to assist or RMA the device
- investigate purchasing a new device with a higher capacity
BUT life is crazy and not all of us have a ton of time on our hands and/or the salary of a NASA senior aerospace engineer - in cases like these, Nottbox is here.
Nottbox was intended for Unifi devices but it should work on most linux operating systems that use systemd (think OpenWRT).
SSH into your Unifi device (this must be enabled explicitly within the web management portal)
Params (remove from command to disable/negate the below options - omit -u and -t if you don't wish to use Pushover for notifications):
- -e | --enable-service : enable the service (so it starts after reboots) (optional, but recommended)
- -u | --user-key : your Pushover User key from https://pushover.net (optional)
- -t | --api-token : your Pushover Nottbox API token from https://pushover.net (optional)
Using cURL:
curl -sSL https://raw.githubusercontent.com/sam-morin/nottbox/main/install-nottbox.sh | bash -s -- -e
with Pushover keys specified:
curl -sSL https://raw.githubusercontent.com/sam-morin/nottbox/main/install-nottbox.sh | bash -s -- -e -u "YourUserKey" -t "YourApiToken"
or wget:
wget -qO- https://raw.githubusercontent.com/sam-morin/nottbox/main/install-nottbox.sh | bash -s -- -e
...
● nottbox.service - A software defined Wattbox cousin for Unifi devices.
Loaded: loaded (/etc/systemd/system/nottbox.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2023-10-08 08:47:01 EDT; 2min 51s ago
Main PID: 411110 (nottbox.sh)
Tasks: 2 (limit: 2386)
Memory: 2.7M
CPU: 134ms
CGroup: /system.slice/nottbox.service
├─411110 /bin/bash /root/nottbox/nottbox.sh
└─412050 sleep 30
Oct 08 08:47:01 unifi-device-name systemd[1]: Started A software defined Wattbox cousin for Unifi devices..
Oct 08 08:47:01 unifi-device-name nottbox.sh[411110]: Nottbox will pause monitoring between 3:45 and 4:45 nightly update window.
Oct 08 08:47:01 unifi-device-name nottbox.sh[411110]: Nottbox started at 2023-10-08 08:47:01
Use systemctl
:
systemctl status nottbox
to show the status
SSH into your Unifi device (this must be enabled explicitly within the web management portal)
In the root directory (you should be here by default after login - but you can check with pwd
), clone the repo and CD into the Nottbox directory:
git clone https://github.com/sam-morin/nottbox.git
cd nottbox
Edit nottbox.yml
to specify your preferences (if a pause is not needed, leave PAUSE_START
and PAUSE_END
blank):
# Configuration file for Nottbox
DOMAIN_OR_IP: one.one.one.one, 1.0.0.1, google.com, 8.8.8.8, 9.9.9.9, 208.67.222.222
PING_FREQUENCY_SEC: 30
DOWNTIME_THRESHOLD_SEC: 90
PAUSE_START: 3:45
PAUSE_END: 4:45
LOG_FILE: /root/nottbox/nottbox.log
These are the default values
You must supply at least 2 targets. You can supply as many targets beyond 2 as you'd like.
Targets are defined as shown in the above nottbox.yml
config file. Separate using commas in the DOMAIN_OR_IP value.
Time is to be defined in 24 hour format
If using the pause functionality, please ensure that your timezone is correct by comparing the current hour with the hour returned from this command:
date -u -d '-4 hours' +'%H'
Adjust your specified time as necessary. Timezone correction configuration option will be added soon!
Set execute file permission:
chmod +x nottbox.sh
Run Nottbox:
./nottbox.sh
Copy default Nottbox systemd service unit file to /etc/systemd/system/nottbox.service
:
cp nottbox.service /etc/systemd/system/
or
Create unit file:
vi /etc/systemd/system/nottbox.service
Paste the following in the editor and then type :x
and hit Enter to save:
[Unit]
Description=A software defined Wattbox cousin for Unifi devices.
After=network.target
[Service]
ExecStart=/root/nottbox/nottbox.sh
Restart=on-failure
RestartSec=2s
User=root
Group=root
Type=simple
[Install]
WantedBy=multi-user.target
Reload the systemd manager configuration:
systemctl daemon-reload
Enable the service (only if you want it to start at boot, skip this step otherwise):
systemctl enable nottbox
Finally, start the service:
systemctl start nottbox
Check the service status:
systemctl status nottbox
Params (included by default, remove from command to disable/negate the below options):
- -f | --remove-log : delete the log as well (if this is omitted, the log file will be moved to
/root/nottbox.log
before deleting/root/nottbox/
) (optional)
Use cURL:
curl -sSL https://raw.githubusercontent.com/sam-morin/nottbox/main/uninstall-nottbox.sh | bash -s -- -f
or wget:
wget -qO- https://raw.githubusercontent.com/sam-morin/nottbox/main/uninstall-nottbox.sh | bash -s -- -f
What this does:
- Stops the Nottbox service
- Disables the Nottbox service
- Deletes the Nottbox service
- Reloads systemd daemon
- Removes the Nottbox directory
- Uninstalls git & cleans up packages
Quick Deployment (script) • Uninstall Nottbox (script) • Manual Deployment