Page 1 of 1
Windows Environment Variables %ProgramFiles% %HomeDrive% etc
Posted: Fri Nov 17, 2017 8:05 am
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
Re: Windows Environment Variables %ProgramFiles% %HomeDrive%
Posted: Fri Nov 17, 2017 10:41 am
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.
Re: Windows Environment Variables %ProgramFiles% %HomeDrive%
Posted: Fri Nov 17, 2017 1:15 pm
by kyang
Thanks
@mcapra!
@rambertnala, mcapra is correct. What are you using to send passive checks?
Re: Windows Environment Variables %ProgramFiles% %HomeDrive%
Posted: Mon Nov 20, 2017 4:14 am
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
Re: Windows Environment Variables %ProgramFiles% %HomeDrive%
Posted: Mon Nov 20, 2017 3:56 pm
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.
Re: Windows Environment Variables %ProgramFiles% %HomeDrive%
Posted: Tue Nov 21, 2017 4:51 am
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???
Re: Windows Environment Variables %ProgramFiles% %HomeDrive%
Posted: Tue Nov 21, 2017 2:41 pm
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.
Re: Windows Environment Variables %ProgramFiles% %HomeDrive%
Posted: Wed Nov 22, 2017 4:29 am
by rambertnala
I will test without quotes and i will tell any result...
check_files is NSClient command not an script made from me...
Re: Windows Environment Variables %ProgramFiles% %HomeDrive%
Posted: Wed Nov 22, 2017 4:09 pm
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"