snmp_exporter service fails

2,108 views
Skip to first unread message

Ummekulsum Musekhan

unread,
Oct 13, 2021, 1:47:36 AM10/13/21
to Prometheus Users

Hi,

I have recently installed snmp_exporter generator, which is generating the snmp_exporter file.
But this service shows failed. I have tried to change the systemd file and give various paths. Also moved the snmp.yml file to different location but still service is failed Following is the output. Can any one help?

grafana:~# systemctl status snmp-exporter.service
● snmp-exporter.service - Prometheus SNMP Exporter Service
Loaded: loaded (/etc/systemd/system/snmp-exporter.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-10-12 13:07:18 +04; 8s ago
Process: 469550 ExecStart=/usr/local/bin/snmp_exporter --config.file=/usr/local/bin/snmp.yml (code=exited, status=203/EXEC)
Main PID: 469550 (code=exited, status=203/EXEC)

Oct 12 13:07:18 grafana systemd[1]: Started Prometheus SNMP Exporter Service.
Oct 12 13:07:18 grafana systemd[469550]: snmp-exporter.service: Failed to execute command: Exec format error
Oct 12 13:07:18 grafana systemd[469550]: snmp-exporter.service: Failed at step EXEC spawning /usr/local/bin/snmp_exporter: Exec format error
Oct 12 13:07:18 grafana systemd[1]: snmp-exporter.service: Main process exited, code=exited, status=203/EXEC
Oct 12 13:07:18 grafana systemd[1]: snmp-exporter.service: Failed with result 'exit-code'.

Brian Candler

unread,
Oct 13, 2021, 3:54:27 AM10/13/21
to Prometheus Users
"Exec format error" = the binary is invalid = there was a problem with how you built the binary.

I expect you'll get the same error running the binary directly at the command line: try
/usr/local/bin/snmp_exporter
and see if that gives a better error message.  Also see if "ldd /usr/local/bin/snmp_exporter" gives you any clues.

This is the sort of error you'd get if you built the binary to run on Linux but you're trying to run it on a Mac, for example.

Ummekulsum Musekhan

unread,
Oct 13, 2021, 4:05:41 AM10/13/21
to Prometheus Users
Hey,
Thanks for your response.

I have changed the systemd file, yet the same error.

grafana:~# systemctl status snmp-exporter.service
● snmp-exporter.service - Prometheus SNMP Exporter Service
     Loaded: loaded (/etc/systemd/system/snmp-exporter.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2021-10-13 12:02:03 +04; 11s ago
    Process: 683678 ExecStart=/usr/local/bin/snmp_exporter (code=exited, status=203/EXEC)
   Main PID: 683678 (code=exited, status=203/EXEC)

Oct 13 12:02:03 grafana systemd[1]: Started Prometheus SNMP Exporter Service.
Oct 13 12:02:03 grafana systemd[683678]: snmp-exporter.service: Failed to execute command: Exec format error
Oct 13 12:02:03 grafana systemd[683678]: snmp-exporter.service: Failed at step EXEC spawning /usr/local/bin/snmp_exporter: Exec format error
Oct 13 12:02:03 grafana systemd[1]: snmp-exporter.service: Main process exited, code=exited, status=203/EXEC
Oct 13 12:02:03 grafana systemd[1]: snmp-exporter.service: Failed with result 'exit-code'.

_________________

Initially I had installed snmp_exporter, but I was unable to get the instance up for my cisco switch (thought local host and snmp_exporter service was running and I was even able to do snmpwalk to my switch). So I removed it and then I installed snmp_exporter generator and that is generating the snmp_exporter file. But after installing this the service itself never came up. 








Brian Candler

unread,
Oct 13, 2021, 5:27:19 AM10/13/21
to Prometheus Users
This is nothing to do with systemd.

Type the following command at the shell prompt:

/usr/local/bin/snmp_exporter

Show what error it returns.  It will almost certainly tell you that the binary is bad.  If so, you either need to download or build a fresh snmp_exporter binary.

Ummekulsum Musekhan

unread,
Oct 13, 2021, 7:04:00 AM10/13/21
to Prometheus Users
This is the output

grafana:~# /usr/local/bin/snmp_exporter
/usr/local/bin/snmp_exporter: line 2: apcups:: command not found
/usr/local/bin/snmp_exporter: line 3: walk:: command not found
/usr/local/bin/snmp_exporter: line 4: -: command not found
/usr/local/bin/snmp_exporter: line 5: -: command not found
/usr/local/bin/snmp_exporter: line 6: -: command not found
/usr/local/bin/snmp_exporter: line 7: -: command not found
/usr/local/bin/snmp_exporter: line 8: -: command not found
/usr/local/bin/snmp_exporter: line 9: -: command not found
/usr/local/bin/snmp_exporter: line 10: -: command not found
/usr/local/bin/snmp_exporter: line 11: -: command not found
/usr/local/bin/snmp_exporter: line 12: -: command not found
/usr/local/bin/snmp_exporter: line 13: -: command not found
/usr/local/bin/snmp_exporter: line 14: -: command not found
/usr/local/bin/snmp_exporter: line 15: get:: command not found
/usr/local/bin/snmp_exporter: line 16: -: command not found
/usr/local/bin/snmp_exporter: line 17: -: command not found
/usr/local/bin/snmp_exporter: line 18: metrics:: command not found
/usr/local/bin/snmp_exporter: line 19: -: command not found
/usr/local/bin/snmp_exporter: line 20: oid:: command not found
/usr/local/bin/snmp_exporter: line 21: type:: command not found
/usr/local/bin/snmp_exporter: line 22: syntax error near unexpected token `('
/usr/local/bin/snmp_exporter: line 22: `    help: The time (in hundredths of a second) since the network management portion'


Brian Candler

unread,
Oct 13, 2021, 9:36:16 AM10/13/21
to Prometheus Users
It looks like you're replaced the snmp_exporter binary with the yaml file.  Try:

less /usr/local/bin/snmp_exporter

to look at the contents.

Possibly you meant to put the generated file into snmp_exporter.yml, but you replaced the snmp_exporter binary by mistake?

Ummekulsum Musekhan

unread,
Oct 14, 2021, 4:41:36 AM10/14/21
to Prometheus Users
Hi Brian,

Following is the output of less /usr/local/bin/snmp_exporter

# WARNING: This file was auto-generated using snmp_exporter generator, manual changes will be lost.
apcups:
  walk:
  - 1.3.6.1.2.1.2
  - 1.3.6.1.4.1.318.1.1.1.12
  - 1.3.6.1.4.1.318.1.1.1.2
  - 1.3.6.1.4.1.318.1.1.1.3
  - 1.3.6.1.4.1.318.1.1.1.4
  - 1.3.6.1.4.1.318.1.1.1.7.2
  - 1.3.6.1.4.1.318.1.1.10.2.3.2
  - 1.3.6.1.4.1.318.1.1.26.10.2.2
  - 1.3.6.1.4.1.318.1.1.26.4.3
  - 1.3.6.1.4.1.318.1.1.26.6.3
  - 1.3.6.1.4.1.318.1.1.26.8.3
  get:
  - 1.3.6.1.2.1.1.3.0
  - 1.3.6.1.4.1.318.1.1.1.8.1.0
  metrics:
  - name: sysUpTime
    oid: 1.3.6.1.2.1.1.3
    type: gauge
    help: The time (in hundredths of a second) since the network management portion
      of the system was last re-initialized. - 1.3.6.1.2.1.1.3
  - name: ifNumber
    oid: 1.3.6.1.2.1.2.1
    type: gauge
    help: The number of network interfaces (regardless of their current state) present
      on this system. - 1.3.6.1.2.1.2.1
  - name: ifIndex
    oid: 1.3.6.1.2.1.2.2.1.1
    type: gauge
    help: A unique value, greater than zero, for each interface - 1.3.6.1.2.1.2.2.1.1
    indexes:
    - labelname: ifIndex
      type: gauge
  - name: ifDescr
    oid: 1.3.6.1.2.1.2.2.1.2
    type: DisplayString
    help: A textual string containing information about the interface - 1.3.6.1.2.1.2.2.1.2
    indexes:
    - labelname: ifIndex


Ummekulsum Musekhan

unread,
Oct 14, 2021, 4:42:21 AM10/14/21
to Prometheus Users
Hi Brian,

Can you please help me sort this out.
How to change the binary file to its original form?

Brian Candler

unread,
Oct 14, 2021, 5:12:34 AM10/14/21
to Prometheus Users
This isn't really a question about prometheus any more, it's a question about system administration in general.  You've unfortunately overwritten one file (the snmp_exporter executable) with another file (a text YAML file).

There are snmp_exporter binaries for various architectures available from the project releases page: https://github.com/prometheus/snmp_exporter/releases

If you need help you with the downloading, unpacking, moving files into the right place and so on, then you should probably talk to a local system administrator who can work with you directly on this.
Reply all
Reply to author
Forward
0 new messages