Skip to content

Commit 2c7c23e

Browse files
authored
Merge pull request #83 from tigerblue77/80-add-docker-healthcheck-to-readmemd
Added Docker healthcheck to README.md
2 parents cf69481 + 10d8be6 commit 2c7c23e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ RUN apt-get update
77
RUN apt-get install ipmitool -y
88

99
ADD functions.sh /app/functions.sh
10+
ADD healthcheck.sh /app/healthcheck.sh
1011
ADD Dell_iDRAC_fan_controller.sh /app/Dell_iDRAC_fan_controller.sh
1112

12-
RUN chmod 0777 /app/functions.sh /app/Dell_iDRAC_fan_controller.sh
13+
RUN chmod 0777 /app/functions.sh /app/healthcheck.sh /app/Dell_iDRAC_fan_controller.sh
1314

1415
WORKDIR /app
1516

17+
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/app/healthcheck.sh" ]
18+
1619
# you should override these default values when running. See README.md
1720
#ENV IDRAC_HOST 192.168.1.100
1821
ENV IDRAC_HOST local

healthcheck.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Enable strict bash mode to stop the script if an uninitialized variable is used, if a command fails, or if a command with a pipe fails
4+
# Not working in some setups : https://github.com/tigerblue77/Dell_iDRAC_fan_controller/issues/48
5+
# set -euo pipefail
6+
7+
source functions.sh
8+
9+
# Check if the iDRAC host is set to 'local' or not then set the IDRAC_LOGIN_STRING accordingly
10+
if [[ $IDRAC_HOST == "local" ]]
11+
then
12+
# Check that the Docker host IPMI device (the iDRAC) has been exposed to the Docker container
13+
if [ ! -e "/dev/ipmi0" ] && [ ! -e "/dev/ipmi/0" ] && [ ! -e "/dev/ipmidev/0" ]; then
14+
echo "/!\ Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0, check that you added the device to your Docker container or stop using local mode. Exiting." >&2
15+
exit 1
16+
fi
17+
IDRAC_LOGIN_STRING='open'
18+
else
19+
echo "iDRAC/IPMI username: $IDRAC_USERNAME"
20+
echo "iDRAC/IPMI password: $IDRAC_PASSWORD"
21+
IDRAC_LOGIN_STRING="lanplus -H $IDRAC_HOST -U $IDRAC_USERNAME -P $IDRAC_PASSWORD"
22+
fi
23+
24+
ipmitool -I $IDRAC_LOGIN_STRING sdr type temperature

0 commit comments

Comments
 (0)