fix: restore tree dropped by 6d224861; land stem95su gdrive-sync (10m) [ci skip]
6d224861 came from a --no-checkout worktree whose empty index made the
commit drop every file except two. This restores 05b50d2b's full tree and
correctly adds stacks/stem95su/gdrive-sync.tf + the service-catalog stem95su
entry. Forward-only (parent=6d224861, no force-push); [ci skip] since the
live infra was never applied from the broken commit.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
6d224861c4
commit
fd0f4a0365
1166 changed files with 358546 additions and 0 deletions
46
scripts/server_safe_poweroff/ups_utils.go
Normal file
46
scripts/server_safe_poweroff/ups_utils.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/gosnmp/gosnmp"
|
||||
)
|
||||
|
||||
type UPSPowerState = struct {
|
||||
inputVoltage int
|
||||
minutesRemaining uint
|
||||
}
|
||||
|
||||
func getSNMPClient() *gosnmp.GoSNMP {
|
||||
|
||||
// Define SNMP connection parameters
|
||||
target := "192.168.1.5"
|
||||
community := "Public0"
|
||||
|
||||
// Create a new SNMP client
|
||||
snmp := &gosnmp.GoSNMP{
|
||||
Target: target,
|
||||
Port: 161, // Default SNMP port
|
||||
Community: community,
|
||||
Version: gosnmp.Version2c, // Use SNMP v2c
|
||||
Timeout: time.Duration(5) * time.Second,
|
||||
}
|
||||
return snmp
|
||||
}
|
||||
func getPowerState(snmp *gosnmp.GoSNMP) (UPSPowerState, error) {
|
||||
oids := []string{
|
||||
// "1.3.6.1.2.1.33.1.2.2.0", // seconds on battery
|
||||
"1.3.6.1.2.1.33.1.3.3.1.3.1", // input voltage
|
||||
"1.3.6.1.2.1.33.1.2.3.0", // minutes remaining
|
||||
}
|
||||
// Perform an SNMP GET request to retrieve the values for the specified OIDs
|
||||
result, err := snmp.Get(oids)
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to perform SNMP GET request: %v", err)
|
||||
}
|
||||
|
||||
inputVoltage := (result.Variables[0].Value).(int)
|
||||
minutesRemaining := result.Variables[1].Value.(uint)
|
||||
return UPSPowerState{inputVoltage, minutesRemaining}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue