Sunday, May 22nd 2011, 8:35pm UTC+2

You are not logged in.

Wer stiehlt meine '&''?

Steph

Trainee

Posts: 74

Number of Nagios server: 2

Nagios Versions: 3.2.0

Distributed monitoring: Nein

Redundant monitoring: Nein

Number of hosts: > 500

Number of services: > 20

OS: Solaris

Plugin Versions: ?

NDO Version: 2

1

Friday, May 20th 2011, 8:47am

Wer stiehlt meine '&''?

Ich verstehe es nicht!

Ich habe ein notification plugin geschrieben das, von Kommandozeile aufgerufen, einwandfrei funktioniert.

Auch wenn es von Nagios aus aufgerufen wird, arbeitet es meistens korrekt, nur wenn die übergebene SERVICENOTESURL das Zeichen '&' enthält, geht es schief.

Normal sieht die URL so aus (Beispiel): http://my.doc.host/path/to/doc?host=a_host&service=a_service

Daraus macht Nagios aber, und es ist verifiziert, daß das Plugin es genau so erhält http://my.doc.host/path/to/doc?host=a_hostservice=a_service

Es schmeißt also einfach das '&' heraus.

So sieht die command.cfg aus

Quellcode

1
2
3
4
5
6
7
8
9
10
11
define command {
        command_name   service-notify
        command_line   $USER1$/notify \
                       --state       '$SERVICESTATE$' \
                       --service     '$SERVICEDESC$' \
                       --ntype       '$NOTIFICATIONTYPE$' \
                       --hostname    '$HOSTADDRESS$' \
                       --output      '$SERVICEOUTPUT$' \
                       --longoutput  '$LONGSERVICEOUTPUT$' \
                       --notesurl    '$SERVICENOTESURL$'
}


Fragen:
1) Bug oder Feature?
2) Irgendein Workaround möglich?

Wolfgang

Sage

Posts: 5,329

Gender: male

Number of Nagios server: 2

Nagios Versions: 3.2.1

Icinga-Version(en): Icinga 1.0.1

Distributed monitoring: Nein

Redundant monitoring: Nein

Number of hosts: >70

Number of services: >200

OS: SLES10

Plugin Versions: 1.4.11

Other Addons: NRPE 2.6, NSCA 2.7, PNP 0.4.14 / 0.6

2

Friday, May 20th 2011, 8:53am

Zitat

1) Bug oder Feature?
Feature
Nagios-Doc: Wiki-Format (3.x) oder als (3.0.6)

Icinga-Doc: (de) (en)

PNP-Troubleshooting (de) (en)

Steph

Trainee

Posts: 74

Number of Nagios server: 2

Nagios Versions: 3.2.0

Distributed monitoring: Nein

Redundant monitoring: Nein

Number of hosts: > 500

Number of services: > 20

OS: Solaris

Plugin Versions: ?

NDO Version: 2

3

Friday, May 20th 2011, 9:18am

Zitat von »Wolfgang«

Feature

Trifft es leider nicht. Das verlinkte bezieht sich nicht auf SERVICENOTESURL und nur um die geht es mir.

