Skip to content

Commit f97099f

Browse files
authored
Merge pull request #24 from sadsfae/development
feat: add uptime and service reporting.
2 parents 84595a3 + 61c771a commit f97099f

2 files changed

Lines changed: 440 additions & 52 deletions

File tree

README.md

Lines changed: 84 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,45 @@ A lightweight CLI for acknowledging and managing Nagios Core alerts via its nati
55
[![Flake8 Lint](https://github.com/sadsfae/mozzo/actions/workflows/flake8.yml/badge.svg)](https://github.com/sadsfae/mozzo/actions/workflows/flake8.yml)
66
[![PyPI version](https://badge.fury.io/py/mozzo.svg)](https://badge.fury.io/py/mozzo)
77

8+
## About
9+
10+
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, and view statuses without needing to install specialized Nagios libraries or scrape HTML.
11+
812
## Table of Contents
913

10-
- [About](#about)
1114
- [Installation](#installation)
12-
- [Option 1: Run from source (Standalone)](#option-1-run-from-source-standalone)
15+
- [Option 1: Run from Source (Standalone)](#option-1-run-from-source-standalone)
1316
- [Option 2: Install via pip](#option-2-install-via-pip)
1417
- [Option 3: Install via Pypi](#install-via-pypi)
1518
- [Configuration](#configuration)
1619
- [Usage](#usage)
17-
- [View Nagios process status](#view-nagios-process-status)
18-
- [List unhandled/alerting services](#list-unhandledalerting-services)
19-
- [List service issue](#list-service-issues)
20-
- [Acknowledge a specific service](#acknowledge-a-specific-service)
21-
- [Acknowledge a host and all its services](#acknowledge-a-host-and-all-its-services)
22-
- [Set downtime for a specific host](#set-downtime-for-a-specific-host)
23-
- [Set downtime for a host and all its services](#set-downtime-for-a-host-and-all-its-services)
24-
- [Set downtime for a specific service](#set-downtime-for-a-specific-service)
25-
- [Disable alerting for a specific service](#disable-alerting-for-a-specific-service)
26-
- [Disable alerting for all services on a host](#disable-alerting-for-all-services-on-a-host)
27-
- [Enable alerting for all services on a host](#enable-alerting-for-all-services-on-a-host)
28-
- [Enable alerting for a specific service](#enable-alerting-for-a-specific-service)
29-
- [Toggle global alerts](#toggle-global-alerts)
20+
- [View Nagios Process Status](#view-nagios-process-status)
21+
- [List Unhandled or Alerting services](#list-unhandledalerting-services)
22+
- [List Service Issue](#list-service-issues)
23+
- [Acknowledge a Specific Service](#acknowledge-a-specific-service)
24+
- [Acknowledge a Host and all its Services](#acknowledge-a-host-and-all-its-services)
25+
- [Set Downtime for a Specific Host](#set-downtime-for-a-specific-host)
26+
- [Set Downtime for a Host and all its Services](#set-downtime-for-a-host-and-all-its-services)
27+
- [Set Downtime for a Specific Service](#set-downtime-for-a-specific-service)
28+
- [Disable Alerting for a Specific Service](#disable-alerting-for-a-specific-service)
29+
- [Disable Alerting for all Services on a Host](#disable-alerting-for-all-services-on-a-host)
30+
- [Enable Alerting for all Services on a Host](#enable-alerting-for-all-services-on-a-host)
31+
- [Enable Alerting for a Specific Service](#enable-alerting-for-a-specific-service)
32+
- [Toggle Global Alerts](#toggle-global-alerts)
3033
- [Setting Ack or Downtime with a Custom Message](#setting-ack-or-downtime-with-a-custom-message)
3134
- [Acknowledging all Unhandled Issues](#acknowledging-all-unhandled-issues)
35+
- [Service Reporting and Uptime](#service-reporting-and-uptime)
36+
- [Listing all Services by Host](#listing-all-services-by-host)
37+
- [Listing Service Details by Host](#listing-service-details-by-host)
38+
- [Uptime Reporting](#uptime-reporting)
39+
- [Report Uptime by Service](#report-uptime-by-service)
40+
- [Report Uptime by Host](#report-uptime-by-host)
41+
- [Exporting Report Data](#exporting-report-data)
3242
- [Contributing](#contributing)
3343

34-
## About
35-
36-
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, and view statuses without needing to install specialized Nagios libraries or scrape HTML.
37-
3844
## Installation
3945

40-
### Option 1: Run from source (Standalone)
46+
### Option 1: Run from Source (Standalone)
4147

4248
You can clone the repository and run the script directly:
4349

@@ -101,79 +107,79 @@ date_format: "%m-%d-%Y %H:%M:%S"
101107
> [!IMPORTANT]
102108
> You can run `mozzo` (if installed) or `./mozzo.py` or `python mozzo.py` (if running from source).
103109

104-
### View Nagios process status
110+
### View Nagios Process Status
105111

106112
```bash
107113
mozzo --status
108114
```
109115

110-
### List unhandled/alerting services
116+
### List Unhandled or Alerting services
111117

112118
```bash
113119
mozzo --unhandled
114120
```
115121

116-
### List service issues
122+
### List Service Issues
117123

118124
```bash
119125
mozzo --service-issues [ --host host.example.com ]
120126
```
121127

122-
### Acknowledge a specific service
128+
### Acknowledge a Specific Service
123129

124130
```bash
125131
mozzo --ack --host host01.example.com --service "HTTP"
126132
```
127133

128-
### Acknowledge a host and all its services
134+
### Acknowledge a Host and all its Services
129135

130136
```bash
131137
mozzo --ack --host host01.example.com --all-services
132138
```
133139

134-
### Set downtime for a specific host
140+
### Set Downtime for a Specific Host
135141

136142
```bash
137143
mozzo --set-downtime --host host01.example.com
138144
```
139145

140-
### Set downtime for a host and all its services
146+
### Set Downtime for a Host and all its Services
141147

142148
```bash
143149
mozzo --set-downtime --host host01.example.com --all-services
144150
```
145151

146-
### Set downtime for a specific service
152+
### Set Downtime for a Specific Service
147153

148154
```bash
149155
mozzo --set-downtime --host host01.example.com --service "HTTP"
150156
```
151157

152-
### Disable alerting for a specific service
158+
### Disable Alerting for a Specific Service
153159

154160
```bash
155161
mozzo --disable-alerts --host host01.example.com --service "HTTP"
156162
```
157163

158-
### Disable alerting for all services on a host
164+
### Disable Alerting for all Services on a Host
159165

160166
```bash
161167
mozzo --disable-alerts --host host01.example.com --all-services
162168
```
163169

164-
### Enable alerting for all services on a host
170+
### Enable Alerting for all Services on a Host
165171

166172
```bash
167173
mozzo --enable-alerts --host host01.example.com --all-services
168174
```
169175

170-
### Enable alerting for a specific service
176+
### Enable Alerting for a Specific Service
171177

172178
```bash
173179
mozzo --enable-alerts --host host01.example.com --service "HTTP"
174180
```
175181

176-
### Toggle global alerts
182+
### Toggle Global Alerts
177183

178184
```bash
179185
mozzo --disable-alerts
@@ -194,6 +200,51 @@ mozzo --set-downtime --host host01.example.com --all-services -m "Patching windo
194200
mozzo --unhandled | grep -E -i "critical|warning" | while read -r level host arrow service; do mozzo --ack --host "$host" --service "$service"; done
195201
```
196202

203+
## Service Reporting and Uptime
204+
* We also support reporting for uptime per host and per service based on Nagios `archivejson.cgi`
205+
206+
### Listing all Services by Host
207+
208+
```bash
209+
mozzo --status --host host01.example.com
210+
```
211+
212+
### Listing Service Details by Host
213+
214+
```bash
215+
mozzo --status --host host01.example.com --service "DNS"
216+
```
217+
218+
### Uptime Reporting
219+
220+
> [!NOTE]
221+
> Default uptime reporting is 365 days if `--days` is not specified.
222+
223+
#### Report Uptime by Service
224+
225+
```bash
226+
mozzo --status --host host01.example.com --service "DNS" --uptime --days 180
227+
228+
```
229+
230+
#### Report Uptime by Host
231+
232+
```bash
233+
mozzo --status --host host01.example.com --uptime
234+
```
235+
236+
### Exporting Report Data
237+
* You can export in both JSON and CSV
238+
239+
```bash
240+
mozzo --status --host host01.example.com --service "DNS" --uptime --format json > /tmp/host01_dns.json
241+
242+
```
243+
244+
```bash
245+
mozzo --status --host host01.example.com --service "HTTP" --uptime --format csv > /tmp/host01_http_json
246+
```
247+
197248
## Contributing
198249

199250
- Please open pull requests against the [development](https://github.com/sadsfae/mozzo/tree/development) branch.

0 commit comments

Comments
 (0)