Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadman switch as described in the readme #8

Open
bengeek2 opened this issue Jul 2, 2023 · 1 comment
Open

Deadman switch as described in the readme #8

bengeek2 opened this issue Jul 2, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@bengeek2
Copy link

bengeek2 commented Jul 2, 2023

Hello,
This script is working fantastic, but I am having trouble setting up a deadmans switch for if linux hangs, such as you described in the readme. Is this code snippit missing from this script, or does it have to be setup manually? I cannot find any references to this online.

@White-Raven
Copy link
Owner

White-Raven commented Jul 2, 2023

Hi, well indeed it's not part of the script published here, I actually haven't had time to refactor it according to the latest wanted adds that were planned (my own R720's board is actually dying, and since I'm moving to new servers, it hasn't even been in my scope the last few months).

The deadman switch was mainly discussed as an indication of what a savvy user would/should do, but that has to be more tailored to the person's setup and would clog that already wonky/messy code dump.
(again, this repo is just me sharing a part of my cron scripts after sanitizing them/truncating the parts that are specific to my setup, so the deadman switch got axed)

In truth, you can do that more simply, running on a second machine a cronjob that just pings your server every so often, and if no answer a couple of times, sets the fans to auto.
Typically you would run it on something like a raspberry pi or an intel compute stick, aka a low powered host dedicated to menial not-compute-heavy but critical tasks that you just never work on and has to to run ALWAYS (like pihole, log aggregation server, UPS server, etc)

Something like that should do the job as a deadman switch:

#!/bin/bash
#the IP address of your target iDrac
IPMIHOST=192.168.0.42

#the IP address of your target Host/Hypervisor
CHECKHOST=192.168.0.40

#iDrac user
IPMIUSER=root

#iDrac password (calvin is the default password)
IPMIPW=calvin

#YOUR IPMI ENCRYPTION KEY
IPMIEK=0000000000000000000000000000000000000000

DATE=$(date '+%d/%m/%Y %H:%M:%S')
if ping -c 1 $CHECKHOST &> /dev/null ; then
  echo "$DATE : Target is up and reachable"
else
  echo "$DATE : Host is unreachable, maybe hang?"
  sleep 10
  if ping -c 1 $CHECKHOST &> /dev/null ; then
      echo "$DATE : Target is up and reachable, all good."
    else
      if ping -c 1 $IPMIHOST &> /dev/null ; then
        echo "$DATE : Target is unreachable twice, play safe."
        ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x01
      else
        echo "$DATE : TargetIPMI also unreachable? Either the whole Target is down, or this host is offline."
    fi
  fi
fi
exit

Hope that helps!

@White-Raven White-Raven added the enhancement New feature or request label Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants