Skip to main content

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:

  • Clearing expired authentication sessions from the database
  • Deleting changelog records older than the configured retention time
  • Deleting job result records older than the configured retention time
  • Check for new NetBox releases (if RELEASE_CHECK_URL is set)

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