Counting the number of running processes using the Profiler

You can use Virtyx to ensure that critical processes remain running on your Linux or Windows servers. You might want to make sure your Node.js processes remain up and running, or be notified if a Jenkins instance goes down.

Setting up the task

Linux or Windows servers. To do this, log in to your Virtyx account and navigate to the agent in question (for more help getting set up, see Getting Started).

Now, click the plus or Add Agent Task button and select Host Metrics (Profiler).

  1. Set the schedule to be as often as you’d like. For critical processes, you might choose to check as often as every minute; for less-critical processes, checking every hour or even every day might be sufficient.
  2. Check the Count running processes option, and enter a process filter. You must enter a process filter. If you do not, no data will be collected.
  3. The Profile Duration option does not apply unless you are using the CPU or Memory options, so you can safely disregard this.

Process Filters

A process filter is a string of characters that will be compared against all the processes running on the agents. If the name of a running process contains the filter you enter, the filter will match the process. For example, the filter sh would match processes named bash, csh, sh, and zsh.

The agent will count the number of running processes that match your filter, and report the sum. For example, if you have are interested in counting your long-running Node.js scripts running, you might choose a process filter of node. If you have three different scripts running, then you’d get 3 as the result of the process count.

You can enter multiple filters separated by commas, such as node,nodemon. This means that you will have two metrics reported, both the number of processes matching the node filter and the number of processes matching the nodemon filter.

For example, suppose you start several processes:

$ nodemon ./server.js &
$ nodemon ./worker.js &
$ node ./migrations/create_db.js

Using the filter node,nodemon as above, we’d get the following two results:

Sample process counter
configuration

Alarms

In order to be notified when your desired state is not met, you’ll need to configure an alarm on the task you created. In your Virtyx dashboard, click the bell icon in the menu bar, then click the gear icon. Click the plus button to add a new alarm, and choose the profiler task you just created.

Select the Process: Count metric and type in your process filter in the text field. Note that you should just use the single process filter you’re interested in, even if you are collecting data for multiple filters. For example, if you entered node,nodemon as the process filters in the task description, you should just enter either node or nodemon here, but not both. If you want to add alarm constraints for both filters, you will need to create two alarms, one for each filter.

Next, you can configure the threshold to whatever you need it to be. If you’re filtering for a script-like process, such as node, python, ruby, or sh, we suggest using the “Greater Than” operator so that you won’t receive false positives if a user executes a one-off script that shares the same process name.