snmp - “collectd - snmp.conf”的原因是什么:语法错误,意外 EOL。使用新 MIB 时开始
问题描述
有很多与我类似的问题,但我找不到适合我的解决方案。
我目前正在使用 collectd 5.8 版的 CentOS 7 机器。
由于配置文件中的错误,collectd.service 不会启动。配置文件位于该文件中/etc/collectd.d/snmp.conf
并从该文件中正确调用collectd.conf
。我的错误如下:
Mar 30 01:16:24 localhost.localdomain collectd[18779]: Parse error in file `/etc/collectd.d/snmp.conf', line 19 near `<newline>': syntax error, unexpected EOL
Mar 30 01:16:24 localhost.localdomain collectd[18779]: yyparse returned error #1
Mar 30 01:16:24 localhost.localdomain collectd[18779]: configfile: Cannot read file `/etc/collectd.d/snmp.conf'.
Mar 30 01:16:24 localhost.localdomain collectd[18779]: Unable to read config file /etc/collectd.conf.
Mar 30 01:16:24 localhost.localdomain collectd[18779]: Error: Reading the config file failed!
Mar 30 01:16:24 localhost.localdomain collectd[18779]: Read the logs for details.
Mar 30 01:16:24 localhost.localdomain systemd[1]: collectd.service: main process exited, code=exited, status=1/FAILURE
Mar 30 01:16:24 localhost.localdomain systemd[1]: Failed to start Collectd statistics daemon.
我在我的代码中找不到任何异常之处,也许你们能找到问题所在。
我的 snmp.conf 文件发生错误的地方如下:
<Plugin snmp
<Data "if_octets">
Type "if_octets"
Table true
Instance "IF-MIB::ifDescr"
Values "IF-MIB::ifOutOctets" "IF-MIB::ifInOctets"
</Data>
<Data "if_speed">
Type "bitrate"
Table true
Instance "IF-MIB::ifDescr"
Values "IF-MIB::ifSpeed"
</Data>
<Data "temperature">
Type "temperature"
Table false
Instance "device"
Scale 0.1
Values "MIKROTIK-MIB::mtxrHlTemperature.0"
</Data>
<Data "processorTemperature">
Type "temperature"
Table false
Instance "processor"
Scale 0.1
Values "MIKROTIK-MIB::mtxrHlProcessorTemperature.0"
</Data>
<Data "fanspeed">
Type "fanspeed"
Table false
Type "fanspeed"
Table false
Instance "fan_speed"
Values "MIKROTIK-MIB::mtxrHlFanSpeed1.0"
</Data>
<Host "best_server_ever">
Address 127.0.0.1
Version 2
Community "public"
Collect "if_speed" "temperature" "processorTemperature" "fanspeed"
Interval 120
Timeout 10
Retries 1
</Host>
<Host "smallest_server_ever">
Address 127.0.0.1
Version 2
Community "public"
Collect "if-speed" "temperature" "processorTemperature" "fanspeed"
Interval 120
Timeout 10
Retries 1
</Host>
</Plugin>
错误发生在第 19 行,这是我使用替代 MIB 的行,该 MIB 位于/usr/share/snmp/mibs/
并且我以前使用过它。
Selinux 当前处于许可模式,因此这不是问题的原因。此外,MIB 的文件权限与其他所有 MIB 的文件权限相同。
解决方案
好的,忘记了 snmp 配置文件顶部的关闭大于号。到目前为止,这不是我最聪明的举动……
收到此错误的每个人的 注意事项:几乎总是在发生此错误时,它是一个简单的拼写错误/语法错误,并不总是出现在提到的行上。大多数情况下,它发生在上述文件的前几行之一。
推荐阅读
- c# - 如何从视图模型中的字符串列表构建字符串?
- c# - 在具有用于测试的内部设置器的类中设置属性(C#)
- javascript - How to display data form html type radio and select using javascript?
- php - 如何使用 php (laravel) 分形转换模型以获取按条件分组的数据?
- mariadb - MariaDB,删除条件不起作用
- python - SAP 通过 Python (PyRFC) 加载数据
- node.js - 如何实现一个节点 js 查询,该查询应该显示来自两个不同表的特定模型的数据?我正在使用环回框架
- android - Android 9 ResolvableApiException onActivityResult 有 resultCode 0 RESULT_CANCELED
- angularjs - 任何改变路线的方法|| angularJS中的指令状态?
- oracle - Oracle 12.2 中的标识符太长问题