46 lignes
2,1 Kio
Bash
46 lignes
2,1 Kio
Bash
#!/bin/bash
|
||
|
||
# INSTALL
|
||
#apt install freeipmi-tools ipmitool
|
||
# foutre ce script dans une tache cron qui se lance toutes les 15mn
|
||
|
||
# CONFIG
|
||
# dossier dans lequel la partie php est présente
|
||
dossier="/var/www/html/ipmiweb"
|
||
# l'adresse IP... MI
|
||
ipmid=192.168.1.19
|
||
# le mot de passe IPMI
|
||
ipmipass="My fuckin secure P4ssW0rd! (lol)"
|
||
|
||
cd ${dossier} || exit 1
|
||
echo "lst"
|
||
ipmitool -I lanplus -H ${ipmid} -U root -P ${ipmipass} sdr list full > ${dossier}/ipmi-lst.log
|
||
while [ ! -s ${dossier}/ipmi-lst.log ]
|
||
do
|
||
ipmitool -I lanplus -H ${ipmid} -U root -P ${ipmipass} sdr list full > ${dossier}/ipmi-lst.log
|
||
done
|
||
# Temp | 41 degrees C | ok
|
||
#Fan 4A | 0 RPM | cr
|
||
echo '<table class="ipmi-list">' > ${dossier}/ipmi-lst.html
|
||
echo '<tr><th>Sonde</th><th>Valeur</th><th>État</th></tr>' >> ${dossier}/ipmi-lst.html
|
||
while read INPUT ; do echo "<tr><td>${INPUT//|/</td><td>}</td></tr>" ; done < ${dossier}/ipmi-lst.log >> ${dossier}/ipmi-lst.html
|
||
echo '</table>' >> ${dossier}/ipmi-lst.html
|
||
|
||
echo "events"
|
||
ipmitool -I lanplus -H ${ipmid} -U root -P ${ipmipass} sel list last 10 > ${dossier}/ipmi-events.log
|
||
# 1 | 06/06/2019 | 21:26:54 | Event Logging Disabled #0x51 | Log area reset/cleared | Asserted
|
||
echo '<table class="ipmi-events">' > ${dossier}/ipmi-events.html
|
||
echo '<tr><th>ID</th><th>Date</th><th>Heure</th><th>Type</th><th>Évènement</th><th>Confirmation</th></tr>' >> ${dossier}/ipmi-events.html
|
||
while read INPUT ; do echo "<tr><td>${INPUT//|/</td><td>}</td></tr>" ; done < ${dossier}/ipmi-events.log >> ${dossier}/ipmi-events.html
|
||
echo '</table>' >> ${dossier}/ipmi-events.html
|
||
|
||
echo "errors"
|
||
ipmitool -I lanplus -H ${ipmid} -U root -P ${ipmipass} sdr list event > ${dossier}/ipmi-errors.log 2>&1
|
||
# ???
|
||
|
||
echo "temp"
|
||
echo "$(date +'%s')000,$(ipmitool -I lanplus -H ${ipmid} -U root -P ${ipmipass} sdr type temperature | grep degrees | sed 's/.*|//' | sed 's/[^0-9-]*//g')" >> ${dossier}/temperature-full.log
|
||
# Ambient Temp | 0Eh | ok | 7.1 | 13 degrees C -> 13 degrees C -> 13
|
||
tail -35040 ${dossier}/temperature-full.log > ${dossier}/temperature.log
|
||
# (script lancé toutes les 15mn): 60÷15 (1h) × 24 (1j) × 365 (1an) = 35040
|
||
chmod -R a+rw ${dossier}
|