Acutally, both icinga2 and your event handler script are telling you exactly what's wrong:

[2016-03-16 09:58:51 +0530] notice/PluginEventTask: Event command for
object 'openstack-in.example.com [2]!cachet-notify' (PID: 1450,
arguments: '/usr/lib64/nagios/plugins/cachet_notify'
'cachet_component' 'newtest' 'service_name' 'cachet-notify'
'service_output' 'HTTP OK: HTTP/1.0 200 OK - 33401 bytes in 0.339
second response time ' 'service_state' 'OK' 'service_state_type'
'HARD') terminated with exit code 1, output: Usage: cachet_notify
cachet_component service_name service_state service_state_type
service_output

Currently, icinga2 is calling the eventhandler this way:
'/usr/lib64/nagios/plugins/cachet_notify' 'cachet_component' 'newtest' 'service_name' 'cachet-notify' 'service_output' 'HTTP OK: HTTP/1.0 200 OK - 33401 bytes in 0.339 second response time ' 'service_state' 'OK' 'service_state_type' 'HARD'

But your eventhandler script states that it expects the following usage:
cachet_notify cachet_component service_name service_state service_state_type service_output

So my guess is that you need to get rid of your argument keys.
Also, your eventhandler script seems to rely on a specific order of arguments, so you should define that as well.

Greetings,
Markus


On 2016-03-16 05:57, Ankush Grover wrote:
Hi Friends,

On enabling the debug code I found out that the Event Handler is
getting execute but it was failing with code 128. On further reading
it is suggested to use arguments instead. So now the EventCommand is

object EventCommand "cachet-notify" {
         import "plugin-event-command"
        command = [ PluginDir + "/cachet_notify" ]
         arguments = {
         cachet_component = "$cachet_component$"
    service_name = "$service.name [1]$"
    service_state = "$service.state$"
    service_state_type = "$service.state_type$"
    service_output = "$service.output$"
}

vars.service.name [5] = "$service.name [1]$"
vars.service.state = "$service.state$"
vars.service.state_type = "$service.state_type$"
vars.service.output = "$service.output$"

 }

With the above EventCommand the plugin now showing in the logs
"terminated with exit code 1". The plugin expect output to be
"cachet_component service_name service_state service_state_type
service_output" and I have the updated to plugin to match its
arguments based on the result.

What is the best way to receive service_name service_state
service_state_type and service_output for an Event Handler and then
pass it onto the plugin..

The Plugin is ->
HTTPS://GITHUB.COM/MPELLEGRIN/NAGIOS-EVENTHANDLER-CACHET    which is
presently compatible with Nagios/Icinga1 but I am running Icinga2 so
trying to make the things work for Icinga2

[2016-03-16 09:58:51 +0530] notice/Process: PID 1450
('/usr/lib64/nagios/plugins/cachet_notify' 'cachet_component'
'newtest' 'service_name' 'cachet-notify' 'service_output' 'HTTP OK:
HTTP/1.0 200 OK - 33401 bytes in 0.339 second response time '
'service_state' 'OK' 'service_state_type' 'HARD') terminated with exit
code 1

[2016-03-16 09:58:51 +0530] notice/PluginEventTask: Event command for
object 'openstack-in.example.com [2]!cachet-notify' (PID: 1450,
arguments: '/usr/lib64/nagios/plugins/cachet_notify'
'cachet_component' 'newtest' 'service_name' 'cachet-notify'
'service_output' 'HTTP OK: HTTP/1.0 200 OK - 33401 bytes in 0.339
second response time ' 'service_state' 'OK' 'service_state_type'
'HARD') terminated with exit code 1, output: Usage: cachet_notify
cachet_component service_name service_state service_state_type
service_output

128 ERROR CODE LOGS

