TuyaOS
tuya_devos_health.h
浏览该文件的文档.
1
12#ifndef __TUYA_DEVOS_HEALTH_H__
13#define __TUYA_DEVOS_HEALTH_H__
14
15#include "tuya_cloud_com_defs.h"
16#include "tal_thread.h"
17#include "tal_mutex.h"
18#include "tuya_list.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24// 默认health monitor检测时间间隔(暂定)
25#define HEALTH_SLEEP_INTERVAL (5)
26// 默认系统上报健康状态时间
27#define HEALTH_REPORT_INTERVAL (60 * 60)
28// 默认系统最小free内存门限设置为5K,正常访问云端、FLASH需要4K内存以上(暂定)
29#ifndef HEALTH_FREE_MEM_THRESHOLD
30#define HEALTH_FREE_MEM_THRESHOLD (1024*8)
31#endif
32// 默认系统最小内存块门限设置为5K,正常访问云端、FLASH需要一次性分配4K内存以上(暂定)
33#define HEALTH_LARGEST_MEM_BLOK_THRESHOLD (1024*5)
34
35// 默认系统最大workq depth
36#define HEALTH_WORKQ_THRESHOLD (50)
37// 默认系统最大msgq num
38#define HEALTH_MSGQ_THRESHOLD (50)
39// 默认系统最大timeq num
40#define HEALTH_TIMEQ_THRESHOLD (100)
41
42//默认喂狗时间,必须是20秒钟的倍数
43#define HEALTH_WATCHDOG_INTERVAL 60
44//默认健康监控扫描间隔,单位是秒,必须是20秒钟的倍数
45#define HEALTH_DETECT_INTERVAL 600
46
47//health指标,必须在g_health_policy顺序定义,不然global type重新分配会不准
48typedef enum {
49 HEALTH_RULE_FREE_MEM_SIZE,
50 HEALTH_RULE_MAX_MEM_SIZE,
51 HEALTH_RULE_ATOP_REFUSE,
52 HEALTH_RULE_ATOP_SIGN_FAILED,
53 HEALTH_RULE_WORKQ_DEPTH,
54 HEALTH_RULE_MSGQ_NUM,
55 HEALTH_RULE_TIMER_NUM,
56 HEALTH_RULE_FEED_WATCH_DOG,
57 HEALTH_RULE_RUNTIME_REPT,
58 HEALTH_RULE_EVENT_PUB
59} HEALTH_MONITOR_RULE_E;
60
61typedef VOID (*health_notify_cb)();
62typedef BOOL_T(*health_query_cb)();
63
64typedef struct {
65 INT_T type; // 检测指标
66 UINT_T threshold; // 门限(发生次数)
67 UINT_T detect_period; // 检测周期
68 health_query_cb query_cb; // 指标查询回调,如果事件型可填NULL
69 health_notify_cb notify_cb; // 指标通知回调
71
72typedef struct {
73 INT_T type;
75
82
93INT_T tuya_devos_add_health_item(UINT_T threshold, UINT_T period, health_query_cb query, health_notify_cb notify);
94
102
110VOID tuya_devos_update_health_item_period(INT_T type, UINT_T period);
111
119VOID tuya_devos_update_health_item_threshold(INT_T type, UINT_T threshold);
120
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif
Definition: tuya_devos_health.h:64
Definition: tuya_devos_health.h:72
Common process - adapter the mutex api provide by OS
VOID tuya_devos_update_health_item_period(INT_T type, UINT_T period)
update health item period
INT_T tuya_devos_health_init_and_start()
devos health init function
VOID tuya_devos_dump_health_item(VOID)
dump health item
VOID tuya_devos_delete_health_item(INT_T type)
delete health item
VOID tuya_devos_update_health_item_threshold(INT_T type, UINT_T threshold)
update health item threshold
INT_T tuya_devos_add_health_item(UINT_T threshold, UINT_T period, health_query_cb query, health_notify_cb notify)
add health item