Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jfV5fwqjk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
管理员
jfV5fwqjk
Commits
5412bc5b
Commit
5412bc5b
authored
May 25, 2018
by
liuyz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送邮件
parent
d7c15aba
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
678 additions
and
96 deletions
+678
-96
emailaddress-rfc2822-1.0.1.jar
WebContent/WEB-INF/lib/emailaddress-rfc2822-1.0.1.jar
+0
-0
simple-java-mail-5.0.3.jar
WebContent/WEB-INF/lib/simple-java-mail-5.0.3.jar
+0
-0
triggerTab.js
WebContent/monitoring/pages/trigger/js/triggerTab.js
+1
-2
triggerTabDetail.jsp
WebContent/monitoring/pages/trigger/triggerTabDetail.jsp
+4
-4
userTab.js
WebContent/monitoring/pages/user/js/userTab.js
+19
-47
userTab.jsp
WebContent/monitoring/pages/user/userTab.jsp
+1
-1
userTabDetail.jsp
WebContent/monitoring/pages/user/userTabDetail.jsp
+20
-5
warningModule.js
WebContent/monitoring/pages/warning/js/warningModule.js
+5
-1
warningTab.js
WebContent/monitoring/pages/warning/js/warningTab.js
+141
-6
TriggerBusiness.java
src_monitoring/com/gaowj/business/TriggerBusiness.java
+3
-0
UserBusiness.java
src_monitoring/com/gaowj/business/UserBusiness.java
+8
-0
UsergroupBusiness.java
src_monitoring/com/gaowj/business/UsergroupBusiness.java
+3
-0
WarningBusiness.java
src_monitoring/com/gaowj/business/WarningBusiness.java
+3
-0
TriggerBusinessImpl.java
...oring/com/gaowj/business/trigger/TriggerBusinessImpl.java
+15
-1
triggerDAO.java
src_monitoring/com/gaowj/business/trigger/triggerDAO.java
+2
-0
triggerDAO.xml
src_monitoring/com/gaowj/business/trigger/triggerDAO.xml
+10
-0
UserBusinessImpl.java
src_monitoring/com/gaowj/business/user/UserBusinessImpl.java
+77
-4
userDAO.java
src_monitoring/com/gaowj/business/user/userDAO.java
+8
-0
userDAO.xml
src_monitoring/com/gaowj/business/user/userDAO.xml
+70
-0
UsergroupBusinessImpl.java
...g/com/gaowj/business/usergroup/UsergroupBusinessImpl.java
+7
-0
usergroupDAO.java
...monitoring/com/gaowj/business/usergroup/usergroupDAO.java
+2
-0
usergroupDAO.xml
src_monitoring/com/gaowj/business/usergroup/usergroupDAO.xml
+11
-0
WarningBusinessImpl.java
...oring/com/gaowj/business/warning/WarningBusinessImpl.java
+8
-0
warningDAO.java
src_monitoring/com/gaowj/business/warning/warningDAO.java
+1
-0
warningDAO.xml
src_monitoring/com/gaowj/business/warning/warningDAO.xml
+3
-0
actAction.java
src_monitoring/com/gaowj/trigger/action/actAction.java
+59
-25
actAction.java
src_monitoring/com/gaowj/warning/action/actAction.java
+66
-0
dataAction.java
src_monitoring/com/gaowj/warning/action/dataAction.java
+17
-0
actAction.java
src_monitoring/com/gaowj/zabbix/action/actAction.java
+80
-0
MailUtil.java
src_utils/com/gaowj/util/MailUtil.java
+34
-0
No files found.
WebContent/WEB-INF/lib/emailaddress-rfc2822-1.0.1.jar
0 → 100644
View file @
5412bc5b
File added
WebContent/WEB-INF/lib/simple-java-mail-5.0.3.jar
0 → 100644
View file @
5412bc5b
File added
WebContent/monitoring/pages/trigger/js/triggerTab.js
View file @
5412bc5b
...
@@ -230,8 +230,7 @@ function updateData(is_entity){
...
@@ -230,8 +230,7 @@ function updateData(is_entity){
* 备注:需更改
* 备注:需更改
**/
**/
function
deleteRow
(
index
){
function
deleteRow
(
index
){
var
is_row
=
$
(
'#list'
).
datagrid
(
'getData'
)[
index
];
var
is_row
=
$
(
'#list'
).
datagrid
(
'getData'
).
rowSet
[
index
];
var
code
=
is_row
.
TRIGGERID
;
var
code
=
is_row
.
TRIGGERID
;
$
.
messager
.
confirm
(
'提示'
,
'确定删除?'
,
function
(
r
)
{
$
.
messager
.
confirm
(
'提示'
,
'确定删除?'
,
function
(
r
)
{
if
(
r
)
{
if
(
r
)
{
...
...
WebContent/monitoring/pages/trigger/triggerTabDetail.jsp
View file @
5412bc5b
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<span>名称:</span>
<span>名称:</span>
</td>
</td>
<td style="width: 85%">
<td style="width: 85%">
<input class="easyui-textbox" id="COMMENTS" name="FIELD_COMMENTS" style="width:500px" />
<input class="easyui-textbox" id="COMMENTS" name="FIELD_COMMENTS" style="width:500px"
data-options="required:true"
/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<span>警告级别:</span>
<span>警告级别:</span>
</td>
</td>
<td style="width: 85%">
<td style="width: 85%">
<input class="easyui-textbox" id="PRIORITY" name="FIELD_PRIORITY" style="width:500px" />
<input class="easyui-textbox" id="PRIORITY" name="FIELD_PRIORITY" style="width:500px"
data-options="required:true"
/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<span>表达式:</span>
<span>表达式:</span>
</td>
</td>
<td style="width: 85%">
<td style="width: 85%">
<input class="easyui-textbox" id="EXPRESSION" name="FIELD_EXPRESSION" style="width:500px" />
<input class="easyui-textbox" id="EXPRESSION" name="FIELD_EXPRESSION" style="width:500px"
data-options="required:true"
/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
<span>描述:</span>
<span>描述:</span>
</td>
</td>
<td style="width: 85%">
<td style="width: 85%">
<input class="easyui-textbox" id="DESCRIPTION" name="FIELD_DESCRIPTION" style="width:500px" />
<input class="easyui-textbox" id="DESCRIPTION" name="FIELD_DESCRIPTION" style="width:500px"
data-options="required:true"
/>
</td>
</td>
</tr>
</tr>
</table>
</table>
...
...
WebContent/monitoring/pages/user/js/userTab.js
View file @
5412bc5b
...
@@ -62,12 +62,13 @@ var is_column = [ [
...
@@ -62,12 +62,13 @@ var is_column = [ [
},
},
{
field
:
'TELEPHONE'
,
title
:
'联系电话'
,
width
:
250
,
align
:
'center'
{
field
:
'TELEPHONE'
,
title
:
'联系电话'
,
width
:
250
,
align
:
'center'
},
},
{
field
:
'
WECHAT'
,
title
:
'微信
'
,
width
:
250
,
align
:
'center'
{
field
:
'
DINGDING'
,
title
:
'钉钉
'
,
width
:
250
,
align
:
'center'
}
}
]
];
]
];
//列表加载完成回调
//列表加载完成回调
function
dataOnLoadSuccess
(){
function
dataOnLoadSuccess
(){
}
}
//设置颜色和每行高度
//设置颜色和每行高度
function
rowstyler
(
index
,
row
){
function
rowstyler
(
index
,
row
){
return
'color:green;height:30px;'
;
return
'color:green;height:30px;'
;
...
@@ -156,6 +157,16 @@ function addUrlOnloadCallback(is_row){
...
@@ -156,6 +157,16 @@ function addUrlOnloadCallback(is_row){
onLoadSuccess
:
function
()
{}
onLoadSuccess
:
function
()
{}
});
});
}
}
$
.
extend
(
$
.
fn
.
validatebox
.
defaults
.
rules
,
{
mobile
:
{
//验证手机号
validator
:
function
(
value
,
param
){
return
/^1
[
3-8
]
+
\d{9}
$/
.
test
(
value
);
},
message
:
'请输入正确的手机号码。'
},
});
//保存
//保存
function
insertData
(
is_entity
){
function
insertData
(
is_entity
){
var
hostIds
=
""
;
var
hostIds
=
""
;
...
@@ -306,56 +317,17 @@ function searchRow(){
...
@@ -306,56 +317,17 @@ function searchRow(){
}
}
/****/
/****/
/**
* 序号:10
* 功能:高级查询弹出
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
//加载高级查询子页面
function
advsearchRow
(){
var
is_row
=
{
OPETYPE
:
'ww'
};
openAdvsearchRow
(
"studentView_studentAdvsearch"
,
is_row
,
"高级查询"
,
true
,
0.65
,
0.95
,
0
,
0
);
}
//加载高级查询子页面成功后的回调
function
addAdvsearchCallback
(
is_row
){
}
//高级查询
function
advsearchData
(
is_entity
){
$
(
'#list'
).
datagrid
(
'load'
,
is_entity
);
}
/****/
/**
/**
* 序号:1
1
* 序号:1
0
* 功能:
处理接口附
件
* 功能:
发送邮
件
* 参数:
* 参数:
* 说明:
* 说明:
* 作者:
高伟杰
* 作者:
刘筠臻
* 时间:201
6-01-22
* 时间:201
8-05-23
* 单位:
宁波金网
* 单位:
杰夫兄弟
* 备注:需更改
* 备注:需更改
**/
**/
function
uploadcommonRow
(
index
){
function
sendEmailRow
(
){
}
}
\ No newline at end of file
/****/
/**
* 序号:12
* 功能:批量处理接口附件
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
function
uploadcommonBatchRow
(){
}
/****/
\ No newline at end of file
WebContent/monitoring/pages/user/userTab.jsp
View file @
5412bc5b
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<table id="list" style="width: 100%; height: 100%;"></table>
<table id="list" style="width: 100%; height: 100%;"></table>
<div id="tb">
<div id="tb">
<form id="userTab_searchForm" style="float:left">
<form id="userTab_searchForm" style="float:left">
名称
: <input id="FIELD_USERNAME" name="FIELD_USERNAME" type="text" style="width: 200px" class="tableInput-easyui">
用户名
: <input id="FIELD_USERNAME" name="FIELD_USERNAME" type="text" style="width: 200px" class="tableInput-easyui">
</form>
</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
...
...
WebContent/monitoring/pages/user/userTabDetail.jsp
View file @
5412bc5b
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<span>用户名:</span>
<span>用户名:</span>
</td>
</td>
<td style="width: 85%">
<td style="width: 85%">
<input class="easyui-textbox" id="USERNAME" name="FIELD_USERNAME" style="width:250px" value="${is_row.NAME}"/>
<input class="easyui-textbox" id="USERNAME" name="FIELD_USERNAME" style="width:250px" value="${is_row.NAME}"
data-options="required:true"
/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<span>邮箱:</span>
<span>邮箱:</span>
</td>
</td>
<td>
<td>
<input class="easyui-textbox" id="EMAIL" name="FIELD_EMAIL" style="width:250px" value="${is_row.EMAIL}" />
<input class="easyui-textbox" id="EMAIL" name="FIELD_EMAIL" style="width:250px" value="${is_row.EMAIL}"
data-options="validType:'email'"
/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
...
@@ -24,15 +24,15 @@
...
@@ -24,15 +24,15 @@
<span>联系电话:</span>
<span>联系电话:</span>
</td>
</td>
<td>
<td>
<input class="easyui-textbox" id="TELEPHONE" name="FIELD_TELEPHONE" style="width:250px" value="${is_row.TELEPHONE}" />
<input class="easyui-textbox" id="TELEPHONE" name="FIELD_TELEPHONE" style="width:250px" value="${is_row.TELEPHONE}"
data-options="validType:'mobile'"
/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td class="tableStyleLable">
<td class="tableStyleLable">
<span>
微信
:</span>
<span>
钉钉
:</span>
</td>
</td>
<td>
<td>
<input class="easyui-textbox" id="
WECHAT" name="FIELD_WECHAT" style="width:250px" value="${is_row.WECHAT
}"/>
<input class="easyui-textbox" id="
DINGDING" name="FIELD_DINGDING" style="width:250px" value="${is_row.DINGDING
}"/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
...
@@ -45,3 +45,17 @@
...
@@ -45,3 +45,17 @@
</tr>
</tr>
</table>
</table>
</form>
</form>
<script type="text/javascript">
$.extend($.fn.validatebox.defaults.rules, {
mobile: { //验证手机号
validator: function(value, param){
return /^1[3-8]+\d{9}$/.test(value);
},
message: '请输入正确的手机号码。'
}
});
</script>
\ No newline at end of file
WebContent/monitoring/pages/warning/js/warningModule.js
View file @
5412bc5b
...
@@ -10,9 +10,13 @@ warningModule.prototype = BusinessObject;
...
@@ -10,9 +10,13 @@ warningModule.prototype = BusinessObject;
//查询警告列表
//查询警告列表
warningModule
.
prototype
.
list
=
function
(){};
warningModule
.
prototype
.
list
=
function
(){};
//发送邮件
warningModule
.
prototype
.
sendMail
=
function
(){};
//创建一个数据获取对象,然后再后续使用
//创建一个数据获取对象,然后再后续使用
warningModule
.
warningDataAction
=
new
warningModule
(
"json"
).
delegate
(
"warningData"
);
warningModule
.
data
=
new
warningModule
(
"json"
).
delegate
(
"warningData"
);
//创建一个数据操作对象,然后再后续使用
warningModule
.
act
=
new
warningModule
(
"json"
).
delegate
(
"warningAct"
);
//说明: 1、所有方法里统一传递josn格式的参数,用于后台交互,如data.listTables(param) ,如没有参数则传'{}',如data.listTables({})
//说明: 1、所有方法里统一传递josn格式的参数,用于后台交互,如data.listTables(param) ,如没有参数则传'{}',如data.listTables({})
// 2、前后台数据获取传输协议 如:json[{'0':{pageCount':'2','pageNo':'1','pageSize':'20','rowSet':'[{0},{1}....]'}}]
// 2、前后台数据获取传输协议 如:json[{'0':{pageCount':'2','pageNo':'1','pageSize':'20','rowSet':'[{0},{1}....]'}}]
...
...
WebContent/monitoring/pages/warning/js/warningTab.js
View file @
5412bc5b
...
@@ -36,9 +36,12 @@ function resetQueryData(){
...
@@ -36,9 +36,12 @@ function resetQueryData(){
* 备注:需更改
* 备注:需更改
**/
**/
//加载状态数据
//加载状态数据
var
v_
status
_data
=
[{
CODE_ID
:
'0'
,
CODE_NAME
:
'正常'
},{
CODE_ID
:
'1'
,
CODE_NAME
:
'问题'
}];
var
v_
value
_data
=
[{
CODE_ID
:
'0'
,
CODE_NAME
:
'正常'
},{
CODE_ID
:
'1'
,
CODE_NAME
:
'问题'
}];
//加载主机列表
//加载主机列表
var
v_host_data
=
hostModule
.
data
.
listAll
().
rowSet
;
var
v_host_data
=
hostModule
.
data
.
listAll
().
rowSet
;
//加载是否提醒数据
var
v_status_data
=
[{
CODE_ID
:
'0'
,
CODE_NAME
:
'未发送'
},{
CODE_ID
:
'1'
,
CODE_NAME
:
'已发送'
}];
/****/
/****/
/**
/**
...
@@ -59,9 +62,9 @@ var is_column = [ [
...
@@ -59,9 +62,9 @@ var is_column = [ [
{
field
:
'DESCRIPTION'
,
title
:
'问题描述'
,
width
:
300
,
align
:
'center'
{
field
:
'DESCRIPTION'
,
title
:
'问题描述'
,
width
:
300
,
align
:
'center'
},
},
{
field
:
'VALUE'
,
title
:
'状态'
,
width
:
120
,
align
:
'center'
,
formatter
:
function
(
value
,
row
,
index
){
{
field
:
'VALUE'
,
title
:
'状态'
,
width
:
120
,
align
:
'center'
,
formatter
:
function
(
value
,
row
,
index
){
for
(
var
i
=
0
;
i
<
v_
status
_data
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
v_
value
_data
.
length
;
i
++
){
if
(
v_
status
_data
[
i
].
CODE_ID
==
value
){
if
(
v_
value
_data
[
i
].
CODE_ID
==
value
){
return
v_
status
_data
[
i
].
CODE_NAME
;
return
v_
value
_data
[
i
].
CODE_NAME
;
}
}
}
}
}},
}},
...
@@ -71,12 +74,21 @@ var is_column = [ [
...
@@ -71,12 +74,21 @@ var is_column = [ [
newDate
.
setTime
(
value
*
1000
);
newDate
.
setTime
(
value
*
1000
);
return
newDate
.
toLocaleString
();
return
newDate
.
toLocaleString
();
}
}
},
{
field
:
'STATUS'
,
title
:
'发送状态'
,
width
:
200
,
align
:
'center'
,
formatter
:
function
(
value
)
{
for
(
var
i
=
0
;
i
<
v_value_data
.
length
;
i
++
)
{
if
(
v_status_data
[
i
].
CODE_ID
==
value
)
{
return
v_status_data
[
i
].
CODE_NAME
;
}
}
}
}
}
]
];
]
];
//列表加载完成回调
//列表加载完成回调
function
dataOnLoadSuccess
(){
function
dataOnLoadSuccess
(){
$
(
'#FIELD_VALUE'
).
combobox
({
$
(
'#FIELD_VALUE'
).
combobox
({
data
:
v_
status
_data
,
data
:
v_
value
_data
,
valueField
:
'CODE_ID'
,
valueField
:
'CODE_ID'
,
textField
:
'CODE_NAME'
,
textField
:
'CODE_NAME'
,
editable
:
false
,
editable
:
false
,
...
@@ -101,8 +113,131 @@ function rowstyler(index,row){
...
@@ -101,8 +113,131 @@ function rowstyler(index,row){
}
}
}
}
//展示列表
//展示列表
datagridLog
(
"list"
,
ls_title
,
gaowj
.
WEB_APP_NAME
+
"/warningData_list"
,
queryData
,
is_column
,
60
,
80
);
datagrid
(
"list"
,
ls_title
,
gaowj
.
WEB_APP_NAME
+
"/warningData_list"
,
queryData
,
is_column
,
70
,
80
);
/****/
/**
* 序号:4
* 功能:设置主页面操作列菜单
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
//操用列显示更多(一般情况下无需更改)
function
formatMenu
(
value
,
data
,
index
)
{
var
returnData
=
""
;
return
returnData
+
"<span class=
\"
icon-ext-moremenu
\"
style=
\"
padding-left:20px;*width:20px;
\"
></span>"
+
"<span data-p1="
+
index
+
" class=
\"
easyui-tooltip
\"
style=
\"
color:blue;cursor:pointer;
\"
>更多</span>"
;
}
//上浮横向菜单集里的具体菜单项(需更改)
function
getOptionMenu
(
data
,
index
){
//上浮菜单具体按钮
var
optionMenu
=
new
Array
();
optionMenu
[
0
]
=
makeBtnOneParama
(
'发送邮件'
,
'icon-edit'
,
"sendMailRow"
,
index
);
optionMenu
[
1
]
=
makeBtnOneParama
(
'发送短信'
,
'icon-edit'
,
"sendMsgRow"
,
index
);
optionMenu
[
2
]
=
makeBtnOneParama
(
'发送钉钉'
,
'icon-edit'
,
"sendDingRow"
,
index
);
var
splitStr
=
' | '
;
var
returnData
=
''
;
for
(
var
i
=
0
;
i
<
optionMenu
.
length
;
i
++
){
returnData
+=
splitStr
+
optionMenu
[
i
];
}
return
returnData
.
substr
(
splitStr
.
length
-
1
);
}
//单个按钮构造
function
makeBtn
(
text
,
cssClass
,
click
){
return
"<span class=
\"
"
+
cssClass
+
"
\"
style=
\"
padding-left:20px;*width:20px;
\"
></span><a href=
\"
javascript:void(0);
\"
onclick=
\"
"
+
click
+
"
\"
>"
+
text
+
"</a>"
;
}
//单按钮单参数构造
function
makeBtnOneParama
(
text
,
cssClass
,
clickName
,
index
){
return
makeBtn
(
text
,
cssClass
,
clickName
+
"('"
+
index
+
"')"
);
}
//返回菜单集的菜单个数(需更改)
function
getOptionMenuCount
(){
var
is_menu_count
=
3
;
return
is_menu_count
;
}
/****/
/**
* 序号:5
* 功能:发送邮件
* 参数:
* 说明:
* 作者:刘筠臻
* 时间:2018-05-24
* 单位:杰夫兄弟
* 备注:需更改
**/
function
sendMailRow
(
index
){
var
is_row
=
$
(
'#list'
).
datagrid
(
'getData'
).
rowSet
[
index
];
var
code
=
is_row
.
EVENTID
;
$
.
messager
.
confirm
(
'提示'
,
'确定发送?'
,
function
(
r
)
{
if
(
r
)
{
var
v_query
=
{};
v_query
.
FIELD_EVENTID
=
code
;
var
v_result
=
warningModule
.
act
.
sendMail
(
v_query
);
$
.
messager
.
alert
(
'提示'
,
v_result
.
VALUE
);
$
(
'#list'
).
datagrid
(
'reload'
);
}
});
}
/****/
/**
* 序号:6
* 功能:发送短信
* 参数:
* 说明:
* 作者:刘筠臻
* 时间:2018-05-24
* 单位:杰夫兄弟
* 备注:需更改
**/
function
sendMsgRow
(){
/*$.messager.confirm('提示', '确定发送?', function(r) {
if (r) {
var v_query = {};
v_query.FIELD_EVENTID = code;
var v_result = warningModule.act.sendMsg(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
});*/
}
/****/
/**
* 序号:7
* 功能:发送钉钉
* 参数:
* 说明:
* 作者:刘筠臻
* 时间:2018-05-24
* 单位:杰夫兄弟
* 备注:需更改
**/
function
sendDingRow
(){
/*$.messager.confirm('提示', '确定发送?', function(r) {
if (r) {
var v_query = {};
v_query.FIELD_EVENTID = code;
var v_result = warningModule.act.sendDing(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
});*/
}
/****/
/****/
/**
/**
...
...
src_monitoring/com/gaowj/business/TriggerBusiness.java
View file @
5412bc5b
package
com
.
gaowj
.
business
;
package
com
.
gaowj
.
business
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -17,4 +18,6 @@ public interface TriggerBusiness {
...
@@ -17,4 +18,6 @@ public interface TriggerBusiness {
*/
*/
Page
<
Map
<
String
,
Object
>>
list_trigger
(
int
pageNo
,
int
pageSize
,
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
Page
<
Map
<
String
,
Object
>>
list_trigger
(
int
pageNo
,
int
pageSize
,
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_media_type
(
Map
<
String
,
Object
>
entity
);
}
}
src_monitoring/com/gaowj/business/UserBusiness.java
View file @
5412bc5b
...
@@ -25,4 +25,12 @@ public interface UserBusiness {
...
@@ -25,4 +25,12 @@ public interface UserBusiness {
void
update_user
(
Map
<
String
,
Object
>
entity
)
throws
BusinessException
;
void
update_user
(
Map
<
String
,
Object
>
entity
)
throws
BusinessException
;
void
delete_user
(
List
<
String
>
listKey
)
throws
BusinessException
;
void
delete_user
(
List
<
String
>
listKey
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_event_send
(
Map
<
String
,
Object
>
entity
);
List
<
Map
<
String
,
Object
>>
list_user_host_view
(
Map
<
String
,
Object
>
entity
);
void
insert_event_send
(
Map
<
String
,
Object
>
entity
)
throws
BusinessException
;
void
insert_event_send_detail
(
Map
<
String
,
Object
>
entity
,
String
send_id
,
int
type
);
}
}
src_monitoring/com/gaowj/business/UsergroupBusiness.java
View file @
5412bc5b
package
com
.
gaowj
.
business
;
package
com
.
gaowj
.
business
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -16,4 +17,6 @@ public interface UsergroupBusiness {
...
@@ -16,4 +17,6 @@ public interface UsergroupBusiness {
* @throws BusinessException
* @throws BusinessException
*/
*/
Page
<
Map
<
String
,
Object
>>
list_usergroup
(
int
pageNo
,
int
pageSize
,
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
Page
<
Map
<
String
,
Object
>>
list_usergroup
(
int
pageNo
,
int
pageSize
,
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_usergroup
(
Map
<
String
,
Object
>
query
);
}
}
src_monitoring/com/gaowj/business/WarningBusiness.java
View file @
5412bc5b
package
com
.
gaowj
.
business
;
package
com
.
gaowj
.
business
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -16,4 +17,6 @@ public interface WarningBusiness {
...
@@ -16,4 +17,6 @@ public interface WarningBusiness {
* @throws BusinessException
* @throws BusinessException
*/
*/
Page
<
Map
<
String
,
Object
>>
list_warning
(
int
pageNo
,
int
pageSize
,
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
Page
<
Map
<
String
,
Object
>>
list_warning
(
int
pageNo
,
int
pageSize
,
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_warning
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
}
}
src_monitoring/com/gaowj/business/trigger/TriggerBusinessImpl.java
View file @
5412bc5b
...
@@ -24,13 +24,16 @@ public class TriggerBusinessImpl implements TriggerBusiness {
...
@@ -24,13 +24,16 @@ public class TriggerBusinessImpl implements TriggerBusiness {
}
}
@Override
@Override
public
Page
<
Map
<
String
,
Object
>>
list_trigger
(
int
pageNo
,
int
pageSize
,
Map
<
String
,
Object
>
query
)
throws
BusinessException
{
public
Page
<
Map
<
String
,
Object
>>
list_trigger
(
int
pageNo
,
int
pageSize
,
Map
<
String
,
Object
>
query
)
throws
BusinessException
{
// 计算起始记录
// 计算起始记录
int
pageStart
=
(
pageNo
-
1
)
*
pageSize
;
int
pageStart
=
(
pageNo
-
1
)
*
pageSize
;
// 获取列表
// 获取列表
List
<
Map
<
String
,
Object
>>
items
=
triggerDAO
.
list_trigger
(
new
RowBounds
(
pageStart
,
pageSize
),
query
);
List
<
Map
<
String
,
Object
>>
items
=
triggerDAO
.
list_trigger
(
new
RowBounds
(
pageStart
,
pageSize
),
query
);
if
(
items
.
size
()
>
0
)
{
change_expression
(
items
);
change_expression
(
items
);
}
// 获取列表个数
// 获取列表个数
int
count
=
triggerDAO
.
list_count_trigger
(
query
);
int
count
=
triggerDAO
.
list_count_trigger
(
query
);
...
@@ -89,4 +92,15 @@ public class TriggerBusinessImpl implements TriggerBusiness {
...
@@ -89,4 +92,15 @@ public class TriggerBusinessImpl implements TriggerBusiness {
}
}
return
keyword
;
return
keyword
;
}
}
/**
* 查询media_type的信息
*
* @param entity
*/
@Override
public
List
<
Map
<
String
,
Object
>>
list_media_type
(
Map
<
String
,
Object
>
entity
)
{
List
<
Map
<
String
,
Object
>>
items
=
triggerDAO
.
list_media_type
(
entity
);
return
items
;
}
}
}
src_monitoring/com/gaowj/business/trigger/triggerDAO.java
View file @
5412bc5b
...
@@ -13,4 +13,6 @@ public interface triggerDAO {
...
@@ -13,4 +13,6 @@ public interface triggerDAO {
int
list_count_trigger
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
int
list_count_trigger
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_function
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_function
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_media_type
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
}
}
src_monitoring/com/gaowj/business/trigger/triggerDAO.xml
View file @
5412bc5b
...
@@ -46,4 +46,13 @@
...
@@ -46,4 +46,13 @@
</if>
</if>
</trim>
</trim>
</select>
</select>
<select
id=
"list_media_type"
parameterType=
"map"
resultType=
"upperCaseKeyMap"
>
SELECT * from media_type m
<trim
prefix=
"WHERE"
prefixOverrides=
"AND |OR"
>
<if
test=
"DESCRIPTION != null and DESCRIPTION != ''"
>
and m.DESCRIPTION = #{DESCRIPTION}
</if>
</trim>
</select>
</mapper>
</mapper>
\ No newline at end of file
src_monitoring/com/gaowj/business/user/UserBusinessImpl.java
View file @
5412bc5b
...
@@ -37,7 +37,7 @@ public class UserBusinessImpl implements UserBusiness{
...
@@ -37,7 +37,7 @@ public class UserBusinessImpl implements UserBusiness{
List
<
Map
<
String
,
Object
>>
items
=
userDAO
.
list_user
(
new
RowBounds
(
pageStart
,
pageSize
),
query
);
List
<
Map
<
String
,
Object
>>
items
=
userDAO
.
list_user
(
new
RowBounds
(
pageStart
,
pageSize
),
query
);
for
(
Map
<
String
,
Object
>
map
:
items
){
for
(
Map
<
String
,
Object
>
map
:
items
){
Map
<
String
,
Object
>
queryhost
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
queryhost
=
new
HashMap
<
String
,
Object
>();
queryhost
.
put
(
"USERID"
,
map
.
get
(
"U
SER
ID"
));
queryhost
.
put
(
"USERID"
,
map
.
get
(
"U
U
ID"
));
//查询用户管理的主机信息
//查询用户管理的主机信息
List
<
Map
<
String
,
Object
>>
list_user_host
=
userDAO
.
list_user_host
(
queryhost
);
List
<
Map
<
String
,
Object
>>
list_user_host
=
userDAO
.
list_user_host
(
queryhost
);
List
<
Integer
>
list_host_id
=
new
ArrayList
<
Integer
>();
List
<
Integer
>
list_host_id
=
new
ArrayList
<
Integer
>();
...
@@ -45,9 +45,6 @@ public class UserBusinessImpl implements UserBusiness{
...
@@ -45,9 +45,6 @@ public class UserBusinessImpl implements UserBusiness{
list_host_id
.
add
(
Integer
.
valueOf
(
user_host
.
get
(
"HOSTID"
).
toString
()));
list_host_id
.
add
(
Integer
.
valueOf
(
user_host
.
get
(
"HOSTID"
).
toString
()));
}
}
map
.
put
(
"LIST_HOST_ID"
,
list_host_id
);
map
.
put
(
"LIST_HOST_ID"
,
list_host_id
);
/*HostBusiness hostBusiness = BusinessManager.getBusiness(HostBusiness.class);
Map<String,Object> host = hostBusiness.query_host_id(Integer.valueOf(map.get("HOSTID").toString()));
map.put("HOSTNAME", host.get("NAME"));*/
}
}
// 获取列表个数
// 获取列表个数
int
count
=
userDAO
.
list_count_user
(
query
);
int
count
=
userDAO
.
list_count_user
(
query
);
...
@@ -166,4 +163,80 @@ public class UserBusinessImpl implements UserBusiness{
...
@@ -166,4 +163,80 @@ public class UserBusinessImpl implements UserBusiness{
userDAO
.
delete_user
(
listKey
);
userDAO
.
delete_user
(
listKey
);
}
}
@Override
public
List
<
Map
<
String
,
Object
>>
list_event_send
(
Map
<
String
,
Object
>
query
)
{
List
<
Map
<
String
,
Object
>>
list_event_send
=
userDAO
.
list_event_send
(
query
);
return
list_event_send
;
}
@Override
public
List
<
Map
<
String
,
Object
>>
list_user_host_view
(
Map
<
String
,
Object
>
entity
)
{
// 获取列表
List
<
Map
<
String
,
Object
>>
list_user
=
userDAO
.
list_user_host_view
(
entity
);
return
list_user
;
}
@Override
public
void
insert_event_send
(
Map
<
String
,
Object
>
entity
)
throws
BusinessException
{
if
(
entity
.
get
(
"UUID"
)
==
null
)
{
entity
.
put
(
"UUID"
,
java
.
util
.
UUID
.
randomUUID
().
toString
());
}
if
(
entity
.
get
(
"CREATE_TIME"
)
==
null
)
{
entity
.
put
(
"CREATE_TIME"
,
new
Date
());
}
// 动态传值插入
List
<
String
>
infoListKey
=
new
ArrayList
<
String
>();
List
<
Object
>
infoList
=
new
ArrayList
<
Object
>();
if
(
entity
.
keySet
()
!=
null
)
{
Set
<
String
>
key
=
entity
.
keySet
();
// 将map集合中的key和value 取出来分别放到list集合里
for
(
String
str
:
key
)
{
infoList
.
add
(
entity
.
get
(
str
));
infoListKey
.
add
(
str
);
}
entity
.
put
(
"infoListKey"
,
infoListKey
);
entity
.
put
(
"infoList"
,
infoList
);
// 插入
userDAO
.
insert_event_send
(
entity
);
}
}
@Override
public
void
insert_event_send_detail
(
Map
<
String
,
Object
>
entity
,
String
send_id
,
int
type
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"UUID"
,
java
.
util
.
UUID
.
randomUUID
().
toString
());
map
.
put
(
"EVENT_SEND_ID"
,
send_id
);
map
.
put
(
"USERID"
,
entity
.
get
(
"UUID"
));
map
.
put
(
"type"
,
type
);
if
(
"0"
.
equals
(
type
))
{
// 手机号
map
.
put
(
"VALUE"
,
entity
.
get
(
"TELEPHONE"
));
}
else
if
(
type
==
1
)
{
// 邮箱
map
.
put
(
"VALUE"
,
entity
.
get
(
"EMAIL"
));
}
else
if
(
"2"
.
equals
(
type
))
{
// 钉钉
map
.
put
(
"VALUE"
,
entity
.
get
(
"DINGDING"
));
}
map
.
put
(
"IS_SUCCESS"
,
1
);
// 动态传值插入
List
<
String
>
infoListKey
=
new
ArrayList
<
String
>();
List
<
Object
>
infoList
=
new
ArrayList
<
Object
>();
if
(
map
.
keySet
()
!=
null
)
{
Set
<
String
>
key
=
map
.
keySet
();
// 将map集合中的key和value 取出来分别放到list集合里
for
(
String
str
:
key
)
{
infoList
.
add
(
map
.
get
(
str
));
infoListKey
.
add
(
str
);
}
map
.
put
(
"infoListKey"
,
infoListKey
);
map
.
put
(
"infoList"
,
infoList
);
// 插入
userDAO
.
insert_event_send_detail
(
map
);
}
}
}
}
src_monitoring/com/gaowj/business/user/userDAO.java
View file @
5412bc5b
...
@@ -25,4 +25,12 @@ public interface userDAO {
...
@@ -25,4 +25,12 @@ public interface userDAO {
void
insert_user_host
(
Map
<
String
,
Object
>
entity
)
throws
BusinessException
;
void
insert_user_host
(
Map
<
String
,
Object
>
entity
)
throws
BusinessException
;
void
delete_user_host
(
String
userId
)
throws
BusinessException
;
void
delete_user_host
(
String
userId
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_event_send
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_user_host_view
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
void
insert_event_send
(
Map
<
String
,
Object
>
entity
)
throws
BusinessException
;
void
insert_event_send_detail
(
Map
<
String
,
Object
>
entity
)
throws
BusinessException
;
}
}
src_monitoring/com/gaowj/business/user/userDAO.xml
View file @
5412bc5b
...
@@ -120,4 +120,73 @@
...
@@ -120,4 +120,73 @@
delete from c_t_zabbix_user_host where USERID = #{USERID}
delete from c_t_zabbix_user_host where USERID = #{USERID}
]]>
]]>
</delete>
</delete>
<select
id=
"list_event_send"
parameterType=
"map"
resultType=
"upperCaseKeyMap"
>
<![CDATA[
select f.*
from c_t_zabbix_event_send f where 1=1
]]>
<if
test=
"UUID != null and UUID != ''"
>
and f.UUID = #{UUID}
</if>
<if
test=
"START_TIME != null and START_TIME != ''"
>
and f.CREATE_TIME
>
= #{START_TIME}
</if>
<if
test=
"END_TIME != null and END_TIME != ''"
>
and f.CREATE_TIME
<
= #{END_TIME}
</if>
<if
test=
"EVENTID != null and EVENTID != ''"
>
and f.EVENTID = #{EVENTID}
</if>
order by f.CREATE_TIME DESC
</select>
<select
id=
"list_user_host_view"
parameterType=
"map"
resultType=
"upperCaseKeyMap"
>
<![CDATA[
select f.*
from user_host_view f where 1=1
]]>
<if
test=
"START_TIME != null and START_TIME != ''"
>
and f.CREATE_TIME
>
= #{START_TIME}
</if>
<if
test=
"END_TIME != null and END_TIME != ''"
>
and f.CREATE_TIME
<
= #{END_TIME}
</if>
<if
test=
"HOSTID != null and HOSTID != ''"
>
and f.HOSTID = #{HOSTID}
</if>
order by f.CREATE_TIME DESC
</select>
<insert
id=
"insert_event_send"
parameterType=
"map"
>
insert into c_t_zabbix_event_send(
<trim
prefix=
""
suffixOverrides=
","
>
<foreach
collection=
"infoListKey"
item=
"key"
>
${key},
</foreach>
</trim>
<![CDATA[ ) values( ]]>
<trim
prefix=
""
suffixOverrides=
","
>
<foreach
collection=
"infoList"
item=
"value"
>
#{value},
</foreach>
</trim>
<![CDATA[ ) ]]>
</insert>
<insert
id=
"insert_event_send_detail"
parameterType=
"map"
>
insert into c_t_zabbix_event_send_detail(
<trim
prefix=
""
suffixOverrides=
","
>
<foreach
collection=
"infoListKey"
item=
"key"
>
${key},
</foreach>
</trim>
<![CDATA[ ) values( ]]>
<trim
prefix=
""
suffixOverrides=
","
>
<foreach
collection=
"infoList"
item=
"value"
>
#{value},
</foreach>
</trim>
<![CDATA[ ) ]]>
</insert>
</mapper>
</mapper>
\ No newline at end of file
src_monitoring/com/gaowj/business/usergroup/UsergroupBusinessImpl.java
View file @
5412bc5b
...
@@ -41,4 +41,11 @@ public class UsergroupBusinessImpl implements UsergroupBusiness {
...
@@ -41,4 +41,11 @@ public class UsergroupBusinessImpl implements UsergroupBusiness {
return
page
;
return
page
;
}
}
@Override
public
List
<
Map
<
String
,
Object
>>
list_usergroup
(
Map
<
String
,
Object
>
query
)
{
// 获取列表
List
<
Map
<
String
,
Object
>>
usergrp
=
usergroupDAO
.
list_usergroup_detail
(
query
);
return
usergrp
;
}
}
}
src_monitoring/com/gaowj/business/usergroup/usergroupDAO.java
View file @
5412bc5b
...
@@ -11,4 +11,6 @@ public interface usergroupDAO {
...
@@ -11,4 +11,6 @@ public interface usergroupDAO {
List
<
Map
<
String
,
Object
>>
list_usergroup
(
RowBounds
rowbounds
,
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_usergroup
(
RowBounds
rowbounds
,
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
int
list_count_usergroup
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
int
list_count_usergroup
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_usergroup_detail
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
}
}
src_monitoring/com/gaowj/business/usergroup/usergroupDAO.xml
View file @
5412bc5b
...
@@ -19,4 +19,14 @@
...
@@ -19,4 +19,14 @@
SELECT count(*) from usrgrp t
SELECT count(*) from usrgrp t
<include
refid=
"Where_Clause"
/>
<include
refid=
"Where_Clause"
/>
</select>
</select>
<select
id=
"list_usergroup_detail"
parameterType=
"map"
resultType=
"upperCaseKeyMap"
>
SELECT * from usrgrp t
<trim
prefix=
"WHERE"
prefixOverrides=
"AND |OR"
>
<if
test=
"NAME != null and NAME != ''"
>
and t.NAME = #{NAME}
</if>
</trim>
order by t.usrgrpid DESC
</select>
</mapper>
</mapper>
\ No newline at end of file
src_monitoring/com/gaowj/business/warning/WarningBusinessImpl.java
View file @
5412bc5b
...
@@ -29,6 +29,7 @@ public class WarningBusinessImpl implements WarningBusiness{
...
@@ -29,6 +29,7 @@ public class WarningBusinessImpl implements WarningBusiness{
// 获取列表
// 获取列表
List
<
Map
<
String
,
Object
>>
items
=
warningDAO
.
list_warning
(
new
RowBounds
(
pageStart
,
pageSize
),
query
);
List
<
Map
<
String
,
Object
>>
items
=
warningDAO
.
list_warning
(
new
RowBounds
(
pageStart
,
pageSize
),
query
);
// 获取列表个数
// 获取列表个数
int
count
=
warningDAO
.
list_count_warning
(
query
);
int
count
=
warningDAO
.
list_count_warning
(
query
);
...
@@ -41,4 +42,11 @@ public class WarningBusinessImpl implements WarningBusiness{
...
@@ -41,4 +42,11 @@ public class WarningBusinessImpl implements WarningBusiness{
return
page
;
return
page
;
}
}
@Override
public
List
<
Map
<
String
,
Object
>>
list_warning
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
{
// 获取列表
List
<
Map
<
String
,
Object
>>
events
=
warningDAO
.
list_warning
(
query
);
return
events
;
}
}
}
src_monitoring/com/gaowj/business/warning/warningDAO.java
View file @
5412bc5b
...
@@ -11,4 +11,5 @@ public interface warningDAO {
...
@@ -11,4 +11,5 @@ public interface warningDAO {
int
list_count_warning
(
Map
<
String
,
Object
>
query
);
int
list_count_warning
(
Map
<
String
,
Object
>
query
);
List
<
Map
<
String
,
Object
>>
list_warning
(
Map
<
String
,
Object
>
query
);
}
}
src_monitoring/com/gaowj/business/warning/warningDAO.xml
View file @
5412bc5b
...
@@ -9,6 +9,9 @@
...
@@ -9,6 +9,9 @@
<if
test=
"VALUE != null and VALUE != ''"
>
<if
test=
"VALUE != null and VALUE != ''"
>
and h.VALUE = #{VALUE}
and h.VALUE = #{VALUE}
</if>
</if>
<if
test=
"EVENTID != null and EVENTID != ''"
>
and h.EVENTID = #{EVENTID}
</if>
</trim>
</trim>
</sql>
</sql>
<select
id=
"list_warning"
parameterType=
"map"
resultType=
"upperCaseKeyMap"
>
<select
id=
"list_warning"
parameterType=
"map"
resultType=
"upperCaseKeyMap"
>
...
...
src_monitoring/com/gaowj/trigger/action/actAction.java
View file @
5412bc5b
package
com
.
gaowj
.
trigger
.
action
;
package
com
.
gaowj
.
trigger
.
action
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.UUID
;
import
com.gaowj.business.TriggerBusiness
;
import
com.gaowj.business.UsergroupBusiness
;
import
com.gaowj.business.action.BasicAction
;
import
com.gaowj.business.action.BasicAction
;
import
com.gaowj.business.comp.BusinessManager
;
import
com.gaowj.business.exception.BusinessException
;
import
com.gaowj.business.exception.BusinessException
;
import
com.gaowj.business.util.RequestUtils
;
import
com.gaowj.business.util.RequestUtils
;
import
com.gaowj.business.util.Status
;
import
com.gaowj.business.util.Status
;
...
@@ -79,11 +83,23 @@ public class actAction extends BasicAction {
...
@@ -79,11 +83,23 @@ public class actAction extends BasicAction {
params
.
setComments
(
entity
.
get
(
"COMMENTS"
).
toString
());
params
.
setComments
(
entity
.
get
(
"COMMENTS"
).
toString
());
TriggerCreateResponse
response
=
zabbixApi
.
trigger
().
create
(
request
);
TriggerCreateResponse
response
=
zabbixApi
.
trigger
().
create
(
request
);
//插入动作
insertAction
(
response
);
jsonObject
.
putAll
(
Status
.
getStatusSuccessMessage
(
"保存成功"
));
}
catch
(
Exception
e
)
{
jsonObject
.
putAll
(
Status
.
getStatusErrorMessage
(
"保存失败"
));
e
.
printStackTrace
();
}
return
"json"
;
}
private
void
insertAction
(
TriggerCreateResponse
response
)
throws
ZabbixApiException
{
TriggerCreateResponse
.
Result
result
=
response
.
getResult
();
TriggerCreateResponse
.
Result
result
=
response
.
getResult
();
List
<
Integer
>
triggerids
=
result
.
getTriggerids
();
List
<
Integer
>
triggerids
=
result
.
getTriggerids
();
ActionCreateRequest
request2
=
new
ActionCreateRequest
();
ActionCreateRequest
createRequest
=
new
ActionCreateRequest
();
Params
e
=
request2
.
createParam
();
Params
e
=
createRequest
.
createParam
();
e
.
setName
(
UUID
.
randomUUID
().
toString
());
e
.
setName
(
UUID
.
randomUUID
().
toString
());
e
.
setStatus
(
0
);
e
.
setStatus
(
0
);
e
.
setEventsource
(
0
);
e
.
setEventsource
(
0
);
...
@@ -98,29 +114,36 @@ public class actAction extends BasicAction {
...
@@ -98,29 +114,36 @@ public class actAction extends BasicAction {
//操作持续时间
//操作持续时间
ActionOperation
actionOperation
=
new
ActionOperation
();
ActionOperation
actionOperation
=
new
ActionOperation
();
actionOperation
.
setOperationtype
(
0
);
actionOperation
.
setOperationtype
(
0
);
actionOperation
.
setEsc_period
(
6
0
);
actionOperation
.
setEsc_period
(
12
0
);
//用户组信息
//用户组信息
List
<
OperationMessageGroup
>
opmessage_grp
=
new
ArrayList
<
OperationMessageGroup
>();
List
<
OperationMessageGroup
>
opmessage_grp
=
new
ArrayList
<
OperationMessageGroup
>();
OperationMessageGroup
grp
=
new
OperationMessageGroup
();
OperationMessageGroup
grp
=
new
OperationMessageGroup
();
grp
.
setUsrgrpid
(
7
);
//查询用户组id
UsergroupBusiness
ugpBusiness
=
BusinessManager
.
getBusiness
(
UsergroupBusiness
.
class
);
Map
<
String
,
Object
>
query
=
new
HashMap
<
String
,
Object
>();
query
.
put
(
"NAME"
,
"Zabbix administrators"
);
List
<
Map
<
String
,
Object
>>
list_ugp
=
ugpBusiness
.
list_usergroup
(
query
);
if
(
list_ugp
.
size
()
>
0
)
{
grp
.
setUsrgrpid
(
Integer
.
valueOf
(
list_ugp
.
get
(
0
).
get
(
"USRGRPID"
).
toString
()));
opmessage_grp
.
add
(
grp
);
opmessage_grp
.
add
(
grp
);
actionOperation
.
setOpmessage_grp
(
opmessage_grp
);
actionOperation
.
setOpmessage_grp
(
opmessage_grp
);
}
//消息类型信息
//消息类型信息
//查询消息类型id
TriggerBusiness
business
=
BusinessManager
.
getBusiness
(
TriggerBusiness
.
class
);
Map
<
String
,
Object
>
media_query
=
new
HashMap
<
String
,
Object
>();
media_query
.
put
(
"DESCRIPTION"
,
"sendrequest"
);
List
<
Map
<
String
,
Object
>>
list_mediaType
=
business
.
list_media_type
(
media_query
);
if
(
list_mediaType
.
size
()
>
0
)
{
OperationMessage
opmessage
=
new
OperationMessage
();
OperationMessage
opmessage
=
new
OperationMessage
();
opmessage
.
setMediatypeid
(
4
);
opmessage
.
setMediatypeid
(
Integer
.
valueOf
(
list_mediaType
.
get
(
0
).
get
(
"MEDIATYPEID"
).
toString
())
);
opmessage
.
setDefault_msg
(
1
);
opmessage
.
setDefault_msg
(
1
);
actionOperation
.
setOpmessage
(
opmessage
);
actionOperation
.
setOpmessage
(
opmessage
);
List
<
ActionOperation
>
operations
=
new
ArrayList
<
ActionOperation
>();
List
<
ActionOperation
>
operations
=
new
ArrayList
<
ActionOperation
>();
operations
.
add
(
actionOperation
);
operations
.
add
(
actionOperation
);
e
.
setOperations
(
operations
);
e
.
setOperations
(
operations
);
zabbixApi
.
action
().
create
(
request2
);
jsonObject
.
putAll
(
Status
.
getStatusSuccessMessage
(
"保存成功"
));
}
catch
(
Exception
e
)
{
jsonObject
.
putAll
(
Status
.
getStatusErrorMessage
(
"保存失败"
));
e
.
printStackTrace
();
}
}
return
"json"
;
zabbixApi
.
action
().
create
(
createRequest
)
;
}
}
public
String
updateTrigger
()
throws
BusinessException
{
public
String
updateTrigger
()
throws
BusinessException
{
...
@@ -162,19 +185,8 @@ public class actAction extends BasicAction {
...
@@ -162,19 +185,8 @@ public class actAction extends BasicAction {
list_triggerid
.
add
(
Integer
.
valueOf
(
c
));
list_triggerid
.
add
(
Integer
.
valueOf
(
c
));
}
}
request
.
setParams
(
list_triggerid
);
request
.
setParams
(
list_triggerid
);
//删除动作
List
<
Integer
>
list_actionid
=
new
ArrayList
<
Integer
>();
deleteAction
(
list_triggerid
);
ActionDeleteRequest
request3
=
new
ActionDeleteRequest
();
ActionGetRequest
request2
=
new
ActionGetRequest
();
ActionGetRequest
.
Params
params
=
request2
.
getParams
();
params
.
setTriggerids
(
list_triggerid
);
ActionGetResponse
response
=
zabbixApi
.
action
().
get
(
request2
);
List
<
ActionObject
>
result
=
response
.
getResult
();
for
(
ActionObject
action
:
result
)
{
list_actionid
.
add
(
action
.
getActionid
());
}
request3
.
setParams
(
list_actionid
);
zabbixApi
.
action
().
delete
(
request3
);
zabbixApi
.
trigger
().
delete
(
request
);
zabbixApi
.
trigger
().
delete
(
request
);
jsonObject
.
putAll
(
Status
.
getStatusSuccessMessage
(
"删除成功"
));
jsonObject
.
putAll
(
Status
.
getStatusSuccessMessage
(
"删除成功"
));
...
@@ -185,4 +197,26 @@ public class actAction extends BasicAction {
...
@@ -185,4 +197,26 @@ public class actAction extends BasicAction {
return
"json"
;
return
"json"
;
}
}
private
void
deleteAction
(
List
<
Integer
>
list_triggerid
)
{
ActionGetRequest
getRequest
=
new
ActionGetRequest
();
ActionGetRequest
.
Params
params
=
getRequest
.
getParams
();
params
.
setTriggerids
(
list_triggerid
);
try
{
ActionGetResponse
response
=
zabbixApi
.
action
().
get
(
getRequest
);
List
<
ActionObject
>
result
=
response
.
getResult
();
if
(
result
.
size
()
>
0
)
{
List
<
Integer
>
list_actionid
=
new
ArrayList
<
Integer
>();
for
(
ActionObject
action
:
result
)
{
list_actionid
.
add
(
action
.
getActionid
());
}
// 根据actionid删除动作
ActionDeleteRequest
deleteRequest
=
new
ActionDeleteRequest
();
deleteRequest
.
setParams
(
list_actionid
);
zabbixApi
.
action
().
delete
(
deleteRequest
);
}
}
catch
(
ZabbixApiException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
}
}
src_monitoring/com/gaowj/warning/action/actAction.java
0 → 100644
View file @
5412bc5b
package
com
.
gaowj
.
warning
.
action
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.gaowj.business.UserBusiness
;
import
com.gaowj.business.WarningBusiness
;
import
com.gaowj.business.action.BasicAction
;
import
com.gaowj.business.comp.BusinessManager
;
import
com.gaowj.business.exception.BusinessException
;
import
com.gaowj.business.util.RequestUtils
;
import
com.gaowj.business.util.Status
;
import
com.gaowj.util.MailUtil
;
import
net.sf.json.JSONObject
;
public
class
actAction
extends
BasicAction
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
6496396449440750926L
;
private
JSONObject
jsonObject
=
new
JSONObject
();
public
JSONObject
getJsonObject
()
{
return
jsonObject
;
}
public
void
setJsonObject
(
JSONObject
jsonObject
)
{
this
.
jsonObject
=
jsonObject
;
}
public
String
sendMail
()
throws
BusinessException
{
Map
<
String
,
Object
>
entity
=
RequestUtils
.
getUpdateFieldMap
(
request
,
RequestUtils
.
UPDATEDATAFIELDPREFIX
);
jsonObject
=
new
JSONObject
();
try
{
String
eventid
=
entity
.
get
(
"EVENTID"
).
toString
();
Map
<
String
,
Object
>
event_query
=
new
HashMap
<
String
,
Object
>();
event_query
.
put
(
"EVENTID"
,
eventid
);
WarningBusiness
business
=
BusinessManager
.
getBusiness
(
WarningBusiness
.
class
);
List
<
Map
<
String
,
Object
>>
list_event
=
business
.
list_warning
(
event_query
);
Map
<
String
,
Object
>
event
=
new
HashMap
<
String
,
Object
>();
event
.
put
(
"UUID"
,
java
.
util
.
UUID
.
randomUUID
().
toString
());
event
.
put
(
"EVENTID"
,
list_event
.
get
(
0
).
get
(
"EVENTID"
));
event
.
put
(
"HOSTID"
,
list_event
.
get
(
0
).
get
(
"HOSTID"
));
event
.
put
(
"CONTENT"
,
list_event
.
get
(
0
).
get
(
"NAME"
)
+
"服务器"
+
list_event
.
get
(
0
).
get
(
"DESCRIPTION"
));
// 插入预警信息发送主表
UserBusiness
userBusiness
=
BusinessManager
.
getBusiness
(
UserBusiness
.
class
);
userBusiness
.
insert_event_send
(
event
);
List
<
Map
<
String
,
Object
>>
list_user
=
userBusiness
.
list_user_host_view
(
event
);
for
(
Map
<
String
,
Object
>
user
:
list_user
)
{
// 发送邮件
MailUtil
.
sendMail
(
user
.
get
(
"EMAIL"
).
toString
(),
"服务器异常预警"
,
event
.
get
(
"CONTENT"
).
toString
());
// 插入发送邮件信息到子表
userBusiness
.
insert_event_send_detail
(
user
,
event
.
get
(
"UUID"
).
toString
(),
1
);
}
jsonObject
.
putAll
(
Status
.
getStatusSuccessMessage
(
"发送成功"
));
}
catch
(
Exception
e
)
{
jsonObject
.
putAll
(
Status
.
getStatusErrorMessage
(
"发送失败"
));
e
.
printStackTrace
();
}
return
"json"
;
}
}
src_monitoring/com/gaowj/warning/action/dataAction.java
View file @
5412bc5b
...
@@ -3,8 +3,10 @@ package com.gaowj.warning.action;
...
@@ -3,8 +3,10 @@ package com.gaowj.warning.action;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
com.gaowj.business.UserBusiness
;
import
com.gaowj.business.WarningBusiness
;
import
com.gaowj.business.WarningBusiness
;
import
com.gaowj.business.action.BasicAction
;
import
com.gaowj.business.action.BasicAction
;
import
com.gaowj.business.comp.BusinessManager
;
import
com.gaowj.business.comp.BusinessManager
;
...
@@ -59,6 +61,21 @@ public class dataAction extends BasicAction{
...
@@ -59,6 +61,21 @@ public class dataAction extends BasicAction{
try
{
try
{
query
=
QueryParamUtil
.
StringToDate
(
query
);
query
=
QueryParamUtil
.
StringToDate
(
query
);
Page
<
Map
<
String
,
Object
>>
pageRows
=
business
.
list_warning
(
pageNo
,
pageSize
,
query
);
Page
<
Map
<
String
,
Object
>>
pageRows
=
business
.
list_warning
(
pageNo
,
pageSize
,
query
);
UserBusiness
userBusiness
=
BusinessManager
.
getBusiness
(
UserBusiness
.
class
);
//预警信息发送状态
for
(
Map
<
String
,
Object
>
item
:
pageRows
.
getItems
()){
Map
<
String
,
Object
>
entity
=
new
HashMap
<
String
,
Object
>();
entity
.
put
(
"EVENTID"
,
item
.
get
(
"EVENTID"
));
List
<
Map
<
String
,
Object
>>
list_event_send
=
userBusiness
.
list_event_send
(
entity
);
if
(
list_event_send
.
size
()
>
0
){
//已发送
item
.
put
(
"STATUS"
,
1
);
}
else
{
//未发送
item
.
put
(
"STATUS"
,
0
);
}
}
setPageCount
((
pageRows
.
getCount
()
-
1
)
/
pageSize
+
1
);
setPageCount
((
pageRows
.
getCount
()
-
1
)
/
pageSize
+
1
);
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
data
.
put
(
"rowSet"
,
QueryParamUtil
.
DateToString
(
pageRows
.
getItems
()));
data
.
put
(
"rowSet"
,
QueryParamUtil
.
DateToString
(
pageRows
.
getItems
()));
...
...
src_monitoring/com/gaowj/zabbix/action/actAction.java
0 → 100644
View file @
5412bc5b
package
com
.
gaowj
.
zabbix
.
action
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.gaowj.business.UserBusiness
;
import
com.gaowj.business.WarningBusiness
;
import
com.gaowj.business.action.BasicAction
;
import
com.gaowj.business.comp.BusinessManager
;
import
com.gaowj.business.exception.BusinessException
;
import
com.gaowj.business.util.QueryParamUtil
;
import
com.gaowj.business.util.RequestUtils
;
import
com.gaowj.util.MailUtil
;
public
class
actAction
extends
BasicAction
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
6496396449440750926L
;
public
void
sendMail
()
throws
BusinessException
{
WarningBusiness
business
=
BusinessManager
.
getBusiness
(
WarningBusiness
.
class
);
UserBusiness
userBusiness
=
BusinessManager
.
getBusiness
(
UserBusiness
.
class
);
Map
<
String
,
Object
>
query
=
RequestUtils
.
getUpdateFieldMap
(
request
,
RequestUtils
.
UPDATEDATAFIELDPREFIX
);
try
{
query
=
QueryParamUtil
.
StringToDate
(
query
);
List
<
Map
<
String
,
Object
>>
listEvents
=
business
.
list_warning
(
query
);
List
<
String
>
eventsId
=
new
ArrayList
<
String
>();
//遍历所有警报
for
(
Map
<
String
,
Object
>
events
:
listEvents
){
eventsId
.
add
(
events
.
get
(
"EVENTID"
).
toString
());
}
//获取已发送的警报信息
Map
<
String
,
Object
>
querys
=
new
HashMap
<
String
,
Object
>();
List
<
Map
<
String
,
Object
>>
listEventSend
=
userBusiness
.
list_event_send
(
querys
);
List
<
String
>
eventSendId
=
new
ArrayList
<
String
>();
for
(
Map
<
String
,
Object
>
sends
:
listEventSend
){
eventSendId
.
add
(
sends
.
get
(
"EVENTID"
).
toString
());
}
//获得未发送的警报信息
List
<
String
>
list_unsend
=
new
ArrayList
<
String
>();
for
(
String
unevent
:
eventsId
)
{
if
(!
eventSendId
.
contains
(
unevent
))
{
list_unsend
.
add
(
unevent
);
}
}
//
for
(
String
eventId
:
list_unsend
){
findUserByHostId
(
business
,
userBusiness
,
eventId
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
void
findUserByHostId
(
WarningBusiness
business
,
UserBusiness
userBusiness
,
String
eventId
)
{
Map
<
String
,
Object
>
event_query
=
new
HashMap
<
String
,
Object
>();
event_query
.
put
(
"EVENTID"
,
eventId
);
List
<
Map
<
String
,
Object
>>
list_event
=
business
.
list_warning
(
event_query
);
Map
<
String
,
Object
>
event
=
new
HashMap
<
String
,
Object
>();
event
.
put
(
"UUID"
,
java
.
util
.
UUID
.
randomUUID
().
toString
());
event
.
put
(
"EVENTID"
,
list_event
.
get
(
0
).
get
(
"EVENTID"
));
event
.
put
(
"HOSTID"
,
list_event
.
get
(
0
).
get
(
"HOSTID"
));
event
.
put
(
"CONTENT"
,
list_event
.
get
(
0
).
get
(
"NAME"
)
+
"服务器"
+
list_event
.
get
(
0
).
get
(
"DESCRIPTION"
));
//插入预警信息发送主表
userBusiness
.
insert_event_send
(
event
);
List
<
Map
<
String
,
Object
>>
list_user
=
userBusiness
.
list_user_host_view
(
event
);
for
(
Map
<
String
,
Object
>
user
:
list_user
){
if
(
user
.
get
(
"EMAIL"
)
!=
null
){
//发送邮件
MailUtil
.
sendMail
(
user
.
get
(
"EMAIL"
).
toString
(),
"服务器异常预警"
,
event
.
get
(
"CONTENT"
).
toString
());
//插入发送邮件信息到子表
userBusiness
.
insert_event_send_detail
(
user
,
event
.
get
(
"UUID"
).
toString
(),
1
);
}
}
}
}
src_utils/com/gaowj/util/MailUtil.java
0 → 100644
View file @
5412bc5b
package
com
.
gaowj
.
util
;
import
org.simplejavamail.email.Email
;
import
org.simplejavamail.email.EmailBuilder
;
import
org.simplejavamail.mailer.Mailer
;
import
org.simplejavamail.mailer.MailerBuilder
;
import
org.simplejavamail.mailer.config.TransportStrategy
;
public
class
MailUtil
{
private
static
Mailer
mailer
=
null
;
static
{
mailer
=
MailerBuilder
.
withSMTPServer
(
"smtp.jfbrother.com"
,
587
,
"Jfxd@jfbrother.com"
,
"nb20162016@"
)
.
withTransportStrategy
(
TransportStrategy
.
SMTP_TLS
)
.
withSessionTimeout
(
10
*
1000
)
.
clearEmailAddressCriteria
()
// turns off email validation
.
withDebugLogging
(
true
)
.
buildMailer
();
}
public
static
void
sendMail
(
Email
email
)
{
mailer
.
sendMail
(
email
);
}
public
static
void
sendMail
(
String
target
,
String
subject
,
String
text
)
{
Email
email
=
EmailBuilder
.
startingBlank
()
.
from
(
"jfxd"
,
"Jfxd@jfbrother.com"
)
.
to
(
target
)
.
withSubject
(
subject
)
.
withPlainText
(
text
)
.
buildEmail
();
mailer
.
sendMail
(
email
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment