关于 Nagios MCP
Nagios MCP 是面向 Nagios Core Web 客户端的 MCP 服务,通过 Nagios CGI 二进制文件读取主机、服务、告警、进程和配置信息。
主要功能
- 01查询主机和服务状态
- 02检查告警及未处理问题
- 03查看健康摘要和程序状态
- 04读取对象列表与配置
- 05查看依赖项、联系人、注释和停机时间
适用场景
- 01检查受监控主机的状态
- 02查看服务告警和未解决问题
- 03检查 Nagios 对象配置
- 04查看依赖关系和计划停机
MCP 相关
通过 `statusjson.cgi` 和 `objectjson.cgi`,向 MCP 客户端提供 Nagios Core 状态与配置查询工具。默认使用 STDIO,也可通过 SSE 传输运行。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
服务地址
http://localhost:8000/sse一键复制安装命令
Claude CodeTerminal
claude mcp add --transport http nagios http://localhost:8000/sseCursor.cursor/mcp.json
{"mcpServers":{"nagios":{"type":"http","url":"http://localhost:8000/sse"}}}在 Cursor 中打开VS Code.vscode/mcp.json
{"servers":{"nagios":{"type":"http","url":"http://localhost:8000/sse"}}}在 VS Code 中打开Claude Desktopclaude_desktop_config.json
{"mcpServers":{"nagios":{"type":"http","url":"http://localhost:8000/sse"}}}Windsurf~/.codeium/windsurf/mcp_config.json
{"mcpServers":{"nagios":{"serverUrl":"http://localhost:8000/sse"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
工具
详细介绍
nagios-mcp
用于 Nagios Core 的 MCP 服务。
此服务由我们为 Nagios Core Web 客户端构建。
服务代码可在此处找到。
该服务使用 Nagios 文件夹中 cgi-bin 或 sbin 文件夹里的 CGI 二进制文件。
更具体地说,它使用 statusjson.cgi 和 objectjson.cgi 文件来提供状态和配置工具。
安装方法:
设置
- 安装 PyPI 软件包
# Using pip
pip install nagios-mcp # or pipx install nagios-mcp
# Using uv (Recommended)
uv tool install nagios-mcp
- 创建配置文件
创建一个
nagios_config.yaml或nagios_config.json文件,并填入下方给出的配置参数。
nagios_url: "http://localhost/nagios"
nagios_user: "your_nagios_core_username"
nagios_pass: "your_nagios_core_password"
ca_cert_path: "path_to_your_ssl_cert" # if the url is https, otherwise leave it empty ("")
启动 SSE 服务
- MCP 服务默认使用 STDIO 传输。如果不需要 SSE 传输,可以跳过此部分。
- 命令:
uvx nagios-mcp --config NAGIOS_CONFIG_FILE --transport sse --host localhost --port 8000
用于 Claude Desktop
- 官方设置指南
- 要在 Claude Desktop 中进行设置,请转到
Settings->Developer->Edit Config。也可以直接修改配置文件:- MacOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- MacOS:
- 在配置文件中添加以下代码块:
{
"mcpServers": {
"nagios": {
"command": "uvx",
"args": [
"nagios-mcp",
"--config",
"PATH_TO_THE_NAGIOS_CONFIG_FILE",
],
},
},
}
- 对于 SSE 传输:
{
"mcpServers": {
"nagios": {
"url": "http://localhost:8000/sse" # change this if you are using different port
}
}
}
用于 Cursor
{
"mcpServers": {
"nagios": {
"command": "uvx",
"args": [
"nagios-mcp",
"--config", "PATH_TO_THE_NAGIOS_CONFIG_FILE"
],
}
}
}
- 对于 SSE 传输:
{
"mcpServers": {
"nagios": {
"url": "http://localhost:8000/sse" # change this if you are using different port
}
}
}
用于 Windsurf
{
"mcpServers": {
"nagios": {
"command": "uvx",
"args": [
"nagios-mcp",
"--config", "PATH_TO_THE_NAGIOS_CONFIG_FILE"
],
}
}
}
- 对于 SSE 传输:
{
"mcpServers": {
"nagios": {
"serverUrl": "http://localhost:8000/sse" # change this if you are using different port
}
}
}
用于 Cline
- 官方设置指南
- 要在 Cline 中设置服务,请转到
MCP Servers->Installed->Configure MCP Servers,这将打开cline_mcp_settings.json文件。将以下代码块添加到文件中。
{
"mcpServers": {
"nagios": {
"command": "uvx",
"args": [
"nagios-mcp",
"--config", "PATH_TO_THE_NAGIOS_CONFIG_FILE"
],
}
}
}
- 对于 SSE 传输:
{
"mcpServers": {
"nagios": {
"url": "http://localhost:8000/sse" # change this if you are using different port
}
}
}
用于 5ire
5ire 是另一个 MCP 客户端。要在 5ire 中进行设置,请转到 Tools -> New,并添加以下配置。
- 工具键:
Nagios - 名称:
NagiosMCP - 命令:
uvx nagios-mcp --config PATH_TO_THE_NAGIOS_CONFIG_FILE
工具列表:
| 工具名称 | 工具描述 |
|---|---|
get_host_status | 检索所有主机或特定主机的状态。 |
get_service_status | 使用 statusjson.cgi 检索服务状态。 |
get_alerts | 检索当前存在问题的主机和服务状态(警报)。 |
get_program_status | 从 statusjson.cgi 检索 Nagios Core 程序状态。 |
get_hosts_in_group_status | 检索特定主机组中所有主机的状态。 |
get_services_in_group_status | 检索特定服务组中所有服务的状态。 |
get_services_on_host_in_group_status | 检索特定主机组中所有服务的状态。 |
get_overall_health_summary | 检索所有主机和服务的整体运行状况摘要。 |
get_unhandled_problems | 检索所有主机和服务中尚未处理的问题。 |
get_object_list_config | 检索对象类型(如 "hosts"、"services"、"hostgroups" 等)的配置列表。 |
get_single_object_config | 检索单个特定对象的配置。 |
get_host_dependencies | 检索指定主机的主机依赖关系。 |
get_service_dependencies | 检索指定主机的服务依赖关系。 |
get_contacts_for_object | 检索需要通知对象的联系人列表。 |
get_comments | 根据主机和服务检索注释。 |
get_comment_by_id | 检索指定评论 ID 对应的注释。 |
get_downtimes | 检索 Nagios 主机进程中计划停机的信息。 |
get_nagios_process_info | 返回 Nagios 进程的信息。(get_program_status 函数的别名) |
- 目前所有工具都使用 GET 请求。其他实用工具以及需要 POST 请求的工具将很快推出。
MCP 服务如何工作?
- Nagios Core Web 客户端通常托管在
http://YOUR_HOST/nagios/ - MCP 服务使用 CGI 二进制文件读取进程和服务的详细信息,这些文件位于 Nagios 主目录的
cgi-bin或sbin子目录中。 - 状态工具和配置工具分别使用
cgi-bin/statusjson.cgi和cgi-bin/objectjson.cgi文件来检索信息。
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。