173 lines
5.9 KiB
PHP
Executable File
173 lines
5.9 KiB
PHP
Executable File
|
|
VERS='2.4.2-12092023'
|
|
|
|
noheader=' update service dailytemp '
|
|
hc_cw=60
|
|
|
|
# mqtt_conn='/usr/bin/mosquitto_sub -h 127.0.0.1 -u emonpi -P emonpimqtt'
|
|
mqtt_conn='/usr/bin/mosquitto_sub -h 127.0.0.1 -u mqtt -P 12mqtt34password56'
|
|
|
|
# mysql_conn='/usr/bin/mysql -h mysqldb.scity.us -P 6033 --user=sysmoninsert --password=sysmoninsert'
|
|
mysql_conn='/usr/bin/mysql'
|
|
|
|
min_acvolt=105
|
|
min_battvolt=49.4
|
|
min_battvolt_sys=48.8
|
|
|
|
PW_FOLDER='/opt/idssys/powerwall'
|
|
PW_LOGFOLDER=${PW_FOLDER}/logs
|
|
PW_LOGARCHIVE=${PW_FOLDER}/logs/archive
|
|
PW_TMPFOLDER=${PW_FOLDER}/.tmp
|
|
[ ! -d ${PW_LOGFOLDER} ] && mkdir ${PW_LOGFOLDER}
|
|
[ ! -d ${PW_LOGARCHIVE} ] && mkdir ${PW_LOGARCHIVE}
|
|
[ ! -d ${PW_TMPFOLDER} ] && mkdir ${PW_TMPFOLDER}
|
|
|
|
PW_LOGFILE=${PW_LOGFOLDER}/logfile
|
|
PW_LOGPOWER=${PW_LOGFOLDER}/log-power
|
|
[ ! -f ${PW_LOGFILE} ] && touch ${PW_LOGFILE}
|
|
[ ! -f ${PW_LOGPOWER} ] && touch ${PW_LOGPOWER}
|
|
|
|
|
|
declare -A PW_POWERWALL_SERVICES
|
|
PW_POWERWALL_SERVICES['temp']='monitor-temp'
|
|
PW_POWERWALL_SERVICES['power']='monitor-power'
|
|
PW_POWERWALL_SERVICES['powerlogger']='monitor-powerlogger'
|
|
|
|
declare -A PW_THRESHOLDS
|
|
# PW_THRESHOLDS['ServerRoomTH']="72,74,76" #TEST1
|
|
# PW_THRESHOLDS['ServerRoomTH']="83,88,95" #Normal broken
|
|
PW_THRESHOLDS['ServerRoomTH']="82,86,92" #Normal -4
|
|
PW_THRESHOLDS['Powerwall-CPU']="122,131,176"
|
|
PW_THRESHOLDS['Powerwall-CPU-Usage']="40,80,90"
|
|
PW_THRESHOLDS['OctoPi-CPU']="122,131,176"
|
|
PW_THRESHOLDS['OctoPi-CPU-Usage']="40,80,90"
|
|
PW_THRESHOLDS['OFF-vMS-Host1-FanSpeed']="6360,11040,16080"
|
|
|
|
PW_ServerRoomTH_Dev='-1'
|
|
|
|
|
|
declare -A PW_SENSOR_TYPE
|
|
PW_SENSOR_TYPE['ServerRoomTH']='mqtt'
|
|
PW_SENSOR_TYPE['Powerwall-CPU']='system'
|
|
PW_SENSOR_TYPE['Powerwall-CPU-Usage']='cpu'
|
|
PW_SENSOR_TYPE['OctoPi-CPU']='remotesystem'
|
|
PW_SENSOR_TYPE['OctoPi-CPU-Usage']='cpu'
|
|
PW_SENSOR_TYPE['iDS-vMS-Host0']='esxi'
|
|
PW_SENSOR_TYPE['iDS-vMS-Host1']='esxi'
|
|
# PW_SENSOR_TYPE['iDS-vMS-Host2']='esxi'
|
|
PW_SENSOR_TYPE['iDS-vMS-Host6']='esxi'
|
|
PW_SENSOR_TYPE['iDS-vMS-Host7']='esxi'
|
|
# PW_SENSOR_TYPE['vMS-iDrac8']='esxi'
|
|
PW_SENSOR_TYPE['OFF-vMS-Host1']='esxi'
|
|
|
|
|
|
declare -A PW_REMOTE_SENSORS
|
|
PW_REMOTE_SENSORS['Powerwall-CPU']='127.0.0.1'
|
|
PW_REMOTE_SENSORS['Powerwall-CPU-Usage']='127.0.0.1'
|
|
PW_REMOTE_SENSORS['ServerRoomTH']='10.10.20.10'
|
|
PW_REMOTE_SENSORS['OctoPi-CPU']='10.10.1.80'
|
|
PW_REMOTE_SENSORS['OctoPi-CPU-Usage']='10.10.1.80'
|
|
|
|
PW_SENSOR_ORD=(ServerRoomTH Powerwall-CPU Powerwall-CPU-Usage OctoPi-CPU OctoPi-CPU-Usage iDS-vMS-Host0 iDS-vMS-Host1 iDS-vMS-Host6 iDS-vMS-Host7 OFF-vMS-Host1)
|
|
# PW_SENSOR_ORD=(iDS-vMS-Host0)
|
|
|
|
declare -A PW_SENSOR_ID
|
|
PW_SENSOR_ID['ServerRoomTH']='2'
|
|
PW_SENSOR_ID['Powerwall-CPU']='6'
|
|
PW_SENSOR_ID['Powerwall-CPU-Usage']='15'
|
|
PW_SENSOR_ID['OctoPi-CPU']='7'
|
|
PW_SENSOR_ID['OctoPi-CPU-Usage']='16'
|
|
PW_SENSOR_ID['iDS-vMS-Host0']='8'
|
|
PW_SENSOR_ID['iDS-vMS-Host1']='9'
|
|
PW_SENSOR_ID['iDS-vMS-Host6']='13'
|
|
PW_SENSOR_ID['iDS-vMS-Host7']='11'
|
|
PW_SENSOR_ID['OFF-vMS-Host1']='10'
|
|
|
|
# PW_SENSOR_ID['iDS-vMS-Host2']='10'
|
|
# PW_SENSOR_ID['vMS-iDrac8']='12'
|
|
|
|
declare -A PW_POWERSENSOR_ID
|
|
PW_POWERSENSOR_ID['inv-in']='3'
|
|
PW_POWERSENSOR_ID['inv-out']='4'
|
|
PW_POWERSENSOR_ID['battery']='5'
|
|
PW_POWERSENSOR_ID['total']='11'
|
|
PW_POWERSENSOR_ID['server-rack']='12'
|
|
PW_POWERSENSOR_ID['network-rack']='13'
|
|
PW_POWERSENSOR_ID['offsite-ups']='15'
|
|
PW_POWERSENSOR_ID['iDS-vMS-Host0']='20'
|
|
PW_POWERSENSOR_ID['iDS-vMS-Host1']='21'
|
|
PW_POWERSENSOR_ID['iDS-vMS-Host6']='26'
|
|
PW_POWERSENSOR_ID['iDS-vMS-Host7']='27'
|
|
PW_POWERSENSOR_ID['OFF-vMS-Host1']='31'
|
|
|
|
declare -A PW_HOST_IDRACS
|
|
PW_HOST_IDRACS['iDS-vMS-Host0']='10.10.2.20'
|
|
PW_HOST_IDRACS['iDS-vMS-Host1']='10.10.2.21'
|
|
# PW_HOST_IDRACS['iDS-vMS-Host2']='10.10.2.22'
|
|
PW_HOST_IDRACS['iDS-vMS-Host6']='10.10.2.26'
|
|
PW_HOST_IDRACS['iDS-vMS-Host7']='10.10.2.27'
|
|
# PW_HOST_IDRACS['vMS-iDrac8']='10.2.1.28'
|
|
PW_HOST_IDRACS['OFF-vMS-Host1']='10.2.1.21'
|
|
|
|
declare -A PW_HOST_ADDRESSES
|
|
PW_HOST_ADDRESSES['iDS-vMS-Host0']='10.10.2.10'
|
|
PW_HOST_ADDRESSES['iDS-vMS-Host1']='10.10.2.11'
|
|
# PW_HOST_ADDRESSES['iDS-vMS-Host2']='10.10.2.12'
|
|
PW_HOST_ADDRESSES['iDS-vMS-Host6']='10.10.2.16'
|
|
PW_HOST_ADDRESSES['iDS-vMS-Host7']='10.10.2.17'
|
|
# PW_HOST_ADDRESSES['vMS-iDrac8']='10.2.1.18'
|
|
PW_HOST_ADDRESSES['OFF-vMS-Host1']='10.2.1.11'
|
|
|
|
declare -A PW_ESXI_HOST_NAMES
|
|
PW_ESXI_HOST_NAMES['10.10.2.10']='iDS-vMS-Host0'
|
|
PW_ESXI_HOST_NAMES['10.10.2.11']='iDS-vMS-Host1'
|
|
# PW_ESXI_HOST_NAMES['10.10.2.12']='iDS-vMS2-Host2'
|
|
PW_ESXI_HOST_NAMES['10.10.2.16']='iDS-vMS-Host6'
|
|
PW_ESXI_HOST_NAMES['10.10.2.17']='iDS-vMS-Host7'
|
|
# PW_ESXI_HOST_NAMES['10.2.1.18']='iDS-vMS2-Offsite.scity.us'
|
|
PW_ESXI_HOST_NAMES['10.2.1.11']='OFF-vMS-Host1'
|
|
|
|
declare -A PW_VCENTER_HOST_NAMES
|
|
PW_VCENTER_HOST_NAMES['10.10.2.10']='ids-vms-iscsi.scity.us'
|
|
PW_VCENTER_HOST_NAMES['10.10.2.11']='ids-vms1.scity.us'
|
|
PW_VCENTER_HOST_NAMES['10.10.2.16']='ids-vms6.scity.us'
|
|
PW_VCENTER_HOST_NAMES['10.10.2.17']='ids-vms7.scity.us'
|
|
PW_VCENTER_HOST_NAMES['10.2.1.11']='ids-vms1.offsite.scity.us'
|
|
|
|
declare -A PW_iDRACHOST_SHORTNAMES
|
|
PW_iDRACHOST_SHORTNAMES['10.10.2.20']='iDS-vMS-Host0'
|
|
PW_iDRACHOST_SHORTNAMES['10.10.2.21']='iDS-vMS-Host1'
|
|
PW_iDRACHOST_SHORTNAMES['10.10.2.26']='iDS-vMS-Host6'
|
|
PW_iDRACHOST_SHORTNAMES['10.10.2.27']='iDS-vMS-Host7'
|
|
PW_iDRACHOST_SHORTNAMES['10.2.1.21']='OFF-vMS-Host1'
|
|
|
|
PW_VCENTERHOST=10.10.1.30
|
|
PW_MAINHOSTS=10.10.2.10,10.10.2.11
|
|
PW_SYSHOSTS=10.10.2.16,10.10.2.17
|
|
PW_OFFSITEHOSTS=10.2.1.11
|
|
PW_MAINSITE_HOSTS="${PW_MAINHOSTS},${PW_SYSHOSTS}"
|
|
PW_ALL_HOSTS="${PW_MAINHOSTS},${PW_SYSHOSTS},${PW_OFFSITEHOSTS}"
|
|
|
|
PW_RACADM_ACCESS=10.10.0.241
|
|
PW_INVERTER_IP=10.10.0.61
|
|
PW_UPS_IP=10.10.1.205
|
|
PW_APCPDU_IP=10.10.1.210
|
|
|
|
IFS=,
|
|
PW_MAINSITE_HOSTS=(${PW_MAINSITE_HOSTS})
|
|
PW_MAINHOSTS=(${PW_MAINHOSTS})
|
|
PW_SYSHOSTS=(${PW_SYSHOSTS})
|
|
PW_OFFSITEHOSTS=(${PW_OFFSITEHOSTS})
|
|
PW_ALLHOSTS=(${PW_ALL_HOSTS})
|
|
unset IFS
|
|
|
|
# RNIP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
|
|
|
|
SENDNOTICE(){
|
|
[ "${PUSHOVER_APP_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2}
|
|
|
|
$(date +%Y-%m-%d-%H-%M-%S)" "${1}" ${3} &
|
|
|
|
[ "${EMAIL_NOTICE}" != "" ] && echo -e "${2}\n\n$(date +%Y-%m-%d-%H-%M-%S)" | mail -s "${1}" ${EMAIL_NOTICE}
|
|
|
|
} |