Toggle navigation
Toggle navigation
This project
Loading...
Sign in
guizhou-monitorV2.0.1
/
agent
·
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
Email Patches
Plain Diff
Browse Files
Authored by
zhangmingm
8 years ago
Commit
d865bbdf1c455d8744aaadcd2677580308451b97
1 parent
2fe51ebf
修改getPingStatus方法。
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
53 deletions
src/com/sitech/ismp/coll/centercoll/CollWindows.java
src/com/sitech/ismp/coll/centercoll/CollWindows.java
View file @
d865bbd
...
...
@@ -30,35 +30,38 @@ public class CollWindows implements CollWindowsMBean {
*/
public
Vector
<
TblATO_KPIDETAIL
>
getPingState
(
HashMap
<
String
,
String
>
params
){
Vector
<
TblATO_KPIDETAIL
>
v
=
new
Vector
<
TblATO_KPIDETAIL
>();
String
ip
=
params
.
get
(
"IP"
);
if
(!
StringUtils
.
isEmpty
(
ip
)){
String
kpiId
=
"FM-00-10-001-999"
;
// Windows 主机连接状态
String
hostName
=
params
.
get
(
"HOST_NAME"
);
String
unitId
=
kbpClass
+
":"
+
hostName
+
"-total"
;
ParamterBean
bean
=
new
ParamterBean
();
bean
.
setDEVICE_IP
(
ip
);
bean
.
setType
(
"windows"
);
log
.
info
(
"*** execute getPingState ** ip=["
+
ip
+
"]** unitId=["
+
unitId
+
"]*********"
);
/**
* getPingState 方法执行后会将状态插入到表中,然后取当前时间
* 根基IP查询失败的次数,如果失败次数为3次,则确定为宕机,发送告警。
*/
CheckConnectionState
server
=
new
CheckConnectionState
();
server
.
getPingState
(
bean
);
// 根据IP获取ping的错误次数。如果是 DOWN 的话,发送告警信息。
String
state
=
server
.
getPingErrorState
(
ip
);
TblATO_KPIDETAIL
kpidetail
=
new
TblATO_KPIDETAIL
();
log
.
info
(
"***** unitId**"
+
unitId
+
"** state **"
+
state
+
"*******"
);
try
{
kpidetail
.
setKPI_ID
(
kpiId
);
kpidetail
.
setUNIT_ID
(
unitId
);
kpidetail
.
setKPI_VALUE
(
state
);
kpidetail
.
setCLL_TIME
(
new
Date
());
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
String
isPing
=
params
.
get
(
"isPing"
)+
""
;
// frank 2017-05-19 添加。Y进行ping操作,N不执行
if
(
"Y"
.
equals
(
isPing
)){
String
ip
=
params
.
get
(
"IP"
);
if
(!
StringUtils
.
isEmpty
(
ip
)){
String
kpiId
=
"FM-00-10-001-999"
;
// Windows 主机连接状态
String
hostName
=
params
.
get
(
"HOST_NAME"
);
String
unitId
=
kbpClass
+
":"
+
hostName
+
"-total"
;
ParamterBean
bean
=
new
ParamterBean
();
bean
.
setDEVICE_IP
(
ip
);
bean
.
setType
(
"windows"
);
log
.
info
(
"*** execute getPingState ** ip=["
+
ip
+
"]** unitId=["
+
unitId
+
"]*********"
);
/**
* getPingState 方法执行后会将状态插入到表中,然后取当前时间
* 根基IP查询失败的次数,如果失败次数为3次,则确定为宕机,发送告警。
*/
CheckConnectionState
server
=
new
CheckConnectionState
();
server
.
getPingState
(
bean
);
// 根据IP获取ping的错误次数。如果是 DOWN 的话,发送告警信息。
String
state
=
server
.
getPingErrorState
(
ip
);
TblATO_KPIDETAIL
kpidetail
=
new
TblATO_KPIDETAIL
();
log
.
info
(
"***** unitId**"
+
unitId
+
"** state **"
+
state
+
"*******"
);
try
{
kpidetail
.
setKPI_ID
(
kpiId
);
kpidetail
.
setUNIT_ID
(
unitId
);
kpidetail
.
setKPI_VALUE
(
state
);
kpidetail
.
setCLL_TIME
(
new
Date
());
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
v
.
add
(
kpidetail
);
}
v
.
add
(
kpidetail
);
}
return
v
;
}
...
...
@@ -74,32 +77,28 @@ public class CollWindows implements CollWindowsMBean {
Vector
<
TblATO_KPIDETAIL
>
v
=
new
Vector
<
TblATO_KPIDETAIL
>();
String
ip
=
params
.
get
(
"IP"
);
if
(!
StringUtils
.
isEmpty
(
ip
)){
String
result
=
server
.
getPingResultByIp
(
ip
);
log
.
info
(
"@@@@@###### getSnmpState ping result="
+
result
+
"###$$$$$$$$$$%%%%%%%%%%"
);
if
(!
StringUtils
.
isEmpty
(
result
)
&&
"UP"
.
equals
(
result
)){
String
kpiId
=
"FM-00-10-001-998"
;
// Windows 设备登录状态
ParamterBean
bean
=
new
ParamterBean
();
String
tempPort
=
params
.
get
(
"PORT"
);
String
community
=
params
.
get
(
"COMMUNITY"
);
int
port
=
Integer
.
parseInt
(
tempPort
);
String
hostName
=
params
.
get
(
"HOST_NAME"
);
log
.
info
(
"******ip "
+
ip
+
"**port "
+
tempPort
+
"****hostName "
+
hostName
+
"*****"
);
bean
.
setDEVICE_IP
(
ip
);
bean
.
setPROTOCOL_PORT
(
port
);
bean
.
setCOMMUNITY
(
community
);
String
state
=
server
.
getConnectionState4Snmp
(
bean
);
String
unitId
=
kbpClass
+
":"
+
hostName
+
"-total"
;
TblATO_KPIDETAIL
kpidetail
=
new
TblATO_KPIDETAIL
();
try
{
kpidetail
.
setKPI_ID
(
kpiId
);
kpidetail
.
setUNIT_ID
(
unitId
);
kpidetail
.
setKPI_VALUE
(
state
);
kpidetail
.
setCLL_TIME
(
new
Date
());
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
v
.
add
(
kpidetail
);
String
kpiId
=
"FM-00-10-001-998"
;
// Windows 设备登录状态
ParamterBean
bean
=
new
ParamterBean
();
String
tempPort
=
params
.
get
(
"PORT"
);
String
community
=
params
.
get
(
"COMMUNITY"
);
int
port
=
Integer
.
parseInt
(
tempPort
);
String
hostName
=
params
.
get
(
"HOST_NAME"
);
log
.
info
(
"******ip "
+
ip
+
"**port "
+
tempPort
+
"****hostName "
+
hostName
+
"*****"
);
bean
.
setDEVICE_IP
(
ip
);
bean
.
setPROTOCOL_PORT
(
port
);
bean
.
setCOMMUNITY
(
community
);
String
state
=
server
.
getConnectionState4Snmp
(
bean
);
String
unitId
=
kbpClass
+
":"
+
hostName
+
"-total"
;
TblATO_KPIDETAIL
kpidetail
=
new
TblATO_KPIDETAIL
();
try
{
kpidetail
.
setKPI_ID
(
kpiId
);
kpidetail
.
setUNIT_ID
(
unitId
);
kpidetail
.
setKPI_VALUE
(
state
);
kpidetail
.
setCLL_TIME
(
new
Date
());
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
v
.
add
(
kpidetail
);
}
return
v
;
}
...
...
Please
register
or
login
to post a comment