Nagios Extended Notification Mail

8. Januar 2009
Screenshot nagios_mail

Ersatz für die von Nagios mitgelieferte Notification-Mail.

Eigentlich bin ich kein Fan von HTML-Mails, aber CSS-Formatierungen machen eine Notification-Mail schon übersichtlicher. Es wird aber auch eine Text-Variante für Handhelds etc. mitgesendet.

Download: nagios_mail-0.9.zip

Installation

Nach dem kopieren der nagios_mail.php müssen nur die Nagios-Notification-Definitionen geändert werden:

# /usr/local/nagios/etc/objects/misccommands.cfg
define command{
        command_name    host-notify-by-email
        command_line    /usr/bin/php -q /opt/nagios_mail.php
        }
 
define command{
        command_name    notify-by-email
        command_line    /usr/bin/php -q /opt/nagios_mail.php
        }

Je nach Distribution muss evt. der PHP-Pfad angepasst werden. Update: seit Version 0.3 ist PEAR nicht mehr notwendig!

Konfiguration

Im Header der PHP-Datei kann der Absender, die Nagios-URL oder das Subject geändert werden.

Changelog

0.9.0
  outlook 2007 html compatibility (back to stoneage)
  added color for UNKNOWN state
 
0.8.0
  added additional header configuration
  (for example to send high-priority mails)
  improved documentation
  improved debug mode
 
0.7.0
  fixed multipart issue (webmailer compatibility)
  added safari header (iPhone Mail compatibility)
 
0.6.0
  added subject templates
  added ability to disable sections
 
0.5.0
  added PHP4 compatibility
 
0.4.0
  added test-mode (if run from command-line)
  removed php-notices
 
0.3.0
  added readme
  removed Mail_mime dependency
  removed css definitions for webmail compatibility
  added links to hostname
 
0.2.0
  changed script to object oriented programming

