Created
June 29, 2020 05:32
-
-
Save sigmaprojects/26c94a6470d9be56c9489edf9bb4cd40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# comments | |
# | |
cd /tmp | |
tempsFile=/tmp/systemps.txt | |
name=ESXI-Olympus | |
description=SigmaProjects-VMWare-Server | |
# get the full path to wget | |
httpCMD=$(which wget) | |
# Put all the temps in a file | |
esxcli hardware ipmi sdr list | grep Temp > $tempsFile | |
# start parsing the file and assigning variables | |
t1="$(cat $tempsFile | grep Temp | awk -F' [^0-9]* ' '$0=$4' | awk 'FNR==1')" | |
n1="Motherboard" | |
t2="$(cat $tempsFile | grep Temp | awk -F' [^0-9]* ' '$0=$4' | awk 'FNR==2')" | |
n2="Card" | |
t3="$(cat $tempsFile | grep Temp | awk -F' [^0-9]* ' '$0=$4' | awk 'FNR==3')" | |
n3="CPU" | |
t4="$(cat $tempsFile | grep Temp | awk -F' [^0-9]* ' '$0=$4' | awk 'FNR==4')" | |
n4="DDR4 A2" | |
t5="$(cat $tempsFile | grep Temp | awk -F' [^0-9]* ' '$0=$4' | awk 'FNR==5')" | |
n5="DDR4 A1" | |
t6="$(cat $tempsFile | grep Temp | awk -F' [^0-9]* ' '$0=$4' | awk 'FNR==6')" | |
n6="DDR4 B2" | |
t7="$(cat $tempsFile | grep Temp | awk -F' [^0-9]* ' '$0=$4' | awk 'FNR==7')" | |
n7="DDR4 B1" | |
jsonBody="$(cat <<EOF | |
{"name":"$name","type":"system","zipcode":"90210","temps":[{"temp":"$t1","name":"$n1"},{"temp":"$t2","name":"$n2"},{"temp":"$t3","name":"$n3"},{"temp":"$t4","name":"$n4"},{"temp":"$t5","name":"$n5"},{"temp":"$t6","name":"$n6"},{"temp":"$t7","name":"$n7"}]} | |
EOF | |
)" | |
# Report the temps | |
$httpCMD -qO- --post-data="$jsonBody" \ | |
--header='Content-Type:application/json' \ | |
'https://hidden/save' \ | |
-O /dev/null | |
# Delete the file | |
rm $tempsFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment