-
-
Save Hugoberry/7549cf73c601eabbf22fc7b7ea9bec67 to your computer and use it in GitHub Desktop.
SuperMicro IPMI Watchdog for Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# vim: set ts=4 sw=4 sts=4 si ai et ft=powershell: | |
# Copyright (c) 2013, ZenRobotics Ltd. | |
# author: Paul Tötterman <[email protected]> | |
# | |
# Permission to use, copy, modify, and/or distribute this software for any | |
# purpose with or without fee is hereby granted, provided that the above | |
# copyright notice and this permission notice appear in all copies. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
# Intelligent Platform Management Interface Specification Second Generation v2.0 | |
# http://www.intel.com/content/www/us/en/servers/ipmi/second-gen-interface-spec-v2-rev1-4.html | |
Set-Variable -option Constant -name ipmicfg -value "C:\ipmi\ipmicfg-win.exe" | |
Set-Variable -option Constant -name watchdog -value ([Byte]0x6) | |
Set-Variable -option Constant -name cmd_reset -value ([Byte]0x22) | |
Set-Variable -option Constant -name cmd_set -value ([Byte]0x24) | |
Set-Variable -option Constant -name cmd_get -value ([Byte]0x25) | |
Set-Variable -option Constant -name timer_nolog -value ([Byte]0x80) | |
Set-Variable -option Constant -name timer_nostop -value ([Byte]0x40) | |
Set-Variable -option Constant -name timer_bios_frb2 -value ([Byte]0x1) | |
Set-Variable -option Constant -name timer_bios_post -value ([Byte]0x2) | |
Set-Variable -option Constant -name timer_os_load -value ([Byte]0x3) | |
Set-Variable -option Constant -name timer_sms -value ([Byte]0x4) | |
Set-Variable -option Constant -name timer_oem -value ([Byte]0x5) | |
Set-Variable -option Constant -name preaction_none -value ([Byte]0x0) | |
Set-Variable -option Constant -name preaction_smi -value ([Byte]0x10) | |
Set-Variable -option Constant -name preaction_nmi -value ([Byte]0x20) | |
Set-Variable -option Constant -name preaction_msgint -value ([Byte]0x30) | |
Set-Variable -option Constant -name action_none -value ([Byte]0x0) | |
Set-Variable -option Constant -name action_reset -value ([Byte]0x1) | |
Set-Variable -option Constant -name action_off -value ([Byte]0x2) | |
Set-Variable -option Constant -name action_cycle -value ([Byte]0x3) | |
Set-Variable -option Constant -name flag_oem -value ([Byte]0x20) | |
Set-Variable -option Constant -name flag_sms -value ([Byte]0x10) | |
Set-Variable -option Constant -name flag_os_load -value ([Byte]0x8) | |
Set-Variable -option Constant -name flag_bios_post -value ([Byte]0x4) | |
Set-Variable -option Constant -name flag_bios_frb2 -value ([Byte]0x2) | |
function Raw-IPMI() { | |
Param([Parameter(Mandatory=$true)][Byte[]]$data) | |
$args = $data | % {"0x{0:X2}" -f $_} | |
& $ipmicfg '-raw' $args | |
} | |
function Watchdog-Set() { | |
Param([Parameter(Mandatory=$false)][Bool]$log=$false, | |
[Parameter(Mandatory=$false)][Bool]$stop=$true, | |
[Parameter(Mandatory=$false)][Byte]$timer=$timer_sms, | |
[Parameter(Mandatory=$false)][Byte]$preaction=$preaction_none, | |
[Parameter(Mandatory=$false)][Byte]$action=$action_none, | |
[Parameter(Mandatory=$false)][Byte]$pre_timeout=0, | |
[Parameter(Mandatory=$false)][Byte]$clear_flags=($flag_oem -bor $flag_sms -bor $flag_os_load -bor $flag_bio_post -bor $flag_bios_frb2), | |
[Parameter(Mandatory=$true)][Int]$timeout) | |
[byte]$timer_use = $timer | |
if ($log) { | |
$timer_use = $timer_use -band (-bnot $timer_nolog) | |
} else { | |
$timer_use = $timer_use -bor $timer_nolog | |
} | |
if ($stop) { | |
$timer_use = $timer_use -band (-bnot $timer_nostop) | |
} else { | |
$timer_use = $timer_use -bor $timer_nostop | |
} | |
[byte]$timer_action = $preaction -bor $action | |
$countdown = 10*$timeout # 100ms increments | |
[byte]$lo = $countdown % 0xff | |
[byte]$hi = $countdown / 0xff | |
$data = ($watchdog, $cmd_set, $timer_use, $timer_action, $pretimeout, $clear_flags, $lo, $hi) | |
Raw-IPMI $data | |
} | |
function Watchdog-Reset() { | |
Raw-IPMI ($watchdog, $cmd_reset) | |
} | |
Watchdog-Set -timeout 10 -action $action_none | |
for () { | |
Start-Sleep -s 5 | |
Watchdog-Reset | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment