Esempio n. 1
0
func main() {
	cloud, err := cloud.NewDbusForComDevicehiveCloud()
	if err != nil {
		log.Panic(err)
	}

	h, _ := os.Hostname()

	for {
		time.Sleep(time.Second)
		c, err := cpu.CPUPercent(time.Second, false)
		if err != nil {
			log.Panic(err)
		}

		v, err := mem.VirtualMemory()
		if err != nil {
			log.Panic(err)
		}

		if len(c) > 0 {
			cloud.SendNotification("stats", map[string]interface{}{
				"cpu-usage":    c[0],
				"memory-total": v.Total,
				"memory-free":  v.Free,
				"name":         h,
			}, 1)
		}
	}
}
func main() {
	c, err := cloud.NewDbusForComDevicehiveCloud()
	if err != nil {
		log.Fatalf("Creation Dbus wrapper with error: %s", err.Error())
	}

	c.SendNotification("[H I G H  N O T I F I C A T I O N]", map[string]interface{}{}, 1000)
}
func main() {
	c, err := cloud.NewDbusForComDevicehiveCloud()
	if err != nil {
		log.Fatalf("Creation Dbus wrapper with error: %s", err.Error())
	}

	for {
		c.SendNotification("LowNotification", map[string]interface{}{}, 2)
		time.Sleep(1 * time.Second)
	}
}