Support sensu check format: https://sensuapp.org/docs/latest/reference/checks.html#example-check-res...
https://sensuapp.org/docs/latest/reference/checks.html#check-result-chec...
The basic idea is allowing to pipe the output to the sensu client: https://sensuapp.org/docs/0.25/reference/clients.html#client-socket-input
Note that while --output=json prints out a single JSON blob, this should print out a single sensor/check per line, as it will need to be separated to be passed to sensu.
Keys that should be printed:
* name (sensor config name)
* status
* ttl (optional, based on --sensu-ttl if provided)
* output
* interval (caching time, if given)
* executed (current time)
* duration: execution time
* source (optional, based on --sensu-source if given)
Comment | File | Size | Author |
---|---|---|---|
#19 | add_output_sensu_to-2788329-19.patch | 6.28 KB | Ginovski |
#19 | interdiff-18-19.txt | 718 bytes | Ginovski |
#18 | add_output_sensu_to-2788329-18.patch | 6.3 KB | Ginovski |
#18 | interdiff-2788329-15-18.txt | 2.27 KB | Ginovski |
#16 | add_output_sensu_to-2788329-16.patch | 11.11 KB | Ginovski |
Comments
Comment #2
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedI am not sure about any of this:
1. Added the drush command 'monitoring-list' and added options for (output, sensu-ttl, sensu-source)
2. Added method: monitoring_drush_list(), and separate methods for table and sensu output.
To do: send results 1 by 1 in foreach to check result input via the Sensu client socket.
Not sure how to do this, any hints?
Comment #3
miro_dietikerThe command already exists, it's monitoring-sensor-config.
You just need to add an option that switches the output format!
Comment #4
BerdirYou also don't have to worry about feeding it to sensu. I'll take care of that, just make sure that the output is correct.
Comment #5
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commented1. Fixed the command, added the options to the existing monitoring-sensor-config drush command.
2. Added options for output, sensu-ttl, sensu-source.
3. Added check for the output in the monitoring_drush_sensor_config method.
4. Added the 2 methods for sensu output, (method for all sensors, method for specific sensor).
Examples to use the command with the options:
- drush monitoring-sensor-config user_new --output=sensu --sensu-ttl=10 --sensu-source=admin
- drush monitoring-sensor-config --output=sensu
5. In the functions for sensu, I print out the sensu input formatted as in the example client socket usage shown here:
https://sensuapp.org/docs/0.25/reference/clients.html#client-socket-input
It's still left to pipe the sensu formatted input to the sensu client:
Comment #6
Berdirthis is still the wrong place, didn't check miros feedback :)
This is about sensor *config*. We want the results, not the configuration.
monitoring_drush_run() is the function you need to extend, which as I said, already has the output option, we just need another elseif there.
Comment #7
miro_dietikerYeah sorry. I knew the command existed, but wrongly mentioned the sensor config list instead of the sensor run.
But i also think that this issue title / summary doesn't properly mention the scope. :-)
Comment #8
BerdirBetter now? ;)
I thought I'd mentioned that this issue isn't about actually passing the data to sensu, forgot about that. We might want to mention https://sensuapp.org/docs/latest/reference/clients.html#example-client-s... in the description for it, though.
Comment #9
BerdirComment #10
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commented1. Added the options in monitoring-run command.
2. Added a function for output in sensu format.
Right now the function's output is in table format, but I have this code for the example in the upper link in #5 and #8 comment socket usage:
Which output should I use in the function?
Comment #11
BerdirAs discussed.
Comment #12
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commented1. Fixed the examples in the drush command. (from monitoring-result to monitoring-run).
2. Added example for the sensu output.
3. Added the correct output in the function.
4. I see use of unknown function getSensorName from the SensorResultInterface in the json output function and it doesn't seem to be working. Should I fix that here or create a followup?
Comment #13
miro_dietikerI think you should get the sensu specific options below in the sensu specific part.
Comment #14
Berdirthose are not really good examples. I'd use example.org as source, and ttl 600 oder so. 10 would be just 10 seconds.
status is 0,1 or 2. See https://sensuapp.org/docs/0.25/reference/checks.html#sensu-check-specifi... (use 3 for unknown)
not verbose output, getMessage()
formatInterval() is for humans. sensu is not a human, it wants seconds :)
same, timestamp.
We also need something else, --sensu-handlers=foo,bar, that is then added as a nested array: https://sensuapp.org/docs/0.25/reference/checks.html#check-attributes
And we also need metrics. this means, for each sensor that is numeric, add a second check result that has name $name_metric. and 'type' => 'metric'. See http://www.programblings.com/2013/11/14/sensu-checks-to-report-metrics/. The ouptut that you provide should then be in the format "$reversed_source.$name $value $executed" $reversed_source is implode('.', array_reverse(explode('.', $source)), meaning, foo.example.org becomes org.example.foo.
Comment #15
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commented1. Fixed 1-5 and added the sensu options in the output=sensu only.
2. Added options:
- sensu-handlers
- sensu-metric-handlers
- sensu-metrics
3. Added host name as default sensu source.
4. Added second metric check result for the numeric sensors.
Comment #16
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commented1. Removed executed from the output.
2. Changed ttl from string to integer.
Comment #17
Berdirhttps://imgflip.com/i/1a6asd
should use the constants. also INFO should be mapped to OK I think.
Comment #18
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedDidn't see that with the patches, my bad :)
1. Changes from #16 again and added the status_codes as constants.
2. Changed INFO to be mapped to OK.
3. Did additional fix for the sensu-metrics.
Comment #19
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedChanged the metric name in the output.
Comment #21
BerdirComment #22
BerdirComment #24
BerdirPorted to 7.x