Skip to content

Commit

Permalink
issue #24 - use freeipmi
Browse files Browse the repository at this point in the history
  • Loading branch information
zerwes committed Dec 18, 2023
1 parent 7cd63ee commit 77557e2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# for check_mk you should set at least
opn_packages:
- bash
- ipmitool
- freeipmi
- libstatgrab
- dmidecode

Expand All @@ -28,6 +28,10 @@ opn_check_mk_path: /usr/local/sbin/check_mk_agent
opn_check_mk_lib_dir: /usr/local/lib/check_mk_agent
opn_check_mk_port: 6556

# patches for the checkmk agent to apply
opn_check_mk_patches:
- check_mk_agent-freeipmi.p0 # https://github.com/Rosa-Luxemburgstiftung-Berlin/ansible-opnsense-checkmk/issues/24

# list of plugins and local checks to install
opn_check_mk_local_checks:
- gateways_status.py
Expand Down
26 changes: 26 additions & 0 deletions files/check_mk_agent-freeipmi.p0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- check_mk_agent 2023-12-15 09:32:07.194344000 +0100
+++ /usr/local/sbin/check_mk_agent 2023-12-15 10:25:58.113316000 +0100
@@ -497,6 +497,23 @@
sed -e 's/ *| */|/g' -e "s/ /_/g" -e 's/_*$//' -e 's/|/ /g' |
grep -v -E '^[^ ]+ na ' |
grep -v ' discrete '
+ elif inpath ipmi-sensors; then
+ echo '<<<ipmi_sensors>>>'
+ if ipmi-sensors --help | grep -q legacy-output; then
+ IPMI_FORMAT="--legacy-output"
+ else
+ IPMI_FORMAT=""
+ fi
+ if ipmi-sensors --help | grep -q " \-\-groups"; then
+ IPMI_GROUP_OPT="-g"
+ else
+ IPMI_GROUP_OPT="-t"
+ fi
+ for class in Temperature Power_Unit Fan; do
+ ipmi-sensors ${IPMI_FORMAT} --sdr-cache-directory /var/cache ${IPMI_GROUP_OPT} "${class}" | sed -e 's/ /_/g' -e 's/:_/ /g' -e 's@ \([^(]*\)_(\([^)]*\))@ \2_\1@'
+ # In case of a timeout immediately leave loop.
+ if [ $? = 255 ]; then break; fi
+ done
fi

# State of LSI MegaRAID controller via MegaCli.
9 changes: 9 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
- opn_install_check_mk
- checkmk_hostname is not defined

- name: apply patches
ansible.posix.patch:
src: "{{ item }}"
dest: "{{ opn_check_mk_path }}"
remote_src: false
with_items: "{{ opn_check_mk_patches | default([]) }}"
when:
- opn_install_check_mk

- name: create lib dirs
ansible.builtin.file:
path: "{{ opn_check_mk_lib_dir }}/{{ item }}"
Expand Down

0 comments on commit 77557e2

Please sign in to comment.