Sensu Ping Check for All Hosts

I am curious, I am running the latest Sensu Go 5.14, and I would like to use a proxy host so that it automatically adds a ping check to each host automatically. I guess I’m trying to figure out how to deploy the configuration so that it just adds it automatically when a new entity comes online?

Hey!

I think a variation of the proxy_request example will work for what you want to do
https://docs.sensu.io/sensu-go/5.14/reference/checks/#using-a-proxy-check-to-monitor-multiple-proxy-entities

Following the example from the docs,
you want the agent that is actually running the ping command to subscribe to the “proxy”
check. and then every entity you want to ping needs to have two labels set:
proxy_type with the value of ‘website’
and
url with the value of the url you want to use with the http_check.sh script

The proxy_type label in the docs example is used as a selector, to select which entities will participate in the proxy_check. Only those entities with the value ‘website’ participate.

The url label in the docs example is used for token substitute to make sure that http_check.sh hits the correct endpoint.

Does that make sense?
For a ping check, you’d use a hostname or a ip address label instead of a url level

If you posted your check definition and an example entity definition I can probably help you figure out why its not working.

For the sake of completeness I like to share a possible solution to achieve this.

This check definition will execute an icmp check against every entity in the namespace “default”.
round_robin is active, because I want to rotate the check between the three backend nodes of the sensu cluster. Therefore, every agent of the backend nodes needs to subscribe to the “external_icmp” subscription. Furthermore it should be assured that the entity name can be resolved by the DNS.

{
  "type": "CheckConfig",
  "api_version": "core/v2",
  "metadata": {
    "name": "icmp",
    "namespace": "default",
    "labels": {
      "sensu.io/managed_by": "sensuctl"
    },
    "created_by": "root"
  },
  "spec": {
    "check_hooks": null,
    "command": "/opt/sensu-plugins-ruby/embedded/bin/check-ping.rb -h {{ .name }} -c1",
    "env_vars": null,
    "handlers": [""],
    "high_flap_threshold": 0,
    "interval": 30,
    "low_flap_threshold": 0,
    "output_metric_format": "",
    "output_metric_handlers": [""],
    "proxy_entity_name": "",
    "proxy_requests": {
      "entity_attributes": ["entity.namespace == 'default'"],
      "splay": true,
      "splay_coverage": 50
    },
    "publish": true,
    "round_robin": true,
    "runtime_assets": null,
    "secrets": null,
    "stdin": false,
    "subdue": null,
    "subscriptions": ["external_icmp"],
    "timeout": 10,
    "ttl": 0
  }
}

Hey!

Yeah i think that would work, you could perhaps abstract the logic a little more and have the ping argument token substitution use an annotation scoped to each proxy entity and then use the entity name as a fallback if the annotation isn’t set. That way you can change the annotation without changing an existing entity naming scheme and messing up other logic that you might have that processes events or some such.

Hi Folks,

I’m working on integration on rundeck + sensu and i have ngnix webserver installed,i would like to monitor the http url status of ngnix on sensu and add annotation and webhooks to run the rundeck job automatically when ngnix process is down.

Can someone please be able to provide the script or yaml/json file to monitor the http check and i can test it.
Thanks in advance.

Thanks
Shamya