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#define HEALTH_FREE_MEM_THRESHOLD (1024*8)
30// 默认系统最小内存块门限设置为5K,正常访问云端、FLASH需要一次性分配4K内存以上(暂定)
31#define HEALTH_LARGEST_MEM_BLOK_THRESHOLD (1024*5)
32
33// 默认系统最大workq depth
34#define HEALTH_WORKQ_THRESHOLD (50)
35// 默认系统最大msgq num
36#define HEALTH_MSGQ_THRESHOLD (50)
37// 默认系统最大timeq num
38#define HEALTH_TIMEQ_THRESHOLD (100)
39
40//默认喂狗时间,必须是20秒钟的倍数
41#define HEALTH_WATCHDOG_INTERVAL 60
42//默认健康监控扫描间隔,单位是秒,必须是20秒钟的倍数
43#define HEALTH_DETECT_INTERVAL 600
44
45//health指标,必须在g_health_policy顺序定义,不然global type重新分配会不准
46typedef enum {
47 HEALTH_RULE_FREE_MEM_SIZE,
48 HEALTH_RULE_MAX_MEM_SIZE,
49 HEALTH_RULE_ATOP_REFUSE,
50 HEALTH_RULE_ATOP_SIGN_FAILED,
51 HEALTH_RULE_WORKQ_DEPTH,
52 HEALTH_RULE_MSGQ_NUM,
53 HEALTH_RULE_TIMER_NUM,
54 HEALTH_RULE_FEED_WATCH_DOG,
55 HEALTH_RULE_RUNTIME_REPT
56} HEALTH_MONITOR_RULE_E;
57
58typedef VOID (*health_notify_cb)();
59typedef BOOL_T(*health_query_cb)();
60
61typedef struct {
62 INT_T type; // 检测指标
63 UINT_T threshold; // 门限(发生次数)
64 UINT_T detect_period; // 检测周期
65 health_query_cb query_cb; // 指标查询回调,如果事件型可填NULL
66 health_notify_cb notify_cb; // 指标通知回调
68
69typedef struct {
70 INT_T type;
72
79
90INT_T tuya_devos_add_health_item(UINT_T threshold, UINT_T period, health_query_cb query, health_notify_cb notify);
91
99
107VOID tuya_devos_update_health_item_period(INT_T type, UINT_T period);
108
116VOID tuya_devos_update_health_item_threshold(INT_T type, UINT_T threshold);
117
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif
Definition: tuya_devos_health.h:61
Definition: tuya_devos_health.h:69
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