nachos 0.1.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. nachos-0.1.9/LICENSE +21 -0
  2. nachos-0.1.9/PKG-INFO +230 -0
  3. nachos-0.1.9/README.md +204 -0
  4. nachos-0.1.9/nagioscli/__init__.py +5 -0
  5. nachos-0.1.9/nagioscli/__main__.py +6 -0
  6. nachos-0.1.9/nagioscli/cli/__init__.py +16 -0
  7. nachos-0.1.9/nagioscli/cli/commands/__init__.py +20 -0
  8. nachos-0.1.9/nagioscli/cli/commands/ack.py +73 -0
  9. nachos-0.1.9/nagioscli/cli/commands/check.py +69 -0
  10. nachos-0.1.9/nagioscli/cli/commands/hosts.py +57 -0
  11. nachos-0.1.9/nagioscli/cli/commands/problems.py +61 -0
  12. nachos-0.1.9/nagioscli/cli/commands/services.py +62 -0
  13. nachos-0.1.9/nagioscli/cli/commands/status.py +123 -0
  14. nachos-0.1.9/nagioscli/cli/decorators.py +39 -0
  15. nachos-0.1.9/nagioscli/cli/handlers.py +69 -0
  16. nachos-0.1.9/nagioscli/core/__init__.py +1 -0
  17. nachos-0.1.9/nagioscli/core/auth.py +73 -0
  18. nachos-0.1.9/nagioscli/core/client.py +420 -0
  19. nachos-0.1.9/nagioscli/core/config.py +127 -0
  20. nachos-0.1.9/nagioscli/core/exceptions.py +37 -0
  21. nachos-0.1.9/nagioscli/core/models.py +97 -0
  22. nachos-0.1.9/nagioscli/services/__init__.py +1 -0
  23. nachos-0.1.9/pyproject.toml +165 -0
  24. nachos-0.1.9/tests/__init__.py +1 -0
  25. nachos-0.1.9/tests/fixtures/__init__.py +1 -0
  26. nachos-0.1.9/tests/fixtures/host_data.json +28 -0
  27. nachos-0.1.9/tests/fixtures/mock_nagios_client.py +110 -0
  28. nachos-0.1.9/tests/fixtures/service_data.json +40 -0
  29. nachos-0.1.9/tests/fixtures/test_client_fixtures.py +111 -0
  30. nachos-0.1.9/tests/integration/__init__.py +1 -0
  31. nachos-0.1.9/tests/unit/__init__.py +1 -0
  32. nachos-0.1.9/tests/unit/test_config.py +137 -0
  33. nachos-0.1.9/tests/unit/test_models.py +117 -0
