Page 1 of 1
Need to include exact cr/lf and spacing in ARGS for command.
Posted: Wed Dec 14, 2016 5:53 am
by rrauwl
Hey folks!
I need to pull the monitoring status from the web front end for status.newrelic.com . On the command line, I've got it working perfectly using this command, with exact spacing and cr/lf of course:
Code: Select all
/usr/lib/nagios/plugins/check_http -w 30 -c 60 -s ' <span class="name">
APM
</span>
<span class="component-status">
Operational
</span>' --ssl -H status.newrelic.com
The issue being, the .cfg files don't seem to parse cr/lf's properly. I'd define it as a macro but again, the only way I know how to do that is in the context of the .cfg, which doesn't parse it properly.
If I have to pass an exact multi-line ARG with whitespace and cr/lf, what's the best method of doing that?
Re: Need to include exact cr/lf and spacing in ARGS for comm
Posted: Wed Dec 14, 2016 10:34 am
by rrauwl
Thanks to the mod for approving this! First time poster, please be gentle.

Re: Need to include exact cr/lf and spacing in ARGS for comm
Posted: Wed Dec 14, 2016 12:26 pm
by dwhitfield
Welcome!
I'm going to ask a few questions so we have a baseline for where things are installed and what functionality you have. What version of Core are you using? Was it compiled from source or installed from distro repos? On what OS/version is nagios running? cat /etc/*-release may be of use.
Re: Need to include exact cr/lf and spacing in ARGS for comm
Posted: Wed Dec 14, 2016 12:37 pm
by rrauwl
dwhitfield wrote:Welcome!
I'm going to ask a few questions so we have a baseline for where things are installed and what functionality you have. What version of Core are you using? Was it compiled from source or installed from distro repos? On what OS/version is nagios running? cat /etc/*-release may be of use.
Hia,
We're running Nagios 4.2.4 on Ubuntu 16.04.01 (Xenial Xerus) with the intention of setting up cross monitoring (with New Relic for example), general enterprise monitoring, etc. It was all compiled from source.
Cheers!
Re: Need to include exact cr/lf and spacing in ARGS for comm
Posted: Wed Dec 14, 2016 3:34 pm
by avandemore
It seems a bit unnecessary and a performance issue waiting to happen to check a large amount of output, but if you must do so I would put the static version in a file and call it from the command:
Code: Select all
/usr/lib/nagios/plugins/check_http -w 30 -c 60 --ssl -H status.newrelic.com -s `cat /path/to/file`
Plugins are literally nothing more than *nix executables so if you think about them as such it's easy to understand.
Re: Need to include exact cr/lf and spacing in ARGS for comm
Posted: Wed Dec 14, 2016 3:44 pm
by dwhitfield
Additionally...
I don't know a ton about it, but have you looked at
https://docs.newrelic.com/docs/apis/res ... ng-started ? I don't know how
https://docs.newrelic.com/docs/apis/res ... -status-v2 interacts with the page you are checking now, but that would be the first place I would go.
I think you could do something with
https://assets.nagios.com/downloads/nag ... ios-XI.pdf if you were using XI.
I also wonder if
https://exchange.nagios.org/directory/P ... nt/details will do what you want.
Re: Need to include exact cr/lf and spacing in ARGS for comm
Posted: Thu Dec 15, 2016 4:02 am
by rrauwl
Thanks for the multiple options! I'm going to look into bot cat'ing out the parameter, as well as the New Relic-specific options that were mentioned (though the technique is going to eventually be needed for broader application).
Thanks for all of the help!
Re: Need to include exact cr/lf and spacing in ARGS for comm
Posted: Thu Dec 15, 2016 10:13 am
by dwhitfield
rrauwl wrote:the technique is going to eventually be needed for broader application
You know more than I do about your situation, but if all you are doing is using regex on a website, then you are going to have to rewrite it for each site and each time they update the site. Of course, this might be true with APIs too, but I suspect there will be more backward compatibility with APIs.
It's also common for people to mimic an industry leader's API. Plenty of copied twitter, Amazon, and last.fm just off the top of my head. So, it might turn out the API route is more portable than you think. I don't know about New Relic's space though. Just food for thought.