hiding password for WMI queries

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
lavignp
Posts: 23
Joined: Thu Sep 26, 2013 10:24 am

hiding password for WMI queries

Post by lavignp »

I already asked this question over in the general forum (before I got access to this one), and I recieved one idea to start with. Hopefully there is another way to address this question...

Is there a way to hide the password when using the WMI wizard to set up monitoring? After I configure the service, if I go in to edit it, I can clearly see the username and password in the command string. We're just trying to be thorough with our security, so we were hoping to not leave that as-is.

I have dug through as much documentation as I could find, and I do see an option to create an authentication file for the Check WMI Plus plugin. How in the world would I make these two work together, in terms of the syntax, which appears to be different from the command line options that are available? Plus, even the idea of having the password in plain text on the Nagios server is still not ideal, but better than the current setup.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: hiding password for WMI queries

Post by BanditBBS »

Use the -A option. Using -A and specify a file with the username, password and domain in it, in the following format:

Code: Select all

username=nagiosxi
password=xxxxxxx
domain=xxxxx
Also, I created one server with WMI checks, modify them to use the -A and then just clone those when needed to add a new server(s)
Last edited by BanditBBS on Tue Oct 22, 2013 7:51 am, edited 1 time in total.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: hiding password for WMI queries

Post by abrist »

Nagios provides a locked down file for sensitive bit lits passwords and for strings that contain illegal macro characters:

Code: Select all

/usr/local/nagios/etc/resource.cfg 
Create a new user macro at the bottom or resource.cfg, we will use $USER9$ and $USER10$ for this example (replace <wmi user> and <wmi pass> with the actual username and password, respectively):

Code: Select all

$USER9$=<wmi user>
$USER10$=<wmi pass>
Now, edit the check to use the $USER9$ and $USER10$ macros in place of the actual credentials. Restart nagios and then you should be set!

EDIT: Bandit has a better answer - listen to him, ignore me :P
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
lavignp
Posts: 23
Joined: Thu Sep 26, 2013 10:24 am

Re: hiding password for WMI queries

Post by lavignp »

Thank you both for the replies.

First of all the $USERX$ macro seems to work just fine when I put it into the GUI, so there's that (The WMI query for the event logs appears to be broken, but I can deal with that separately). This may save me the trouble of manually editing those files.

However, when I looked into editing each respective hostname.cfg file under /usr/local/nagios/etc/services, I noticed the comment in each one:

# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios QL will overwite all manual settings during the next update

So...how/where would I edit that command string?
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: hiding password for WMI queries

Post by BanditBBS »

abrist wrote:EDIT: Bandit has a better answer - listen to him, ignore me :P
Next time, make the text larger and brighter when you say something like that :)
lavignp wrote:First of all the $USERX$ macro seems to work just fine when I put it into the GUI, so there's that (The WMI query for the event logs appears to be broken, but I can deal with that separately). This may save me the trouble of manually editing those files.
That could be a DNS issue I just experience as well. In your resolv.conf file, make sure all DNS suffixes are listed it should be searching. Doing that fixed my issue.
lavignp wrote:However, when I looked into editing each respective hostname.cfg file under /usr/local/nagios/etc/services, I noticed the comment in each one:
Modify the services in the core config manager. Then when you apply configuration, those files will be over written
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
lavignp
Posts: 23
Joined: Thu Sep 26, 2013 10:24 am

Re: hiding password for WMI queries

Post by lavignp »

Thanks Bandit, I looked in Core config, and saw what you were referring to in the services. Good to know..

Also, adding the additional search domain to resolv.conf fixed the issue. What's weird is that I specified the FQDN when I set up the host, so I don't know WHY that didn't work...
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: hiding password for WMI queries

Post by BanditBBS »

lavignp wrote:Also, adding the additional search domain to resolv.conf fixed the issue. What's weird is that I specified the FQDN when I set up the host, so I don't know WHY that didn't work...
Those EXACT same words came out of my mouth when I ran into the issue here....it makes absolutely no sense!
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: hiding password for WMI queries

Post by sreinhardt »

Unfortunately I had the same issues as well, the only thing I can figure is that wmic or perl wmi stuff does some very funky resolution stuff with how it expects fqdn's to work, that may not be the normal case in windows environments.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
sujitt
Posts: 132
Joined: Thu Apr 25, 2013 1:50 pm

Re: hiding password for WMI queries

Post by sujitt »

Adding into a file should be a standard feature within the WMI wizard. it is a hassle to do this to every service to add a -A option in XI.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: hiding password for WMI queries

Post by abrist »

I have submitted an internal feature request for this wizard option.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked