Skip to content

Commit fb3ecd1

Browse files
committed
增加一个todo
1 parent 810f6a0 commit fb3ecd1

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ cd ServerStatus/server && make
6767

6868
#### 二、修改配置文件
6969
```diff
70-
! watchdog rule 可以为任何已知字段的表达式
70+
! watchdog rule 可以为任何已知字段的表达式。注意Exprtk库默认使用窄字符类型,中文等Unicode字符无法解析计算,todo等待修复
7171
! watchdog interval 最小通知间隔
7272
! watchdog callback 可自定义为Post方法的URL,告警内容将拼接其后并发起回调
7373

@@ -89,13 +89,21 @@ cd ServerStatus/server && make
8989
"location": "🇨🇳",
9090
"password": "USER_DEFAULT_PASSWORD",
9191
"monthstart": 1
92-
},
92+
}
93+
],
94+
"monitors": [
95+
{
96+
"name": "百度一下",
97+
"host": "https://www.baidu.com",
98+
"interval": 60,
99+
"type": "https"
100+
}
93101
],
94102
"watchdog":
95103
[
96104
{
97-
"name": "服务器负载高监控,排除内存大于32G物理机,同时排除俄勒冈机器",
98-
"rule": "cpu>90&load_1>4&memory_total<33554432&name!='俄勒冈'",
105+
"name": "服务器负载高监控,排除内存大于32G物理机,同时排除node1机器",
106+
"rule": "cpu>90&load_1>4&memory_total<33554432&name!='node1'",
99107
"interval": 600,
100108
"callback": "https://yourSMSurl"
101109
},
@@ -106,8 +114,8 @@ cd ServerStatus/server && make
106114
"callback": "https://yourSMSurl"
107115
},
108116
{
109-
"name": "服务器宕机告警,排出俄勒冈,排除s02",
110-
"rule": "online4=0&online6=0&name!='俄勒冈'&username!='s02'",
117+
"name": "服务器宕机告警,排出node1,排除s02",
118+
"rule": "online4=0&online6=0&name!='node1'&username!='s02'",
111119
"interval": 600,
112120
"callback": "https://yourSMSurl"
113121
},
@@ -124,7 +132,7 @@ cd ServerStatus/server && make
124132
"callback": "https://yourSMSurl"
125133
},
126134
{
127-
"name": "你可以组合任何已知字段的表达式",
135+
"name": "你可以组合任何已知字段的表达式,注意Exprtk库目前不支持中文等Unicode字符",
128136
"rule": "(hdd_used/hdd_total)*100>95",
129137
"interval": 1800,
130138
"callback": "https://yourSMSurl"

server/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"type": "https"
4747
},
4848
{
49-
"name": "主机交流",
49+
"name": "502论坛",
5050
"host": "https://www.hostloc.com",
5151
"interval": 60,
5252
"type": "https"

server/src/main.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,23 @@ void CMain::WatchdogMessage(int ClientNetID, double load_1, double load_5, doubl
278278
int ID = 0;
279279
while (strcmp(Watchdog(ID)->m_aName, "NULL"))
280280
{
281+
// Exprtk库默认使用窄字符类型,但可能会出现中文等Unicode字符无法正确解析的问题。
282+
// todo: 为解决此问题,可以使用宽字符类型替换Exprtk库中默认的窄字符类型。
283+
// #include <string>
284+
// #include <vector>
285+
// #include <exprtk.hpp>
286+
// typedef exprtk::expression<wchar_t> expression_type;
287+
// typedef exprtk::parser<wchar_t> parser_type;
288+
// int main()
289+
// {
290+
// std::wstring expression_string = L"sin(x)";
291+
// expression_type expression;
292+
// parser_type parser;
293+
// parser.compile(expression_string, expression);
294+
// double x = 3.14;
295+
// double result = expression.value();
296+
// return 0;
297+
// }
281298
typedef exprtk::symbol_table<double> symbol_table_t;
282299
typedef exprtk::expression<double> expression_t;
283300
typedef exprtk::parser<double> parser_t;

0 commit comments

Comments
 (0)