Nachtrag: Trifft es DOCH, denn ich habe probeweise das '&' entfernt und schon erscheint es :-(

Mist! Meiner Meinung nach aber ein bug. Zumindest in der Doku, oder?

This post has been edited 1 times, last edit by "Steph" (May 20th 2011, 9:56am)


dnsmichi

Master

Posts: 2,102

Birthday: May 30th 1983 (27)

Gender: male

Location: Wien

Occupation: DNS & Monitoring Developer

Number of Nagios server: 3x Icinga prod, 2x test/dev

Nagios Versions: s/nagios/icinga/

Icinga-Version(en): 1.4.0 / GIT

Distributed monitoring: Ja

Redundant monitoring: Ja

Number of hosts: 1000+

Number of services: 15000+

OS: RHEL 5.6 x64

Plugin Versions: 1.4.15

IDO-Version: 1.4.0 / GIT MySQL/Postgresql/Oracle

Other Addons: PNP 0.6.11, check_mk GIT

4

Friday, May 20th 2011, 10:04am

Zitat von »Steph«

Nachtrag: Trifft es DOCH, denn ich habe probeweise das '&' entfernt und schon erscheint es :-(


wo hast du das entfernt? im macro output oder in der nagios.cfg?

Zitat von »Steph«

Mist! Meiner Meinung nach aber ein bug. Zumindest in der Doku, oder?


wieso? steht doch eh genau da, dass '&' entfernt wird in macros, was bei dir ja auch der fall ist. wenn du das nicht haben moechtest, musst du die config anpassen.
Icinga 1.4 MySQL,PGSQL,Oracle and IPv6

Demos

Docs http://docs.icinga.org
Wiki https://wiki.icinga.org

Dev Tracker https://dev.icinga.org

* egrep -v "^#|^$" configfile

Join us online!
irc.freenode.net #icinga-devel

Using Icinga? Tell us!

Steph

Trainee

Posts: 74

Number of Nagios server: 2

Nagios Versions: 3.2.0

Distributed monitoring: Nein

Redundant monitoring: Nein

Number of hosts: > 500

Number of services: > 20

OS: Solaris

Plugin Versions: ?

NDO Version: 2

5

Friday, May 20th 2011, 10:30am

Zitat von »dnsmichi«

wo hast du das entfernt? im macro output oder in der nagios.cfg?

nagios.cfg. Danach erscheint es bei Aufruf des notify plugins.

Zitat von »dnsmichi«

wieso? steht doch eh genau da, dass '&' entfernt wird in macros, was bei dir ja auch der fall ist. wenn du das nicht haben moechtest, musst du die config anpassen.

Steht da eben nicht. Dort steht:

Zitat

This option allows you to specify illegal characters that should be stripped from macros before being used in notifications, event handlers, and other commands. This DOES NOT affect macros used in service or host check commands. You can choose to not strip out the characters shown in the example above, but I recommend you do not do this. Some of these characters are interpreted by the shell (i.e. the backtick) and can lead to security problems. The following macros are stripped of the characters you specify:

$HOSTOUTPUT$, $HOSTPERFDATA$, $HOSTACKAUTHOR$, $HOSTACKCOMMENT$, $SERVICEOUTPUT$, $SERVICEPERFDATA$, $SERVICEACKAUTHOR$, and $SERVICEACKCOMMENT$


Und bei den Macros ist eben nicht $SERVICENOTESURL$ aufgeführt.

bern

Professional

Posts: 1,406

Number of Nagios server: 2-5

Nagios Versions: 1-3

Distributed monitoring: Nein

Redundant monitoring: Nein

Number of hosts: 80-200

Number of services: 1400-2000

OS: Linux

Plugin Versions: Whatever I can download, patch, or cobble together myself :-)

Other Addons: n2rrd, PNP, livestatus

6

Friday, May 20th 2011, 2:15pm

Zitat von »Steph«

Trifft es leider nicht. Das verlinkte bezieht sich nicht auf SERVICENOTESURL und nur um die geht es mir.
Nachtrag: Trifft es DOCH, denn ich habe probeweise das '&' entfernt und schon erscheint es :-(
Mist! Meiner Meinung nach aber ein bug. Zumindest in der Doku, oder?
Ist es und es ist IMHO auch den relevanten Leuten bekannt, daß die Macro Sanitization ziemlich wild 'rumagiert, wo sie offiziell nicht hingehört. :|

Hab' selbst 'mal auf den Code geguckt und den Eindruck gewonnen, daß man die Logik in größerem Umfang umstellen müßte, um die korrekte (:= dokumentierte) Unterscheidung hinzukriegen ...

dnsmichi

Master

Posts: 2,102

Birthday: May 30th 1983 (27)

Gender: male

Location: Wien

Occupation: DNS & Monitoring Developer

Number of Nagios server: 3x Icinga prod, 2x test/dev

Nagios Versions: s/nagios/icinga/

Icinga-Version(en): 1.4.0 / GIT

Distributed monitoring: Ja

Redundant monitoring: Ja

Number of hosts: 1000+

Number of services: 15000+

OS: RHEL 5.6 x64

Plugin Versions: 1.4.15

IDO-Version: 1.4.0 / GIT MySQL/Postgresql/Oracle

Other Addons: PNP 0.6.11, check_mk GIT

7

Friday, May 20th 2011, 5:10pm

man koennte rumraten beginnen, wie alt jede common/macros.c ist und wie sich das dann auf die clean options auswirkt. STRIP_ILLEGAL_MACRO_CHARS wird nur dann gesetzt bzw prozessiert, wenn sichs um folgendes handelt im latest nagios head.

Quellcode

1
2
3
4
5
                        /* host/service output/perfdata and author/comment macros should get cleaned */
                        if((x>=16 && x<=19) ||(x>=49 && x<=52) || (x>=99 && x<=100) || (x>=124 && x<=127)){
                                *clean_options|=(STRIP_ILLEGAL_MACRO_CHARS|ESCAPE_MACRO_CHARS);
                                log_debug_info(DEBUGL_MACROS,2,"  New clean options: %d\n",*clean_options);
                                }


macht man sich noch die include/macros.h dazu auf, und tut zahlen vergleichen. bzw sucht nach der SERVICENOTESURL

Quellcode

1
#define MACRO_SERVICENOTESURL                   78


kann man davon ausgehen, dass der aktuelle nagios code das nicht cleanen wird. wos allerdings dann doch reingreift, ist die mit git blame 5ba058d7 (Ethan Galstad 2008-02-10 17:19:24 +0000 449) hinzugekommene /* url macros should get cleaned */
da faellt auch SERVICENOTESURL hinein. get_url_encoded_string ist das zauberwort hierzu wo dann allerdings ebenfalls '&' durchgereicht wird.

also ich wuerds grundsaetzlich mal an einer alten nagios version festmachen, wo das noch nicht gefixed wurde.
Icinga 1.4 MySQL,PGSQL,Oracle and IPv6

Demos

Docs http://docs.icinga.org
Wiki https://wiki.icinga.org

Dev Tracker https://dev.icinga.org

* egrep -v "^#|^$" configfile

Join us online!
irc.freenode.net #icinga-devel

Using Icinga? Tell us!

Similar threads