snmpmibcollectd

What is the cause of "collectd - snmp.conf": syntax error, unexpected EOL. Starting when new MIB is used


There are many problems similar to mine but I can't find the right solutions for mine.

I am currently working on a CentOS 7 machine with collectd version 5.8.

The collectd.service won't start due to an error in the configuration file. The configuration file is located in /etc/collectd.d/snmp.conf and is called correctly from the collectd.conf file. My error is the following:

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.


I can't find anything out of the ordinary in my code, maybe you guys can find the problem.

My snmp.conf file, where the error occurs, goes as follows:

<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>

The error occurs on line 19, this is the line where I use an alternative MIB, the MIB is located in /usr/share/snmp/mibs/ and I've used it before.

Selinux is currently in permissive mode so this can't be the cause of the problem. Also the file permissions of the MIB is the same as the ones of every other MIB.


Solution

  • Okey, forgot the closing greater-than sign at the top of the snmp configuration file. This wasn't my smartest move so far...

    Note for everyone getting this error: Almost always when this error occurs it's a simple typo/syntax mistake and doesn't always occur on the mentioned line. Most of the time it occurs on one of the previous lines of the mentioned file.