Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
FalconPlugin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ops
FalconPlugin
Commits
9dd69f85
Commit
9dd69f85
authored
Oct 29, 2019
by
李贺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改监控进程插件
parent
55e107e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
60_processlist_monitor.py
sys/process/60_processlist_monitor.py
+48
-0
90_processlist_monitor.py.bak
sys/process/90_processlist_monitor.py.bak
+0
-0
No files found.
sys/process/60_processlist_monitor.py
0 → 100644
View file @
9dd69f85
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
subprocess
import
Popen
,
PIPE
import
json
import
time
data
=
[]
endpoint
=
"172.30.4.75"
def
get_all_mountpoint
():
data
=
[]
p0
=
Popen
([
'ps'
,
'-aux'
],
stdout
=
PIPE
,
stderr
=
PIPE
)
raw_data
=
Popen
([
'sort'
,
'-k4nr'
],
stdin
=
p0
.
stdout
,
stdout
=
PIPE
,
stderr
=
PIPE
)
.
communicate
()[
0
]
for
i
in
raw_data
.
split
(
'
\n
'
):
data
.
append
(
i
)
if
len
(
data
)
==
60
:
break
return
data
if
__name__
==
"__main__"
:
list
=
get_all_mountpoint
()
for
i
in
list
:
process
=
i
.
split
(
' '
)
while
''
in
process
:
process
.
remove
(
''
)
print
process
[
10
:]
tmp_memory_percent
=
{
"endpoint"
:
endpoint
,
"tags"
:
"pid="
+
process
[
1
]
+
",cmd="
+
' '
.
join
(
process
[
10
:]),
"timestamp"
:
int
(
time
.
time
()),
"metric"
:
"sys.process.memory.percent"
,
"counterType"
:
"GAUGE"
,
"value"
:
process
[
3
],
"step"
:
60
}
tmp_cpu_percent
=
{
"endpoint"
:
endpoint
,
"tags"
:
"pid="
+
process
[
1
]
+
",cmd="
+
' '
.
join
(
process
[
10
:]),
"timestamp"
:
int
(
time
.
time
()),
"metric"
:
"sys.process.cpu.percent"
,
"counterType"
:
"GAUGE"
,
"value"
:
process
[
4
],
"step"
:
60
}
data
.
append
(
tmp_cpu_percent
)
data
.
append
(
tmp_memory_percent
)
print
json
.
dumps
(
data
)
\ No newline at end of file
sys/process/90_processlist_monitor.py
→
sys/process/90_processlist_monitor.py
.bak
View file @
9dd69f85
File moved
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