Need to include exact cr/lf and spacing in ARGS for command.

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
rrauwl
Posts: 4
Joined: Wed Dec 14, 2016 5:50 am

Need to include exact cr/lf and spacing in ARGS for command.

Post 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?
rrauwl
Posts: 4
Joined: Wed Dec 14, 2016 5:50 am

Re: Need to include exact cr/lf and spacing in ARGS for comm

Post by rrauwl »

Thanks to the mod for approving this! First time poster, please be gentle. :)
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Need to include exact cr/lf and spacing in ARGS for comm

Post 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.
rrauwl
Posts: 4
Joined: Wed Dec 14, 2016 5:50 am

Re: Need to include exact cr/lf and spacing in ARGS for comm

Post 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!
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Need to include exact cr/lf and spacing in ARGS for comm

Post 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.
Previous Nagios employee
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Need to include exact cr/lf and spacing in ARGS for comm

Post 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.
rrauwl
Posts: 4
Joined: Wed Dec 14, 2016 5:50 am

Re: Need to include exact cr/lf and spacing in ARGS for comm

Post 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!
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Need to include exact cr/lf and spacing in ARGS for comm

Post 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.
Locked