Sensu Plugin for Parsing raw XML

Hi All,

We would just like to seek for your expert opinion.

We have a Sensu and ELK Stack integration project and we need to create a Sensu check that will parse a raw XML file to convert its output as a metric. Then, we can send this output directly to Elastic Stack thru logstash. We wanted to fully utilize the capability of Sensu and do all the alerting in it which is why we can’t consider parsing the XML directly in logstash.

We are beginners in Ruby and we are not really sure how to start writing a custom plugin/check. We’d truly appreciate if anyone can guide us on where to start. Thanks in advanced!

The theory of writing checks is intentionally rather simple. While you can do many, many different things, a check is basically

  • any executable script

  • that returns 0 if all is fine (OK)

  • that returns 1 if there is something that might be a problem (WARN)

  • that returns 2 if there is a critical flaw (CRITICAL)

  • that may return any other exit code for different results (UNKNOWN)

A check that produces a metric will also

  • write the metric(s) to stdout in graphite syntax (some.metric.name.grouped.by.dots float unix_timestamp, e.g. kronos.sensors.coretemp-isa-0000.core1 34.0 1489162933)

These scripts do not have to be in Ruby, but it would preferable since they’ll be accepted should you want to contribute yours to the community repositories (and we’d like you to :slight_smile: )
I think I’m also supposed to mention this: https://github.com/sensu-plugins/sensu-plugin ; it’s a framework so you don’t need to write all the code yourself - however I’ve not used it in depth yet.

···

On Friday, May 5, 2017 at 7:27:53 AM UTC+2, Kaye wrote:

Hi All,

We would just like to seek for your expert opinion.

We have a Sensu and ELK Stack integration project and we need to create a Sensu check that will parse a raw XML file to convert its output as a metric. Then, we can send this output directly to Elastic Stack thru logstash. We wanted to fully utilize the capability of Sensu and do all the alerting in it which is why we can’t consider parsing the XML directly in logstash.

We are beginners in Ruby and we are not really sure how to start writing a custom plugin/check. We’d truly appreciate if anyone can guide us on where to start. Thanks in advanced!

Hi Alexander,

Thank you so much for the useful advice. Everything is working now and we’ve managed to create some custom checks in ruby. :slight_smile:

Regards.

···

On Friday, May 5, 2017 at 1:27:53 PM UTC+8, Kaye wrote:

Hi All,

We would just like to seek for your expert opinion.

We have a Sensu and ELK Stack integration project and we need to create a Sensu check that will parse a raw XML file to convert its output as a metric. Then, we can send this output directly to Elastic Stack thru logstash. We wanted to fully utilize the capability of Sensu and do all the alerting in it which is why we can’t consider parsing the XML directly in logstash.

We are beginners in Ruby and we are not really sure how to start writing a custom plugin/check. We’d truly appreciate if anyone can guide us on where to start. Thanks in advanced!

Hey,

Just want to clarify something as a maintainer of the plugins, we will accept plugins in multiple languages and while I prefer them in ruby I have reviewed plugins in ruby, python, bash, shell, and powershell. While there are no guidelines that would not be accepted language wise (we probably should have a blurb somewhere) I feel like really the only one I would ever not accept is perl unless it was written by 1 of the 5 total global perl developers in the world that actually write it in a way don’t hate the language. My stance is write plugins for readability; many maintainers do not run most of the plugins so we may not be familiar with it and it typically does not come with testing artifacts.

Thanks,

···

On Wednesday, July 5, 2017 at 11:17:51 PM UTC-7, Kaye wrote:

Hi Alexander,

Thank you so much for the useful advice. Everything is working now and we’ve managed to create some custom checks in ruby. :slight_smile:

Regards.

On Friday, May 5, 2017 at 1:27:53 PM UTC+8, Kaye wrote:

Hi All,

We would just like to seek for your expert opinion.

We have a Sensu and ELK Stack integration project and we need to create a Sensu check that will parse a raw XML file to convert its output as a metric. Then, we can send this output directly to Elastic Stack thru logstash. We wanted to fully utilize the capability of Sensu and do all the alerting in it which is why we can’t consider parsing the XML directly in logstash.

We are beginners in Ruby and we are not really sure how to start writing a custom plugin/check. We’d truly appreciate if anyone can guide us on where to start. Thanks in advanced!