Monitoring Platform_Project Survival Monitoring (2)

Query database monitoring data

Insert picture description here

select
          id, entry_name, ip,port, ver_url, phone,open_id,alarm_state ,state,release_start_time,release_end_time, create_Time, update_Time, delete_Time, flag
        from mhaqjk.mhaq_survival
        where flag = 0  and NOW() NOT BETWEEN release_start_time AND release_end_time

Insert picture description here

Initiate a call to url and return the response status code code.
Query the Redis cache and return size (number of errors)

If there are no errors in Redis, size is null

Response status code failed

If there is no size error report times in redis and the project address access fails, (alarm status is 0), send WeChat
and set redis to 1;
otherwise (there is no error report times in redis, but the project address is accessible,) set redis is 0;
Insert picture description here

If the number of error reports already exists in Redis, size is not null

Insert picture description here

Project address response is unsuccessful

(Already have alarm information in Redis, and the project address is unavailable) The alarm status is 0 and is issued 微信通知.
If (the number of alarms is equal to 1 time or less than 3 times), the alarm status is 0 and issued 短信通知.
If it is (the size of the number of alarms is greater than 33, the error is still reported after half an hour), issue again 短信通知,
set Redis to 1, (ie reset the size of the number of Redis alarms), and update the data.

And set the platform survival status status to 0, update the data, and the number of errors reported in Redis +1;

Successful response

(The number of alarms size already exists in Redis, but the response is successful this time). Reset the number of alarms in redis to 0, set the platform survival status to 1, and update the database.

(As long as the platform is unavailable, send WeChat, send text messages in the first three minutes, and send text messages again after 30 minutes)

Send SMS

Insert picture description here
Parameters: MhaqSurvival
If the alarm status is 1, return directly without sending SMS;
otherwise, construct a parameter Map: templateParamsMap
parameter:

String content="平台:"+survival.getEntryName()+":"+survival.getVerUrl()+"失效";

Obtain mobile phone number String getPhones = survival.getPhone();
Create a new set of infos;
determine whether the obtained mobile phone number is empty, if it is not empty, pass , cut the mobile phone number string,
create a new log entity class MhaqInfoLog infoLog = new MhaqInfoLog();
record and send the log information;
then send the SMS, the parameter is the mobile phone number, templateParamsMap

Send WeChat

Insert picture description here
If the alarm status is 1, it will return directly without issuing.
The parameters are: MhaqSurvival
get getOpenId, get url getVerUrl,
split OpenID ,,
Insert picture description here
get time time;
loop through the OpenId array, create a new paras collection,

List<TemplateParam> paras=new ArrayList<TemplateParam>();
				paras.add(new TemplateParam("first","百事通加盟平台存活预警:","#930093"));
				paras.add(new TemplateParam("time",time,"#0044BB"));
				paras.add(new TemplateParam("ip_list",verUrl,"#0044BB"));
				paras.add(new TemplateParam("sec_type",content,"#0044BB"));
				monitorService.sendMsgByWeiXing(paras, openId, time);	

Build template parameters and send to WeChat.

Guess you like

Origin blog.csdn.net/DreamsArchitects/article/details/108779090