How to subscribe a client many times to the same check using variables for single execution customization

Hi.

I need to monitor single process memory consumption of many processes in the same server. I’ve already configured this check for one process (tomcat_1). This is the check configured on Sensu server (1.6):

{
“checks”: {
“memory_metrics_per_process”: {
“command”: “/opt/sensu/embedded/bin/metrics-process-status.rb -p :::memory_pp.process_name::: --scheme :::memory_pp.scheme:::”,
“interval”: 60,
“type”: “metric”,
“handlers”: [
“influx_tcp”
],
“subscribers”: [ “memory_per_process” ]
}
}
}

This is the current client (1.6) configuration:

{
“client”: {
“name”: “client”,
“subscriptions”: [
“memory”,
“memory_per_process”,
“disk_usage”,
“uptime”
],
“disk”: {“warning”: 80,“critical”: 90},
“memory”: {“warning”: 80,“critical”: 90},
“memory_pp”: {“process_name”: “myprocess”,“scheme”: “tomcat_1”},
“keepalive”: {“handler”: “mailer”}
}
}

I need to add other checks of the same type (memory_pp) on the same server for other processes. Is there a way to avoid check duplication on server side (memory_metrics_per_process => memory_metrics_per_process_1, memory_metrics_per_process_2, memory_metrics_per_process_3, …) and configure only the client to repeat the same check with different processes?

Thanks
Luca

You can use CM to make it easier but they each needs to have their own definition typically. It is possible to write a check that accepts a comma separated list of processes and schemes.

1 Like

Hi Luca,

I am trying to monitor memory consumption of a single process. Can you tell me how it is possible using Sensu.?

Hi.

You can replicate my current solution, that will save metrics on an influxdb. For example, let’s say you want to monitor a process with the string “tomcat” in the running command:

  1. install sensu plugin “process checks” on the server where you want to monitor the process:
  1. configure the generic memory ckeck command on Sensu server:

{
“checks”: {
“memory_metrics_per_process”: {
“command”: “/opt/sensu/embedded/bin/metrics-process-status.rb -p :::memory_pp.process_name::: --scheme :::memory_pp.scheme:::”,
“interval”: 60,
“type”: “metric”,
“handlers”: [
“influx_tcp”
],
“subscribers”: [ “memory_per_process” ]
}
}
}

This is a generic check for process memory consumption.

  1. configure the custom check on the server where you want to monitor the process, customizing process_name and scheme on the configuration:

{
“client”: {
“name”: “client”,
“subscriptions”: [
(…)
“memory_per_process”
],
“memory_pp”: {“process_name”: “tomcat”,“scheme”: “tomcat”},
}
}

2 Likes

Great … thanks Luca . Its worked like a charm

1 Like