diff options
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | apt.go | 3 | ||||
| -rw-r--r-- | apt_linux.go | 3 | ||||
| -rw-r--r-- | argv.go | 3 | ||||
| -rw-r--r-- | distro.go | 3 | ||||
| -rw-r--r-- | doGui.go | 7 | ||||
| -rw-r--r-- | http.go | 7 | ||||
| -rw-r--r-- | machine.go | 27 | ||||
| -rw-r--r-- | main.go | 18 | ||||
| -rw-r--r-- | structs.go | 4 | ||||
| -rw-r--r-- | tableWindow.go | 1 | ||||
| -rw-r--r-- | watchdog.go | 3 |
12 files changed, 67 insertions, 18 deletions
@@ -7,9 +7,11 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M) # REDOMOD = $(shell if [ -e go.mod ]; then echo go.mod; else echo no go mod; fi) REDOMOD = $(shell if [ -e go.sum ]; then echo go.sum exists; else GO111MODULE= go mod init; GO111MODULE= go mod tidy; fi) -all: goimports build +all: goimports build nogui ./zookeeper --version - ./zookeeper + +nogui: + ./zookeeper --gui nocui build: GO111MODULE=off go build -v -x \ @@ -1,3 +1,6 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + package main import ( diff --git a/apt_linux.go b/apt_linux.go index 7e534f0..1abb583 100644 --- a/apt_linux.go +++ b/apt_linux.go @@ -1,3 +1,6 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + package main import ( @@ -1,3 +1,6 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + package main /* @@ -1,4 +1,7 @@ // Copyright 2016 The go-qemu Authors. +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -84,12 +84,17 @@ func (tw *tableWindow) showTable(allm *zoopb.Machines) { m := all.Next() tw.grid.NewLabel(m.Hostname) tw.grid.NewLabel(fmt.Sprintf("%d", m.Cpus)) - tw.grid.NewLabel(fmt.Sprintf("%d", m.Memory)) + gb := m.Memory / (1024 * 1024) + ms := fmt.Sprintf("%d MB", gb) + tw.grid.NewLabel(ms) tw.grid.NewLabel(m.Distro) tw.grid.NewLabel(findVersion(m, "zood")) tw.grid.NewLabel(findVersion(m, "bash")) dur := m.Laststamp.AsTime() tw.grid.NewLabel(fmt.Sprintf("%v", time.Since(dur))) + tw.grid.NewButton("upgrade", func() { + log.Info("figure out upgrade", m.Hostname) + }) tw.grid.NextRow() } } @@ -1,3 +1,6 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + package main import ( @@ -37,6 +40,8 @@ func okHandler(w http.ResponseWriter, r *http.Request) { } if route == "/machine" { + handleMachine(w, hostname, msg) + var m *zoopb.Machine m = new(zoopb.Machine) if err := m.Unmarshal(msg); err != nil { @@ -97,7 +102,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) { if route == "/save" { log.HttpMode(w) defer log.HttpMode(nil) - if err := me.machines.ConfigSave(); err == nil { + if err := me.machines2.ConfigSave(); err == nil { log.Log(NOW, "ConfigSave() ok") } else { log.Log(NOW, "ConfigSave() failed", err) @@ -1,6 +1,11 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + package main import ( + "net/http" + "strings" "time" "go.wit.com/lib/protobuf/zoopb" @@ -8,6 +13,26 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" ) +func handleMachine(w http.ResponseWriter, hostname string, data []byte) { + hostname = strings.TrimSpace(hostname) + if hostname == "" { + log.Info("something went wrong. hostname is blank") + } + log.Info("lookoing for", hostname) + m := me.machines.FindByHostname(hostname) + if m == nil { + newm := new(zoopb.Machine) + err := newm.Unmarshal(data) + if err != nil { + log.Info("machine Unmarshal() failed", hostname) + return + } + me.machines.Append(newm) + return + } + log.Info("not new machine", hostname) +} + // someone sent machine 'u' is it new? // if not, update the record of it func updateMachine(u *zoopb.Machine) string { @@ -18,6 +43,8 @@ func updateMachine(u *zoopb.Machine) string { if m == nil { log.Info("adding new machine", u.Hostname) me.machines.Append(u) + log.Info("save machines pb file here...") + // me.machines.ConfigSave() return "new" } // log.Info("updating machine", m.Hostname) @@ -1,16 +1,5 @@ -// Copyright 2016 The go-qemu Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 package main @@ -47,7 +36,8 @@ func main() { me = new(stuff) me.hostname, _ = os.Hostname() me.pollDelay = 10 * time.Second - me.machines = new(zoopb.Machines) + me.machines = zoopb.NewMachines() + me.machines2 = zoopb.NewMachines() if err := me.machines.ConfigLoad(); err != nil { log.Warn("load config failed", err) os.Exit(-1) @@ -1,3 +1,6 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + package main import ( @@ -18,6 +21,7 @@ type stuff struct { distro string // debian,redhat,gentoo,macos,wincrap packages *zoopb.Packages // installed packages and versions machines *zoopb.Machines // every machine that has reported itself to the zookeeper + machines2 *zoopb.Machines // every machine that has reported itself to the zookeeper targets map[string]string // what versions the machines should be running upgrade map[string]bool // use this to trigger builds myGui *gui.Node // the gui toolkit handle diff --git a/tableWindow.go b/tableWindow.go index 39e21b9..f4db2b9 100644 --- a/tableWindow.go +++ b/tableWindow.go @@ -89,6 +89,7 @@ func makeTableWindow() *tableWindow { pw.grid.NewLabel("zood") pw.grid.NewLabel("bash") pw.grid.NewLabel("age") + pw.grid.NewLabel("upgrade") pw.grid.NextRow() // add the patches to the grid diff --git a/watchdog.go b/watchdog.go index 9cce396..6cea461 100644 --- a/watchdog.go +++ b/watchdog.go @@ -1,3 +1,6 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + package main import ( |
