Page 1 of 1

check_http_content

Posted: Thu Jun 24, 2021 9:51 am
by s.diwakar1
Hi All,

I am using check_http_content script to monitor my URL Content.

Getting below output while executing below command manually:

Command:

Code: Select all

./check_http_content -U https://xxx -m {"version":"1.0","status":"SUCCESS"}
Output:

Code: Select all

CONTENT ERROR: EXPR NOT FOUND (last: {"version":"1.0","status":"SUCCESS"})
full output was:
{"version":"1.0","status":"SUCCESS"}
I am passing same content as shown in URL. But still it is giving error.

Can anyone help me in this please?

Thanks in advance!

Re: check_http_content

Posted: Thu Jun 24, 2021 5:26 pm
by benjaminsmith
Hi @s.diwakar1,

Looking over the plugin it does a simple Perl regex match against the URL vs the matching argument. Since this is a complex string, try wrapping the matching string in single quotes and escape any special characters.

For example, the plugin page on the Nagios Exchange contains this following string.
my @output_lines = split(/
This does not work.

Code: Select all

[root@localhost libexec]# ./check_http_content -U https://exchange.nagios.org/directory/Plugins/Websites,-Forms-and-Transactions/check_http_content/details  -m 'my @output_lines = split(/'
Unmatched ( in regex; marked by <-- HERE in m/my @output_lines = split( <-- HERE // at ./check_http_content line 66.
[root@localhost libexec]#
However, escaping the forward slash corrects the issue.

Code: Select all

[root@localhost libexec]# ./check_http_content -U https://exchange.nagios.org/directory/Plugins/Websites,-Forms-and-Transactions/check_http_content/details  -m 'my @output_lines = split\(/'
CONTENT OK: EXPR FOUND[root@localhost libexec]#
Let us know if you get it working and post the full check command if it's failing.

Re: check_http_content

Posted: Fri Jun 25, 2021 4:15 am
by s.diwakar1
Hi @benjaminsmith,

I am getting expected output after wrapping the string in single quotes.

I have tried below commands and they are working as expected:

Code: Select all

./check_http_content -U https://xxx -m '{"version":"1.0","status":"SUCCESS"}'

Code: Select all

./check_http_content -U https://xxx -m SUCCESS

Code: Select all

./check_http_content -U https://xxx -m 'SUCCESS'
Thank you for your support as always and giving me the clarification in detail with example.

Thank you so much once again.

Re: check_http_content

Posted: Fri Jun 25, 2021 9:04 am
by benjaminsmith
Hi @s.diwakar1,

Your welcome! Glad to see that's working now and we'll go ahead and mark this as resolved. Feel free to open another if you have any new questions.

Thank you for using the Nagios Community Forum!

Benjamin