On 21.05.2014 18:52, Michael Friedrich wrote:> On 21.05.2014 18:06, Niranjan Babu Bommu wrote:
>>
>> Hi,
>>
>> I'm having difficult time to setup pagerduty in incinga2, can any one
>> please help me out on this.
>>
>> I followed these instructions.
>>
>> http://www.pagerduty.com/docs/guides/icinga-integration-guide/
>
> That's written for Icinga 1.x as there is no official final release of
> Icinga 2 yet. But soon, Beta is up for next.
>
> Creating a notification, a user (and group) as well as notification
> commands is presumingly easy following the Icinga 2 documentation.
>
> The pagerduty script uses environment variables, but does not tell which
> ones are required and which are not. You should ask them about it and
> modify your notification command setting the required environment
> variables.
>
> Icinga 2 does not export everything into the environment unlike Icinga
> 1.x does. But rather allows you to define which variable is exported and
> which macro value should be fetched.

I've sent them a mail asking which macros are required. In the meantime you can try the untested on-the-fly configuration I've sent them too after getting insights which environment macros are used:

[--QUOTE--]
Generally, the four required environment variables are noted int the following cURL-call example:

curl -d "pd_nagios_object=host" -d "CONTACTPAGER=13a49387497498987497849784914" -d "NOTIFICATIONTYPE=PROBLEM" -d "HOSTSTATE=down" http://events.pagerduty.com/nagios/2010-04-15/create_event

However, we also recommend that users also include the additional variables noted here: https://support.pagerduty.com/entries/23579473-Customizing-Phone-SMS-Messages-in-Nagios.
[--QUOTE--]

[--SNIP--]
object NotificationCommand "notify-service-by-pagerduty" {
  import "plugin-notification-command"
command = "/usr/local/bin/pagerduty_icinga.pl enqueue -f pd_nagios_object=service"

  env = {
    "CONTACTPAGER" = "$user.pager$"
    "NOTIFICATIONTYPE" = "$notification.type$"
    "SERVICEDESC" = "$service.name$"
    "HOSTNAME" = "$host.name$"
    "HOSTALIAS" = "$host.display_name$"
    "SERVICESTATE" = "$service.state$"
    "SERVICEOUTPUT" = "$service.output$"
  }
}

object NotificationCommand "notify-host-by-pagerduty" {
  import "plugin-notification-command"
command = "/usr/local/bin/pagerduty_icinga.pl enqueue -f pd_nagios_object=host"

  env = {
    "CONTACTPAGER" = "$user.pager$"
    "NOTIFICATIONTYPE" = "$notification.type$"
    "HOSTNAME" = "$host.name$"
    "HOSTALIAS" = "$host.display_name$"
    "HOSTSTATE" = "$host.state$"
    "HOSTOUTPUT" = "$host.output$"
  }
}

object User "pagerduty" {
  display_name = "PagerDuty Notification User"
  pager = "<YOURPAGERDUTYSERVICEKEY>"
}

apply Notification "pagerduty-service" to Service {
  command = "notify-service-by-pagerduty"
  states = [ OK, Warning, Critical, Unknown ]
  types = [ Problem, Acknowledgement, Recovery, Custom ]
  period = "24x7"
  users = [ "pagerduty" ]

  assign where service.vars.enable_pagerduty == true
}

apply Notification "pagerduty-host" to Host {
  command = "notify-host-by-pagerduty"
  states = [ Up, Down ]
  types = [ Problem, Acknowledgement, Recovery, Custom ]
  period = "24x7"
  users = [ "pagerduty" ]

  assign where host.vars.enable_pagerduty == true
}

object Service "pagerduty-test-service" {
  import "generic-service"
  check_command = "ping4"
  host_name = "pagerduty-test-host"

  vars.enable_pagerduty = true
}

object Host "pagerduty-test-host" {
  import "generic-host"
  address = "127.0.0.1"

  vars.enable_pagerduty = true
}
[--SNIP--]


Remember, I did not test that configuration not having an pagerduty around - it may contain validation errors, so verify it working, and if not, please fix it and post feedback here.

best regards,
Michael


--
DI (FH) Michael Friedrich

[email protected]  || icinga open source monitoring
https://twitter.com/dnsmichi || lead core developer
[email protected]       || https://www.icinga.org/team
irc.freenode.net/icinga      || dnsmichi
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to