From ee90d2713f2d5f415a458bd04f59add32d7e3cb1 Mon Sep 17 00:00:00 2001 From: Jimmy Huang Date: Mon, 24 Jan 2022 13:31:49 +0800 Subject: [PATCH] refs issue-1201 in upstream. Add 100 characters from response body to bean.msg after keyword not match. --- server/model/monitor.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index c4441d63e..1866fdb7c 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -231,7 +231,11 @@ class Monitor extends BeanModel { bean.msg += ", keyword is found"; bean.status = UP; } else { - throw new Error(bean.msg + ", but keyword is not found"); + data = data.replace(/<[^>]*>?|[\n\r]|\s+/gm, " "); + if ( data.length > 50 ) { + data = data.substring(0, 47) + "..."; + } + throw new Error(bean.msg + ", but keyword is not in [ " + data + " ]"); } }