/lastoutage dumps everything

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-08 13:42:42 -05:00
parent 0e3fc9cb80
commit 52fc6a840d
2 changed files with 13 additions and 5 deletions

View File

@ -11,9 +11,9 @@ import (
) )
var args struct { var args struct {
ListRepos bool `arg:"--list-repos" help:"list all repositories"` ListRepos bool `arg:"--list-repos" help:"list all repositories"`
Port int `arg:"--port" help:"port to run on (default is 2520)"` Port int `arg:"--port" help:"port to run on (default is 2520)"`
Hostname string `arg:"--hostname" help:"hostname to use"` Hostname string `arg:"--hostname" help:"hostname to use"`
} }
func init() { func init() {

12
main.go
View File

@ -7,6 +7,7 @@ import (
"time" "time"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/lib/gui/shell"
) )
// var accessf, clientf *os.File // var accessf, clientf *os.File
@ -31,11 +32,18 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
// requrl := parts[0] // requrl := parts[0]
if tmp == "/powersource" { if tmp == "/powersource" {
fmt.Fprintln(w, "Utility Power") fmt.Fprintln(w, "TODO: fix this")
return return
} }
if tmp == "/lastoutage" { if tmp == "/lastoutage" {
fmt.Fprintln(w, "Blackout at 2024/09/25 20:21:57 for 33 sec.") // r := shell.Output("", []string{"ls", "-l", "/"})
r := shell.Output("", []string{"pwrstat", "-status"})
// log.Info("ls -l / START")
// log.Info("ls -l / =", r.Stdout())
// log.Info("ls -l / END")
fmt.Fprintln(w, r.Stdout())
return return
} }
fmt.Fprintln(w, "UNKNOWN URL:", tmp) fmt.Fprintln(w, "UNKNOWN URL:", tmp)