nachos-0.1.9/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 lduchosal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
nachos-0.1.9/PKG-INFO ADDED
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.1
2
+ Name: nachos
3
+ Version: 0.1.9
4
+ Summary: A CLI tool to manage Nagios Core via HTTP REST API
5
+ Keywords: nagios,monitoring,cli,api,devops
6
+ Author-Email: lduchosal <lduchosal@github.com>
7
+ License: MIT
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: System Administrators
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: System :: Monitoring
18
+ Classifier: Topic :: System :: Systems Administration
19
+ Project-URL: Homepage, https://github.com/lduchosal/nagioscli
20
+ Project-URL: Bug Reports, https://github.com/lduchosal/nagioscli/issues
21
+ Project-URL: Source, https://github.com/lduchosal/nagioscli
22
+ Project-URL: Documentation, https://github.com/lduchosal/nagioscli/blob/main/README.md
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: click<9.0,>=8.0
25
+ Description-Content-Type: text/markdown
26
+
27
+ # nagioscli
28
+
29
+ [![Python Version](https://img.shields.io/badge/python-3.10+-blue.svg)](https://python.org)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
31
+
32
+ A CLI tool to manage Nagios Core via HTTP REST API.
33
+
34
+ ## Features
35
+
36
+ - Query host and service status
37
+ - List all problems (warning, critical, unknown)
38
+ - Force immediate checks
39
+ - Acknowledge problems
40
+ - List hosts and services
41
+ - JSON output support
42
+ - Password manager (`pass`) integration
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ # From PyPI
48
+ pip install nagioscli
49
+
50
+ # From source
51
+ pip install git+https://github.com/lduchosal/nagioscli.git
52
+
53
+ # Development
54
+ git clone https://github.com/lduchosal/nagioscli.git
55
+ cd nagioscli
56
+ pdm install
57
+ ```
58
+
59
+ ## Quick Start
60
+
61
+ ### Configuration
62
+
63
+ Create `nagioscli.ini` in the current directory or `~/.nagioscli.ini`:
64
+
65
+ ```ini
66
+ [nagios]
67
+ url = http://nagios.example.com/nagios
68
+ username = nagiosadmin
69
+
70
+ [auth]
71
+ method = pass_path
72
+ pass_path = nagios/admin
73
+
74
+ [settings]
75
+ timeout = 30
76
+ ```
77
+
78
+ ### Basic Usage
79
+
80
+ ```bash
81
+ # List all problems
82
+ nagioscli problems
83
+
84
+ # Query service status
85
+ nagioscli status service web01.example.com HTTP
86
+
87
+ # Query host status
88
+ nagioscli status host web01.example.com
89
+
90
+ # Force service check
91
+ nagioscli check web01.example.com HTTP
92
+
93
+ # Acknowledge a problem
94
+ nagioscli ack web01.example.com HTTP "Working on it"
95
+
96
+ # List all hosts
97
+ nagioscli hosts
98
+
99
+ # List services for a host
100
+ nagioscli services web01.example.com
101
+ ```
102
+
103
+ ## Commands
104
+
105
+ | Command | Description |
106
+ |---------|-------------|
107
+ | `problems` | List all services with problems |
108
+ | `status service <host> <service>` | Query service status |
109
+ | `status host <host>` | Query host status |
110
+ | `check <host> <service>` | Force service check |
111
+ | `check-host <host>` | Force host check |
112
+ | `ack <host> <service> <comment>` | Acknowledge service problem |
113
+ | `ack-host <host> <comment>` | Acknowledge host problem |
114
+ | `hosts` | List all monitored hosts |
115
+ | `services <host>` | List services for a host |
116
+
117
+ ## Output Options
118
+
119
+ ```bash
120
+ # JSON output
121
+ nagioscli problems --json
122
+
123
+ # Quiet mode (exit codes only)
124
+ nagioscli problems --quiet
125
+
126
+ # Verbose debugging
127
+ nagioscli problems -v
128
+ nagioscli problems -vv
129
+ nagioscli problems -vvv
130
+ ```
131
+
132
+ ## Configuration Options
133
+
134
+ ### Authentication Methods
135
+
136
+ #### Password in config file
137
+ ```ini
138
+ [nagios]
139
+ url = http://nagios.example.com/nagios
140
+ username = admin
141
+ password = secret
142
+ ```
143
+
144
+ #### Password from pass (password-store)
145
+ ```ini
146
+ [nagios]
147
+ url = http://nagios.example.com/nagios
148
+ username = admin
149
+
150
+ [auth]
151
+ method = pass_path
152
+ pass_path = nagios/admin
153
+ ```
154
+
155
+ #### Password from environment variable
156
+ ```ini
157
+ [nagios]
158
+ url = http://nagios.example.com/nagios
159
+ username = admin
160
+
161
+ [auth]
162
+ method = env_var
163
+ env_var = NAGIOS_PASSWORD
164
+ ```
165
+
166
+ ## Exit Codes
167
+
168
+ | Code | Meaning |
169
+ |------|---------|
170
+ | 0 | Success |
171
+ | 1 | General error |
172
+ | 2 | Configuration error |
173
+ | 3 | Authentication error |
174
+ | 4 | API error |
175
+ | 5 | Not found |
176
+
177
+ ## Development
178
+
179
+ ```bash
180
+ # Clone and setup
181
+ git clone https://github.com/lduchosal/nagioscli.git
182
+ cd nagioscli
183
+ pdm install -G dev
184
+
185
+ # Run tests
186
+ pdm test
187
+
188
+ # Lint and format
189
+ pdm lint
190
+ pdm format
191
+
192
+ # Type check
193
+ pdm typecheck
194
+
195
+ # Build
196
+ pdm build
197
+ ```
198
+
199
+ ## Architecture
200
+
201
+ ```
202
+ nagioscli/
203
+ ├── cli/ # Click CLI interface
204
+ │ ├── commands/ # Individual commands
205
+ │ ├── decorators.py # Common CLI options
206
+ │ └── handlers.py # Error handlers
207
+ ├── core/ # Core business logic
208
+ │ ├── auth.py # Authentication
209
+ │ ├── client.py # Nagios HTTP client
210
+ │ ├── config.py # Configuration
211
+ │ ├── exceptions.py # Custom exceptions
212
+ │ └── models.py # Data models
213
+ └── services/ # Business services
214
+ ```
215
+
216
+ ## License
217
+
218
+ MIT License - see [LICENSE](LICENSE) for details.
219
+
220
+ ## Contributing
221
+
222
+ 1. Fork the repository
223
+ 2. Create a feature branch
224
+ 3. Make your changes
225
+ 4. Run tests and linting
226
+ 5. Submit a pull request
227
+
228
+ ## Related Projects
229
+
230
+ - [check_msdefender](https://github.com/lduchosal/check_msdefender) - Nagios plugin for Microsoft Defender
nachos-0.1.9/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # nagioscli
2
+
3
+ [![Python Version](https://img.shields.io/badge/python-3.10+-blue.svg)](https://python.org)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ A CLI tool to manage Nagios Core via HTTP REST API.
7
+
8
+ ## Features
9
+
10
+ - Query host and service status
11
+ - List all problems (warning, critical, unknown)
12
+ - Force immediate checks
13
+ - Acknowledge problems
14
+ - List hosts and services
15
+ - JSON output support
16
+ - Password manager (`pass`) integration
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ # From PyPI
22
+ pip install nagioscli
23
+
24
+ # From source
25
+ pip install git+https://github.com/lduchosal/nagioscli.git
26
+
27
+ # Development
28
+ git clone https://github.com/lduchosal/nagioscli.git
29
+ cd nagioscli
30
+ pdm install
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ### Configuration
36
+
37
+ Create `nagioscli.ini` in the current directory or `~/.nagioscli.ini`:
38
+
39
+ ```ini
40
+ [nagios]
41
+ url = http://nagios.example.com/nagios
42
+ username = nagiosadmin
43
+
44
+ [auth]
45
+ method = pass_path
46
+ pass_path = nagios/admin
47
+
48
+ [settings]
49
+ timeout = 30
50
+ ```
51
+
52
+ ### Basic Usage
53
+
54
+ ```bash
55
+ # List all problems
56
+ nagioscli problems
57
+
58
+ # Query service status
59
+ nagioscli status service web01.example.com HTTP
60
+
61
+ # Query host status
62
+ nagioscli status host web01.example.com
63
+
64
+ # Force service check
65
+ nagioscli check web01.example.com HTTP
66
+
67
+ # Acknowledge a problem
68
+ nagioscli ack web01.example.com HTTP "Working on it"
69
+
70
+ # List all hosts
71
+ nagioscli hosts
72
+
73
+ # List services for a host
74
+ nagioscli services web01.example.com
75
+ ```
76
+
77
+ ## Commands
78
+
79
+ | Command | Description |
80
+ |---------|-------------|
81
+ | `problems` | List all services with problems |
82
+ | `status service <host> <service>` | Query service status |
83
+ | `status host <host>` | Query host status |
84
+ | `check <host> <service>` | Force service check |
85
+ | `check-host <host>` | Force host check |
86
+ | `ack <host> <service> <comment>` | Acknowledge service problem |
87
+ | `ack-host <host> <comment>` | Acknowledge host problem |
88
+ | `hosts` | List all monitored hosts |
89
+ | `services <host>` | List services for a host |
90
+
91
+ ## Output Options
92
+
93
+ ```bash
94
+ # JSON output
95
+ nagioscli problems --json
96
+
97
+ # Quiet mode (exit codes only)
98
+ nagioscli problems --quiet
99
+
100
+ # Verbose debugging
101
+ nagioscli problems -v
102
+ nagioscli problems -vv
103
+ nagioscli problems -vvv
104
+ ```
105
+
106
+ ## Configuration Options
107
+
108
+ ### Authentication Methods
109
+
110
+ #### Password in config file
111
+ ```ini
112
+ [nagios]
113
+ url = http://nagios.example.com/nagios
114
+ username = admin
115
+ password = secret
116
+ ```
117
+
118
+ #### Password from pass (password-store)
119
+ ```ini
120
+ [nagios]
121
+ url = http://nagios.example.com/nagios
122
+ username = admin
123
+
124
+ [auth]
125
+ method = pass_path
126
+ pass_path = nagios/admin
127
+ ```
128
+
129
+ #### Password from environment variable
130
+ ```ini
131
+ [nagios]
132
+ url = http://nagios.example.com/nagios
133
+ username = admin
134
+
135
+ [auth]
136
+ method = env_var
137
+ env_var = NAGIOS_PASSWORD
138
+ ```
139
+
140
+ ## Exit Codes
141
+
142
+ | Code | Meaning |
143
+ |------|---------|
144
+ | 0 | Success |
145
+ | 1 | General error |
146
+ | 2 | Configuration error |
147
+ | 3 | Authentication error |
148
+ | 4 | API error |
149
+ | 5 | Not found |
150
+
151
+ ## Development
152
+
153
+ ```bash
154
+ # Clone and setup
155
+ git clone https://github.com/lduchosal/nagioscli.git
156
+ cd nagioscli
157
+ pdm install -G dev
158
+
159
+ # Run tests
160
+ pdm test
161
+
162
+ # Lint and format
163
+ pdm lint
164
+ pdm format
165
+
166
+ # Type check
167
+ pdm typecheck
168
+
169
+ # Build
170
+ pdm build
171
+ ```
172
+
173
+ ## Architecture
174
+
175
+ ```
176
+ nagioscli/
177
+ ├── cli/ # Click CLI interface
178
+ │ ├── commands/ # Individual commands
179
+ │ ├── decorators.py # Common CLI options
180
+ │ └── handlers.py # Error handlers
181
+ ├── core/ # Core business logic
182
+ │ ├── auth.py # Authentication
183
+ │ ├── client.py # Nagios HTTP client
184
+ │ ├── config.py # Configuration
185
+ │ ├── exceptions.py # Custom exceptions
186
+ │ └── models.py # Data models
187
+ └── services/ # Business services
188
+ ```
189
+
190
+ ## License
191
+
192
+ MIT License - see [LICENSE](LICENSE) for details.
193
+
194
+ ## Contributing
195
+
196
+ 1. Fork the repository
197
+ 2. Create a feature branch
198
+ 3. Make your changes
199
+ 4. Run tests and linting
200
+ 5. Submit a pull request
201
+
202
+ ## Related Projects
203
+
204
+ - [check_msdefender](https://github.com/lduchosal/check_msdefender) - Nagios plugin for Microsoft Defender
@@ -0,0 +1,5 @@
1
+ """nagioscli - A CLI tool to manage Nagios Core via HTTP REST API."""
2
+
3
+ __version__ = "0.1.9"
4
+ __author__ = "lduchosal"
5
+ __email__ = "lduchosal@github.com"
@@ -0,0 +1,6 @@
1
+ """Main entry point for nagioscli."""
2
+
3
+ from nagioscli.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1,16 @@
1
+ """CLI module for nagioscli."""
2
+
3
+ import click
4
+
5
+ from .commands import register_all_commands
6
+
7
+
8
+ @click.group()
9
+ @click.version_option()
10
+ def main() -> None:
11
+ """Nagios CLI - Manage Nagios Core via HTTP REST API."""
12
+ pass
13
+
14
+
15
+ # Register all commands
16
+ register_all_commands(main)
@@ -0,0 +1,20 @@
1
+ """Commands package for CLI."""
2
+
3
+ from typing import Any
4
+
5
+ from .ack import register_ack_commands
6
+ from .check import register_check_commands
7
+ from .hosts import register_hosts_commands
8
+ from .problems import register_problems_commands
9
+ from .services import register_services_commands
10
+ from .status import register_status_commands
11
+
12
+
13
+ def register_all_commands(main_group: Any) -> None:
14
+ """Register all commands with the main CLI group."""
15
+ register_problems_commands(main_group)
16
+ register_status_commands(main_group)
17
+ register_check_commands(main_group)
18
+ register_hosts_commands(main_group)
19
+ register_services_commands(main_group)
20
+ register_ack_commands(main_group)
@@ -0,0 +1,73 @@
1
+ """Acknowledge commands for CLI."""
2
+
3
+ from typing import Any
4
+
5
+ import click
6
+
7
+ from nagioscli.core.client import NagiosClient
8
+ from nagioscli.core.config import load_config
9
+
10
+ from ..decorators import common_options
11
+ from ..handlers import OutputFormatter, handle_error
12
+
13
+
14
+ def register_ack_commands(main_group: Any) -> None:
15
+ """Register acknowledge commands with the main CLI group."""
16
+
17
+ @main_group.command("ack")
18
+ @click.argument("hostname")
19
+ @click.argument("service")
20
+ @click.argument("comment")
21
+ @common_options
22
+ def ack_cmd(
23
+ hostname: str,
24
+ service: str,
25
+ comment: str,
26
+ config: str,
27
+ verbose: int,
28
+ ) -> None:
29
+ """Acknowledge a service problem."""
30
+ try:
31
+ cfg = load_config(config)
32
+ client = NagiosClient(cfg, verbose=verbose)
33
+
34
+ OutputFormatter.format_verbose(
35
+ f"Acknowledging {hostname}/{service}", verbose
36
+ )
37
+
38
+ success = client.acknowledge_service(hostname, service, comment)
39
+
40
+ if success:
41
+ click.echo(f"Acknowledged {hostname}/{service}")
42
+ else:
43
+ click.echo(f"Failed to acknowledge {hostname}/{service}")
44
+
45
+ except Exception as e:
46
+ handle_error(e, verbose)
47
+
48
+ @main_group.command("ack-host")
49
+ @click.argument("hostname")
50
+ @click.argument("comment")
51
+ @common_options
52
+ def ack_host_cmd(
53
+ hostname: str,
54
+ comment: str,
55
+ config: str,
56
+ verbose: int,
57
+ ) -> None:
58
+ """Acknowledge a host problem."""
59
+ try:
60
+ cfg = load_config(config)
61
+ client = NagiosClient(cfg, verbose=verbose)
62
+
63
+ OutputFormatter.format_verbose(f"Acknowledging host {hostname}", verbose)
64
+
65
+ success = client.acknowledge_host(hostname, comment)
66
+
67
+ if success:
68
+ click.echo(f"Acknowledged host {hostname}")
69
+ else:
70
+ click.echo(f"Failed to acknowledge host {hostname}")
71
+
72
+ except Exception as e:
73
+ handle_error(e, verbose)
@@ -0,0 +1,69 @@
1
+ """Check commands for CLI."""
2
+
3
+ from typing import Any
4
+
5
+ import click
6
+
7
+ from nagioscli.core.client import NagiosClient
8
+ from nagioscli.core.config import load_config
9
+
10
+ from ..decorators import common_options
11
+ from ..handlers import OutputFormatter, handle_error
12
+
13
+
14
+ def register_check_commands(main_group: Any) -> None:
15
+ """Register check commands with the main CLI group."""
16
+
17
+ @main_group.command("check")
18
+ @click.argument("hostname")
19
+ @click.argument("service")
20
+ @common_options
21
+ def check_cmd(
22
+ hostname: str,
23
+ service: str,
24
+ config: str,
25
+ verbose: int,
26
+ ) -> None:
27
+ """Force immediate service check."""
28
+ try:
29
+ cfg = load_config(config)
30
+ client = NagiosClient(cfg, verbose=verbose)
31
+
32
+ OutputFormatter.format_verbose(
33
+ f"Forcing check for {hostname}/{service}", verbose
34
+ )
35
+
36
+ success = client.force_service_check(hostname, service)
37
+
38
+ if success:
39
+ click.echo(f"Force check submitted for {hostname}/{service}")
40
+ else:
41
+ click.echo(f"Failed to submit force check for {hostname}/{service}")
42
+
43
+ except Exception as e:
44
+ handle_error(e, verbose)
45
+
46
+ @main_group.command("check-host")
47
+ @click.argument("hostname")
48
+ @common_options
49
+ def check_host_cmd(
50
+ hostname: str,
51
+ config: str,
52
+ verbose: int,
53
+ ) -> None:
54
+ """Force immediate host check."""
55
+ try:
56
+ cfg = load_config(config)
57
+ client = NagiosClient(cfg, verbose=verbose)
58
+
59
+ OutputFormatter.format_verbose(f"Forcing check for host {hostname}", verbose)
60
+
61
+ success = client.force_host_check(hostname)
62
+
63
+ if success:
64
+ click.echo(f"Force check submitted for host {hostname}")
65
+ else:
66
+ click.echo(f"Failed to submit force check for host {hostname}")
67
+
68
+ except Exception as e:
69
+ handle_error(e, verbose)
@@ -0,0 +1,57 @@
1
+ """Hosts command for CLI."""
2
+
3
+ import json
4
+ from typing import Any
5
+
6
+ import click
7
+
8
+ from nagioscli.core.client import NagiosClient
9
+ from nagioscli.core.config import load_config
10
+
11
+ from ..decorators import common_options, output_options
12
+ from ..handlers import OutputFormatter, handle_error
13
+
14
+
15
+ def register_hosts_commands(main_group: Any) -> None:
16
+ """Register hosts commands with the main CLI group."""
17
+
18
+ @main_group.command("hosts")
19
+ @common_options
20
+ @output_options
21
+ def hosts_cmd(
22
+ config: str,
23
+ verbose: int,
24
+ output_json: bool,
25
+ quiet: bool,
26
+ ) -> None:
27
+ """List all monitored hosts."""
28
+ try:
29
+ cfg = load_config(config)
30
+ client = NagiosClient(cfg, verbose=verbose)
31
+
32
+ OutputFormatter.format_verbose(f"Querying hosts from {cfg.url}", verbose)
33
+
34
+ hosts = client.get_all_hosts()
35
+
36
+ if output_json:
37
+ output = [
38
+ {
39
+ "host": h.name,
40
+ "status": h.status,
41
+ "status_text": OutputFormatter.format_host_status(h.status),
42
+ }
43
+ for h in hosts
44
+ ]
45
+ click.echo(json.dumps(output, indent=2))
46
+ elif quiet:
47
+ for h in hosts:
48
+ click.echo(h.name)
49
+ else:
50
+ for h in hosts:
51
+ status_text = OutputFormatter.format_host_status(h.status)
52
+ click.echo(f"{status_text:12} {h.name}")
53
+
54
+ click.echo(f"\nTotal: {len(hosts)} host(s)")
55
+
56
+ except Exception as e:
57
+ handle_error(e, verbose)