Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loganalysis
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
liushutao
loganalysis
Commits
3c363424
Commit
3c363424
authored
Nov 23, 2022
by
liushutao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改统计逻辑
parent
1ff209ba
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
6 deletions
+53
-6
src/main/java/com/pmc/loganalysis/controller/PmcGetData.java
+1
-1
src/main/java/com/pmc/loganalysis/service/SmsPushsysService.java
+1
-1
src/main/java/com/pmc/loganalysis/service/impl/SmsPushsysServiceImpl.java
+27
-1
src/main/java/com/pmc/loganalysis/task/FiveIndexMonitorTask.java
+10
-1
src/main/java/com/pmc/loganalysis/util/DateUtils.java
+14
-1
src/main/java/com/pmc/loganalysis/util/shell/ExecShell.java
+0
-1
No files found.
src/main/java/com/pmc/loganalysis/controller/PmcGetData.java
View file @
3c363424
...
...
@@ -41,7 +41,7 @@ public class PmcGetData {
String
endTime
=
DateUtils
.
getDateStringYMDHMS
(
endDate
,
DateUtils
.
DATE_TIME_PATTERN
);
String
endTimestr
=
DateUtils
.
getDateStringYMDHMS
(
endDate
,
DateUtils
.
DATE_YYYYMMDDHHMMSS
);
return
smsPushsysService
.
pushTravelCardByMinRate
(
startTime
,
endTime
,
startTimestr
,
endTimestr
);
return
smsPushsysService
.
pushTravelCardByMinRate
(
startTime
,
endTime
,
startTimestr
,
endTimestr
,
"1"
,
""
);
}
}
src/main/java/com/pmc/loganalysis/service/SmsPushsysService.java
View file @
3c363424
...
...
@@ -12,7 +12,7 @@ public interface SmsPushsysService {
/**
* 统计每分钟日志
*/
String
pushTravelCardByMinRate
(
String
startTimeStr
,
String
endTimeStr
,
String
shellPath
,
String
logPath
);
String
pushTravelCardByMinRate
(
String
startTimeStr
,
String
endTimeStr
,
String
shellPath
,
String
logPath
,
String
flag
,
String
startTimeStri
);
}
src/main/java/com/pmc/loganalysis/service/impl/SmsPushsysServiceImpl.java
View file @
3c363424
...
...
@@ -38,12 +38,19 @@ public class SmsPushsysServiceImpl implements SmsPushsysService {
* @return
*/
@Override
public
String
pushTravelCardByMinRate
(
String
startTime
,
String
endTime
,
String
startTimeStr
,
String
endTimeStr
){
public
String
pushTravelCardByMinRate
(
String
startTime
,
String
endTime
,
String
startTimeStr
,
String
endTimeStr
,
String
tjflag
,
String
startTimeStri
){
DynamicDataSourceContextHolder
.
setDataSourceKey
(
DataType
.
MASTER
);
String
logPath1
=
""
;
if
(
StringUtils
.
isBlank
(
shellPath
)
){
return
"配置脚本信息有误"
;
}
// pCode = CryptoEncoder.base64Decode(pCode);
if
(
"00"
.
equals
(
tjflag
)){
logPath
=
"/opt/pmc/envoy/envoy-in/logs/envoy-in.txt."
+
startTimeStri
;
logPath1
=
"/opt/pmc/envoy/envoy-in/logs/envoy-in.txt"
;
}
else
{
logPath
=
"/opt/pmc/envoy/envoy-in/logs/envoy-in.txt"
;
}
List
<
String
>
commandList1
=
this
.
getCommandList
(
startTimeStr
,
endTimeStr
,
shellPath
,
logPath
);
String
finalCommand
=
""
;
for
(
String
str
:
commandList1
){
...
...
@@ -58,6 +65,24 @@ public class SmsPushsysServiceImpl implements SmsPushsysService {
if
(
result
==
null
||
""
.
equals
(
result
)){
result
=
"0"
;
}
String
result2
=
""
;
if
(
"00"
.
equals
(
tjflag
)){
List
<
String
>
commandList2
=
this
.
getCommandList
(
startTimeStr
,
endTimeStr
,
shellPath
,
logPath1
);
String
finalCommand2
=
""
;
for
(
String
str
:
commandList2
){
finalCommand2
=
finalCommand2
+
str
+
" && "
;
}
finalCommand2
=
finalCommand2
.
substring
(
0
,
finalCommand2
.
length
()-
4
);
result2
=
ExecShell
.
executes
(
finalCommand2
);
if
(
result2
==
null
||
""
.
equals
(
result2
)){
result2
=
"0"
;
}
}
if
(!
"0"
.
equals
(
result2
)&&!
""
.
equals
(
result2
)){
Integer
result1
=
Integer
.
valueOf
(
result
)+
Integer
.
valueOf
(
result2
);
result
=
result1
.
toString
();
}
Date
nowDate
=
new
Date
();
//获取当前时间的前一分钟
String
createTime
=
DateUtils
.
getDateStringYMDHMS
(
nowDate
,
DateUtils
.
DATE_TIME_PATTERN_YYYYMMDDHHMMSSSSS
);
...
...
@@ -88,6 +113,7 @@ public class SmsPushsysServiceImpl implements SmsPushsysService {
String
timePath
=
path
+
" "
+
startTime
+
" "
+
endTime
+
" "
;
String
command
=
timePath
+
logPath
;
log
.
info
(
"统计数据命令:"
+
command
);
commandStrList
.
add
(
command
);
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/pmc/loganalysis/task/FiveIndexMonitorTask.java
View file @
3c363424
...
...
@@ -39,17 +39,26 @@ public class FiveIndexMonitorTask {
*/
@Scheduled
(
cron
=
"${springTiming.monitor1-min-time}"
)
public
void
StatisticsTravelCardDaily
()
{
String
flag
=
"1"
;
//获取现在时间(开始时间)
Date
nowDate
=
new
Date
();
//获取当前时间的前一分钟
Date
startDate
=
DateUtils
.
getDate
(
nowDate
,
beforeminutes
);
String
startTime
=
DateUtils
.
getDateStringYMDHMS
(
startDate
,
DateUtils
.
DATE_TIME_PATTERN
);
String
startTimeStri
=
DateUtils
.
getDateStringYMDHMS
(
startDate
,
DateUtils
.
DATE_YYYYMMDD
);
String
startTimestr
=
DateUtils
.
getDateStringYMDHMS
(
startDate
,
DateUtils
.
DATE_YYYYMMDDHHMMSS
);
Date
endDate
=
DateUtils
.
getDate
(
nowDate
,
beforeendminutes
);
Date
endDates
=
DateUtils
.
getDate
(
nowDate
,
inputminute
);
String
endTime
=
DateUtils
.
getDateStringYMDHMS
(
endDates
,
DateUtils
.
DATE_TIME_PATTERNS
);
String
endTimestr
=
DateUtils
.
getDateStringYMDHMS
(
endDate
,
DateUtils
.
DATE_YYYYMMDDHHMMSS
);
smsPushsysService
.
pushTravelCardByMinRate
(
startTime
,
endTime
,
startTimestr
,
endTimestr
);
//获取当前时间,进行判断是否当前时间是00:00:00或者00:01:00
String
startDateNewstr
=
DateUtils
.
getDateStringYMDHMS
(
nowDate
,
DateUtils
.
DATE_YYYYMMDDHHMMSS
);
String
endTimeStrs
=
startDateNewstr
.
substring
(
startDateNewstr
.
length
()-
6
);
if
(
"000000"
.
equals
(
endTimeStrs
)||
"000100"
.
equals
(
endTimeStrs
))
{
flag
=
"00"
;
}
smsPushsysService
.
pushTravelCardByMinRate
(
startTime
,
endTime
,
startTimestr
,
endTimestr
,
flag
,
startTimeStri
);
}
...
...
src/main/java/com/pmc/loganalysis/util/DateUtils.java
View file @
3c363424
...
...
@@ -30,7 +30,7 @@ public class DateUtils {
public
final
static
String
DATE_XIE
=
"yyyy/MM/dd"
;
public
final
static
String
DATE_YYYYMMDD
=
"yyyyMMdd"
;
public
final
static
String
DATE_YYYYMMDDHH
=
"yyyyMMddHH"
;
public
final
static
String
DATE_YYYYMMDDHHMM
=
"yyyyMMddHHmm"
;
public
final
static
String
DATE_YYYYMMDDHHMMSS
=
"yyyyMMddHHmmss"
;
...
...
@@ -287,4 +287,17 @@ public class DateUtils {
String
date
=
sdf
.
format
(
sdate
);
return
date
;
}
//获取当前时间的00:00时
public
static
Date
getDateByday
()
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
new
Date
());
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
Date
zero
=
calendar
.
getTime
();
return
zero
;
}
}
src/main/java/com/pmc/loganalysis/util/shell/ExecShell.java
View file @
3c363424
...
...
@@ -94,7 +94,6 @@ public class ExecShell {
/**
* 登录主机
* @return
...
...
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