diff --git a/sonic_data_client/non_db_client.go b/sonic_data_client/non_db_client.go index a29fe354e..d7d2bb7ee 100644 --- a/sonic_data_client/non_db_client.go +++ b/sonic_data_client/non_db_client.go @@ -73,6 +73,10 @@ var ( path: []string{"OTHERS", "platform", "cpu"}, getFunc: dataGetFunc(getCpuUtil), }, + { // Get host uptime + path: []string{"OTHERS", "proc", "uptime"}, + getFunc: dataGetFunc(getSysUptime), + }, { // Get proc meminfo path: []string{"OTHERS", "proc", "meminfo"}, getFunc: dataGetFunc(getProcMeminfo), @@ -280,6 +284,18 @@ func getProcStat() ([]byte, error) { return b, nil } +func getSysUptime() ([]byte, error) { + uptime, _ := linuxproc.ReadUptime("/proc/uptime") + b, err := json.Marshal(uptime) + if err != nil { + log.V(2).Infof("%v", err) + return b, err + } + + log.V(4).Infof("getSysUptime, output %v", string(b)) + return b, nil +} + func getBuildVersion() ([]byte, error) { // Load and parse the content of version file