Skip to content

Commit

Permalink
Revert "ups-shecduled-tasks script moved"
Browse files Browse the repository at this point in the history
This reverts commit 63be7b6.
  • Loading branch information
alainwolf committed Mar 5, 2023
1 parent 36941bc commit 1419b4a
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
#!/usr/bin/env sh
#! /bin/sh
#
# SSH connection settings
_REMOTE_SSH_HOST='somehost.example.com'
_REMOTE_SSH_USER='nut'
_SSH_KEY='/etc/nut/ssh/id_rsa'
SSH_HOST='ap.example.net'
SSH_USER='nut'
SSH_KEY='/etc/nut/ssh/id_rsa'

case $1 in
onbatt)
message="Power Failure on UPS ${UPSNAME}!"
echo -e "Warning: UPS $UPSNAME experienced a power failure and is now running on battery!" \
| mail -s"Warning: $message" root
remote_cmd="log warning message=\"${message}\""
ssh $_REMOTE_SSH_HOST -l $_REMOTE_SSH_USER -i $_SSH_KEY $remote_cmd
ssh $SSH_HOST -l $SSH_USER -i $SSH_KEY $remote_cmd
;;
online)
message="Power restored on UPS $UPSNAME"
echo -e "Power on UPS $UPSNAME has been restored." \
| mail -s"$message" root
remote_cmd="log info message=\"${message}\""
ssh REMOTE_$SSH_HOST -l REMOTE_$_REMOTE_SSH_USER -i $_SSH_KEY $remote_cmd
ssh $SSH_HOST -l $SSH_USER -i $SSH_KEY $remote_cmd
;;
lowbatt)
message="Low battery on UPS ${UPSNAME}!"
echo -e "Warning: UPS $UPSNAME is low on battery! All connected Systems will be shut down soon." \
| mail -s"Warning: $message" root
remote_cmd="log warning message=\"${message}\""
ssh $_REMOTE_SSH_HOST -l $_REMOTE_SSH_USER -i $_SSH_KEY $remote_cmd
ssh $SSH_HOST -l $SSH_USER -i $SSH_KEY $remote_cmd
;;
fsd)
message="Forced Shutdown from UPS ${UPSNAME}!"
echo -e "Warning: All Systems connected to UPS $UPSNAME will be shut down now!" \
| mail -s"Warning: $message" root
remote_cmd="log error message=\"${message}\" ; beep 0.5 ; delay 4000ms ; beep 0.5 ; system shutdown!"
ssh $_REMOTE_SSH_HOST -l $_REMOTE_SSH_USER -i $_SSH_KEY $remote_cmd
ssh $SSH_HOST -l $SSH_USER -i $SSH_KEY $remote_cmd
;;
commok)
message="Communications restored with UPS $UPSNAME"
echo -e "Communications with UPS $UPSNAME have been restored." \
| mail -s"$message" root
remote_cmd="log info message=\"${message}\""
ssh $_REMOTE_SSH_HOST -l $_REMOTE_SSH_USER -i $_SSH_KEY $remote_cmd
ssh $SSH_HOST -l $SSH_USER -i $SSH_KEY $remote_cmd
;;
commbad)
message=""
echo -e "Warning: Lost communications with UPS ${UPSNAME}!" \
| mail -s"Warning: Lost communications with UPS ${UPSNAME}!" root
remote_cmd="log warning message=\"${message}\""
ssh $_REMOTE_SSH_HOST -l $_REMOTE_SSH_USER -i $_SSH_KEY $remote_cmd
ssh $SSH_HOST -l $SSH_USER -i $SSH_KEY $remote_cmd
;;
shutdown)
message="System $HOST is shutting down now!"
echo -e "Warning: System $HOST is shutting down now!" \
| mail -s"Warning: $message" root
remote_cmd="log warning message=\"${message}\""
ssh $_REMOTE_SSH_HOST -l $_REMOTE_SSH_USER -i $_SSH_KEY $remote_cmd
ssh $SSH_HOST -l $SSH_USER -i $SSH_KEY $remote_cmd
;;
replbatt)
message="Replace battery on UPS ${UPSNAME}!"
echo -e "Warning: The UPS $UPSNAME needs to have its battery replaced!" \
| mail -s"Warning: $message" root
remote_cmd="log warning message=\"${message}\""
ssh $_REMOTE_SSH_HOST -l $_REMOTE_SSH_USER -i $_SSH_KEY $remote_cmd
ssh $SSH_HOST -l $SSH_USER -i $SSH_KEY $remote_cmd
;;
nocomm)
message="The UPS $UPSNAME can’t be contacted for monitoring!"
echo -e "Warning: The UPS $UPSNAME can’t be contacted for monitoring!" \
| mail -s"Warning: $message" root
remote_cmd="log warning message=\"${message}\""
ssh $_REMOTE_SSH_HOST -l $_REMOTE_SSH_USER -i $_SSH_KEY $remote_cmd
ssh $SSH_HOST -l $SSH_USER -i $SSH_KEY $remote_cmd
;;
*)
logger -t ups-scheduled-tasks "Unrecognized command: $1"
Expand Down

0 comments on commit 1419b4a

Please sign in to comment.