Windows Environment Variables %ProgramFiles% %HomeDrive% etc

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
rambertnala
Posts: 60
Joined: Fri Feb 26, 2016 7:15 am

Windows Environment Variables %ProgramFiles% %HomeDrive% etc

Post by rambertnala »

Hi friends.

I have different computers to monitorize using passive checks

Problem is some computers have "C:\Archivos de Programa" and others "C:\Program Files" folder

so how can i use variable %PROGRAMFILES% with passive checks

How can I use any other environment variable???

Thanks and regards
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Windows Environment Variables %ProgramFiles% %HomeDrive%

Post by mcapra »

It probably depends on what you're using to ship the passive checks.

send_nrdp.php / NSClient++ / NCPA all probably have their own quirks in this regard. However, I would think that as long as you're including the environment variables in your command definitions on the Windows side of things, and the environment variables have the appropriate scope for the user executing those commands, that should be sufficient.

I've never encountered immediate problems using appropriately scoped environment variables in PHP and Java on a Windows environment.
Former Nagios employee
https://www.mcapra.com/
kyang

Re: Windows Environment Variables %ProgramFiles% %HomeDrive%

Post by kyang »

Thanks @mcapra!

@rambertnala, mcapra is correct. What are you using to send passive checks?
rambertnala
Posts: 60
Joined: Fri Feb 26, 2016 7:15 am

Re: Windows Environment Variables %ProgramFiles% %HomeDrive%

Post by rambertnala »

I am using NRDP

and i would like to create a nsclient.ini valid for all computers

My score is to get size of file into a folder. That folder is a subdir of "Program Files" in some computers and "Archivos de Programa" all others.

I am using following command

check_files file="C:\\Program Files\\Microsoft SQL Server\\MSSQL$~1\\Data\\templog.ldf"

and

check_files file="C:\\Archivos de Programa\\Microsoft SQL Server\\MSSQL$~1\\Data\\templog.ldf"

So would be possible get anything like this

check_files file="%PROGRAMFILES%\\Microsoft SQL Server\\MSSQL$~1\\Data\\templog.ldf"

Thanks and regards
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Windows Environment Variables %ProgramFiles% %HomeDrive%

Post by npolovenko »

@rambertnala, I think this is possible as long as you have that environment variable set up in system settings. Depending on your system if you right click on my computer, you should be able to go to Advanced System Settings, then advanced and make sure that the system has the correct definition for %PROGRAMFILES% variable. You can also create a new variable from there as well.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
rambertnala
Posts: 60
Joined: Fri Feb 26, 2016 7:15 am

Re: Windows Environment Variables %ProgramFiles% %HomeDrive%

Post by rambertnala »

hi.

Yes I have variable %PROGRAMFILES% ready, but how can i use it into this passive command

check_files file="%PROGRAMFILES%\\Microsoft SQL Server\\MSSQL$~1\\Data\\templog.ldf"

Using that command theres is an error, so how can i manage it???

Is this possible???
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Windows Environment Variables %ProgramFiles% %HomeDrive%

Post by npolovenko »

@rambertnala, I'm sorry that it didn't work for you. I couldn't find any documentation on this issue from NSClient's side. I would probably try to remove quotes from your path definition and see if that works. Make sure to go to services and restart NSClient++ service every time you make changes. Another way to achieve your goal would be to define the check_files path inside the script itself instead of the ini file. That way you'd know what language is used and what is the correct way to use an environment variable.
Also, here's the link to NSClient forum: https://forums.nsclient.org/, you can also post this question there as well.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
rambertnala
Posts: 60
Joined: Fri Feb 26, 2016 7:15 am

Re: Windows Environment Variables %ProgramFiles% %HomeDrive%

Post by rambertnala »

I will test without quotes and i will tell any result...

check_files is NSClient command not an script made from me...
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Windows Environment Variables %ProgramFiles% %HomeDrive%

Post by npolovenko »

@rambertnala, Sounds good. You may also try to use the following command instead. Paste this in the external scripts section:

Code: Select all

alias_check_file = check_files path=%PROGRAMFILES%"\\Microsoft SQL Server\\MSSQL$~1\\Data\\templog.ldf"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked