NetBox Health Checks & Maintenance

Introduction

In order to keep your NetBox instance operating smoothly you can run housekeeping and maintenance scripts.

NetBox Housekeeping Script

NetBox includes a housekeeping management command that should be run nightly. This command handles:

The official documentation is here netbox/docs/administration/housekeeping.md at develop · netbox-community/netbox (github.com)

image.png

As per the NetBox developer suggestions, you can schedule the housekeeping script to run each day by enabling the schedule job in Semaphore.

image.png

NetBox Health Check

The NetBox Health Check script runs some useful commands to quickly capture the state of your NetBox instance, for example, checking processes are running, checking system logs, etc.

systemctl is-active netbox
systemctl is-active netbox-rq
python3 /opt/netbox/netbox/manage.py check
grep -i 'error' /var/log/nginx/netbox.error.log || true
grep -i 'warning' /var/log/nginx/netbox.error.log || true
journalctl -u netbox --since '24 hours ago' -n 250 | grep -i 'error' || true
journalctl -u netbox-rq --since '24 hours ago' -n 250 | grep -i 'error' || true

When you run the script, you'll see output like this:

image.png

In this scenario we can quickly see there is an error when starting NetBox, which pointed us in the right direction for troubleshooting a syntax issue in settings.py (using the commands detailed above). 

image.png


Revision #7
Created 22 September 2024 20:58:13 by Richard Foster
Updated 9 October 2024 14:05:47 by Richard Foster