prometheus-community / ipmi_exporter

Remote IPMI exporter for Prometheus
MIT License
459 stars 131 forks source link

collector_cmd seems to force /usr/sbin prefix #199

Closed growly closed 2 months ago

growly commented 2 months ago

Not sure why this is happening, whether it's to do with how the user is set up (PATH) or whether it's part of this codebase, but in trying to force sudo collection on Debian 12.0 it seems as if ipmi_exporter tries to force /usr/sbin/ as a prefix for the command.

Here's my ipmi_local.yml:

modules:
        default:
                # Available collectors are bmc, ipmi, chassis, dcmi, sel, and sm-lan-mode
                collectors:
                - bmc
                - ipmi
                - dcmi
                - chassis
                - sel
                # Got any sensors you don't care about? Add them here.
                exclude_sensor_ids:
                - 2
                - 29
                - 32
                collector_cmd:
                  bmc: sudo
                  ipmi: sudo
                  dcmi: sudo
                  chassis: sudo
                  sel: sudo
                custom_args:
                  bmc:
                  - "/usr/sbin/bmc-info"
                  ipmi:
                  - "/usr/sbin/ipmimonitoring"
                  sel:
                  - "/usr/sbin/ipmi-sel"
                  dcmi:
                  - "/usr/sbin/ipmi-dcmi"
                  chassis:
                  - "/usr/sbin/ipmi-chassis"
                  sel:
                  - "/usr/sbin/ipmi-sel"

With this I get the following error deep in syslog: Failed to collect SEL data" target=[local] error="error running /usr/sbin/sudo: fork/exec /usr/sbin/sudo: no such file or directory:

Fair enough, my sudo lives in /usr/bin and there's no link from /usr/sbin.

So I tried making it an absolute path:

                collector_cmd:
                  ipmi: /usr/bin/sudo

But then I get this!

Failed to collect sensor data" target=[local] error="error running /usr/sbin/usr/bin/sudo: fork/exec /usr/sbin/usr/bin/sudo: no such file or directory: 

The fix is to add a symlink from /usr/sbin/sudo to /usr/bin/sudo, but that's not gonna work out of the box. Seems like this is surprising behaviour for specifying a an absolute command.

Don't have a moment to find the culprit in the codebase so sorry I can't do more of my own homework. Thought I'd report the issue anyway.

bitfehler commented 2 months ago

This is caused by a patch that Debian applies, see #153 for all the details if you care :slightly_smiling_face:

I think the workaround would currently be to start the exporter with --freeipmi.path=/usr/bin and use just sudo in the config file. The fact that the prefix gets added to an absolute path seems a bit silly indeed, I'll take a look at that.

bitfehler commented 2 months ago

In the next release, your totally correct approach of setting the collector_cmd to /usr/bin/sudo should also work.

growly commented 2 months ago

tysm 🙏