inspec/docs/resources/processes.md.erb

84 lines
1.9 KiB
Text
Raw Normal View History

2016-09-22 12:43:57 +00:00
---
title: About the processes Resource
---
# processes
Use the `processes` InSpec audit resource to test properties for programs that are running on the system.
## Syntax
2016-09-22 12:43:57 +00:00
A `processes` resource block declares the name of the process to be tested, and then declares one (or more) property/value pairs:
describe processes('process_name') do
its('property_name') { should eq ['property_value'] }
end
where
* `processes('process_name')` specifies the name of a process to check. If this is a string, it will be converted to a Regexp. For more specificity, pass a Regexp directly.
2016-09-22 12:43:57 +00:00
* `property_name` may be used to test user (`its('users')`) and state properties (`its('states')`)
## Matchers
2016-09-22 12:43:57 +00:00
This InSpec audit resource has the following matchers:
### be
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_be" %>
### cmp
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_cmp" %>
### eq
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_eq" %>
### include
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_include" %>
### match
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_match" %>
### property_name
2016-09-22 12:43:57 +00:00
The `property_name` matcher tests the named property for the specified value:
its('property_name') { should eq ['property_value'] }
## Examples
2016-09-22 12:43:57 +00:00
The following examples show how to use this InSpec audit resource.
### Test if the list length for the mysqld process is 1
2016-09-22 12:43:57 +00:00
describe processes('mysqld') do
its('list.length') { should eq 1 }
end
### Test if the init process is owned by the root user
2016-09-22 12:43:57 +00:00
describe processes('init') do
its('users') { should eq ['root'] }
end
### Test if a high-priority process is running
2016-09-22 12:43:57 +00:00
describe processes('some_process') do
its('states') { should eq ['R<'] }
end
### Test for a process using a specific Regexp
If the process name is too common for a string to uniquely find it,
you may use a regexp. Inclusion of whitespace characters may be
needed.
describe processes(Regexp.new("/usr/local/bin/swap -d")) do
its('list.length') { should eq 1 }
end