Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ops
/
monitor-service
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
fanzelei
9 years ago
Commit
604a0a4fed262295123b2a970e4c382c50105a20
2 parents
8c7d26d0
9ab81884
Merge branch 'master' of
http://git.yoho.cn/ops/monitor-service
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
159 additions
and
39 deletions
monitor-service-middleware/src/main/java/com/monitor/middleware/rabbitmq/task/job/QueueViewJob.java
monitor-service-mysql/src/main/java/com/model/User.java
monitor-service-mysql/src/main/java/com/monitor/mysql/mapper/AuthModuleMapper.java
monitor-service-mysql/src/main/java/com/monitor/mysql/mapper/UserMapper.java
monitor-service-mysql/src/main/resources/com/monitor/mysql/mapper/AuthModuleMapper.xml
monitor-service-mysql/src/main/resources/com/monitor/mysql/mapper/MObjectInfoMapper.xml
monitor-service-mysql/src/main/resources/com/monitor/mysql/mapper/MTypeInfoMapper.xml
monitor-service-mysql/src/main/resources/com/monitor/mysql/mapper/RabbitAlertMapper.xml
monitor-service-mysql/src/main/resources/com/monitor/mysql/mapper/UserMapper.xml
monitor-service-user/src/main/java/com/monitor/user/ctrl/ModuleCtrl.java
monitor-service-user/src/main/java/com/monitor/user/ctrl/UserCtrl.java
monitor-service-middleware/src/main/java/com/monitor/middleware/rabbitmq/task/job/QueueViewJob.java
View file @
604a0a4
...
...
@@ -92,10 +92,8 @@ public class QueueViewJob implements Callable {
DEBUG
.
error
(
"Failed to parse queue_view info: {} , error {}"
,
respJson
,
e
);
return
;
}
catch
(
Exception
e
)
{
DEBUG
.
error
(
"Failed to execute monitor task , error {} "
,
e
);
}
catch
(
Exception
e
)
{
DEBUG
.
error
(
"Failed to execute monitor task , error {} "
,
e
);
return
;
}
...
...
@@ -122,7 +120,7 @@ public class QueueViewJob implements Callable {
queueInfo
.
setAlert_high
(
alert
);
if
(
queueInfo
.
getMessages
()
>
alert
)
{
if
(
0
<
alert
&&
queueInfo
.
getMessages
()
>
alert
)
{
//alert
String
msg
=
buildAlarmMsg
(
queueInfo
);
...
...
monitor-service-mysql/src/main/java/com/model/User.java
View file @
604a0a4
...
...
@@ -16,4 +16,8 @@ public class User {
private
int
level
;
private
String
email
;
private
String
mobile
;
}
...
...
monitor-service-mysql/src/main/java/com/monitor/mysql/mapper/AuthModuleMapper.java
View file @
604a0a4
...
...
@@ -2,6 +2,7 @@ package com.monitor.mysql.mapper;
import
com.model.AuthModule
;
import
com.model.User
;
import
com.monitor.model.domain.PageBean
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
...
...
@@ -21,5 +22,10 @@ public interface AuthModuleMapper {
AuthModule
selectById
(
@Param
(
"id"
)
int
id
);
List
<
AuthModule
>
selectAuthModules
(
PageBean
page
);
int
selectCount
();
int
deleteByName
(
@Param
(
"name"
)
String
name
);
}
...
...
monitor-service-mysql/src/main/java/com/monitor/mysql/mapper/UserMapper.java
View file @
604a0a4
package
com
.
monitor
.
mysql
.
mapper
;
import
com.model.HostGroup
;
import
com.model.User
;
import
com.monitor.model.domain.PageBean
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
...
...
@@ -12,9 +14,9 @@ public interface UserMapper {
int
insert
(
User
user
);
int
update
Pwd
(
User
user
);
int
update
(
User
user
);
int
update
Level
(
User
user
);
int
update
Pwd
(
User
user
);
int
deleteByName
(
@Param
(
"name"
)
String
name
);
...
...
@@ -26,5 +28,8 @@ public interface UserMapper {
User
selectById
(
@Param
(
"id"
)
int
id
);
List
<
User
>
selectUsers
(
PageBean
page
);
int
selectCount
();
}
...
...
monitor-service-mysql/src/main/resources/com/monitor/mysql/mapper/AuthModuleMapper.xml
View file @
604a0a4
...
...
@@ -44,4 +44,22 @@
where id = #{id,jdbcType=INTEGER}
</update>
<select
id=
"selectCount"
resultType=
"java.lang.Integer"
>
select
count(1)
from auth_module
</select>
<select
id=
"selectAuthModules"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from auth_module
order by id desc
limit #{startIndex},#{pageSize}
</select>
<delete
id=
"deleteByName"
parameterType=
"java.lang.String"
>
delete from auth_module
where module_name = #{name,jdbcType=VARCHAR}
</delete>
</mapper>
\ No newline at end of file
...
...
monitor-service-mysql/src/main/resources/com/monitor/mysql/mapper/MObjectInfoMapper.xml
View file @
604a0a4
...
...
@@ -13,7 +13,7 @@
<id
property=
"moUrl"
column=
"url"
></id>
</resultMap>
<select
id=
"getAllMosInfo"
resultType=
"com.model.MObjectInfo"
resultMap=
"mobjectInfoMapper"
useCache=
"true"
>
<select
id=
"getAllMosInfo"
resultType=
"com.model.MObjectInfo"
resultMap=
"mobjectInfoMapper"
>
SELECT * FROM mobject_info ORDER BY id asc
</select>
...
...
@@ -38,7 +38,7 @@
</update>
<select
id=
"selectMObjectsInfoByTypes"
resultType=
"com.model.MObjectInfo"
resultMap=
"mobjectInfoMapper"
useCache=
"true"
>
<select
id=
"selectMObjectsInfoByTypes"
resultType=
"com.model.MObjectInfo"
resultMap=
"mobjectInfoMapper"
>
SELECT * FROM mobject_info
where type_id in
...
...
monitor-service-mysql/src/main/resources/com/monitor/mysql/mapper/MTypeInfoMapper.xml
View file @
604a0a4
...
...
@@ -14,7 +14,7 @@
<sql
id=
"Base_Column_List"
>
id, alias, isLeaf, parent_id
</sql>
<select
id=
"getAllTypesInfo"
resultType=
"com.model.TypeInfo"
resultMap=
"typeInfoMap"
useCache=
"true"
>
<select
id=
"getAllTypesInfo"
resultType=
"com.model.TypeInfo"
resultMap=
"typeInfoMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM type_info ORDER BY id asc
...
...
monitor-service-mysql/src/main/resources/com/monitor/mysql/mapper/RabbitAlertMapper.xml
View file @
604a0a4
...
...
@@ -10,13 +10,11 @@
<id
property=
"alertHigh"
column=
"alert"
></id>
</resultMap>
<select
id=
"getAllAlertsInfo"
resultType=
"com.model.RabbitAlertInfo"
resultMap=
"rabbitAlertInfoMapper"
useCache=
"true"
>
<select
id=
"getAllAlertsInfo"
resultType=
"com.model.RabbitAlertInfo"
resultMap=
"rabbitAlertInfoMapper"
>
SELECT * FROM rabbitalert_info ORDER BY id asc
</select>
<select
id=
"queryAlertInfo"
resultType=
"com.model.RabbitAlertInfo"
resultMap=
"rabbitAlertInfoMapper"
useCache=
"true"
>
<select
id=
"queryAlertInfo"
resultType=
"com.model.RabbitAlertInfo"
resultMap=
"rabbitAlertInfoMapper"
>
SELECT * FROM rabbitalert_info WHERE id = #{moId} AND alias= #{queueName}
</select>
...
...
monitor-service-mysql/src/main/resources/com/monitor/mysql/mapper/UserMapper.xml
View file @
604a0a4
...
...
@@ -6,10 +6,12 @@
<result
column=
"name"
property=
"name"
jdbcType=
"VARCHAR"
/>
<result
column=
"pwd"
property=
"pwd"
jdbcType=
"VARCHAR"
/>
<result
column=
"level"
property=
"level"
jdbcType=
"INTEGER"
/>
<result
column=
"email"
property=
"email"
jdbcType=
"VARCHAR"
/>
<result
column=
"mobile"
property=
"mobile"
jdbcType=
"VARCHAR"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, name, pwd, level
id, name, pwd, level
, email, mobile
</sql>
<select
id=
"selectById"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Integer"
>
...
...
@@ -32,6 +34,14 @@
from user
</select>
<select
id=
"selectUsers"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from user
order by id desc
limit #{startIndex},#{pageSize}
</select>
<delete
id=
"deleteById"
parameterType=
"java.lang.Integer"
>
delete from user
where id = #{id,jdbcType=INTEGER}
...
...
@@ -44,23 +54,30 @@
<insert
id=
"insert"
parameterType=
"com.model.User"
>
insert into user
(name,pwd,level, create_time, update_time)
(name,pwd,level,
email,mobile,
create_time, update_time)
values
(#{name,jdbcType=VARCHAR},#{pwd,jdbcType=VARCHAR},#{level,jdbcType=INTEGER}, now(),now())
(#{name,jdbcType=VARCHAR},#{pwd,jdbcType=VARCHAR},#{level,jdbcType=INTEGER},
#{email,jdbcType=INTEGER},#{mobile,jdbcType=INTEGER},now(),now())
</insert>
<update
id=
"update
Pwd
"
parameterType=
"com.model.User"
>
<update
id=
"update"
parameterType=
"com.model.User"
>
update user
set pwd = #{pwd,jdbcType=VARCHAR},
update_time = now()
set level = #{level,jdbcType=INTEGER},
email = #{email,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR},
update_time = now()
where id = #{id,jdbcType=INTEGER}
</update>
<update
id=
"update
Level
"
parameterType=
"com.model.User"
>
<update
id=
"update
Pwd
"
parameterType=
"com.model.User"
>
update user
set level = #{level,jdbcType=INTEGER},
update_time = now()
set pwd = #{pwd,jdbcType=VARCHAR},
where id = #{id,jdbcType=INTEGER}
</update>
<select
id=
"selectCount"
resultType=
"java.lang.Integer"
>
select
count(1)
from user
</select>
</mapper>
\ No newline at end of file
...
...
monitor-service-user/src/main/java/com/monitor/user/ctrl/ModuleCtrl.java
View file @
604a0a4
...
...
@@ -2,6 +2,9 @@ package com.monitor.user.ctrl;
import
com.model.AuthModule
;
import
com.model.User
;
import
com.monitor.model.domain.PageBean
;
import
com.monitor.model.page.PageRequest
;
import
com.monitor.model.page.PageResponse
;
import
com.monitor.model.response.BaseResponse
;
import
com.monitor.mysql.mapper.AuthModuleMapper
;
import
org.slf4j.Logger
;
...
...
@@ -89,5 +92,51 @@ public class ModuleCtrl {
}
}
@RequestMapping
(
"/getAuthModules"
)
@ResponseBody
public
BaseResponse
<
PageResponse
<
AuthModule
>>
getAuthModules
(
@RequestBody
PageRequest
req
)
{
try
{
log
.
info
(
"getAuthModules with param is {}"
,
req
);
// 组装分页对象
PageBean
page
=
PageBean
.
initPageInfo
(
req
.
getCurrentPage
(),
req
.
getPageSize
(),
req
);
// 先查询符合条件的总数量
int
total
=
authModuleMapper
.
selectCount
();
// 数量为0 直接返回
if
(
total
==
0
)
{
// 返回初始page对象
return
null
;
}
// 获取列表
List
<
AuthModule
>
authModules
=
authModuleMapper
.
selectAuthModules
(
page
);
if
(
CollectionUtils
.
isEmpty
(
authModules
))
{
log
.
debug
(
"getAuthModules is null with param is {}"
,
req
);
return
null
;
}
PageResponse
<
AuthModule
>
response
=
new
PageResponse
<
AuthModule
>();
response
.
setCurrentPage
(
req
.
getCurrentPage
());
response
.
setPageSize
(
req
.
getPageSize
());
response
.
setTotal
(
total
);
response
.
setRows
(
authModules
);
return
new
BaseResponse
<
PageResponse
<
AuthModule
>>(
response
);
}
catch
(
Exception
e
){
log
.
error
(
"getAuthModules error"
,
e
);
return
new
BaseResponse
<>(
e
.
getMessage
());
}
}
@RequestMapping
(
"/deleteByName"
)
@ResponseBody
public
BaseResponse
deleteByName
(
String
name
)
{
try
{
int
result
=
authModuleMapper
.
deleteByName
(
name
);
return
new
BaseResponse
<
Integer
>(
result
);
}
catch
(
Exception
e
){
log
.
error
(
"getUserById error"
,
e
);
return
null
;
}
}
}
...
...
monitor-service-user/src/main/java/com/monitor/user/ctrl/UserCtrl.java
View file @
604a0a4
package
com
.
monitor
.
user
.
ctrl
;
import
com.model.HostGroup
;
import
com.model.User
;
import
com.monitor.model.domain.PageBean
;
import
com.monitor.model.page.PageRequest
;
import
com.monitor.model.page.PageResponse
;
import
com.monitor.model.response.BaseResponse
;
import
com.monitor.mysql.mapper.UserMapper
;
import
org.slf4j.Logger
;
...
...
@@ -76,11 +80,11 @@ public class UserCtrl {
}
}
@RequestMapping
(
"/update
Pwd
"
)
@RequestMapping
(
"/update"
)
@ResponseBody
public
BaseResponse
updatePwd
(
@RequestBody
User
user
)
{
try
{
int
result
=
userMapper
.
update
Pwd
(
user
);
int
result
=
userMapper
.
update
(
user
);
return
new
BaseResponse
<
Integer
>(
result
);
}
catch
(
Exception
e
){
log
.
error
(
"getUserById error"
,
e
);
...
...
@@ -88,20 +92,6 @@ public class UserCtrl {
}
}
@RequestMapping
(
"/updateLevel"
)
@ResponseBody
public
BaseResponse
updateAuth
(
@RequestBody
User
user
)
{
try
{
int
result
=
userMapper
.
updateLevel
(
user
);
return
new
BaseResponse
<
Integer
>(
result
);
}
catch
(
Exception
e
){
log
.
error
(
"getUserById error"
,
e
);
return
null
;
}
}
@RequestMapping
(
"/deleteByName"
)
@ResponseBody
public
BaseResponse
deleteByName
(
String
name
)
{
...
...
@@ -125,5 +115,40 @@ public class UserCtrl {
return
null
;
}
}
@RequestMapping
(
"/getUsers"
)
@ResponseBody
public
BaseResponse
<
PageResponse
<
User
>>
getUsers
(
@RequestBody
PageRequest
req
)
{
try
{
log
.
info
(
"getUsers with param is {}"
,
req
);
// 组装分页对象
PageBean
page
=
PageBean
.
initPageInfo
(
req
.
getCurrentPage
(),
req
.
getPageSize
(),
req
);
// 先查询符合条件的总数量
int
total
=
userMapper
.
selectCount
();
// 数量为0 直接返回
if
(
total
==
0
)
{
// 返回初始page对象
return
null
;
}
// 获取列表
List
<
User
>
users
=
userMapper
.
selectUsers
(
page
);
if
(
CollectionUtils
.
isEmpty
(
users
))
{
log
.
debug
(
"getUsers is null with param is {}"
,
req
);
return
null
;
}
PageResponse
<
User
>
response
=
new
PageResponse
<
User
>();
response
.
setCurrentPage
(
req
.
getCurrentPage
());
response
.
setPageSize
(
req
.
getPageSize
());
response
.
setTotal
(
total
);
response
.
setRows
(
users
);
return
new
BaseResponse
<
PageResponse
<
User
>>(
response
);
}
catch
(
Exception
e
){
log
.
error
(
"getUsers error"
,
e
);
return
new
BaseResponse
<>(
e
.
getMessage
());
}
}
}
...
...
Please
register
or
login
to post a comment