6.6. Resource Operations
To ensure that resources remain healthy, you can add a monitoring operation to a resource's definition. If you do not specify a monitoring operation for a resource, by default the
pcs
command will create a monitoring operation, with an interval that is determined by the resource agent. If the resource agent does not provide a default monitoring interval, the pcs command will create a monitoring operation with an interval of 60 seconds.
Table 6.4, “Properties of an Operation” summarizes the properties of a resource monitoring operation.
6.6.1. Configuring Resource Operations
You can configure monitoring operations when you create a resource, using the following command.
pcs resource create resource_id standard:provider:type|type [resource_options] [op operation_action operation_options [operation_type operation_options]...]
For example, the following command creates an
IPaddr2
resource with a monitoring operation. The new resource is called VirtualIP
with an IP address of 192.168.0.99 and a netmask of 24 on eth2
. A monitoring operation will be performed every 30 seconds.
# pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=24 nic=eth2 op monitor interval=30s
Alternately, you can add a monitoring operation to an existing resource with the following command.
pcs resource op add resource_id operation_action [operation_properties]
Use the following command to delete a configured resource operation.
pcs resource op remove resource_id operation_name operation_properties
Note
You must specify the exact operation properties to properly remove an existing operation.
To change the values of a monitoring option, you can update the resource. For example, you can create a
VirtualIP
with the following command.
# pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=24 nic=eth2
By default, this command creates these operations.
Operations: start interval=0s timeout=20s (VirtualIP-start-timeout-20s) stop interval=0s timeout=20s (VirtualIP-stop-timeout-20s) monitor interval=10s timeout=20s (VirtualIP-monitor-interval-10s)
To change the stop timeout operation, execute the following command.
#pcs resource update VirtualIP op stop interval=0s timeout=40s
#pcs resource show VirtualIP
Resource: VirtualIP (class=ocf provider=heartbeat type=IPaddr2) Attributes: ip=192.168.0.99 cidr_netmask=24 nic=eth2 Operations: start interval=0s timeout=20s (VirtualIP-start-timeout-20s) monitor interval=10s timeout=20s (VirtualIP-monitor-interval-10s) stop interval=0s timeout=40s (VirtualIP-name-stop-interval-0s-timeout-40s)
Note
When you update a resource's operation with the
pcs resource update
command, any options you do not specifically call out are reset to their default values.
6.6.2. Configuring Global Resource Operation Defaults
You can use the following command to set global default values for monitoring operations.
pcs resource op defaults [options]
For example, the following command sets a global default of a
timeout
value of 240 seconds for all monitoring operations.
# pcs resource op defaults timeout=240s
To display the currently configured default values for monitoring operations, do not specify any options when you execute the
pcs resource op defaults
command.
For example, following command displays the default monitoring operation values for a cluster which has been configured with a
timeout
value of 240 seconds.
# pcs resource op defaults
timeout: 240s
Note that a cluster resource will use the global default only when the option is not specified in the cluster resource definition. By default, resource agents define the
timeout
option for all operations. For the global operation timeout value to be honored, you must create the cluster resource without the timeout
option explicitly or you must remove the timeout
option by updating the cluster resource, as in the following command.
# pcs resource update VirtualIP op monitor interval=10s
For example, after setting a global default of a
timeout
value of 240 seconds for all monitoring operations and updating the cluster resource VirtualIP
to remove the timeout value for the monitor
operation, the resource VirtualIP
will then have timeout values for start
, stop
, and monitor
operations of 20s, 40s and 240s, respectively. The global default value for timeout operations is applied here only on the monitor
operation, where the default timeout
option was removed by the previous command.
# pcs resource show VirtualIP
Resource: VirtualIP (class=ocf provider=heartbeat type=IPaddr2)
Attributes: ip=192.168.0.99 cidr_netmask=24 nic=eth2
Operations: start interval=0s timeout=20s (VirtualIP-start-timeout-20s)
monitor interval=10s (VirtualIP-monitor-interval-10s)
stop interval=0s timeout=40s (VirtualIP-name-stop-interval-0s-timeout-40s)