# cat /root/bin/iot-carriots.sh
#!/bin/bash
#created by Byomkesh on 10-14Feb2018
echo '
' >/root/bin/data/iotdata.txt
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|grep -e Temp -e Slot|tr -s '\n' ' '|perl -e '$in=<>; $in =~ /Slot Number: ([^ ]*) .*Drive Temperature :[ ]*([^ ]*)C .*Slot Number: ([^ ]*) .*Drive Temperature :[ ]*([^ ]*)C .*Slot Number: ([^ ]*) .*Drive Temperature :[ ]*([^ ]*)C .*Slot Number: ([^ ]*) .*Drive Temperature :[ ]*([^ ]*)C .*Slot Number: ([^ ]*) .*Drive Temperature :[ ]*([^ ]*)C .*/; print "$1 $2 $3 $4 $5 $6 $7 $8 $9 $10"'|(read a b c d e f g h i j k; echo -n '
/usr/sbin/isensor -s -g fan,temp,voltage,current|cut -d "|" -f 5,7|sed -e 's/ //g' -e's/\+//g' -e's/\%//g'|grep -e "C$" -e "V$" -e "A$" -e"RPM$"|tr -s '|' ' '|sed -e "s/C$//" -e "s/V$//" -e "s/A$//" -e"s/RPM$//"|while read a b c ; do a=`echo $a|tr '\.' '_'`; echo -n '<'$a'>'$b''$a'>'; done >>/root/bin/data/iotdata.txt
echo '
' >>/root/bin/data/iotdata.txt
curl -s --request POST --data-binary @/root/bin/data/iotdata.txt --header "carriots.apikey:6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx6" --header "content-type:application/xml" http://api.carriots.com/streams 2>&1 >/dev/null
#curl -s --request POST --data-binary @/root/bin/data/iotdata.txt --header "carriots.apikey:6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx66" --header "content-type:application/xml" http://api.carriots.com/streams
# cat /root/bin/data/iotdata.txt