// PublishOnce publish system memory only once
PublishOnce publish system memory only once
// PublishOnce publish system memory only once
func (m *memory) PublishOnce(qos byte) {
	topicMemTotal := m.topic + "/TOTAL"
	topicMemFree := m.topic + "/FREE"
	topicMemAvailable := m.topic + "/AVAILABLE"
	sysMem := meminfo.Clean(service.CmdExec("cat", "/proc/meminfo"), "MemTotal:", "MemFree:", "MemAvailable:")
	if sysMem != nil {
		if token := m.client.Publish(topicMemTotal, qos, false, sysMem["MemTotal"]); token.Wait() && token.Error() != nil {
			log.Println(token.Error())
		}
		if m.debug {
			log.Println("[PUB]", qos, topicMemTotal, sysMem["MemTotal"])
		}
		if token := m.client.Publish(topicMemFree, qos, false, sysMem["MemFree"]); token.Wait() && token.Error() != nil {
			log.Println(token.Error())
		}
		if m.debug {
			log.Println("[PUB]", qos, topicMemFree, sysMem["MemFree"])
		}
		if token := m.client.Publish(topicMemAvailable, qos, false, sysMem["MemAvailable"]); token.Wait() && token.Error() != nil {
			log.Println(token.Error())
		}
		if m.debug {
			log.Println("[PUB]", qos, topicMemAvailable, sysMem["MemAvailable"])
		}
	}
}
func ( m * memory ) PublishOnce ( qos byte ) { topicMemTotal := m . topic + " " topicMemFree := m . topic + " " topicMemAvailable := m . topic + " " sysMem := meminfo . Clean ( service . CmdExec ( " " , " " ) , " " , " " , " " ) if sysMem != nil { if token := m . client . Publish ( topicMemTotal , qos , false , sysMem [ " " ] ) ; token . Wait ( ) && token . Error ( ) != nil { log . Println ( token . Error ( ) ) } if m . debug { log . Println ( " " , qos , topicMemTotal , sysMem [ " " ] ) } if token := m . client . Publish ( topicMemFree , qos , false , sysMem [ " " ] ) ; token . Wait ( ) && token . Error ( ) != nil { log . Println ( token . Error ( ) ) } if m . debug { log . Println ( " " , qos , topicMemFree , sysMem [ " " ] ) } if token := m . client . Publish ( topicMemAvailable , qos , false , sysMem [ " " ] ) ; token . Wait ( ) && token . Error ( ) != nil { log . Println ( token . Error ( ) ) } if m . debug { log . Println ( " " , qos , topicMemAvailable , sysMem [ " " ] ) } } }
PublishOnce publish system memory only once
PublishOnce publish system memory only once
// publish total memory // debug // publish free memory // debug // publish available memory // debug