Exemple #1
0
// CPUTemp return cpu temp.
func (r *Raspberry) CPUTemp(data string) []byte {
	cpuTemp := cpu.Clean(cmd.Exec("vcgencmd", "measure_temp"), "temp=", "'C")
	if cpuTemp == "" {
		return nil
	}
	return ctrl.GetMessage("RPI1_CPU_TEMP", cpuTemp)
}
Exemple #2
0
// CPUCoreVolt return core volt.
func (r *Raspberry) CPUCoreVolt(data string) []byte {

	cpuCoreVolt := cpu.Clean(cmd.Exec("vcgencmd", "measure_volts", "core"), "volt=", "V")
	if cpuCoreVolt == "" {
		return nil
	}
	return ctrl.GetMessage("RPI1_CPU_CORE_VOLT", cpuCoreVolt)
}
Exemple #3
0
// CPUMemory return cpu memory.
func (r *Raspberry) CPUMemory(data string) []byte {

	cpuMem := cpu.Clean(cmd.Exec("vcgencmd", "get_mem", "arm"), "arm=", "M")
	if cpuMem == "" {
		return nil
	}
	return ctrl.GetMessage("RPI1_CPU_MEM", cpuMem)
}
Exemple #4
0
// SystemMemory return system memory.
func (r *Raspberry) SystemMemory(data string) []byte {

	sysMem := memory.Clean(cmd.Exec("cat", "/proc/meminfo"), "MemTotal:", "MemFree:", "MemAvailable:")
	if sysMem == nil {
		return nil
	}
	jSysMem, err := json.Marshal(sysMem)
	if err != nil {
		log.Println(err)
		return nil
	}

	return ctrl.GetMessage("RPI1_SYS_MEM", string(jSysMem))
}