radiorabe / rabe-zabbix

Collection of various Zabbix templates and helper scripts created or used by Radio Bern RaBe
https://radiorabe.github.io/rabe-zabbix/
GNU Affero General Public License v3.0
106 stars 62 forks source link

ipmi-sensor-discovery.sh: 47: set: Illegal option -o pipefail #41

Closed xenadmin closed 5 years ago

xenadmin commented 6 years ago

Hallo, discovered your work on share.zabbix.com. I downloaded the script and tried to run if from shell, but it fails immediately. Any idea why this happens? Thank you!

EDIT: I'm on Debian 9 Stretch amd64 with Zabbix 3.4.x If I comment out line 47 the script seems to work.

paraenggu commented 6 years ago

In what shell (and version) are you starting this script?

echo "Default shell is: ${SHELL}"
echo "Current shell is: ${0}"
xenadmin commented 6 years ago

root@zabprox:/usr/lib/zabbix/externalscripts# echo "Default shell is: ${SHELL}" Default shell is: /bin/bash root@zabprox:/usr/lib/zabbix/externalscripts# echo "Current shell is: ${0}" Current shell is: -bash

paraenggu commented 6 years ago

OK, at least root is using bash as the default shell, which is supposed to support -o pipefail. The script uses #!/bin/bash as the shebang, which should execute the script with bash anyway.

Can you please try the following steps:

  1. Run set -o pipefail from a bash prompt and check if you also get the Illegal option error message
  2. Add the following lines to the script (right after the comment header) and let it execute by the Zabbix-Server/Proxy (as the zabbix user)
echo "0:            ${0}"                      > /tmp/debug.out
echo "SHELL:        ${SHELL}"                 >> /tmp/debug.out
echo "proc-exe:     $(readlink /proc/$$/exe)" >> /tmp/debug.out
echo "SHELLOPTS:    ${SHELLOPTS}"             >> /tmp/debug.out
echo "BASHOPTS:     ${BASHOPTS}"              >> /tmp/debug.out
echo "BASH_VERSION: ${BASH_VERSION}"          >> /tmp/debug.out
  1. Post the output of /tmp/debug.out
xenadmin commented 6 years ago

Sorry, I forgot you! I will update this comment tomorrow! Keep up the great work, I will come back to you and your IPMI collection asap!

paraenggu commented 5 years ago

@xenadmin is this issue still relevant to you? Otherwise I would close it within the next days.

Thanks for your feedback.

xenadmin commented 5 years ago

I think this can be closed. I switched over to the official SNMP templates (https://www.zabbix.com/documentation/4.0/manual/introduction/whatsnew400#new_templates) and adjusted them to my needs. Many thanks for your help! If I should ever take a look again at IPMI, I will remember you!