|
1 |
| -/** |
| 1 | +/** |
2 | 2 | * Tencent is pleased to support the open source community by making Tars available.
|
3 | 3 | *
|
4 | 4 | * Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.
|
|
21 | 21 | extern TC_Config * g_pconf;
|
22 | 22 | extern TarsHashMap<NotifyKey, NotifyInfo, ThreadLockPolicy, MemStorePolicy> * g_notifyHash;
|
23 | 23 |
|
| 24 | +std::string Alarm = "[alarm]"; |
| 25 | +std::string Error = "[error]"; |
| 26 | +std::string Warn = "[warn]"; |
| 27 | +std::string Fail = "[fail]"; |
| 28 | +std::string Normal = "[normal]"; |
| 29 | + |
| 30 | +static std::string getNotifyLevel(const std::string& sNotifyMessage) |
| 31 | +{ |
| 32 | + |
| 33 | + if (sNotifyMessage.find(Alarm) != std::string::npos) return Alarm; |
| 34 | + if (sNotifyMessage.find(Error) != std::string::npos) return Error; |
| 35 | + if (sNotifyMessage.find(Warn) != std::string::npos) return Warn; |
| 36 | + if (sNotifyMessage.find(Fail) != std::string::npos) return Error; |
| 37 | + |
| 38 | + return Normal; |
| 39 | +} |
| 40 | + |
| 41 | +static std::string getNotifyLevel(int level) |
| 42 | +{ |
| 43 | + switch(level) |
| 44 | + { |
| 45 | + case NOTIFYERROR: |
| 46 | + return Error; |
| 47 | + case NOTIFYWARN: |
| 48 | + return Warn; |
| 49 | + default: |
| 50 | + case NOTIFYNORMAL: |
| 51 | + return Normal; |
| 52 | + } |
| 53 | + |
| 54 | + return Normal; |
| 55 | +} |
| 56 | + |
24 | 57 | void NotifyImp::loadconf()
|
25 | 58 | {
|
26 | 59 | TC_DBConf tcDBConf;
|
@@ -321,6 +354,11 @@ void NotifyImp::reportNotifyInfo(const tars::ReportInfo & info, tars::TarsCurren
|
321 | 354 | rd["set_group"] = make_pair(TC_Mysql::DB_STR, "");
|
322 | 355 | }
|
323 | 356 |
|
| 357 | + if (info.eType == REPORT) { |
| 358 | + rd["command"] = make_pair(TC_Mysql::DB_STR, getNotifyLevel(info.sMessage)); |
| 359 | + } else { |
| 360 | + rd["command"] = make_pair(TC_Mysql::DB_STR, getNotifyLevel(info.eLevel)); |
| 361 | + } |
324 | 362 | rd["result"] = make_pair(TC_Mysql::DB_STR, info.sMessage);
|
325 | 363 | rd["notifytime"] = make_pair(TC_Mysql::DB_INT, "now()");
|
326 | 364 | string sTable = "t_server_notifys";
|
|
0 commit comments