Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (26 sloc) 1.16 KB
layout title published tags
default
processexists
true
reference
process functions
functions
processexists
process
processes
ps
cached function

[%CFEngine_function_prototype(regex)%]

Description: Return whether a process matches the given [anchored][anchored] regular expression regex.

This function searches for the given regular expression in the process table. Use .*sherlock.* to find all the processes that match sherlock. Use .*\bsherlock\b.* to exclude partial matches like sherlock123 (\b matches a word boundary).

[%CFEngine_function_attributes(regex)%]

The process table is usually obtained with something like ps -eo user,pid,ppid,pgid,%cpu,%mem,vsize,ni,rss,stat,nlwp,stime,time,args, and the CMD or COMMAND field (args) is used to match against. However the exact data used may change per platform and per CFEngine release.

Example:

    classes:
      # the class "holmes" will be set if a process line contains the word "sherlock"
      "holmes" expression => processexists(".*sherlock.*");

History: Introduced in CFEngine 3.9

See also: [processes][processes] [findprocesses()][findprocesses].

You can’t perform that action at this time.