A command-line assistant for acknowledging and managing Nagios Core alerts.
Project description
mozzo
A lightweight CLI for acknowledging and managing Nagios Core alerts and reporting via its native CGI scripts.
About
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.
Table of Contents
- 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
- List Acknowledgement History for a Service
- List Acknowledgement History for a Host
- List Acknowledgement History for a Custom Timeframe
- 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
- Viewing Nagios Logs
- Service Reporting and Uptime
- Contributing
Installation
Option 1: Run from Source (Standalone)
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 --help
Option 2: Install via pip
Install 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 --help
Option 3: Install via Pypi
python -m venv mozzo
. !$/bin/activate
pip install mozzo
Configuration
Mozzo 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.ymland 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.yml
Your 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
default_reporting_days: 365 # in days
verify_ssl: false
date_format: "%m-%d-%Y %H:%M:%S"
Usage
[!IMPORTANT] You can run
mozzo(if installed) or./mozzo.pyorpython mozzo.py(if running from source).
View Nagios Process Status
mozzo --status
List Unhandled or Alerting services
mozzo --unhandled
List Service Issues
mozzo --service-issues [ --host host.example.com ]
Acknowledge a Specific Service
mozzo --ack --host host01.example.com --service "HTTP"
Acknowledge a Host and all its Services
mozzo --ack --host host01.example.com --all-services
[!TIP] You can pass
--daysincluding a float value for downtime, otherwise the value inconfig.ymlis used.
List Acknowledgement History for a Service
mozzo --host host01.example.com --service "HTTP" --ack-history
List Acknowledgement History for a Host
mozzo --host host01.example.com --ack-history
List Acknowledgement History for a Custom Timeframe
mozzo --host host01.example.com --ack-history --days 30
Set Downtime for a Specific Host
mozzo --set-downtime --host host01.example.com
mozzo --set-downtime --host host01.example.com --days 0.5
Set Downtime for a Host and all its Services
mozzo --set-downtime --host host01.example.com --all-services
Set Downtime for a Specific Service
mozzo --set-downtime --host host01.example.com --service "HTTP"
mozzo --set-downtime --host host01.example.com --service "HTTP" --days 2
Disable Alerting for a Specific Service
mozzo --disable-alerts --host host01.example.com --service "HTTP"
Disable Alerting for all Services on a Host
mozzo --disable-alerts --host host01.example.com --all-services
Enable Alerting for all Services on a Host
mozzo --enable-alerts --host host01.example.com --all-services
Enable Alerting for a Specific Service
mozzo --enable-alerts --host host01.example.com --service "HTTP"
Toggle Global Alerts
mozzo --disable-alerts
mozzo --enable-alerts
Setting Ack or Downtime with a Custom Message
mozzo --ack --host host01.example.com --message "Acknowledged per ticket INC-12345"
mozzo --set-downtime --host host01.example.com --all-services -m "Patching window"
Acknowledging all Unhandled Issues
- 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"; done
Listing all Services by Host
mozzo --status --host host01.example.com
Listing Service Details by Host
mozzo --status --host host01.example.com --service "DNS"
Listing Service Details on All Hosts
mozzo --status --service "DNS"
Listing Service Details with Output
To show DNS results for all hosts that have the service:
mozzo --status --service "DNS" --show-output
To show DNS results for a specific host that has the service:
mozzo --status --host host01.example.com --service "DNS" --show-output
Listing Service Details with Filter
- 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 CRITICAL
To 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 critical
[!TIP] Use
--show-outputto 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
Viewing Nagios Logs
View Nagios alert logs from the last 24 hours:
mozzo --log
View logs for a custom time range:
mozzo --log --days 7
View logs for the last 12 hours:
mozzo --log --days 0.5
View raw log including state dumps (for debugging):
mozzo --log --full
[!NOTE] On busy servers,
--logmay take 1-2 minutes as it downloads the full log file. Use shell pipes to limit output:mozzo --log | head -n 100
Service Reporting and Uptime
- We also support reporting for uptime per host and per service based on Nagios
archivejson.cgi
Uptime Reporting
[!NOTE] Default uptime reporting uses
default_reporting_daysfromconfig.ymlDefault is 365 days unless you specify
--days
Report Uptime by Service
mozzo --status --host host01.example.com --service "DNS" --uptime --days 180
Report Uptime by Host
mozzo --status --host host01.example.com --uptime
Exporting Report Data
- You can export in both JSON and CSV
mozzo --status --host host01.example.com --service "DNS" --uptime --format json > /tmp/host01_dns.json
mozzo --status --host host01.example.com --service "HTTP" --uptime --format csv > /tmp/host01_http.csv
Contributing
- Please open pull requests against the development branch.
- I maintain an Ansible playbook to install Nagios Core here and clients.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mozzo-0.11.0.tar.gz.
File metadata
- Download URL: mozzo-0.11.0.tar.gz
- Upload date:
- Size: 56.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f46c500cb1446065b9122c5fe602d70910218729e696b8c8edea89e7b38a0d96
|
|
| MD5 |
77e963546814df1a15b53b50f1f1a15b
|
|
| BLAKE2b-256 |
2eabd76a6310876a3ca22c0f44d2ac8048a4f587536a85e24ff91a53800372f8
|
File details
Details for the file mozzo-0.11.0-py3-none-any.whl.
File metadata
- Download URL: mozzo-0.11.0-py3-none-any.whl
- Upload date:
- Size: 39.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff926db5c75771b643d8e835837ed50315d9a71c229290b67079769d9d3a0f07
|
|
| MD5 |
fd100864a968b653a5dd95d97465d5ad
|
|
| BLAKE2b-256 |
ff655e6744c08a4fa85e8bc0cfd78386ff7efb7a16b0390e190a8c0de6430850
|