# local sensu check

**URL:** <https://discourse.sensu.io/t/local-sensu-check/131>\
**Category:** Sensu Classic (EOL)\
**Created:** [January 29, 2014, 1:46pm UTC](https://discourse.sensu.io/t/local-sensu-check/131 "2014-01-29T13:46:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.sensu.io/u/Matt)\
**Post date:** [January 29, 2014, 1:46pm UTC](https://discourse.sensu.io/t/local-sensu-check/131/1 "2014-01-29T13:46:15Z")

</div>

If I fire of a check on a local machine to localhost:3030, usually  
with cron for scheduling. Is there any way to set the handler? at the  
moment the server sends to the default handler.

Thanks,

Matt

---

<div class="post-metadata">

**Author:** ![Jake\_Davis](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@Jake\_Davis](https://discourse.sensu.io/u/Jake_Davis)\
**Post date:** [January 29, 2014, 11:15pm UTC](https://discourse.sensu.io/t/local-sensu-check/131/2 "2014-01-29T23:15:41Z")

</div>

Matt,

Check out [this gist](https://gist.github.com/nstielau/3797054) for an example. The “handlers” key maps to the array of handlers you want to run.

Hope that helps,

Jake

> **···**
>
> On Wed, Jan 29, 2014 at 1:46 PM, Matt [foomatty@gmail.com](mailto:foomatty@gmail.com) wrote:
> 
> > If I fire of a check on a local machine to localhost:3030, usually
> > 
> > with cron for scheduling. Is there any way to set the handler? at the
> > 
> > moment the server sends to the default handler.
> > 
> > Thanks,
> > 
> > Matt

---

<div class="post-metadata">

**Author:** ![Kyle\_Anderson](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@Kyle\_Anderson](https://discourse.sensu.io/u/Kyle_Anderson)\
**Post date:** [January 30, 2014, 4:01am UTC](https://discourse.sensu.io/t/local-sensu-check/131/3 "2014-01-30T04:01:48Z")

</div>

You should be able to set the handler in the json you are sending to  
localhost:3030

As far as I can tell the data of the "check" part doesn't strip the  
handler part in any way, kinda jut publishes the result as-is after  
adding the client name:  
[https://github.com/sensu/sensu/blob/master/lib/sensu/socket.rb#L34](https://github.com/sensu/sensu/blob/master/lib/sensu/socket.rb#L34)

So setting the handler according to the check part of the hash like:  
[http://sensuapp.org/docs/0.12/events](http://sensuapp.org/docs/0.12/events)

Should work.

> **···**
>
> On Wed, Jan 29, 2014 at 5:46 AM, Matt \<foomatty@gmail.com\> wrote:
> 
> > If I fire of a check on a local machine to localhost:3030, usually  
> > with cron for scheduling. Is there any way to set the handler? at the  
> > moment the server sends to the default handler.
> > 
> > Thanks,
> > 
> > Matt

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.sensu.io/u/Matt)\
**Post date:** [January 30, 2014, 3:54pm UTC](https://discourse.sensu.io/t/local-sensu-check/131/4 "2014-01-30T15:54:51Z")

</div>

Of course guys, yep I can write it to the socket.  
sock.write "{ \"handlers\": [\"#{handler}\"], \"name\": \"#{name}\",  
\"output\": \"#{msg}\", \"status\": #{status} }"

> **···**
>
> On 30 January 2014 04:01, Kyle Anderson \<kyle@xkyle.com\> wrote:
> 
> > You should be able to set the handler in the json you are sending to  
> > localhost:3030
> > 
> > As far as I can tell the data of the "check" part doesn't strip the  
> > handler part in any way, kinda jut publishes the result as-is after  
> > adding the client name:  
> > [https://github.com/sensu/sensu/blob/master/lib/sensu/socket.rb#L34](https://github.com/sensu/sensu/blob/master/lib/sensu/socket.rb#L34)
> > 
> > So setting the handler according to the check part of the hash like:  
> > [http://sensuapp.org/docs/0.12/events](http://sensuapp.org/docs/0.12/events)
> > 
> > Should work.
> > 
> > On Wed, Jan 29, 2014 at 5:46 AM, Matt \<foomatty@gmail.com\> wrote:
> > 
> > > If I fire of a check on a local machine to localhost:3030, usually  
> > > with cron for scheduling. Is there any way to set the handler? at the  
> > > moment the server sends to the default handler.
> > > 
> > > Thanks,
> > > 
> > > Matt

---

<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:** [November 22, 2018, 2:05am UTC](https://discourse.sensu.io/t/local-sensu-check/131/5 "2018-11-22T02:05:06Z")

</div>


