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
Email Patches
Plain Diff
Browse Files
Authored by
qinchao
7 years ago
Commit
05f9a9235b966164fdcced98a2378fe061bf67c8
1 parent
c2ff2032
恶意ip显示
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
3 deletions
monitor-service-influxdb/src/main/java/com/monitor/influxdb/mapper/impl/MaliciousIpMapperImpl.java
monitor-service-other/src/main/java/com/monitor/other/maliciousip/service/impl/MaliciousIpServiceImpl.java
monitor-service-influxdb/src/main/java/com/monitor/influxdb/mapper/impl/MaliciousIpMapperImpl.java
View file @
05f9a92
...
...
@@ -102,6 +102,7 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM
Map
<
String
,
String
>
m
=
new
HashMap
();
m
.
put
(
"reason"
,(
String
)
ls
.
get
(
s
.
getColumns
().
indexOf
(
"reason"
)));
m
.
put
(
"dur"
,(
String
)
ls
.
get
(
s
.
getColumns
().
indexOf
(
"dur"
)));
m
.
put
(
"time"
,
""
+
ls
.
get
(
s
.
getColumns
().
indexOf
(
"time"
)));
resultMap
.
put
(
ip
,
m
);
}
}
...
...
monitor-service-other/src/main/java/com/monitor/other/maliciousip/service/impl/MaliciousIpServiceImpl.java
View file @
05f9a92
...
...
@@ -357,6 +357,8 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
//组装数据
List
<
MaliciousIp
>
listMaliciousIp
=
new
ArrayList
<
MaliciousIp
>();
long
ts
=
0
l
;
String
insertTime
=
""
;
String
insertTime2
=
""
;
for
(
String
mipKey
:
mipKeys
){
MaliciousIp
mip
=
new
MaliciousIp
();
mip
.
setIp
(
mipKey
);
...
...
@@ -366,6 +368,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
if
(
awsIpInfo
.
get
(
mipKey
)
!=
null
){
Map
<
String
,
String
>
awsInfo
=
awsIpInfo
.
get
(
mipKey
);
String
reason
=
awsInfo
.
get
(
"reason"
);
insertTime
=
awsInfo
.
get
(
"time"
);
try
{
MaliciousIpModel
model
=
JSON
.
parseObject
(
reason
,
MaliciousIpModel
.
class
);
reason
=
model
.
toHtmlString
();
...
...
@@ -383,6 +386,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
reasonDur
+=
"</br>"
;
}
String
reason
=
qcloudInfo
.
get
(
"reason"
);
insertTime2
=
qcloudInfo
.
get
(
"time"
);
try
{
MaliciousIpModel
model
=
JSON
.
parseObject
(
reason
,
MaliciousIpModel
.
class
);
reason
=
model
.
toHtmlString
();
...
...
@@ -399,7 +403,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
//reasonDur += "qcloud: " + qcloudInfo.get("dur")+ " -- "+ qcloudInfo.get("reason") ;
}
mip
.
setReasonDur
(
reasonDur
);
if
(
ts
>
0
){
/*
if(ts>0){
String time="";
try{
time=new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(new Date(ts));
...
...
@@ -407,18 +411,42 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
}
mip.setTime(time);
}
}
*/
mip
.
setTs
(
ts
);
if
(
StringUtils
.
isNotBlank
(
insertTime
)&&
StringUtils
.
isNotBlank
(
insertTime2
)){
try
{
if
(
insertTime
.
compareTo
(
insertTime2
)>
0
){
mip
.
setTime
(
insertTime
.
substring
(
0
,
10
)+
" "
+
insertTime
.
substring
(
11
,
19
));
}
else
{
mip
.
setTime
(
insertTime2
.
substring
(
0
,
10
)+
" "
+
insertTime2
.
substring
(
11
,
19
));
}
}
catch
(
Exception
e
){
}
}
listMaliciousIp
.
add
(
mip
);
}
//排序
Collections
.
sort
(
listMaliciousIp
,
new
Comparator
<
MaliciousIp
>(){
public
int
compare
(
MaliciousIp
arg0
,
MaliciousIp
arg1
)
{
long
compare
=
arg0
.
getTs
()
-
arg1
.
getTs
();
/*
long compare= arg0.getTs() - arg1.getTs();
if(compare<0L){
return 1;
}else{
return -1;
}*/
if
(
StringUtils
.
isBlank
(
arg0
.
getTime
())){
return
1
;
}
else
if
(
StringUtils
.
isBlank
(
arg1
.
getTime
())){
return
1
;
}
else
{
int
i
=
arg0
.
getTime
().
compareTo
(
arg1
.
getTime
());
if
(
i
<
0
){
return
1
;
}
else
{
return
-
1
;
}
}
}
...
...
Please
register
or
login
to post a comment