Skip to main content

Simple utility for checking if processes are running

Project description


procmon logo

Python tests badge

procmon is a small utility for checking whether certain processes are found in the ps -ef process list. The utility is not a daemon, meaning it will run once and then die. So to monitor that a certain process is running, you would for example have procmon in cron.

If the looked for process is running, promon will exit with return code 0. If the process isn't found or if not enough processes are found (see -e flag), then procmon exits with 1.

Usage

Check if a process is running:

procmon "firefox -param"

Make the filter case-insensitive (-i / --insensitive):

procmon -i "FiReFox -param"

Mandate the minimum number of matched processes expected (default is 1):

procmon -e 5 "firefox -param"

Setting the log level:

procmon --log-level debug "firefox -param"

Sending an email notification on error. This requires you to have a procmon.cfg configured with the SMTP server settings:

procmon --send-email "firefox -param"

Configuration

The configuration of procmon happens at two levels;

  1. In the CLI (command line interface)
  2. In a configuration file (this is where SMTP settings etc are)

CLI

The below is a copy of the procmon --help output. It shows available configuration parameters and their meaning.

usage: procmon [-h] [-c CONFIG] [-e EXPECTED_MATCHES] [-i] [--send-email] [--log-level LOG_LEVEL] [--version] [filter]

positional arguments:
  filter                Filter string to match processes for

options:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        Path for configuration file (default: /etc/procmon.cfg, ./procmon.cfg)
  -e EXPECTED_MATCHES, --expected-matches EXPECTED_MATCHES
                        Number of matches required for a successful result
  -i, --insensitive     Case insensitive process matching
  --send-email          Send email notification
  --log-level LOG_LEVEL
                        Log level; debug, info, warning, error
  --version             Print the procmon version number

Configuration file

Using a configuration file is entirely optional for users that are not using the --send-email option. The configuration file is only used for configuring SMTP settings and similar.

Paths

procmon is looking for configuration files in the following paths:

  • /etc/procmon.cfg
  • ./procmon.cfg

Example configuration file

A full example of a configuration file can be found under https://github.com/sebdah/procmon/blob/main/examples/procmon.cfg

Example

The below command would be looking for a process called python bpytop (case insensitive). It would expect to find at least 2 matches. And it would be logging on the debug level.

procmon -i --log-level debug -m 2 python bpytop

Development

Releasing

  1. Update the version number in pyproject.toml and procmon
  2. Commit the version number updates
  3. Create a new git tag git tag <version>
  4. Push version updates and tags git push && git push --tags

EditorConfig

The project uses EditorConfig for configuration of IDEs for development. Please make sure you have EditorConfig enabled in your IDE when developing, that will make your code abide to the coding guidelines automatically.

Running tests

The Makefile is configured for running tests unless you want to run it in your editor. Simply execute:

make test

This assumes that Python and pytest are available on your host.

License

APACHE LICENSE 2.0 Copyright 2022 Sebastian Dahlgren

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

procmon-0.2.1.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

procmon-0.2.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file procmon-0.2.1.tar.gz.

File metadata

  • Download URL: procmon-0.2.1.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for procmon-0.2.1.tar.gz
Algorithm Hash digest
SHA256 efa82fa6495b5cc4ecd34fbb47f65ba6c01a95ccf83a3827d55d8b848813741e
MD5 166ae84bff12c9cdc48435932b2a5494
BLAKE2b-256 53891d817913b405447a258045a3ec02404b9e444066aeabccbbbb885526832e

See more details on using hashes here.

File details

Details for the file procmon-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: procmon-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for procmon-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b7056835cd91997c07adb03e97aeecb060daef48d79c71744b0da5322019361
MD5 61c46723718d5b1f69e90b1cf666ad42
BLAKE2b-256 14562606d48587c42791b09c38fb6085bc3353152070fcbd52d4e080281357eb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page