Skip to content

Instantly share code, notes, and snippets.

@sigmaprojects
Created June 28, 2020 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sigmaprojects/ae1c348fc695865a6fea950a3d0652f6 to your computer and use it in GitHub Desktop.
Save sigmaprojects/ae1c348fc695865a6fea950a3d0652f6 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# esxi raid temp reporter
# this file is saved in /vmfs/volumes/Pandora/
#
# awk command to get just the temps
# cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3'
#
# awk command to get specific rows, this index starts at 1
# cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3' | awk 'FNR == 9'
#
#
#
cd /opt/lsi/perccli
tempsFile=/tmp/temps.txt
name=ESXI-Olympus
description=SigmaProjects-VMWare-Server
# get the full path to wget
httpCMD=$(which wget)
# Get the Drive Temps and put it in a new file
./perccli /c0/s0-10 show all | grep Temp > $tempsFile
# Get the BBU temp and append it to the file
./perccli /c0/bbu show all | grep -m1 Temp >> $tempsFile
# go to a tmp directory
cd /tmp/
# start parsing the file and assigning variables
d1="$(cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3' | awk 'FNR == 1')"
d2="$(cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3' | awk 'FNR == 2')"
d3="$(cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3' | awk 'FNR == 3')"
d4="$(cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3' | awk 'FNR == 4')"
d5="$(cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3' | awk 'FNR == 5')"
d6="$(cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3' | awk 'FNR == 6')"
d7="$(cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3' | awk 'FNR == 7')"
d8="$(cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3' | awk 'FNR == 8')"
bbu="$(cat $tempsFile | awk -F'[^0-9]*' '$0=$2$3' | awk 'FNR == 9')"
bbuBody="$(cat <<EOF
{"name":"$name","type":"battery","zipcode":"90210","temps":[{"temp":$bbu,"name":"BBU"}]}
EOF
)"
# Report drive temps
$httpCMD -qO- --post-data "name=$name&type=drive&temps=$d1&temps=$d2&temps=$d3&temps=$d4&temps=$d5&temps=$d6&temps=$d7&temps=$d8&names=Drive%201&names=Drive%202&names=Drive%203&names=Drive%204&names=Drive%205&names=Drive%206&names=Drive%207&names=Drive%208&zipcode=92395" https://hidden/save
# Report the BBU temp
$httpCMD -qO- --post-data="$bbuBody" \
--header='Content-Type:application/json' \
'https://hidden/save'
# Delete the file
rm $tempsFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment