-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d0ca60
commit 1c29119
Showing
4 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import ir_http | ||
from . import psutils_helpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import psutil | ||
|
||
from prometheus_client import Gauge | ||
|
||
|
||
MEMORY_USAGE_VMS = Gauge( | ||
"memory_user_vms_mb", "Memory usage in MB", ["process","pid"] | ||
) | ||
|
||
MEMORY_USAGE_RSS = Gauge( | ||
"memory_user_rss_mb", "Memory usage in MB", ["process", "pid"] | ||
) | ||
|
||
|
||
def get_process_info(): | ||
for process in psutil.process_iter(['pid', 'name', 'memory_full_info', 'cpu_percent']): | ||
try: | ||
print(process.cmdline()) | ||
if process.info['memory_full_info']: | ||
if process.nice() == 10: | ||
ProcessLabel = "workercron" | ||
elif process.info['pid'] == 1: | ||
ProcessLabel = "dispatcher" | ||
elif any(['gevent' in x for x in process.cmdline()]): | ||
ProcessLabel = "gevent" | ||
elif any(['odoo' in x for x in process.cmdline()]): | ||
ProcessLabel = "workerhttp" | ||
else: | ||
ProcessLabel = "other" | ||
MEMORY_USAGE_VMS.labels(ProcessLabel,process.info['pid']).set(process.info['memory_full_info'].rss / 1024 / 1024) | ||
MEMORY_USAGE_RSS.labels(ProcessLabel,process.info['pid']).set(process.info['memory_full_info'].vms / 1024 / 1024) | ||
|
||
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): | ||
pass |