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
- Multiple authentication methods:
- Basic auth (password, environment variable)
- Password manager (
pass) integration - Vouch Proxy (SSO/OAuth) support
Installation
# From PyPI
pip install nachos
# 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 |
login |
Authenticate via Vouch Proxy (SSO) |
logout |
Clear saved authentication token |
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
nagioscli supports multiple authentication methods for different environments.
Basic Auth - Password in config file
[nagios]
url = http://nagios.example.com/nagios
username = admin
password = secret
Basic Auth - Password from pass (password-store)
[nagios]
url = http://nagios.example.com/nagios
username = admin
[auth]
method = pass_path
pass_path = nagios/admin
Basic Auth - Password from environment variable
[nagios]
url = http://nagios.example.com/nagios
username = admin
[auth]
method = env_var
env_var = NAGIOS_PASSWORD
Vouch Proxy (SSO/OAuth)
For Nagios behind Vouch Proxy with SSO authentication:
# Interactive login - opens browser, paste cookie from DevTools
nagioscli login
The token is cached in ~/.nagioscli_token and used automatically.
Alternatively, set the cookie directly in config:
[nagios]
url = https://nagios.example.com/nagios
username = admin
[auth]
method = vouch_cookie
vouch_cookie = H4sIAAAA...
To get the cookie value manually:
- Open browser to your Nagios URL
- Authenticate via SSO
- Open DevTools (F12) → Application → Cookies
- Copy the
VouchCookievalue
To logout and clear the cached token:
nagioscli logout
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
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 nachos-0.1.12.tar.gz.
File metadata
- Download URL: nachos-0.1.12.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.4 CPython/3.11.14 FreeBSD/14.3-RELEASE-p7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0dd6bb4375dc1b65326a5d5ca17156da2ca5c0fc9e6dc3a4cfcc0657a049f1f
|
|
| MD5 |
00ab40436e3080ed81f9cd2ad9ed4ba1
|
|
| BLAKE2b-256 |
f5308bde25d40122ba4233af8e4531fe88f920de685e4d01c6e9987b53d88ce0
|
File details
Details for the file nachos-0.1.12-py3-none-any.whl.
File metadata
- Download URL: nachos-0.1.12-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.4 CPython/3.11.14 FreeBSD/14.3-RELEASE-p7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
358ba7002f1b44c04bc9ee6e254b27746160ac4a0744469b87abbc997c8d93bd
|
|
| MD5 |
bd03e9361cbdadcbbdbfd5f50937cd7a
|
|
| BLAKE2b-256 |
a28fa3b74c4455e9404028694aa4f8a5e1e251745b13a82797e131d8c18d6cd7
|