Ive installed it in a docker using alpine thanks OP @IOT_Ninja
this guide assumes that you have a working Home Assistant & Mosquitto Broker
Create a folder for this to sit in and 2 sub folders
sudo mkdir /mnt/storage/docker/ipmi
sudo mkdir /mnt/storage/docker/ipmi/compose
sudo mkdir /mnt/storage/docker/ipmi/Dockerbuild
after this in cd into the Dockerbuild dir
cd /mnt/storage/docker/ipmi/Dockerbuild
once here do a git clone of this repo by running this command
git clone https://github.com/nehabhardwaj01/docker-cron .
once that is done you should a few files in your Dockerbuild folder
Dockerfile
entrypoint.sh
README.md
run.sh
we need to edit these to use alpine instead of ubuntu
so open up the dockerfile in notepadd++ or which ever text editor you use
#FROM ubuntu:16.04
FROM alpine:3.14.0
MAINTAINER Neha Bhardwaj
# Install cron
#RUN apt-get update && apt-get install -y cron
RUN apk update && apk add ipmitool mosquitto-clients bash
# Add files
ADD run.sh /run.sh
ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /run.sh /entrypoint.sh
ENTRYPOINT /entrypoint.sh
and paste this into to that file
then the same with entrypoint.sh
#!/bin/bash
# Start the run once job.
echo "Docker container has been started"
declare -p | grep -Ev 'BASHOPTS|BASH_VERSINFO|EUID|PPID|SHELLOPTS|UID' > /container.env
# Setup a cron schedule
echo "SHELL=/bin/bash
BASH_ENV=/container.env
* * * * * /run.sh >> /var/log/cron.log 2>&1
# This extra line makes it a valid cron" > scheduler.txt
crontab scheduler.txt
crond -f
if you are wanting it to run less then every minute you need to change the cron on line 11 use crontab.guru
and finally the run.sh
#!/bin/bash
SHELL=/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin
MQTT_IP='<MQTT SERVER/HA IP ADDRESS>'
MQTT_USER='<MQTT USERNAME>'
MQTT_PW='<MQTT PASSWORD>'
IPMI_IP='<IPMI IP ADDRESS>'
IPMI_USER='<IPMI USERNAME>'
IPMI_PW='<IPMI PASSWORD>'
NUMBER_OF_SENSORS='14'
CUT_COLUMN='5'
TOPIC[1]='server_cpu1_temp'
TOPIC[2]='server_cpu2_temp'
TOPIC[3]='server_system_temp'
TOPIC[4]='server_peripheral_temp'
TOPIC[5]='server_pch_temp'
TOPIC[6]='server_10g_temp'
TOPIC[7]='server_fan1'
TOPIC[8]='server_fan2'
TOPIC[9]='server_fan3'
TOPIC[10]='server_fan4'
TOPIC[11]='server_fan5'
TOPIC[12]='server_fan6'
TOPIC[13]='server_fana'
TOPIC[14]='server_fanb'
SDR[1]='3.1'
SDR[2]='3.2'
SDR[3]='7.1'
SDR[4]='7.2'
SDR[5]='7.3'
SDR[6]='7.4'
SDR[7]='29.1'
SDR[8]='29.2'
SDR[9]='29.3'
SDR[10]='29.4'
SDR[11]='29.5'
SDR[12]='29.6'
SDR[13]='29.7'
SDR[14]='29.8'
for i in $(eval echo "{1..$NUMBER_OF_SENSORS}")
do
PAYLOAD=$(ipmitool -I lanplus -H "$IPMI_IP" -U "$IPMI_USER" -P "$IPMI_PW" sdr entity "${SDR[$i]}"|cut -d '|' -f$CUT_COLUMN|awk '{print $1}')
# mosquitto_pub -r -t "${TOPIC[$i]}" -m "$PAYLOAD" -h "$MQTT_IP" -u "$MQTT_USER" -P "$MQTT_PW"
mosquitto_pub -r -t "${TOPIC[$i]}" -m "$PAYLOAD" -h "$MQTT_IP"
done
in this file you will need to change a few things depending on your set up
i dont run a MQTT user name and password if you do you will need to # line 43 out and re use line 42
if you dont use an MQTT username and password also make sure to # lines 4 & 5
if you wish to use more sensors makes sure to change line 9 , and then adding the extra TOPICS and SDR which match your
to get your IPMI Print out of the sensors you can run the same command as in the OP
ipmitool -I lanplus -H <IPMI IP ADDRESS> -U <IPMI USERNAME> -P <IPMI PASSWORD> sdr elist full
You should get something like the following, showing the readout from your various motherboard sensors and their corresponding IPMI data. Mine follows the format of:
Sensor | Address | Status | Sensor Data Record (SDR) Entity | Sensor Value
CPU Temp | 01h | ok | 3.1 | 36 degrees C
PCH Temp | 0Ah | ok | 7.3 | 49 degrees C
System Temp | 0Bh | ok | 7.1 | 28 degrees C
Peripheral Temp | 0Ch | ok | 7.2 | 39 degrees C
VcpuVRM Temp | 10h | ok | 8.1 | 38 degrees C
VmemABVRM Temp | 12h | ok | 8.2 | 32 degrees C
VmemCDVRM Temp | 13h | ok | 8.3 | 27 degrees C
FAN1 | 41h | ok | 29.1 | 4100 RPM
FAN2 | 42h | ns | 29.2 | No Reading
FAN3 | 43h | ok | 29.3 | 2400 RPM
FAN4 | 44h | ok | 29.4 | 2400 RPM
FAN5 | 45h | ok | 29.5 | 2400 RPM
FANA | 47h | ns | 29.7 | No Reading
FANB | 48h | ok | 29.8 | 2500 RPM
FANC | 49h | ok | 29.9 | 2600 RPM
use this information from your server to adjust the run.sh
if you dont have ipmitool installed you will need to run
sudo apt install ipmitool
when you have edited an saved these files you need to build the image ready to use
to do this make sure you are in the Dockerbuild dir & run the following command
sudo docker build . -t psp\ipmi_mqtt
make sure to change the name to something you want after the -t
this will build you and image to use
then to create an docker-compose.yml to use
run
sudo touch /mnt/storage/docker/ipmi/compose/docker-compose.yml
then open this file up in your file editor and paste the following
version: "3"
services:
ipmimqtt:
image: psp/ipmi_mqtt
container_name: ipmi_mqtt
be sure to change the image name to whatever you called it you can also call the container whatever you wish
once you have done this you are ready to build the container
you can do this by running the following command from inside the compose dir
docker-compose up -d
this will create and start the container assuming everything is correct
you can run docker ps to see a list of running containers and hopefully its there
all thats left to do is create the MQTT sensors in Home Assistant which can be done the same as the OP makes sure to match up from your run.sh file though
make sure to change your file paths in any of the commands above to match your system
thanks @nayneyT for the help
PATT