unexpected end of file

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

unexpected end of file

Post by WillemDH »

Trying to monitor a rather long URL again, but having some escaping issues again. Already tried to make a macro for '&', but it doesn't seem enough... I was wondering what other characters need escaping..

IN CLI everything works fine:

Code: Select all

/usr/local/nagios/libexec/check_http -H stad.gent -u '/sparql?default-graph-uri=&query=prefix+schema:+%3Chttp://schema.org/%3E%0D%0AASK+%7B%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?id+=+%22%22)%0D%0A%7D%0D%0AUNION+%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?type+=+%22%22)%0D%0A%7D%0D%0A%7D&format=text/html&timeout=0&debug=on' -S -s 'false' HTTP OK: HTTP/1.1 200 OK - 298 bytes in 0.021 second response time |time=0.021460s;;;0.000000 size=298B;;;0
In Nagios XI I tried many combination, single, double quotes, $USER10$=& in resources.cfg...

Code: Select all

-u "/sparql?default-graph-uri=$User10$query=prefix+schema:+%3Chttp://schema.org/%3E%0D%0AASK+%7B%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?id+=+%22%22)%0D%0A%7D%0D%0AUNION+%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?type+=+%22%22)%0D%0A%7D%0D%0A%7D$User10$format=text/html$User10$timeout=0$User10$debug=on" -S -s 'false'
What other characters need escaping in service arguments?

Code: Select all

-u "/sparql?default-graph-uri=&query=prefix+schema:+%3Chttp://schema.org/%3E%0D%0AASK+%7B%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?id+=+%22%22)%0D%0A%7D%0D%0AUNION+%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?type+=+%22%22)%0D%0A%7D%0D%0A%7D&format=text/html&timeout=0&debug=on" -S -s 'false'
The host is 'stad.gent' and externally availble if someone would like to give it a try... Thanks!!

EDIT: Went very crazy and tried escaping lots of stuff, but still having the same issue...

Code: Select all

-u '/sparql$USER11$default-graph-uri=$User10$query=prefix$USER14$schema:$USER14$%3Chttp://schema.org/%3E%0D%0AASK$USER14$%7B%0D%0A%7B%0D%0A$USER11$loc$USER14$%3Chttp://stad.gent/data/internal/resourceId%3E$USER14$$USER11$id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E$USER14$$USER11$type.%0D%0A%0D%0AFILTER$USER14$$USER12$$USER11$id$USER14$=$USER14$%22%22$USER13$%0D%0A%7D%0D%0AUNION$USER14$%0D%0A%7B%0D%0A$USER11$loc$USER14$%3Chttp://stad.gent/data/internal/resourceId%3E$USER14$$USER11$id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E$USER14$$USER11$type.%0D%0A%0D%0AFILTER$USER14$$USER12$$USER11$type$USER14$=$USER14$%22%22$USER13$%0D%0A%7D%0D%0A%7D$User10$format=text/html$User10$timeout=0$User10$debug=on' -S -s 'false'
reource.cfg:

Code: Select all

$USER10$=&
$USER11$=?
$USER12$=(
$USER13$=)
$USER14$=+
Same question as in https://support.nagios.com/forum/viewto ... +ampersand.. Why is this so hard? I would like to make a feature request to make it easier to monitor things with special chars in..
Nagios XI 5.8.1
https://outsideit.net
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: unexpected end of file

Post by tmcdonald »

Are you using the Test Check Command button in the CCM, or are you saving the check and letting it run? The results between the two may differ, and the Test Check Command button is not always accurate.
Former Nagios employee
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: unexpected end of file

Post by WillemDH »

Trevor, please. I was hoping you know I already know that. :) No Im not using this test button. Eof Result is in XI..
Nagios XI 5.8.1
https://outsideit.net
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: unexpected end of file

Post by tgriep »

That is strange. I setup a service check like below.

Code: Select all

define service {
	host_name			stad.gent
	service_description		stad.gent http
	use				generic-service
	display_name			stad.gent http
	check_command			check-host-alive-http! -u '/sparql?default-graph-uri=&query=prefix+schema:+%3Chttp://schema.org/%3E%0D%0AASK+%7B%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?id+=+%22%22)%0D%0A%7D%0D%0AUNION+%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?type+=+%22%22)%0D%0A%7D%0D%0A%7D&format=text/html&timeout=0&debug=on' -S -s 'false'!!!!!!!
	register			1
	}	
When I ran it, I received an OK status.

Code: Select all

HTTP OK: HTTP/1.0 302 Found - 105 bytes in 5.421 second response time
I copied exactly what you posted in the first code block that uses the single quote.
Maybe your check_http command is defined differently.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: unexpected end of file

