问题描述
我遵循了本指南:
已经在服务器(Debian 9)上运行了 pnp4nagios。但我不能再进一步了,忙了好几个星期试图解决这个问题。
我被困在这一点上:
验证 Nagflux 是否正常工作
执行以下查询以验证 InfluxDB 正在填充 Nagios 性能数据:
curl -G "http://localhost:8086/query?db=nagflux&pretty=true" --data-urlencode "q=show series"
当我执行该命令时,我得到:
{
"results": [
{}
]
}
已经在另一个发行版 (CentOS 8) 上这样做了,仍然没有结果。
但是当我执行这个命令时(在文档的前面)
curl -G "http://localhost:8086/query?pretty=true" --data-urlencode "q=show databases"
这有效:
{
"results": [
{
"series": [
{
"name": "databases","columns": [
"name"
],"values": [
[
"_internal"
],[
"nagflux"
]
]
}
]
}
]
}
我可以在 Grafana 中成功添加 InfluxDB 数据源,但是当我尝试从“FROM”字段中选择它时我无法选择任何数据。
它只显示:
所以我很好奇我做错了什么,通常 Nagios 支持的文档效果很好。
非常感谢您阅读我的问题:)
解决方法
由于您已经安装了 PNP4Nagios,https://support.nagios.com/kb/article/nagios-core-using-grafana-with-pnp4nagios-803.html 将是更适合您的解决方案。
/usr/local/nagios/etc/nagios.cfg 有不同的 host_perfdata_file_processing_command 当您尝试填充 influxdb(使用 nagflux)而不是使用 Grafana 和 PNP4Nagios 时。
,您不需要另一台服务器。我有 Nagios Core、InfluxDB、Nagflux、Histou 和 Grafana 在同一台机器上工作。
而且您不必卸载 PNP4Nagios,只需在启动时停止并禁用服务:systemctl stop npcd.service && systemctl disable npcd.service
。
之后,您必须根据:https://support.nagios.com/kb/article/nagios-core-performance-graphs-using-influxdb-nagflux-grafana-histou-802.html#Nagios_Command_Config 修改 nagios.cfg
以更改 host_perfdata_file_processing_command value
,并更改 *_perfdata_file_template
的格式。
然后在 process-host-perfdata-file-nagflux
中定义 process-service-perfdata-file-nagflux
和 commands.cfg
命令。
如果你确实像上面描述的那样,一分钟后你应该会在你的 nagflux 数据库中看到变化。 安装 influxdb-client,然后:
influx
use nagflux
SELECT * FROM METRICS
您应该会看到您的数据库正在加载 :)