# Puppet/Sensu: Use sensu-plugins-network-check to ping all monitored hosts

**URL:** <https://discourse.sensu.io/t/puppet-sensu-use-sensu-plugins-network-check-to-ping-all-monitored-hosts/2642>\
**Category:** Sensu Go\
**Created:** [July 11, 2021, 8:02am UTC](https://discourse.sensu.io/t/puppet-sensu-use-sensu-plugins-network-check-to-ping-all-monitored-hosts/2642 "2021-07-11T08:02:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahoiroman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/ahoiroman/32/508_2.png) [@ahoiroman](https://discourse.sensu.io/u/ahoiroman)\
**Post date:** [July 11, 2021, 8:02am UTC](https://discourse.sensu.io/t/puppet-sensu-use-sensu-plugins-network-check-to-ping-all-monitored-hosts/2642/1 "2021-07-11T08:02:12Z")

</div>

Hello everybody,

I am using the sensu module for puppet to monitor all my hosts.

Now I’d like to add a ping test ([sensu-plugins-network-checks/check-ping.rb at master · sensu-plugins/sensu-plugins-network-checks · GitHub](https://github.com/sensu-plugins/sensu-plugins-network-checks/blob/master/bin/check-ping.rb)) so that every registered host is being pinged by the sensu backend.

Has anybody done this before? How can I tell the sensu-backend to ping all those hosts?

Thanks for every hint 🙂

---

<div class="post-metadata">

**Author:** ![ahoiroman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/ahoiroman/32/508_2.png) [@ahoiroman](https://discourse.sensu.io/u/ahoiroman)\
**Post date:** [July 12, 2021, 6:58am UTC](https://discourse.sensu.io/t/puppet-sensu-use-sensu-plugins-network-check-to-ping-all-monitored-hosts/2642/2 "2021-07-12T06:58:18Z")

</div>

I just saw in the docs that I could make use of `proxy_requests`. Is there any example of how to solve this using puppet and the ping-scenario?

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [July 12, 2021, 7:24pm UTC](https://discourse.sensu.io/t/puppet-sensu-use-sensu-plugins-network-check-to-ping-all-monitored-hosts/2642/3 "2021-07-12T19:24:00Z")

</div>

hey,  
I’m not sure the complexity of proxy requests is what you want. If all the registered hosts managed by puppet are running Sensu agents, the Sensu agents provide a keepalive event so if the sensu agent stops responding (and you don’t have auto deregistration enabled for that agent) the keepalive will result in a non zero status after a timeout. Is there a specific reason why the keepalive event isn’t sufficient logic for your situation?

---

<div class="post-metadata">

**Author:** ![ahoiroman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/ahoiroman/32/508_2.png) [@ahoiroman](https://discourse.sensu.io/u/ahoiroman)\
**Post date:** [July 12, 2021, 7:26pm UTC](https://discourse.sensu.io/t/puppet-sensu-use-sensu-plugins-network-check-to-ping-all-monitored-hosts/2642/4 "2021-07-12T19:26:10Z")

</div>

Hi,

I am already sending messages via slack if keep alive is missing for 120sec. But we had currently the scenario where hosts were sending keepalive but ping had a package loss of 30%. I hope to get this into our Sensu monitoring somehow.

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [July 12, 2021, 7:37pm UTC](https://discourse.sensu.io/t/puppet-sensu-use-sensu-plugins-network-check-to-ping-all-monitored-hosts/2642/5 "2021-07-12T19:37:49Z")

</div>

hmmm  
And you don’t want to ping out from the agents right? You want to ping all the entities registered in Sensu from a central pinger?

---

<div class="post-metadata">

**Author:** ![ahoiroman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/ahoiroman/32/508_2.png) [@ahoiroman](https://discourse.sensu.io/u/ahoiroman)\
**Post date:** [July 12, 2021, 7:48pm UTC](https://discourse.sensu.io/t/puppet-sensu-use-sensu-plugins-network-check-to-ping-all-monitored-hosts/2642/6 "2021-07-12T19:48:42Z")

</div>

Hi @jspaleta,

Right 🙂

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [July 12, 2021, 7:59pm UTC](https://discourse.sensu.io/t/puppet-sensu-use-sensu-plugins-network-check-to-ping-all-monitored-hosts/2642/7 "2021-07-12T19:59:32Z")

</div>

Okay to do this with proxy-requests I _think_ you’ll want to follow a pattern like this:

1. run a centralized agent subscribed to a special subscription that non of the remote agents you want to ping subscribe to (Ex: proxy-ping)

2. Create a proxy-ping check patterned like this

```auto
---
type: CheckConfig
api_version: core/v2
metadata:
  name: proxy-ping
spec:
  command: check-ping.rb ---host {{ .annotations.ping-host }}
  interval: 60
  proxy_requests:
    entity_attributes:
    - entity.entity_class == 'agent'
    - entity.annotations.ping-enabled == 'true'
  publish: true
  runtime_assets:
  - sensu-plugins-network-checks
  - sensu-ruby-runtime
  subscriptions:
  - proxy-ping

```

This pattern instructs your centralized agent with subscription proxy-ping to run this check for each registered entity that matches the specified entity conditions: the entity is an `agent` and has `ping-enabled` annotation set to `true`

1. make sure all the agents you want to ping with necessary annotations to drive the ping check. In my example pattern above you’d need the `proxy-host` and `ping-enabled` annotation set with correct string values. Also make sure that none of the remote agents you want to ping are subscribed to proxy-ping subscription. You only want the centralized agent running on the same host as the sensu-backend participating in that subscription, its the only agent running the check.
