GLPI integration with Nagios through custom event handlers

Nagios is an industry leader in network and resource monitoring and GLPI is a great ITIL based help desk system but neither provide integration to each other out of the box. As an IT Manager who uses both systems I found a need to alert the help desk when Nagios recognized a system failure. Of course, Nagios could always send an email alert to a mailbox and then GLPI could pickup that email and create a new ticket. This can work out of the box and I actually ran this configuration for some time but I found out that my help desk was being inundated with tickets that were not being closed and Nagios tickets were filling up the help desk even after the error was rectified on Nagios. Not a very scalable solution. So I set out to find a better solution and my goal was to be able to automatically close GLPI tickets when systems or services return to normal in Nagios. After some research I decided I would write a custom Nagios host and service event handler that opens and closes tickets on GLPI. You can read more about Nagios custom event handlers here You can also download the event handlers at the end of this article. The below event handlers will create new GLPI tickets for Nagios events and close them once the issue has been resolved.  These scripts are written in PHP and do require direct access to the GLPI MySQL database. This solution also requires the web services plugin on the GLPI server.

Pulling it all together

Modify the event handler files to include a GLPI username, password and GPLI server IP, GLPI MySQL Username and Password.  If you are on GPLI version .80+ then enter a GLPI watcher user ID or GLPI group ID.  Then move the files to your /usr/share/nagios/event_handlers/ folder. Next modify your Nagios commands.cfg (/etc/nagios3/commands.cfg) to include the following commands:

# 'manage-host-tickets' command definition
define command{
command_name manage-host-tickets
command_line php /usr/share/nagios3/plugins/eventhandlers/manage-host-tickets.php event="$HOSTSTATE$" state="$HOSTSTATETYPE$" eventhost="$HOSTNAME$" hostattempts="$HOSTATTEMPT$" maxhostattempts="$MAXHOSTATTEMPTS$" hostproblemid="$HOSTPROBLEMID$" lasthostproblemid="$LASTHOSTPROBLEMID$"
}

# 'manage-service-tickets' command definition
define command{
command_name manage-service-tickets
command_line php /usr/share/nagios3/plugins/eventhandlers/manage-service-tickets.php event="$SERVICESTATE$" state="$SERVICESTATETYPE$" hoststate="$HOSTSTATE$" eventhost="$HOSTNAME$" service="$SERVICEDISPLAYNAME$" serviceattempts="$SERVICEATTEMPT$" maxserviceattempts="$MAXSERVICEATTEMPTS$" servicestate="$SERVICESTATE$" lastservicestate="$LASTSERVICESTATE$" servicecheckcommand="$SERVICECHECKCOMMAND$" serviceoutput="$SERVICEOUTPUT$" longserviceoutput="$LONGSERVICEOUTPUT$"
}

Next, modify your generic-host_nagios2.cfg (/etc/nagios3/conf.d)

define host{
        name                            generic-host    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host event handler is enabled
        flap_detection_enabled          1       	; Flap detection is enabled
        failure_prediction_enabled      1       	; Failure prediction is enabled
        process_perf_data               1       	; Process performance data
        retain_status_information       1       	; Retain status information across program restarts
        retain_nonstatus_information    1       	; Retain non-status information across program restarts
		check_command                   check-host-alive
		event_handler		            manage-host-tickets
		max_check_attempts      1
		notification_interval   0
		notification_period     24x7
		notification_options    d,u,r
		contact_groups          admins
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }

And then modify the generic-service-nagios2.cfg (/etc/nagios3/conf.d)

define service{
        name                            generic-service ; The 'name' of this service template
        active_checks_enabled           1       ; Active service checks are enabled
        passive_checks_enabled          1       ; Passive service checks are enabled/accepted
        parallelize_check               1       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
        obsess_over_service             1       ; We should obsess over this service (if necessary)
        check_freshness                 0       ; Default is to NOT check service 'freshness'
        notifications_enabled           1       ; Service notifications are enabled
        event_handler_enabled           1       ; Service event handler is enabled
        flap_detection_enabled          1       ; Flap detection is enabled
        failure_prediction_enabled      1       ; Failure prediction is enabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
		notification_interval           0		; Only send notifications on status change by default.
		event_handler		            manage-service-tickets
		is_volatile                     0
		check_period                    24x7
		normal_check_interval           5
		retry_check_interval            1
		max_check_attempts              4
		notification_period             24x7
		notification_options            w,u,c,r
		contact_groups                  admins
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }

