Documentation ¶
Index ¶
- Variables
- func GetJobsWithErrorInHandler() uint16
- func GetPendingJobCount() int
- func GetPowerState(switchId string) (bool, error)
- func Init()
- func InitLogger(logger *logrus.Logger)
- func RunNodeCheck() error
- func SaveCurrentPowerUsage() error
- func SaveCurrentPowerUsageWithLogs()
- func SetPower(switchId string, powerOn bool) error
- func SetSwitchPowerAll(switchId string, powerOn bool, username string) error
- func StartPowerUsageSnapshotScheduler() error
- type JobResult
- type PowerDrawDataPointUnixMillis
- type PowerJob
- type PowerRequest
Constants ¶
This section is empty.
Variables ¶
var ErrorLockDownMode = errors.New("cannot set power: lockdown mode is enabled")
Functions ¶
func GetJobsWithErrorInHandler ¶
func GetJobsWithErrorInHandler() uint16
Returns the number of registered failed jobs of the last running daemon (can also be the current daemon)
func GetPendingJobCount ¶
func GetPendingJobCount() int
Returns the number of currently pending jobs in the queue
func GetPowerState ¶
Returns the power state of a given switch Checks if the switch exists beforehand
func InitLogger ¶
func RunNodeCheck ¶
func RunNodeCheck() error
Runs a health-check on all nodes of the system Used in system-level healthcheck
func SaveCurrentPowerUsage ¶ added in v0.0.57
func SaveCurrentPowerUsage() error
Takes a snapshot of the current power draw and inserts it into the database
func SaveCurrentPowerUsageWithLogs ¶ added in v0.0.57
func SaveCurrentPowerUsageWithLogs()
Wrapper around `saveCurrentPowerUsage` which handles errors through logging Is also more verbose than the original function
func SetPower ¶
As setPower, just with additional logs and account for taking a snapshot of the power states
func SetSwitchPowerAll ¶
Sets the power-state of a specific switch Checks if the switch exists Checks if the user has all required permissions Sends a power request to all available nodes
func StartPowerUsageSnapshotScheduler ¶ added in v0.0.58
func StartPowerUsageSnapshotScheduler() error
Sets up a scheduler which triggers the flushing of old power usage records
Types ¶
type PowerDrawDataPointUnixMillis ¶ added in v0.0.57
type PowerDrawDataPointUnixMillis struct { Id uint `json:"id"` Time uint `json:"time"` // Is represented as Unix-millis On database.PowerDrawData `json:"on"` Off database.PowerDrawData `json:"off"` }
Just like the equivalent in the database module except the time is represented using Unix-millis
func GetPowerUsageRecordsUnixMillis ¶ added in v0.0.57
func GetPowerUsageRecordsUnixMillis(maxAgeHours int) ([]PowerDrawDataPointUnixMillis, error)
Acts like a wrapper for the `database.GetPowerUsageRecords` The main difference is that dates are transformed into unix-millis (which are easier to parse for any API client)