app/tests/test_monitoring.py
Adrià Casajús 2660c96fa7
Fix: Track processes that start with the same chars independently (smtp vs stmpd) (#974)
* Fix: Track processes that start with the same chars independently (smtp vs stmpd)

* Format

* Added more test

Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
2022-05-12 12:37:19 +02:00

17 lines
542 B
Python

from monitoring import _process_ps_output
def test_monitoring_proc_count():
data = """
PID TTY STAT TIME COMMAND
1432 ? S< 0:00 [loop44]
3438 ? Ssl 0:00 /bin/sh arg
3440 ? Sl 0:00 /bin/cron args
3440 ? Sl 0:00 smtp arg
3448 ? Sl 0:00 smtpd arg
3441 ? Sl 0:00 other smtpd arg
"""
result = _process_ps_output(["smtp", "smtpd", "cron"], data)
assert 1 == result["smtp"]
assert 1 == result["smtpd"]
assert 0 == result["cron"]