Post by WillemDH »

What version of heck_http are you using? I have:

Code: Select all

/usr/local/nagios/libexec/check_http -V
check_http v2.0.3.85.gb94a (nagios-plugins 2.0.3)
This is my service definition:

Code: Select all

define service {
        host_name                       stad.gent
        service_description             URL_Content_LOD
        use                             dig-web-app-content-prio2
        servicegroups                   +all_svc_web_url_intern
        check_command                   check_xi_service_http!-u '/sparql?default-graph-uri=&query=prefix+schema:+%3Chttp://schema.org/%3E%0D%0AASK+%7B%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?id+=+%22%22)%0D%0A%7D%0D%0AUNION+%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?type+=+%22%22)%0D%0A%7D%0D%0A%7D&format=text/html&timeout=0&debug=on' -S -s 'false'!!!!!!!
        check_period                    xi_timeperiod_24x7
        notification_period             xi_timeperiod_24x7
        contacts                        +nagiosadmin
        contact_groups                  +cg_domein_web,cg_dummy
        _xiwizard                       websiteurl
        register                        1
        }

Code: Select all

/sparql?default-graph-uri=&query=prefix+schema:+%3Chttp://schema.org/%3E%0D%0AASK+%7B%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?id+=+%22%22)%0D%0A%7D%0D%0AUNION+%0D%0A%7B%0D%0A?loc+%3Chttp://stad.gent/data/internal/resourceId%3E+?id;%0D%0A%3Chttp://stad.gent/data/internal/resourceType%3E+?type.%0D%0A%0D%0AFILTER+(?type+=+%22%22)%0D%0A%7D%0D%0A%7D&format=text/html&timeout=0&debug=on
is exactly the same. The command check-host-alive-http has no $ARG1$. Can you check this? Is it possible it works for you becasue it just check stad.gent without $ARG1$? Could you check with 'check_xi_service_http' command please?
You do not have the required permissions to view the files attached to this post.
Nagios XI 5.8.1
https://outsideit.net
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: unexpected end of file

Post by tgriep »

Sorry, My command was messed up and was giving me false positives. I tried as many combinations of escaping that I could and still haven't found one that worked.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: unexpected end of file

Post by tgriep »

I finally got it to work.

I created an entry in the resource.cfg file like this.

Code: Select all

$USER9$='/sparql?default-graph-uri=&query=prefix+schema:+<http://schema.org/>%0D%0AASK+{%0D%0A{%0D%0A?loc+<http://stad.gent/data/internal/resourceId>+?id;%0D%0A<http://stad.gent/data/internal/resourceType>+?type.%0D%0A%0D%0AFILTER+(?id+=+"")%0D%0A}%0D%0AUNION+%0D%0A{%0D%0A?loc+<http://stad.gent/data/internal/resourceId>+?id;%0D%0A<http://stad.gent/data/internal/resourceType>+?type.%0D%0A%0D%0AFILTER+(?type+=+"")%0D%0A}%0D%0A}&format=text/html&timeout=0&debug=on'
Then I defined the command to use the $USER9$ like below.

Code: Select all

 check_http Hostaddress!-u $USER9$ -S -s 'false'
Try that out and let us know if it works.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: unexpected end of file

Post by WillemDH »

Thought about that but didn't have the chance to test. I'll try that tomorrow.

As we are adding web applications in an automated way, I will need to adjust our scripts so that if the URL contains a special char, a macro needs to be created. Could I also get a list of all characters which won't work in XI arguments..

It's hard to believe for me that there is no way to prevent all these escaping issues. In normal circumstances using single quotes around a string should mean that no escaping is necessary. Please make a high priority feature request to implement a way to make all character work when between single quotes? Or is this really technically impossible?

Grtz
Nagios XI 5.8.1
https://outsideit.net
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: unexpected end of file

Post by tgriep »

Here is the list characters that have to be escaped.
`~$&|'"<>

Escaping the characters is needed for Core so it can build the command correctly for it to run.

Edit:
Located in nagios.cfg:
illegal_macro_output_chars=`~$&|'"<>

If this gets changed it will give you a lot of problems, but this is where they are being set.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: unexpected end of file

Post by WillemDH »

So is it me or is the only to-be-escaped 'special' char in my url an &. As I made a macro $USER10$ for that and replaced the & with $USER10$ why wasn't that working? (I'll try again tomorrow to double-check-verify this statement.) Or did you also try test it with a macro which only replaced &?
Another question => Can the macros in resource.cf be named whatever or do thay always have to be named $USERXX$?
Nagios XI 5.8.1
https://outsideit.net
Locked