diff options
| -rw-r--r-- | apt.go | 12 | ||||
| -rw-r--r-- | main.go | 3 | ||||
| -rw-r--r-- | send.go | 2 | ||||
| -rw-r--r-- | structs.go | 2 |
4 files changed, 10 insertions, 9 deletions
@@ -21,21 +21,21 @@ func initPackages() { new1 := new(zoopb.Package) new1.Name = pkg new1.Version = version - if me.packages.Append(new1) { + if me.machine.Packages.Append(new1) { // log.Info("added", new1.Name, "ok") } else { log.Info("added", new1.Name, "failed") } } - log.Info(me.hostname, "has distro", me.distro, "with", me.packages.Len(), "packages installed") + log.Info(me.hostname, "has distro", me.distro, "with", me.machine.Packages.Len(), "packages installed") } func addNew(name string, version string) bool { new1 := new(zoopb.Package) new1.Name = name new1.Version = version - return me.packages.Append(new1) + return me.machine.Packages.Append(new1) } func updatePackages() { @@ -49,20 +49,20 @@ func updatePackages() { var newCounter, changeCounter int // Print the installed packages and their versions for pkg, version := range newP { - found := me.packages.FindByName(pkg) + found := me.machine.Packages.FindByName(pkg) if found == nil { log.Info("adding new", pkg, version) addNew(pkg, version) newCounter += 1 } else { found.Version = version - if me.packages.Update(found) { + if me.machine.Packages.Update(found) { changeCounter += 1 } } } - footer := fmt.Sprintf("%s has distro %s with %d packages installed", me.hostname, me.distro, me.packages.Len()) + footer := fmt.Sprintf("%s has distro %s with %d packages installed", me.hostname, me.distro, me.machine.Packages.Len()) if changeCounter != 0 { footer += fmt.Sprintf(" (%d changed)", changeCounter) } @@ -54,10 +54,11 @@ func main() { // init my machine protobuf me.machine = new(zoopb.Machine) + me.machine.Packages = new(zoopb.Packages) me.machine.Hostname = me.hostname // init the installed package list - me.packages = new(zoopb.Packages) + // me.packages = new(zoopb.Packages) initPackages() go NewWatchdog() @@ -16,7 +16,7 @@ func send() { func pingStatus() error { var url string url = urlbase + "/status?hostname=" + me.hostname - msg, err := me.packages.Marshal() + msg, err := me.machine.Packages.Marshal() if err != nil { log.Info("proto.Marshal() failed:", err) return err @@ -16,5 +16,5 @@ type stuff struct { dog *time.Ticker // the watchdog timer distro string // debian,redhat,gentoo,macos,wincrap machine *zoopb.Machine // my protobuf - packages *zoopb.Packages // installed packages and versions + // packages *zoopb.Packages // installed packages and versions } |
