Zigbee Protocol Controller 1.6.0
zigpc_uptime.hpp
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
4 ******************************************************************************
5 * The licensor of this software is Silicon Laboratories Inc. Your use of this
6 * software is governed by the terms of Silicon Labs Master Software License
7 * Agreement (MSLA) available at
8 * www.silabs.com/about-us/legal/master-software-license-agreement. This
9 * software is distributed to you in Source Code format and is governed by the
10 * sections of the MSLA applicable to Source Code.
11 *
12 *****************************************************************************/
13#ifndef ZIGPC_DIAGNOSTIC_UPTIME_H
14#define ZIGPC_DIAGNOSTIC_UPTIME_H
15#include <time.h>
16#include <stdio.h>
17#include <linux/unistd.h>
18#include <errno.h>
19#include <linux/kernel.h>
20#include <sys/sysinfo.h>
21#include "sl_log.h"
22
24
26{
27 private:
28 long value;
29
30 public:
32 std::string metric_id) :
34 {}
37 {
38 struct sysinfo s_info;
39 int error = sysinfo(&s_info);
40 if (error != 0) {
41 sl_log_error("zigpc uptime metric",
42 "Failed to read uptime code error = %d\n",
43 error);
44 }
45
46 value = s_info.uptime;
47 serialized_value = std::to_string(value);
48
50 }
51};
52#endif
Abstract top level metric from which all diagnostic metric derive from.
Definition: zigpc_diagnostics_metric.hpp:25
zigpc_diagnostics_notification & on_update_complete
Definition: zigpc_diagnostics_metric.hpp:28
std::string serialized_value
Definition: zigpc_diagnostics_metric.hpp:30
std::string metric_id
Definition: zigpc_diagnostics_metric.hpp:29
Definition: zigpc_diagnostics_notification.hpp:20
virtual void notify(std::string metric_id)
Definition: zigpc_diagnostics_notification.hpp:22
Definition: zigpc_uptime.hpp:26
zigpc_uptime_metric(zigpc_diagnostics_notification &notif, std::string metric_id)
Definition: zigpc_uptime.hpp:31
long value
Definition: zigpc_uptime.hpp:28
void update_value()
Definition: zigpc_uptime.hpp:36
~zigpc_uptime_metric()
Definition: zigpc_uptime.hpp:35
#define sl_log_error(tag, fmtstr,...)
Definition: sl_log.h:145