92 Antworten to “Nagios Extended Notification Mail”

  1. Oliver sagt:

    Hallo, ich bekomme die Notify nicht zum laufen. Habe genau nach Anleitung die Konfiguration vorgenommen. Ich bin noch nicht so fit in Linux, aber für mich stellt sich die Frage wie die Mail versendet werden soll? Ich denke das geht aus dem PHP Code hervor, muss ich denn für das Versenden noch ein Pfad einstellen? Sprich /usr/bin/mail oder so? Danke für eine schnelle Hilfe. Oliver

  2. otto sagt:

    Bei nagios_mail-0.3 wird die mail() Funktion von PHP benutzt. Diese sollte zumindest auf Linux-Systemen einen sendmail-wrapper zum versenden verwenden. Je nach php.ini z.B. “sendmail_path = /usr/sbin/sendmail -t -i”

    In der nächsten Version werde ich mal eine Test-Funktion einbauen. Update: die aktuelle Version (0.4) hat einen Test-Modus.

  3. Oliver sagt:

    Hallo Otto, danke für die schnelle Antwort. Ich habe nun einige PHP Dateien gefunden und versuche diese gerade anzupassen. Mein Problem was ich derzeitig noch habe: Ich schicke Mails über /bin/mail mit dem Postfix. Wenn ich nun auf Sendmail umsteigen möchte muss dieser deinstalliert werden, was ich nicht kann da noch andere funktionen von dem Postfix abhängig sind. Wie kann ich PHP so umstricken das er den /bin/mail benutzt?

  4. Oliver sagt:

    Supi hat funktioniert.

  5. Oliver sagt:

    Zu früh gefreut. nur mit der Testmail hat es funktioniert. Nicht aber aus Nagios selbst. Trotz restart des Nagios Process.

  6. otto sagt:

    Probiere mal das Script als Nagios-User aufzurufen, evt. kommt dann eine aussagekräftigere Fehlermeldung:

    su -l -s /bin/sh NAGIOSUSER
    php nagios_mail.php

  7. Oliver sagt:

    CONTACTEMAIL env-var is empty (not run from Nagios?) or “mail_add_to_address” not configured (Testmode) unter dem Benutzer Nagios. Klar kein Mail empfänger drin. Ich habe aber mehere empfänger in den Contacts.

  8. otto sagt:

    Bitte nochmal mit einer Mailadresse in “mail_add_to_address” versuchen (als Nagios-User).

  9. Oliver sagt:

    Es scheint als übergäbe er nicht die Makros zum PHP Code.

  10. Fredrik sagt:

    Hi! Sorry for writing in english but my german is not that good unfortunatly. Thanks for a great script. I have some problems though. The test works brilliant but the real notifications wont work. I do not recive anything. My config file is command.cfg and not misccommands.cfg but I guess it does not matter. I also had to use command_name notify-service-by-email and notify-host-by-email (default) and not host-notify-by-email and notify-by-email as your config showed. Maybe I missed something?

  11. otto sagt:

    Hi,

    - make sure that in Nagios configuration the “enable_environment_macros=1″ setting is enabled.
    - check the nagios log-file while running passive check commands
    - test running the nagios_mail.php as the nagios user:

    su -l -s /bin/sh NAGIOSUSER
    php nagios_mail.php

  12. Fredrik sagt:

    Thanks for your super fast reply. Now it works great. Now I will just try to add the pnpgraphs in the mail as well.

  13. Stephan sagt:

    Hey,
    also ich bekomme das Script einfach nicht zum laufen.
    “enable_environment_macro” ist auf 1 gesetzt.
    Testmail klappt, sofern eine Mailadresse unter “mail_add_to_address” eingetragen ist. Lass ich die Mailadresse eingetragen, verschickt Nagios auch eine Testmail an die eingetragene Adresse. Nehme ich die Adresse wieder raus, kommt keine Mail an, Nagios meldet aber den Versand einer Mail. Im Sendmail-Log steht aber kein Eintrag.
    Auch mir kommt es vor als ob die Macros nicht übergeben werden.
    Achja, sendmail-path ist auch gesetzt.
    ???

  14. otto sagt:

    Hi,

    please check that the “variables_order” setting in php.ini contains an “E”, it should be something like variables_order = “EGPCS”. If the “E” is missing no Nagios-macros will be transfered to the PHP-Script.

    If someone is worried about performance or security issues: you could create a seperate php.ini (like php.ini_nagios) and specify it at the command definition in nagios:

    command_line /usr/bin/php -q -c /etc/php.ini_nagios /opt/nagios_mail.php

  15. Stephan sagt:

    Yeah, that looks good!
    Thanks for your help and the cool script :-)

  16. tesso sagt:

    Die in der Mail angezeigte Kontaktgruppe ist nicht die Kontaktgruppe des Servers. Ich habe noch nicht herausbekommen, welche er dort nimmt.

  17. Michael sagt:

    Hallo
    bekomme leider einen PHP Fehler: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in nagios_mail.php on line 548.
    Hat jemand eine hierzu eine Idee??

  18. otto sagt:

    Hi, ich tippe mal auf PHP4. PHP5 ist Voraussetzung…

  19. Michael sagt:

    schade ;( wäre zu schön gewesen…

  20. otto sagt:

    sollte jetzt auch unter PHP4 laufen…

  21. Luca sagt:

    Hallo, Skript funktioniert auf Anhieb, vielen Dank für die Arbeit!
    Wie kann ich einstellen, dass im Betreff der Mail zuerst der Hostname und danach der Service Typ angezeigt wird?

    Vielen Dank und Gruss

    Luca

  22. otto sagt:

    Hi,

    das geht derzeit nur, indem in Zeile 622 (Host) und 646 (Service) die jeweiligen Zeilen vertauscht werden. Bei Gelegenheit werde ich das mal komfortabeler gestalten…

  23. Luca sagt:

    Vielen Dank, hat funktioniert!
    Wie kann ich die Contact Details und Statistics ganz ausblenden?

    Danke und Gruss

    Luca

  24. otto sagt:

    Version 0.6: Das Subject kann jetzt in der Konfiguration geändert werden. Bei den Sektionen gibt es ab sofort auch einen Schalter “active” mit welchem z.B. die Kontakt-Details abgeschaltet werden können.

  25. Jakob sagt:

    Hallo Otto,
    ich komm nicht weiter. Mein Problem ist, dass der Nagios keine HTML-Mails versendet, die Testmail kommt aber an. Ich kann das Script als NagiosUser ausführen, in der php.ini hab ich den sendmailpfad und EGPCS eingetragen.
    Hast du noch einen Tipp fuer mich?

  26. Gerald sagt:

    Wie disabled man die einzelnen section genau ?

  27. otto sagt:

    In jedem Abschnitt der Konfiuguration gibt es einen Schalter “active” – dieser muss auf “false” gesetzt werden um eine Sektion (oder eine ganze Gruppe) zu deaktivieren. Alternativ ist es auch möglich, den Schalter “active” auf “HOST” oder “SERVICE” zu setzen, um den Abschnitt je nach Notification-Typ anzuzeigen.

  28. Marc sagt:

    Hallo, versuche es gerade in Groundwork Open Source zu integrieren und habe volgenden fehler:
    /usr/local/groundwork/php/bin -q usr/local/groundwork/php/lib/php/nagios_mail.php
    Error executing command (Permission denied)
    Bin kein Linux guru… hast du eine Idee ?
    Danke.

  29. otto sagt:

    schwer zu sagen. In der Pfadangabe nach dem “-q” fehlt ein “/” am Anfang.

  30. Marc sagt:

    Ich bin so blöd !!!
    /usr/local/groundwork/php/bin/php -q /usr/local/groundwork/php/lib/php/nagios_mail.php

    So gehts :-)

    Vielen Dank ! Super script !!!

  31. Jaap Lelie sagt:

    Hallo Otto, great script — Kudos to you! :-)
    I have the notifications running, but can’t seem to use the ‘Acknowledge this problem’ option. I suspect that this is due to the fact that the nagios environment (which sends out the emails) is runs as user ‘nagios’, and the recipients are not authenticated with this account as they click the link.

    Is this fix-able? Is there something I can do to enable these links?

    Thanks,
    Jaap.

  32. otto sagt:

    Hi Jaap,
    “Acknowledge this problem” is just a link to the right place at the webinterface. The authentication takes place in the interface. This is not fixable ;) . The only thing you can try is so specify username and password in your $config['nagios_url'] variable like this: “http://user:password@www.example.com/nagios”. But i would never recommend this! Otto

  33. Jaap Lelie sagt:

    Thanks Otto! Crystal clear.
    All the best — Jaap.

  34. [...] Extended Nagios Notification Mail ist jetzt für das iPhone optimiert. Bei der Gelegenheit habe ich mir gleich mal die entsprechenden [...]

  35. Jason sagt:

    Everything works great, thank you very much for the plugin!

    I followed another guide for Nagios and now have information put into a wikki page link that I have configured via the extended host or service template. Would it be possible to add a line somewhere in the nagios_mail.php notification to append information that is found in the extended field link to the email that is sent? This might be easier said then done, but thought it couldn’t hurt to ask.

  36. otto sagt:

    Hi Jason. Sorry i dont understand exactly what you mean. What field “link” do you mean? Is it a Nagios Config-Var? Pleace specify more details ;)

  37. Jason sagt:

    Well right now in the extended templates I have used the URL Notes field as ‘http://nagios.testbox.net/wikki/$HOSTNAME$’. We have been filling out that page with information such as primary contact, secondary contact, applications running on that server, etc. It would be great to have the information from that appended to end of the alert emails.

  38. deoli.de sagt:

    Sehr geehrter Herr Berger,

    das Skript ist absolut klasse und mit Hilfe des einen oder anderen Tipps aus den Kommentaren kam es einwandfrei zum Laufen, vielen Dank für das Bereitstellen dieser Lösung!

    Mit freundlichen Grüßen aus Rödermark,
    Oliver Köhl

    Dear Mr. Berger,

    thank you very much for this script by using the help out of the comments it works great. Thank you for sharing this solution with the community.

    Best regards from Roedermark (Germany),
    Oliver Koehl

  39. Thomas sagt:

    Thanks for your plugin, it really works great and makes nagios messages at lot more readable even on my mobile.
    One thing I can’t get to work is to show the host and service acknowledgment if I set “active” to “HOST” or “SERVICE”.
    It works fine for host and service notifies but when a service or host is acknowledges it doesn’t show the author and the comment of the person who acknowledged the problem. Any help would really be appreciated.

  40. Mecke sagt:

    Hi,
    Mail kommt schonmal schöner an, nur nich wie im screenshot mit so einem Roten Viereck bzw Grünen. der quelltext sagst: irgendwas mit “green” hab da mal den hex farbcode eingetragen hilft auch nix.
    bin aber auch kein php/html master also irgendeine idee?

    gruß Mecke

  41. otto sagt:

    Hi, das variiert je nach Benachrichtigung: “problems” sind rot, “recoverys” grün, “warnings” orange, “acknowledgements” blau. Welchen Mail-Client verwendest du denn?

  42. Mecke sagt:

    also wir verwenden outlook 2007, schuldige die späte antwort, habe den html code jetzt auch nochmal im Firefox angeschaut und da wird es richtig dargestellt also outlook2007 problem oder einstellungs sache.
    wenn ich gefunden habe wo es einzustellen ist sage ich nochmal bescheid

  43. Horst sagt:

    Hi!
    Just to extend the range I repost my prior post in english:
    I just won’t get this script to run on my server. In Testmode an email is send (as well via commandline as via nagios). But within the testmail there are no macros resolved. Is that normal? As soon as I remove the mail_add_to_address no emails are sent which leads me to the assumption that no macros are provided to the script by nagios. But the enable_environment_macros configuration is set to 1 and the standard printf notifications are working perfectly. Thanks in advance for any help!

  44. Horst sagt:

    Finally I was able to fix the problem and the problem had nothing to do with the script, just with my debian installation any my lag in php knowledge.

    For all debian user:
    Make sure you have the package “php5-cli” installed on your system. It’s the command-line interpreter for the php5 scripting language and without this package no php5-commandline-scripts will run. Hopefuly this information can prevent someone else from hours of debugging!
    Thanks again Otto for all your help!

  45. Daniel sagt:

    Hallo Otto,

    ich habe die Notification per Mail super einfach zum laufen bekommen und finde es sieht echt gut aus. Hast du einen Tipp für mich, warum die Statistik-Sektion nicht ausgegeben wird? Die Rubriken in der Config sind alle aktiviert (true).

    Viele Grüße
    Daniel

  46. otto sagt:

    Evt. werden die Variablen nicht von Nagios übergeben… Schalte mal den debug-modus ein – im Text-Body der Mail sollten dann alle Variablen auftauchen. Gruß Otto.

  47. Daniel sagt:

    Hallo Otto,

    den Debug-Modus hab ich eingeschaltet, jedoch sehe ich die Variablen nicht in der Mail. Mal davon ausgehend, dass Nagios diese Daten nicht übergibt, wie kann ich Nagios dazu bringenm, es doch zu tun?

    Viele Grüße
    Daniel

  48. otto sagt:

    Die Debug-Ausgabe ist nur in der Text-Variante der Mail sichtbar (nicht HTML). Ansonsten in den Quelltext der Mail schauen… Welche Nagios Version?

  49. Daniel sagt:

    Hallo Otto,

    ich nutze Nagios® 3.0.6 mit der Groundwork-Oberfläche. Im Quelltext der Mail ist leider nichts zu erkennen. Hilft es dir, wenn ich Auszüge der Mail hier poste?

    Viele Grüße
    Daniel

  50. Jonas sagt:

    Hi Otto, erstma vielen Dank für dein super php script, ich hab mich lange mit dem normalen notifications rumgeschlagen und nichts hat geklappt. nun hab ich in 2 minuten dein php script installiert und hab auch erfolgreich die Test-Mail bekommen, nun aber weiss ich nicht recht wie weiter? in meiner Testmail steht z.b
    Hostname — HOSTNAME
    Alias –HOSTALIAS

    muss ich noch weitere konfigurationen machen z.b in contacts.cfg oder so damit er mir service fehler sendet?

    sry das ist alles neuland für mich bitte um verständniss.

    Cheers

  51. otto sagt:

    Sorry, dann würde ich erstmal checken, warum die normale Notification nicht funktioniert. Etwas einlesen in die Nagios-Konfiguration kann ich dir wohl keiner ersparen… ;) Gruß Otto

  52. Jonas sagt:

    Hi Otto, ich hab mal den debug modus eingeschaltet und hier ein Auszug aus dem Log.

    [1255422647] Warning: Attempting to execute the command “/usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $PROBLEM$\n\nService: HD – C:\ System\nHost: $vialissrv03$\nAddress: 192.168.0.27\nState: WARNING\n\nDate/Time: Tue Oct 13 09:00:47 CEST 2009\n\nAdditional Info:\n\nC:\ – total: 19.99 Gb – used: 15.99 Gb (80%) – free 4.00 Gb (20%)” | /bin/mail -s “** $PROBLEM$ Service Alert: $vialissrv03$/HD – C:\ System is WARNING **” jonas.korteweg@vialis.ch” resulted in a return code of 127. Make sure the script or binary you are trying to execute actually exists…
    [1255422807] SERVICE ALERT: server23.rph.local;Memory Usage;OK;HARD;3;Memory usage: total:4192.58 Mb – used: 3210.33 Mb (77%) – free: 982.25 Mb (23%)

    muss ich evtl. den /usr/bin/printf umleiten zu irgendeinem anderen ort?

    köntnest du mir bitte weiterhelfen? Tausend Dank

  53. Jonas sagt:

    Ok, ich habs gelöst. Danke totzdem für die Hilfe und vielen Dank für dein super script!!

  54. Sabrina sagt:

    Hi Jonas,

    ich hab genau das selbe Problem das bei mir
    Hostname — HOSTNAME
    Alias –HOSTALIAS
    drinsteht.
    Wie hast du das gelöst ?

    Grüße Sabrina

  55. otto sagt:

    Hi, das mit Hostname — HOSTNAME ist der Testmodus. Im Testmodus wird einfach jeder wert mit dem Namen der Nagios-Variable gefüllt. Wenn das Script dann von Nagios ausgeführt wird, füllen sich diese Variablen mit den realen Werten. Soweit also durchaus normal im Testmodus. Der Testmodus ist eigentlich nur dafür da um zu checken ob überhaupt vom System die Mail verschickt werden kann.

  56. Sabrina sagt:

    Problem ist wenn das von Nagios ausgeführt wird, ist das genau so.
    Die Mail sieht genauso wie die Testmail aus, weis echt nicht wo ich da den Fehler hab.

    Danke dir schonmal Otto.

  57. Sabrina sagt:

    Hat sich erledigt. Ich hätte nur von Anfang an die richtige Datei bearbeiten sollen :)

    Vielen Dank für das tolle Script!

  58. Gerald sagt:

    Hi !

    Ist es möglich outlook high priority mails zu versenden ? Welche schalter benötigt ich im script ?
    Danke

  59. otto sagt:

    Hi, z.Zt. noch nicht möglich, aber schau doch in ein paar Tagen nochmal vorbei… Otto

  60. Pier sagt:

    Hi. I’m using your email mod and i find it very useful.
    I modified (actually a friend of mine) your version adding a custom field because i need to report some custom infos based on host o service condition. For example if the notification is for a down of a host, then i add some text. If the host is in recovery, then i add some other text. Could you implement this in your original script? I can send you mine to copy from that.
    Thank you

  61. otto sagt:

    your welcome to send me your additions. i will see if i can include them. (you will find the address at the top of the script.) Otto

  62. Terje sagt:

    Problems with Outlook 2007. The HTML page is not correctly formated on Outlook 2007, no color notification..etc..

  63. otto sagt:

    Hi, sorry i can not look at this at the moment (don’t have 2007). I tested it successfull with outlook 2003. Are you sure you dont have “simple html” or something like that enabled? Otto

  64. Terje sagt:

    Hi, Otto..
    Your E-mail addition to nagios works very well with Outlook 2003. My company is upgrading to Outlook 2007, and for some reason the formatting on the mailpage is all wrong.

    All information is now located on the very left side of the mail so you have to scroll to the bottom of the page to get all information. No color buttons are displayed. If you forward a mail in Outlook 2003 this is similar; all info is pressed on the very left side of the mail page.

    I have tried to play around with the different settings in Outlook 2007, but so far no luck :( If you google HTML and Outlook 2007 you see there are several issues here..

    /terje

  65. Terje sagt:

    Here is a tool for validating HTML pages in Outlook 2007 (for developers)

    http://msdn.microsoft.com/en-us/library/aa338200.aspx

  66. otto sagt:

    Thanks! I added Outlook 2007 compatibility right now – goodbye clean html-layout ;)

  67. [...] mit der Ironie. Wieso ich jetzt erst darauf komme? Ein Nutzer der Nagios Notification Mail hat mich darauf gebracht, dass diese nicht korrekt mit Outlook 2007 dargestellt wird. Kann gar [...]

  68. Terje sagt:

    Hi, Otto..
    It works..!! The HTML code is now displayed correctly in Outlook 2007 (and 2003) Thanks ! :)

  69. Thomas sagt:

    Hi Otto,

    thanks for the script! I used it with nagios for some time now without problems.
    I switched to ICINGA (the nagios fork) and tried to make it work again. I am stuck with the following error:
    (su’ed to ICINGAUSER)
    # php -q nagios_mail.php
    PHP Notice: Undefined index: mail_add_to_address in /usr/local/icinga/bin/nagios_mail.php on line 696

    CONTACTEMAIL env-var is empty (not run from Nagios?) or ‘mail_add_to_address’ not configured (Testmode)

    So where do I need to look at? Is it an problem due to icinga? I have openSuse 11.2 on 64 bit and have enabled the EGPCS variables_order in the php.ini.

    Thomas

  70. Otto sagt:

    Hi,

    sorry i actually dont tested with ICINGA (and i think i dont get the chance to do so in the next weeks). But it seems that the ENV-Vars are not available to the mail-script – or maybe they are spelled different? Did you tried the debug-mode of the script?

    Otto

  71. CarstenH sagt:

    Hallo,

    eine vielleicht blöde Frage, aber wenn ich in Nagios
    “Send custom host notification”
    ausführe, bekomme ich auch die E-Mail im HTML-Format, aber
    der Kommentar wird nicht mitgeschickt. Läßt sich der noch
    irgendwo aktivieren?

    Gruß,
    Carsten

  72. otto sagt:

    Stimmt, der Kommentar wird nirgendwo ausgegeben (hab die Funktion noch nie benutzt). Die Variable heißt “NOTIFICATIONCOMMENT”. Du könntest einfach einen neuen Abschnitt einfügen. z.B. unter Host-Output (ca. Zeile 247):

    array(
    ‘name’ => false,
    ‘nagios_env’ => ‘HOSTOUTPUT’,
    ‘required’ => false,
    ),
    array(
    ‘name’ => “Comment”,
    ‘nagios_env’ => ‘NOTIFICATIONCOMMENT’,
    ‘required’ => false,
    ),

  73. CarstenH sagt:

    Danke.

  74. Fabian G sagt:

    Habe heute auch die Benachrichtigung integriert in Nagios 3.2.0. Funktioniert hervoragend. Für meinen Geschmack etwas zu viel Infos, aber man kann die Sektionen die man nicht will in der nagios_mail.php einfach auskommentieren.
    Jetzt hab ich aber noch eine Frage. Würde gerne die Links ändern, Bei Host Information würde ich gerne, wenn ich auf die Addresse klicke, auf die Nagiosseite des Hosts kommen. Außerdem würde ich gerne unter Service Details wenn ich auf den Service klicke, gleich zu Nagios und dem Service wechseln. Kannst du mir einen hint geben wie ich das bewerkstelligen kann?
    Danke

  75. Ted sagt:

    Das Skript ist wunderbar und wir würden es gerne nutzen,
    nur müssen wir feststellen was uns eigentlich hätte klar sein können das es nicht mit dem SystemMonitoring Plugin für OTRS 2.4 zusammen harmoniert. Das liegt wohl offensichtlich an den RegEX und den Subjects, also mit etwas “reenginiering” sollte es aber durchaus klappen. Danke nochmals

  76. hec sagt:

    hallo,
    habe das script jetzt auch bei mir laufen.
    Bei SLES OS gibt es wohl zu beachten das es 2 PHP.inis gibt. Für PHP5-CLI und PHP5 Apache:

    /etc/php5/cli/php.ini
    /etc/php5/apache2/php.ini

    Wichtig ist vor allen, das die EGPCS Option.

    Ansonsten ist das Script ein solides Grundgerüst um seine Notifications zu customizen… Danke dafür!

  77. vtm sagt:

    great script !!! :)

  78. [...] ich langsam genug. Deshalb habe ich mich nach einer anderen Lösung umgesehen und habe mit “Nagios Extended Notification Mail” von Otto Berger eine super Alternative [...]

  79. IRO sagt:

    Hello

    I found this script very useful. Thank you!

    Just to let you know there is a typo at line 301:
    ‘name’ => ‘Servive details’ :)

    IRO

  80. Chris sagt:

    Hallo Otto,

    finde dein script total super. Allerdings funktioniert es bei mir überhaupt nicht so wie es soll. Es scheitert schon an der Testmail. Ich bin jetzt auch nicht so der Linuxspezialist. Das komische ist, wenn ich die Testmail versende, kommt sie beim ersten Versuch an. Will ich noch eine weitere versenden passiert nichts mehr. Sobald ich die nagios_mail.php allerdings verändere und speicher, sendet er automatisch wieder eine Testmail raus.

    In der php.ini habe ich “sendmail_path = /usr/sbin/sendmail -t -i” gesetzt und die variables order stimmt auch. Wie genau läuft das denn ab, aus der nagios_mail.php wird die E-Mail generiert und dann per sendmail (Postfix) versendet?

    Hast du vielleicht eine Idee wodran das liegen könnte? Oder irgendwo was in logs geschrieben, dass ich den Fehler näher eingrenzen kann? Produktiv habe ich das ganze bis jetzt noch nicht getestet, nur die Testmails.

    Achso und noch was, bei mir gibts es in /usr/bin/ einmal ‘php’ und einmal ‘php5′ , ist es egal welches es verwende? Hab es mit beiden versucht, aber wie gesagt nach der ersten Testmail geht keine weitere Testmail mehr raus.

    MfG
    chris

  81. otto sagt:

    Sorry, mir fällt dazu nicht viel ein. Grundsätzlich würde ich mich erstmal darum kümmern das die Testmail zuverlässig versendet wird. PHP generiert die Mail und versendet diese dann über das eingestellte sendmail-kommando. Meist ist das dann ein Wrapper auf das jeweilige Tool des Mailservers. Wie das genau bei Postfix ist weiß ich nicht aber ich gehe davon aus, dass es mit der Standardeinstellung funktionieren sollte. Warum es nur beim ersten Mal funktioniert kann ich dir nicht sagen ;)

  82. tedtester sagt:

    Ok also wir haben das Script eingesetzt und jetzt musste wieder leider feststellen, das aber einer gewissen Größenordnung an Services/Hosts bzw. ab einer Menge Mails es dazu kommt das ein Nagios Prozess sich so verabschiedet, das komplette Nagios Systeme hängen, nichts mehr wird executed. Auch mit enable large_installtion_tweaks um die Prozessverwaltung vom OS übernehmen zu lassen, brachte leider keine Besserung. Nutzen nun leider wieder standard. “mailx”, “mail” – Trotzdem genial das Script. Aber wir vermuten der zusätzliche PHP Gewerkel macht dann doch nochmals Performance aus.

  83. tedtester sagt:

    Kommando zurück, das Problem ist viel Komplexer.
    Irgendwas in Verbindung mit localtime() in Verbindung mit environment_macros, glibc usw. Hängt Nagios weg. Das Problem gab es schon in älteren nagiosversionen also auch in 3.2.1 und tritt vermehrt auf in Verbindung mit Livestatus.

  84. tontonitch sagt:

    For Icinga, the environment variable names are different.
    To retrieve correctly the variable in the script, the following change must be done at line 643 (v0.9):

    if (strpos($key, ‘NAGIOS_’) !== false) {
    to
    if (strpos($key, ‘ICINGA_’) !== false) {

    Yannick

  85. tino sagt:

    Hi Otto,
    ich habe leider immernoch das Problem, dass die Mails nur im Test-Modus ankommen und keine brauchbaren Infos enthalten.
    Tortzdem ein echt super Script!!!
    Wenn jetzt das noch funktioniert, ist das eine wunderbare alternative.

    Tino

  86. Heiko sagt:

    Hallo Otto,

    kann es sein das Dein Script nur unter Nagios 3.x arbeitet ?
    Ich bekomme Ihn unter Nagios 2.5 (SuSE SLES9) nicht zum Fliegen.

    Gruss Heiko

  87. otto sagt:

    Hi, funktioniert denn der Testmodus unter SLES9?

  88. Joe Precious sagt:

    Hi

    Back in English I’m afraid!

    I’ve installed the scripts and the test works fine, but I get nothing at all from Nagios. I’ve confirmed that environment macros are enabled and tested as the nagios user which is fine. The Nagios logs show a notification being sent, but I get nothing.

    Not really sure where to look next to try and troubleshoot.

    Thanks

    Joe

  89. Bo sagt:

    Hi,

    when I try to send the test email I get the following error message:
    /usr/bin/php -q /opt/nagios_mail.php

    Could not open input file: /opt/nagios_mail.php

    does anyone know what is wrong?
    Please help.
    Thanks in advance.

  90. Bo sagt:

    Hi,

    I reinstalled my system and configured postfix (before it was exim4)
    I had also to change “variables_order” to “EGPCS” in php.ini.
    Everything works fine. Great script.
    Thank you

  91. pat sagt:

    Hi Otto,
    geniales script.
    Leider wird bei den (service notification) der Betreff z.T viel zu lange > 300 Zeichen. Wie kann ich nur den Betreff kürzen, damit dieser auch in Outlook 2007 angezeigt wird? habe mit substr rumprobiert, leider ohne Erfolg.
    Besten Dank

  92. pat sagt:

    Hi Otto,

    möchte noch anfügen, das ich im Betreff natürlich den “%%SERVICEOUTPUT%%” auch mit anzeigen möchte. Ist dieser zu lang >160 Zeichen, sollte er auf 160 Zeichen gekürzt werden. In der Beschreibung soll die volle Länge ersichtlich bleiben.

Antwort hinterlassen