diff --git a/defaults/main.yml b/defaults/main.yml index 2c66906..a5698a8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,7 +2,7 @@ # for check_mk you should set at least opn_packages: - bash - - ipmitool + - freeipmi - libstatgrab - dmidecode @@ -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 diff --git a/files/check_mk_agent-freeipmi.p0 b/files/check_mk_agent-freeipmi.p0 new file mode 100644 index 0000000..d18e87a --- /dev/null +++ b/files/check_mk_agent-freeipmi.p0 @@ -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 '<<>>' ++ 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. diff --git a/tasks/main.yml b/tasks/main.yml index 3fc3d17..af971c4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 }}"