notice/PluginEventTask: Event command for object
'openstack-in.example!cachet-notify' (PID: 32500, arguments:
'/usr/lib64/nagios/plugins/cachet_notify newtest cachet-notify
CRITICAL SOFT 'CRITICAL - Socket timeout after 10 seconds'')
terminated with exit code 128, output:
execvpe(/usr/lib64/nagios/plugins/cachet_notify newtest cachet-notify
CRITICAL SOFT 'CRITICAL - Socket timeout after 10 seconds') failed: No
such file or directory

Thanks & Regards

Ankush Grover

On Tue, Mar 15, 2016 at 3:40 PM, Ankush Grover
<ankushcen...@gmail.com> wrote:

Hi Friends,

I have setup IcingaMaster in HA mode along with 2 Satellite Servers
all on Centos 6/7 64-bit. On one of the Satellite server i am trying
execute an event_command but some how the command is not getting
executed.

Icinga Version on Satellite server is 2.3.8 and on the Icinga Master
is 2.3.6. Presently the EventCommand and Host Configuration is local
to Icinga Satellite server.

ICINGA FEATURE LIST ON THE SATELLITE SERVER:

Disabled features: compatlog debuglog gelf icingastatus livestatus
opentsdb perfdata statusdata syslog
Enabled features: api checker command graphite ido-mysql mainlog
notification

EVENT COMMAND

object EventCommand "cachet-notify" {
import "plugin-event-command"
command = [ PluginDir + "/cachet_notify $cachet_component$
$service.name [1]$ $service.state$ $service.state_type$
$service.output$" ]

}

HOST CONFIGURATION FILE

object Host "openstack-in.example.com [2]" {
import "generic-host"
address = "172.31.4.253"
vars.os = "Linux"
vars.notification["mail"] = {
groups = [ "icingaadmins" ]
enable_event_handler = true
}
}

object Service "cachet-notify" {
import "generic-service"
host_name = "openstack-in.example.com [2]"
check_command = "http"
vars.cachet_component = "newtest"
event_command = "cachet-notify"
enable_event_handler = true
}

Notifications comes properly if the apache goes up or down on the
openstack-in.example server but the event_command is not getting
executed.

ICINGA LOGS

[2016-03-15 08:56:21 +0530] information/ApiClient: Reconnecting to
API endpoint 'icingamaster1.example.com [3]' via host
'icingamaster1.example.com [3]' and port '5665'
[2016-03-15 08:56:21 +0530] information/ApiClient: Reconnecting to
API endpoint 'icingamaster2.example.com [4]' via host
'icingamaster2.example.com [4]' and port '5665'
[2016-03-15 08:56:21 +0530] information/IdoMysqlConnection: MySQL
IDO instance id: 1 (schema version: '1.13.0')
[2016-03-15 08:56:22 +0530] information/ApiListener: New client
connection for identity 'icingamaster1.example.com [3]'
[2016-03-15 08:56:22 +0530] information/ApiListener: New client
connection for identity 'icingamaster2.example.com [4]'
[2016-03-15 09:00:47 +0530] information/ExternalCommandListener:
Executing external command: [1458012647]
SEND_CUSTOM_SVC_NOTIFICATION;openstack-in.example.com
[2];cachet-notify;2;testuser;new test
[2016-03-15 09:00:47 +0530] information/Checkable: Checking for
configured notifications for object 'openstack-in.example.com
[2]!cachet-notify'
[2016-03-15 09:00:47 +0530] information/Notification: Sending
notification 'openstack-in.example.com
[2]!cachet-notify!mail-icingaadmin' for user 'icingaadmin'
[2016-03-15 09:00:47 +0530] information/Notification: Completed
sending notification 'openstack-in.example.com
[2]!cachet-notify!mail-icingaadmin' for checkable
'openstack-in.example.com [2]!cachet-notify'
[2016-03-15 09:01:09 +0530] information/Checkable: Checking for
configured notifications for object 'openstack-in.example.com
[2]!cachet-notify'
[2016-03-15 09:01:09 +0530] information/Notification: Sending
notification 'openstack-in.example.com
[2]!cachet-notify!mail-icingaadmin' for user 'icingaadmin'
[2016-03-15 09:01:09 +0530] information/Notification: Completed
sending notification 'openstack-in.example.com
[2]!cachet-notify!mail-icingaadmin' for checkable
'openstack-in.example.com [2]!cachet-notify'
[2016-03-15 09:01:21 +0530] information/DynamicObject: Dumping
program state to file '/var/lib/icinga2/icinga2.state'
[2016-03-15 09:03:40 +0530] information/Checkable: Checking for
configured notifications for object 'openstack-in.example.com
[2]!cachet-notify'
[2016-03-15 09:03:40 +0530] information/Notification: Sending
notification 'openstack-in.example.com
[2]!cachet-notify!mail-icingaadmin' for user 'icingaadmin'
[2016-03-15 09:03:40 +0530] information/Notification: Completed
sending notification 'openstack-in.example.com
[2]!cachet-notify!mail-icingaadmin' for checkable
'openstack-in.example.com [2]!cachet-notify'

Do let me know if you need any further information.

Thanks & Regards

Ankush Grover



Links:
------
[1] http://service.name
[2] http://openstack-in.example.com
[3] http://icingamaster1.example.com
[4] http://icingamaster2.example.com
[5] http://vars.service.name

_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users
_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to