You will now receive helpdesk tickets in GLPI when alerts are created in Nagios and those tickets will be removed when the service or host has been restored.  GLPI can now handle the appropriate  notifications.

Download

[wp_ad_camp_2] [wpdm_file id=1] Happy Monitoring!

65 Comments

  1. Hello blogger, i must say you have very interesting posts here.
    Your website can go viral. You need initial traffic only.
    How to get it? Search for; Mertiso’s tips go viral

  2. Mark-Monty

    Hi Derrik I used your plugin, and I think is good I used glpi version 0.90 and nagios XI, when I create a DOWN ticket everything is ok, but I have a problem when the device is UP because don’t work, in webserver historical appears “Connection(anonymus,IP,glpi.test,xml-rpc)”, but when create the new ticket it uses the correct user, the webservices log only show me the run time of execution method glpi.test.
    Can you help me??.

    1. Derrick

      Thanks for your comment, glad it worked for you. I have recently updated the eventhandlers to work with GLPI 9.1.2

  3. You inspire me in my work

    1. Pas sûr qu’avec un géniteur aussi étroit d’esprit que sa prose le laisse entendre, les enfants soient « Ã©quilibrés et heoaqux &rreuu;… Plus sûrement de la graine de psy et/ou plus grave…

  4. I appreciate, cause I found just what I was having a look for.
    You’ve ended my 4 day long hunt! God Bless you man. Have a nice day.

    Bye

    1. Derrick

      You’re welcome!

  5. Hi Derrick

    Is there any update on the scripts for GLPI0.85.4 and Webservices 1.5.0. I am getting an error “xmlrpc error(1): Access denied” when i run the test from this website.

    Are you able to assist.

    Regards

  6. Javi

    Hi!

    you wrote “You can also download the event handlers at the end of this article.” but i can’t download it

    where can I download them?

    thank you!

    1. Derrick

      Download manager was broken. I’ve fixed it and the download is available on this page again.

  7. Nice article! Can you please update it for GLPI 0.85 ?

    1. Derrick

      Works with 0.85

  8. Anton

    Update for GLPI 0.85 & WebServices 1.5.0?

    1. Derrick

      Works with 0.85 and newest webservices.

  9. mikco

    It´s posible to used in Zabbix?

    1. Derrick

      Does Zabbix use Nagios? If so, then probably.

  10. yellowcox

    Hi,

    Thx for your work Derrick!

    Open a ticket is fine, but I have this problem to close a ticket:

    2014-10-10 15:01:28
    Connection: user, IP
    Protocol: xml-rpc, Method: glpi.listTickets, Function: PluginWebservicesMethodHelpdesk::methodListTickets
    Params: Array
    (
    [method] => glpi.listTickets
    [url] => plugins/webservices/xmlrpc.php
    [host] => server
    [order] => id
    [status] => new
    )
    Compression: Server:/, Config:0, Agent:?
    Duration: 0.118
    Response size: 76
    Response content: Array
    (
    [faultCode] => 14
    [faultString] => Bad parameter (status)
    )

    I’m under GLPI v0.84.50 and webservices plugin v1.4.2
    Thanks for your help

    1. Derrick

      Hello,

      I’ve just released a new version of the event handlers that is GLPI 84.5 compatible. I’ve rewritten them to use GLPI webservices for opening and closing tickets. There are less configurables now and they are fully tested.

      Download the new scripts here or on Nagios Exchange and let me know if you have any issues.

  11. Yau Tee Kuan

    How do i troubleshoot this problem?

    php manage-host-tickets.php event=”DOWN” state=”HARD” eventhost=”Myhost” hostattempts=”4″ maxhostattempts=”4″ hostproblemid=”1″ lasthostproblemid=”1″
    + Calling ‘glpi.test’ on http://10.4.137.153/glpi/plugins/webservices/xmlrpc.php
    xmlrpc error(1): Access denied

    1. Derrick

      Without seeing any other logs, I suspect that error indicates bad credentials. I haven’t done any testing with the newest version of GLPI and cannot confirm that these event handlers work at this point. I have been trying to deploy GLPI v.85 and Nagios but have been busy.

  12. Hi, i need some help with the integration php pages on nagios eventhandler, this is my error:

    Compression: Server:/On, Config:1, Agent:?
    Duration: 0.110
    Response size: 76
    Response content: Array
    (
    [faultCode] => 14
    [faultString] => Bad parameter (status)
    )
    Additional Info:

    (
    [glpi] => 0.84.5
    [monitoring] => 0.84+1.0
    [webservices] => 1.4
    )

    thanks for your help.

  13. Viny Azevedo

    SOLVED:

    Install PHP5-mysql in Nagios Server.

    Tks

  14. Viny Azevedo

    Line 159:

    $mysql = mysql_connect($xmlhost, $sqluser, $sqlpwd) or die(mysql_error());

    1. Derrick

      New version no longer uses mysql command to close tickets.

  15. Viny Azevedo

    Dear,

    Please, Nagios can not close the tickets.

    GLPI: 084.5
    Nagios: 4.0.6
    WebServices: 1.4.2

    Nagios log: [1399494798] wproc: stdout line 04: xmlrpc error (14): Bad parameter (status)

    I changed the status of “solved” to “5”, but it did not work.

    thank you

    1. Viny Azevedo

      New error:

      1399501269] wproc: stderr line 01: PHP Fatal error: Call to undefined function mysql_connect() in /usr/share/nagios3/plugins/eventhandlers/manage-service-tickets.php on line 159

  16. Elliot

    Hello,

    Should this plugin still be working for GLPI v0.84.5?

    We have just started using Nagios (NagiosFAN), but have been using GLPI for years and having a plugin such as this working would be a God-send!

    I have followed the install instructions and tried my best to get this to work, but I have hit a brick wall now. I can run the command from the command line and I receive no error but no ticket gets created in GLPI.


    [root@vm-h002474-nagios eventhandlers]# php manage-host-tickets.php event=”CRITICAL” state=”HARD” hoststate=”UP” eventhost=”testPC” hostattempts=”3″ maxhostattempts=”3″ hostproblemid=”CRITICAL” lasthostproblemid=”CRITICAL”
    + Calling ‘glpi.test’ on http://helpdesk.hayley-group.local/plugins/webservices/xmlrpc.php

    Any feedback would be highly appreciated.

    Elliot

    1. Derrick

      I have not checked against 0.84.5. I’m in the process of migrating to a VM and will will test with a new installation.

      1. Elliot

        That’s great to hear, David. I will stop by again soon and check for any updates 🙂

        1. Elliot

          Oops, I meant ‘Derrick’! My apologies 🙂

        2. Derrick

          The new version is finished and I’ve uploaded to this site and Nagios Exchange.

  17. paul

    Hello,

    When i apply this command “php manage-host-tickets.php”

    I just get

    Array
    (
    )

    All concerned files are 755 or 777.

    —–

    Thank’s
    Paul.

  18. Denis

    I have the same problem as “Vad” the 13/12
    the status of ticket is: 0 0
    Where Can I change to have 1 on the output for new ticket?
    Thank’s a lot.
    Denis

  19. Vad

    Hi Y.Legrand,

    where i can found an update?

    Thank’s a lot.

  20. Y. Legrand

    Hi,

    I have found and fix the problem.

    Thanks

    1. Vad

      Hi Y.Legrand,

      where i can found an update?

      Thank’s a lot.

  21. Y. Legrand

    Hi,

    This is exactly what i am looking for 🙂

    My Glpi is on a Linux server [CentOS release 6.4 (Final)], and
    the problem is that i have not “xmlrpc.php” on this server !

    1) For GLPI server, where can i find “xmlrpc.php”?, in which linux package?
    Here is all packages who contain “xmlrpc.php”. Which one should-i install?

    root@Glpi> yum provides *xmlrpc.php*
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Loading mirror speeds from cached hostfile
    * base: distrib-coffee.ipsl.jussieu.fr
    * epel: fr2.rpmfind.net
    * extras: distrib-coffee.ipsl.jussieu.fr
    * updates: distrib-coffee.ipsl.jussieu.fr
    php-bartlett-PHP-CompatInfo-2.25.0-1.el6.noarch : Find out version and the extensions required for a piece of code to run
    Repo : epel
    Matched from:
    Filename : /usr/share/pear/Bartlett/PHP/CompatInfo/Reference/xmlrpc.php

    drupal6-6.29-1.el6.noarch : An open-source content-management platform
    Repo : epel
    Matched from:
    Filename : /usr/share/drupal6/xmlrpc.php

    moodle-2.4.7-1.el6.noarch : A Course Management System
    Repo : epel
    Matched from:
    Filename : /var/www/moodle/web/webservice/xmlrpc/lang/en/webservice_xmlrpc.php

    dokuwiki-0-0.20.20130510a.el6.noarch : Standards compliant simple to use wiki
    Repo : epel
    Matched from:
    Filename : /usr/share/dokuwiki/lib/exe/xmlrpc.php

    horde-3.3.11-1.el6.noarch : The common framework for all Horde applications
    Repo : epel
    Matched from:
    Filename : /usr/share/horde/lib/Horde/RPC/xmlrpc.php

    wordpress-3.7.1-1.el6.noarch : Blog tool and publishing platform
    Repo : epel
    Matched from:
    Filename : /usr/share/wordpress/xmlrpc.php

    drupal7-7.24-1.el6.noarch : An open-source content-management platform
    Repo : epel
    Matched from:
    Filename : /usr/share/drupal7/xmlrpc.php

    2) And on the Nagios server, in “manage-*-tickets.php”, which path must-i put for $xmlurl variable ?
    $xmlurl = “?/xmlrpc.php”;

    Here is the results when i call your program :
    php /usr/lib64/nagios/event_handlers/manage-service-tickets.php event=”CRITICAL” state=”HARD” hoststate=”UP” eventhost=”PcSevag” service=”ServiceName” serviceattempts=”3″ maxserviceattempts=”3″ servicestate=”CRITICAL” lastservicestate=”OK” servicecheckcommand=”SERVICE_CHECK_COMMAND” serviceoutput=”SERVICE_OUTPUT” longserviceoutput=”LONG_SERVICE_OUTPUT”
    + Calling ‘glpi.test’ on http://192.168.0.211/plugins/webservices/xmlrpc.php
    PHP Fatal error: Call to undefined function xmlrpc_encode_request() in /usr/lib64/nagios/event_handlers/manage-service-tickets.php on line 92

    Thank you very much for your job and wish you a great christmas

  22. Vad

    Very last question i promise,

    the statut of ticket is : 0 0
    where can i change to have 1 on the output for new ticket?

    Thank’s a lot.

    Vad

    1. d-rock

      I was working on your issue a bit this morning and think I have a solution for you but I won’t be able to finish up until Monday. I’ll reply back with an update soon. Thanks

  23. Vad

    Hi Again,

    i try your plugin from nagios exchange it’s working better, there just one thing in ticket close and i don’t know where i can solve the problem :

    + Calling ‘glpi.doLogin’ on http://bsd-web/glpi/plugins/webservices/xmlrpc.php
    + Calling ‘glpi.listTickets’ on http://bsd-web/glpi/plugins/webservices/xmlrpc.php?session=fgv5m6v32afpfn28lc3bncepf5

    Warning: date() [function.date]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Europe/Berlin’ for ‘CET/1.0/no DST’ instead in /usr/local/www/glpi/plugins/webservices/inc/methodsession.class.php on line 357

    faultCode

    14

    faultString

    Bad parameter (status)

    + Bad response

    if you have some idea it wil be great.
    thank’s in advance.

    Vad

  24. Vad

    The plugin always calling “Calling ‘glpi.test'” function when i test this command manually:

    php manage-host-tickets.php event=”DOWN” state=”HARD” eventhost=”Myhost” hostattempts=”4″ maxhostattempts=”4″ hostproblemid=”1″ lasthostproblemid=”1″

    if you have any idea it will be appreciate.

  25. Vad

    Hi,

    i test to integrate your plugin but i don’t know why when i launch the command manually it work in webservice event log :

    2013-12-13 11:40:59
    Execute method:glpi.test (xml-rpc), function:PluginWebservicesMethodCommon::methodTest, duration:0.038, size:92
    2013-12-13 11:40:59
    Connexion: anonymous, 192.168.10.247
    Protocol: xml-rpc, Method: glpi.test, Function: PluginWebservicesMethodCommon::methodTest
    Params: Array
    (
    [method] => glpi.test
    [url] => glpi/plugins/webservices/xmlrpc.php
    [host] => bsd-web
    )
    Compression: Server:/, Config:0, Agent:?
    Duration: 0.038
    Response size: 92
    Response content: Array
    (
    [glpi] => 0.84.2
    [webservices] => 1.4
    [monitoring] => 0.84+1.0
    )

    but no ticket is create and when ths command is launch by Nagios nothing append only the event handler in nagios.log. No error message

    Glpi > 0.84 with webservice > 1.4 on Server > Freebsd 9.0
    Nagios > 3.5.1 on Another Server > Freebsd 9.0

    thank’s in advance for your help

    Vad

  26. d-rock

    What are the glpi MySQL database names? I have the database hard coded as “GLPI”. You will want to change the name if you have used a different one.

    Search both event handlers for “mysql_select_db(“glpi”) or die(mysql_error());” and replace “glpi” with your database name. I should probably change this.

    1. judanssi

      Does this assume, that GLPI and DB are running on same host? At least I couldnt find different server settings for DB.

      Also I have “little kind of” problems with php:

      PHP Warning: fopen(/var/log/nagios/manage-host-tickets.log): failed to open stream: No such file or directory in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 32
      Array
      (
      )
      PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 44
      PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 45
      PHP Notice: Undefined index: eventhost in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 46
      PHP Notice: Undefined index: event in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 47
      PHP Notice: Undefined index: state in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 48
      PHP Notice: Undefined index: hostattempts in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 49
      PHP Notice: Undefined index: maxhostattempts in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 50
      PHP Notice: Undefined index: hostproblemid in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 51
      PHP Notice: Undefined index: lasthostproblemid in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 52

      1. Derrick

        You should be able to run nagios and glpi an separate hosts but the eventhandlers need to run on the nagios host. The new version no longer requires DB configuration.

  27. LAURENTOR999

    Hi,
    Great jobs, but I have these permission error : (I have made some modifications since my glpi is in https)
    root@eon eventhandlers]# php manage-service-tickets.php
    + Calling ‘glpi.test’ on https://eon/glpi/plugins/webservices/xmlrpc.php
    xmlrpc error(1): Accès refusé

    I have checked the permission on the php scripts :

    -rwxr-xr-x 1 root root 9542 juin 28 09:35 manage-host-tickets.php
    -rwxr-xr-x 1 root root 9840 juin 28 09:39 manage-service-tickets.php

    I have checked the permission on the xmlrpc file in the glpi/plugins directory too and even If I do a chmod 777, I have the error.

    And I have set up an local super-admin(R) glpi user in the two scripts with a watcher user who is admin too. I have GLPI 0.83.91.

    Thanks for your help.

    1. LAURENTOR999

      I think I have resolved my permission issue since I have created a new client in the webservice plugin configuration with the correct IP adress.

      But now, I don’t have any tickets created. I have checked the webservice logs :

      801 2013-06-28 10:55 GLPI USER Connexion (GLPIUSER, 10.1.99.250, glpi.doLogout, xml-rpc)
      800 2013-06-28 10:55 GLPI USER Connexion (GLPIUSER, 10.1.99.250, glpi.createTicket, xml-rpc)

      Thanks for helping

  28. Delfer

    In nagios.log not show nothing relevant

    [1369669732] HOST NOTIFICATION: User1;monitor;DOWN;manage-hosts-glpi;Manually set to Down by nagiosadmin
    [1369669750] HOST ALERT: monitor;UP;HARD;1;OK – 10.60.1.4: rta 0.029ms, lost 0%
    [1369669750] HOST NOTIFICATION: User1;monitor;UP;manage-hosts-glpi-hosts;OK – 10.60.1.4: rta 0.029ms, lost 0%

    The DOWN open the ticket but the UP does nothing.

  29. Anna Patil

    php5-xmlrpc is installed and

    -rwxrwxrwx 1 nagios nagios 7562 May 26 15:41 manage-host-tickets.php
    -rwxrwxrwx 1 nagios nagios 7702 May 26 14:02 manage-service-tickets.php

    getting below error

    [root@nagios eventhandlers]# php manage-host-tickets.php
    Array
    (
    )
    PHP Notice: Undefined index: eventhost in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 46
    PHP Notice: Undefined index: event in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 47
    PHP Notice: Undefined index: state in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 48
    PHP Notice: Undefined index: hostattempts in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 49
    PHP Notice: Undefined index: maxhostattempts in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 50
    PHP Notice: Undefined index: hostproblemid in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 51
    PHP Notice: Undefined index: lasthostproblemid in /usr/local/nagios/libexec/eventhandlers/manage-host-tickets.php on line 52
    [root@cacti-sme eventhandlers]#

    thanks

  30. Delfer

    Hi!
    I have the same problem that Salluste. I can create a ticket when the service or host is down, but it’s impossible to close the ticket. I have a remote access for mysql and in the mysql.log i havent error. but at the end nothing change could you help me thanks

    I have installed the last version of your eventhandlers…

    1. Delfer

      My GLPI version is 0.83

    2. d-rock

      CD to the event handler directory and run the php script:

      php manage-host-tickets.php

      Check the output. You should see:

      “+ Calling ‘glpi.test’ on http://~GLPI IP~/plugins/webservices/xmlrpc.php”

      If you don’t it could be permissions or that php5-xmlrpc is not installed.

      1. Delfer

        Thanks but that is not the solution:

        php5-xmlrpc is installed with 777 permissions.

        -rwxrwxrwx 1 root root 3249 nov 8 2011 xmlrpc.php

        When I run the php script, I don’t see the call to glpi.test, only show errors related with the parameters script:

        [root@monitor]# php manage-host-tickets.php
        Array
        (
        )
        PHP Notice: Undefined index: eventhost in /usr/local/lib/nagios/plugins/glpi/manage-host-tickets.php on line 46
        PHP Notice: Undefined index: event in /usr/local/lib/nagios/plugins/glpi/manage-host-tickets.php on line 47
        PHP Notice: Undefined index: state in /usr/local/lib/nagios/plugins/glpi/manage-host-tickets.php on line 48
        PHP Notice: Undefined index: hostattempts in /usr/local/lib/nagios/plugins/glpi/manage-host-tickets.php on line 49
        PHP Notice: Undefined index: maxhostattempts in /usr/local/lib/nagios/plugins/glpi/manage-host-tickets.php on line 50
        PHP Notice: Undefined index: hostproblemid in /usr/local/lib/nagios/plugins/glpi/manage-host-tickets.php on line 51
        PHP Notice: Undefined index: lasthostproblemid in /usr/local/lib/nagios/plugins/glpi/manage-host-tickets.php on line 52

        Thanks in advance.

        1. d-rock

          Thanks for posting the errors, that helps. What is in your Nagios log?

    3. Artem R.

      i have same problem. And logs clean. Tickets not close…

  31. d-rock

    DiddyDaveUK,

    Check your nagios log (/var/log/nagios3/nagios.log) for the host failure. You should see a log entry that looks like this:

    HOST EVENT HANDLER: ~YOUR HOSTNAME~;DOWN;SOFT;1;manage-host-tickets

    If there is no log entry it means the event handler is not firing. Check your nagios host configuration and make sure it is configured to use your generic-host template.

    define host {
    host_name ~HOSTNAME~
    alias ~HOSTALIAS~
    address ~HOSTIP~
    use generic-host
    }

    Then check your generic-host template and make sure it is configured to use the event handler.

    define host{
    name generic-host
    notifications_enabled 1
    event_handler_enabled 1
    flap_detection_enabled 1
    failure_prediction_enabled 1
    process_perf_data 1
    retain_status_information 1
    retain_nonstatus_information 1
    check_command check-host-alive
    event_handler manage-host-tickets
    check_interval 3
    retry_interval 1
    max_check_attempts 3
    notification_interval 0
    notification_period 24x7
    notification_options d,u,r
    contact_groups admins
    register 0
    }

    If everything looks good you can try to fire the event handler manually. CD to the event handler directory and run:

    php manage-host-tickets.php

    The command should return:

    + Calling ‘glpi.test’ on http://~GLPI IP~/plugins/webservices/xmlrpc.php

    If it fails it could be a permissions problem. Permissions should look like this:

    -rwxr-xr-x manage-host-tickets.php
    -rwxr-xr-x manage-service-tickets.php

    Report back with your results. Thanks

  32. DiddyDaveUK

    I have followed your instructions but it is not working for me for some reason.

    GLPI: 0.83.7
    I have the GLPI Plugins running: Webservcies and Monitoring Servcies

    I have amended the above in Nagios v 3.2.3

    The only thing I can see it been is that my GLPI MySQL does NOT have a root password it has been left blank as we only use it for internal use at this time.

    1. d-rock

      DiddyDaveUK,

      Are tickets being created? The script only uses the Mysql account to close previously opened tickets. Also, your GLPI instance must have a Mysql account that it uses even if your GLPI instance is internal only – you can use this account and password in the script.

      1. DiddyDaveUK

        Hi thanks for the reply….
        No, helpdesk tickets are created on the event of a host been down.

        The GLPI Instance does have a MySQL Account I have just set it up with the default root account which does not have a password.

        I do have a test GLPI System running to which I do have a password fopr the MySQL Root account but it still does not open or close any calls.

        May be I’m doing something wrong but I can see where…?

        Do I need to setup the WebServices plugin at all….? I have set this with a setup to allow the IP of the nagios system.

        Ta!

        1. d-rock

          Let’s try to get tickets created first, then we can deal with the Mysql account.

          You need the WebServices plugin installed in GLPI for the Nagios Event Handlers to function. Install the plugin and then force a Nagios event, such as shutting down a montitored server. Let me know if it creates a ticket.

          1. DiddyDaveUK

            The WebServices plugin is installed and running. All the amendments are in place on the nagios system. When I down a server that is been monitored nothing is created in the GLPI.

            Just a quick note I am using the NSClient+ on the windows units if this matters…

  33. d-rock

    I’ve recoded these event handlers to be compatible with GLPI 0.83. Unfortunately, I can no longer test with versions older than 0.83. If you run into problems, post back here and I will change them accordingly.

  34. salluste

    thanks for this eventhandler, I can create a ticket when the service is down, but it’s impossible to close the ticket. I have a remote access for my sql and in the mysql.log i havent error. but at the end nothing change could you help me thanks

    1. d-rock

      I sent you an email. The scripts need direct mysql access to close tickets. Make sure the mysql username, password and server address are set in the beginning of the script. Also make sure remote mysql access is enabled.

    2. d-rock

      I fixed the event handlers. Re-download and enter your sql user and password details. Should fix your problem.

Leave a Reply

Your email address will not be published. Required fields are marked *

*