A CLI tool to manage Nagios Core via HTTP REST API
Project description
nagioscli
A CLI tool to manage Nagios Core via HTTP REST API.
Features
- Query host and service status
- List all problems (warning, critical, unknown)
- Force immediate checks
- Acknowledge problems
- List hosts and services
- JSON output support
- Password manager (
pass) integration
Installation
# From PyPI
pip install nagioscli
# From source
pip install git+https://github.com/lduchosal/nagioscli.git
# Development
git clone https://github.com/lduchosal/nagioscli.git
cd nagioscli
pdm install
Quick Start
Configuration
Create nagioscli.ini in the current directory or ~/.nagioscli.ini:
[nagios]
url = http://nagios.example.com/nagios
username = nagiosadmin
[auth]
method = pass_path
pass_path = nagios/admin
[settings]
timeout = 30
Basic Usage
# List all problems
nagioscli problems
# Query service status
nagioscli status service web01.example.com HTTP
# Query host status
nagioscli status host web01.example.com
# Force service check
nagioscli check web01.example.com HTTP
# Acknowledge a problem
nagioscli ack web01.example.com HTTP "Working on it"
# List all hosts
nagioscli hosts
# List services for a host
nagioscli services web01.example.com
Commands
| Command | Description |
|---|---|
problems |
List all services with problems |
status service <host> <service> |
Query service status |
status host <host> |
Query host status |
check <host> <service> |
Force service check |
check-host <host> |
Force host check |
ack <host> <service> <comment> |
Acknowledge service problem |
ack-host <host> <comment> |
Acknowledge host problem |
hosts |
List all monitored hosts |
services <host> |
List services for a host |
Output Options
# JSON output
nagioscli problems --json
# Quiet mode (exit codes only)
nagioscli problems --quiet
# Verbose debugging
nagioscli problems -v
nagioscli problems -vv
nagioscli problems -vvv
Configuration Options
Authentication Methods
Password in config file
[nagios]
url = http://nagios.example.com/nagios
username = admin
password = secret
Password from pass (password-store)
[nagios]
url = http://nagios.example.com/nagios
username = admin
[auth]
method = pass_path
pass_path = nagios/admin
Password from environment variable
[nagios]
url = http://nagios.example.com/nagios
username = admin
[auth]
method = env_var
env_var = NAGIOS_PASSWORD
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Configuration error |
| 3 | Authentication error |
| 4 | API error |
| 5 | Not found |
Development
# Clone and setup
git clone https://github.com/lduchosal/nagioscli.git
cd nagioscli
pdm install -G dev
# Run tests
pdm test
# Lint and format
pdm lint
pdm format
# Type check
pdm typecheck
# Build
pdm build
Architecture
nagioscli/
├── cli/ # Click CLI interface
│ ├── commands/ # Individual commands
│ ├── decorators.py # Common CLI options
│ └── handlers.py # Error handlers
├── core/ # Core business logic
│ ├── auth.py # Authentication
│ ├── client.py # Nagios HTTP client
│ ├── config.py # Configuration
│ ├── exceptions.py # Custom exceptions
│ └── models.py # Data models
└── services/ # Business services
License
MIT License - see LICENSE for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
Related Projects
- check_msdefender - Nagios plugin for Microsoft Defender
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nachos-0.1.9.tar.gz
(16.8 kB
view details)
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
nachos-0.1.9-py3-none-any.whl
(17.8 kB
view details)
File details
Details for the file nachos-0.1.9.tar.gz.
File metadata
- Download URL: nachos-0.1.9.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.4 CPython/3.12.3 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ca4052996ce9eb9cdbf5f3bcb046021275e4c0dedae9c4860a586bd2a359238
|
|
| MD5 |
5ab2ba9c10495d27e8819fc7c01bc1dc
|
|
| BLAKE2b-256 |
d1aa5571c1502c698a2d77e1e2c1dd9c48451253538f1eea4071429044ffad53
|
File details
Details for the file nachos-0.1.9-py3-none-any.whl.
File metadata
- Download URL: nachos-0.1.9-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.4 CPython/3.12.3 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6eb252a282a1cc6774c2f5b942a6c97c300c6886d57180534bbf97bf4cae2088
|
|
| MD5 |
8a6bf7938d1e05e69ca3dfe54b1f844c
|
|
| BLAKE2b-256 |
c5c1e8e6702a3b19a5a42fdbf1096d3e838876d55c4949df2cb894b359aacc50
|