# osTicket handler

**URL:** <https://discourse.sensu.io/t/osticket-handler/142>\
**Category:** Sensu Classic (EOL)\
**Created:** [February 13, 2014, 9:05pm UTC](https://discourse.sensu.io/t/osticket-handler/142 "2014-02-13T21:05:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Fischer](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@Dan\_Fischer](https://discourse.sensu.io/u/Dan_Fischer)\
**Post date:** [February 13, 2014, 9:05pm UTC](https://discourse.sensu.io/t/osticket-handler/142/1 "2014-02-13T21:05:08Z")

</div>

Is it bad form to call a php script from a ruby sensu handler?

That is just what I did to get Sensu to send incidents to osTicket and create tickets:

result = %x[php /opt/sensu/api\_ticket\_create.php “#{phpargs}”]

Maybe it would be worth rewriting into ruby to get it shared on sensu-community-plugins but that is beyond me at this point.

I will clean it up a bit before doing a PR. I will post it on the osTicket forums and spread the word about Sensu.

Dan

---

<div class="post-metadata">

**Author:** ![Riccardo\_Tacconi](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@Riccardo\_Tacconi](https://discourse.sensu.io/u/Riccardo_Tacconi)\
**Post date:** [February 14, 2014, 10:00am UTC](https://discourse.sensu.io/t/osticket-handler/142/2 "2014-02-14T10:00:25Z")

</div>

As the docs say, it is possible to create a plugin in any language, but ideally they could be all written in Ruby. You could create a GIST and post the link here so we could see the code.

> **···**
>
> On Thursday, 13 February 2014 21:05:08 UTC, Dan Fischer wrote:
> 
> > Is it bad form to call a php script from a ruby sensu handler?
> > 
> > That is just what I did to get Sensu to send incidents to osTicket and create tickets:
> > 
> > result = %x[php /opt/sensu/api\_ticket\_create.php “#{phpargs}”]
> 
> > Maybe it would be worth rewriting into ruby to get it shared on sensu-community-plugins but that is beyond me at this point.
> > 
> > I will clean it up a bit before doing a PR. I will post it on the osTicket forums and spread the word about Sensu.
> > 
> > Dan

---

<div class="post-metadata">

**Author:** ![Dan\_Fischer](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@Dan\_Fischer](https://discourse.sensu.io/u/Dan_Fischer)\
**Post date:** [February 14, 2014, 1:58pm UTC](https://discourse.sensu.io/t/osticket-handler/142/3 "2014-02-14T13:58:55Z")

</div>

I put the ruby and php code up here: [https://gist.github.com/canoedf/9001274](https://gist.github.com/canoedf/9001274)

I tried to use a single line of curl instead of using php curl but just could not work out the syntax for an error free osTicket API call.

This is my first ruby work ever - be gentle

Dan

> **···**
>
> On Friday, February 14, 2014 3:00:25 AM UTC-7, Riccardo Tacconi wrote:
> 
> > As the docs say, it is possible to create a plugin in any language, but ideally they could be all written in Ruby. You could create a GIST and post the link here so we could see the code.
> > 
> > On Thursday, 13 February 2014 21:05:08 UTC, Dan Fischer wrote:
> > 
> > > Is it bad form to call a php script from a ruby sensu handler?
> > > 
> > > That is just what I did to get Sensu to send incidents to osTicket and create tickets:
> > > 
> > > result = %x[php /opt/sensu/api\_ticket\_create.php “#{phpargs}”]
> 
> > > Maybe it would be worth rewriting into ruby to get it shared on sensu-community-plugins but that is beyond me at this point.
> > > 
> > > I will clean it up a bit before doing a PR. I will post it on the osTicket forums and spread the word about Sensu.
> > > 
> > > Dan

---

<div class="post-metadata">

**Author:** ![Riccardo\_Tacconi](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@Riccardo\_Tacconi](https://discourse.sensu.io/u/Riccardo_Tacconi)\
**Post date:** [February 14, 2014, 2:35pm UTC](https://discourse.sensu.io/t/osticket-handler/142/4 "2014-02-14T14:35:53Z")

</div>

Change OSTICKET class to OSTicket, you have to use 2 spaces soft tabs, that’s a rule accepted in the Ruby community. You can make a POST request with ruby and it is very simple:

[http://stackoverflow.com/questions/16474985/how-do-i-post-json-via-http-in-ruby-after-conversion-from-python](http://stackoverflow.com/questions/16474985/how-do-i-post-json-via-http-in-ruby-after-conversion-from-python)

Why are you using the begin statement?

timemout(30) does not exist, try

```auto
  while true do
    puts Time.now # or call tick function
    sleep 30
  end

```

```auto

```

```auto
Why you are not running your code to see if it works?

```

> **···**
>
> On 14 February 2014 13:58, Dan Fischer [ebay2007buys@gmail.com](mailto:ebay2007buys@gmail.com) wrote:
> 
> > I put the ruby and php code up here: [https://gist.github.com/canoedf/9001274](https://gist.github.com/canoedf/9001274)
> > 
> > I tried to use a single line of curl instead of using php curl but just could not work out the syntax for an error free osTicket API call.
> > 
> > This is my first ruby work ever - be gentle
> > 
> > Dan
> > 
> > On Friday, February 14, 2014 3:00:25 AM UTC-7, Riccardo Tacconi wrote:
> > 
> > > As the docs say, it is possible to create a plugin in any language, but ideally they could be all written in Ruby. You could create a GIST and post the link here so we could see the code.
> > > 
> > > On Thursday, 13 February 2014 21:05:08 UTC, Dan Fischer wrote:
> > > 
> > > > Is it bad form to call a php script from a ruby sensu handler?
> > > > 
> > > > That is just what I did to get Sensu to send incidents to osTicket and create tickets:
> > > > 
> > > > result = %x[php /opt/sensu/api\_ticket\_create.php “#{phpargs}”]
> 
> > > > Maybe it would be worth rewriting into ruby to get it shared on sensu-community-plugins but that is beyond me at this point.
> > > > 
> > > > I will clean it up a bit before doing a PR. I will post it on the osTicket forums and spread the word about Sensu.
> > > > 
> > > > Dan
> 
> –  
> Riccardo Tacconi  
> Ruby on Rails and PHP development - System Administration  
> [VIRTUELOGIC LIMITED](http://www.virtuelogic.net/)
> 
> [http://github.com/rtacconi](http://github.com/rtacconi)  
> [http://riccardotacconi.blogspot.com](http://riccardotacconi.blogspot.com)  
> [http://twitter.com/rtacconi](http://twitter.com/rtacconi)

---

<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/osticket-handler/142/5 "2018-11-22T02:05:07Z")

</div>


