A lightweight CLI for acknowledging and managing Nagios Core alerts and reporting via its native CGI scripts.
Mozzo interacts with Nagios Core (4.x) via cmd.cgi and statusjson.cgi using standard HTTPS requests. It allows you to acknowledge alerts, schedule downtime, generate service/host uptime reporting and view statuses without needing to install specialized Nagios libraries or scrape HTML.
Note
This is compatible with Nagios Core 4.4.x and hasn't been tested with 4.5.x but will probably work.
- Installation
- Configuration
- Usage
- View Nagios Process Status
- List Unhandled or Alerting services
- List Service Issues
- Acknowledge a Specific Service
- Acknowledge a Host and all its Services
- Set Downtime for a Specific Host
- Set Downtime for a Host and all its Services
- Set Downtime for a Specific Service
- Disable Alerting for a Specific Service
- Disable Alerting for all Services on a Host
- Enable Alerting for all Services on a Host
- Enable Alerting for a Specific Service
- Toggle Global Alerts
- Setting Ack or Downtime with a Custom Message
- Acknowledging all Unhandled Issues
- Listing all Services by Host
- Listing Service Details by Host
- Listing Service Details on All Hosts
- Listing Service Details with Output
- Listing Service Details with Filter
- Service Reporting and Uptime
- Contributing
You can clone the repository and run the script directly:
git clone https://github.com/sadsfae/mozzo.git
cd mozzo
chmod +x mozzo.py
./mozzo.py --helpInstall globally or in a virtual environment to make the mozzo command available anywhere:
git clone https://github.com/sadsfae/mozzo.git
cd mozzo
pip install .
mozzo --helppython -m venv mozzo
. !$/bin/activate
pip install mozzoMozzo requires a configuration file named config.yml. It will search for this file in the following order:
~/.config/mozzo/config.yml./config.yml(Current directory)/etc/mozzo/config.yml
Tip
Copy the example config.yml and edit it first.
mkdir -p ~/.config/mozzo
curl -s -o ~/.config/mozzo/config.yml https://raw.githubusercontent.com/sadsfae/mozzo/refs/heads/main/config.yml
vim ~/.config/mozzo/config.ymlYour config.yml needs the following structure:
nagios_server: https://nagios.example.com
nagios_cgi_path: /nagios/cgi-bin
nagios_username: nagiosadmin
nagios_password: mysecurepassword
default_downtime: 120 # in minutes
verify_ssl: false
date_format: "%m-%d-%Y %H:%M:%S"Important
You can run mozzo (if installed) or ./mozzo.py or python mozzo.py (if running from source).
mozzo --statusmozzo --unhandledmozzo --service-issues [ --host host.example.com ]mozzo --ack --host host01.example.com --service "HTTP"mozzo --ack --host host01.example.com --all-servicesmozzo --set-downtime --host host01.example.commozzo --set-downtime --host host01.example.com --all-servicesmozzo --set-downtime --host host01.example.com --service "HTTP"mozzo --disable-alerts --host host01.example.com --service "HTTP"mozzo --disable-alerts --host host01.example.com --all-servicesmozzo --enable-alerts --host host01.example.com --all-servicesmozzo --enable-alerts --host host01.example.com --service "HTTP"mozzo --disable-alerts
mozzo --enable-alertsmozzo --ack --host host01.example.com --message "Acknowledged per ticket INC-12345"
mozzo --set-downtime --host host01.example.com --all-services -m "Patching window"- This bash one-liner can ack all unhandled issues in one swoop.
mozzo --unhandled | grep -E -i "critical|warning" | while read -r level host arrow service; do mozzo --ack --host "$host" --service "$service"; donemozzo --status --host host01.example.commozzo --status --host host01.example.com --service "DNS"mozzo --status --service "DNS"To show DNS results for all hosts that have the service:
mozzo --status --service "DNS" --show-outputTo show DNS results for a specific host that has the service:
mozzo --status --host host01.example.com --service "DNS" --show-output- You can filter results by passing a human-readable status to
--output-filter. - Valid options are:
PENDING,OK,WARNING,UNKNOWN, andCRITICAL. (Filters are case-insensitive).
To show DNS results for all hosts that have the service in a CRITICAL state:
mozzo --status --service "DNS" --output-filter CRITICALTo show DNS results for a specific host that has the service in a CRITICAL state, while also showing the plugin output:
mozzo --status --host host01.example.com --service "DNS" --show-output --output-filter criticalTip
Use --show-output to see the Nagios plugin's full details
Further, you can combine them all to show full plugin output for all DNS failures:
mozzo --status --service "DNS" --output-filter CRITICAL --show-output- We also support reporting for uptime per host and per service based on Nagios
archivejson.cgi
Note
Default uptime reporting is 365 days if --days is not specified.
mozzo --status --host host01.example.com --service "DNS" --uptime --days 180mozzo --status --host host01.example.com --uptime- You can export in both JSON and CSV
mozzo --status --host host01.example.com --service "DNS" --uptime --format json > /tmp/host01_dns.jsonmozzo --status --host host01.example.com --service "HTTP" --uptime --format csv > /tmp/host01_http.csv- Please open pull requests against the development branch.
- I maintain an Ansible playbook to install Nagios Core here and clients.