// 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) }
// 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) }
// 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) }
// 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)) }