62 lines
1.7 KiB
Plaintext
62 lines
1.7 KiB
Plaintext
/******************************************************************************************************************
|
|
* Action instruction algorithm
|
|
*
|
|
* arg[0] data determination expression
|
|
*
|
|
* 表达式算法
|
|
*
|
|
* 1.0 2020-12-17 zoufuzhou
|
|
******************************************************************************************************************/
|
|
#include <base/BitTool.h>
|
|
#include <dao/DBMag.h>
|
|
#include <eqpalg/algs/exp.h>
|
|
#include <eqpalg/utility/build_alarm_info.h>
|
|
|
|
extern std::map<std::string, ITEM> glob_items;
|
|
|
|
int Exp::init() {
|
|
LOG d("Exp::init", AUTO_CATCH_PID);
|
|
try {
|
|
|
|
} catch (const std::exception &e) {
|
|
d.Error() << mix_cc::get_nested_exception(e) << std::endl;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
Exp::Exp(const string &name, const Json::Value &rulejson, const string &ruleId)
|
|
: AlgBase(name, rulejson, ruleId) {
|
|
logger_.reset(new LOG("Exp:" + rule_name_, AUTO_CATCH_PID));
|
|
try {
|
|
this->init();
|
|
} catch (const std::exception &e) {
|
|
logger_->Error() << mix_cc::get_nested_exception(e) << std::endl;
|
|
}
|
|
}
|
|
|
|
Exp::~Exp() {}
|
|
|
|
|
|
|
|
std::string Exp::mon_proc() {
|
|
|
|
act_triggered_ = exp_act_->evaluate();
|
|
logger_->Debug() << "act_triggered_:" << m_expstr << "=" << act_triggered_
|
|
<< endl;
|
|
if ((bool)act_triggered_) {
|
|
this->print_exp_vars();
|
|
logger_->Warn() << "alarmed" << endl;
|
|
|
|
auto msg =
|
|
rule_name_ + " " + m_json_param["action_condition"]["error"][1].asString();
|
|
|
|
logger_->Debug() << msg << endl;
|
|
msg = build_alarm_info(MsgLevel::ERROR, rule_id_, rule_name_, "EXP", msg,
|
|
query_time_range_);
|
|
query_time_range_.set_left(query_time_range_.get_right());
|
|
query_time_range_.set_right(system_clock::now());
|
|
return msg;
|
|
}
|
|
return "";
|
|
}
|