All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
After I don't know which version something that we're using stopped working properly. As it's a test with an action that rarely is used we find just now but could be that is happening from long ago. We know that by the end of 2013 it worked properly (should have been introduced in 9.86 or 9.90).
Basically we're checking for a ping and if the test fails 4 times it executes a batch file. That works. What it doesn't work is the processing of what's inside the batch and I believe it might be because we're calling an executable.
@echo off
set datetimef=%date:~-4%.%date:~3,2%.%date:~0,2% %time:~0,2%.%time:~3,2%.%time:~6,2%
echo %datetimef% - Changed DNS entry for ISP2 >> dns-.log
dnscmd localhost /recorddelete domain.com ftp CNAME ip1.domain.com /f
dnscmd localhost /recordadd domain.com ftp CNAME ip2.domain.com
dnscmd localhost /recorddelete domain.com mail CNAME ip1.domain.com /f
dnscmd localhost /recordadd domain.com mail CNAME ip2.domain.com
dnscmd localhost /recorddelete domain.com www CNAME ip1.domain.com /f
dnscmd localhost /recordadd domain.com www CNAME ip2.domain.com
So, the log file is written and the first command is run (changing ftp entry), but the rest is ignored. That's is what lead me to believe that maybe you call the batch and opens a process, and the batch calls the app and opens a new process but when it exits HM thinks the processing ended. I know... I'm not a proper programmer and this might be silly thinking so don't blame me.
Anyway, if you run the batch file from a command prompt it works. If you launch it from a scheduled task it works as well.
That's is what lead me to believe that maybe you call the batch and opens a process, and the batch calls the app and opens a new process but when it exits HM thinks the processing ended.
This should not be a problem.
Are you sure
dnscmd localhost /recorddelete domain.com ftp CNAME ip1.domain.com /f
is executed?
Could you please add more logging.
E.g.
dnscmd localhost /recorddelete domain.com ftp CNAME ip1.domain.com /f
echo Line 1 executed >> dns-.log
dnscmd localhost /recordadd domain.com ftp CNAME ip2.domain.com
echo Line 2 executed >> dns-.log
etc..
What Windows/Service pack is used on HostMonitor system?
HostMonitor is started as Service or Application?
Windows 2008 R2 with the updates available until today.
Yes, that command is executed and even more, the .bat file I'm using works properly if launched from command prompt. It does everything I ask to (every line runs).
By doing what you asked (adding log after each execution) I see I was confused and not even the first dnscmd line is working. The batch only registers the starting log line and then no more.
EDIT: sorry I forgot to add, it's running as a service and with the local administrator.
Last edited by jcasares on Fri Apr 17, 2015 12:23 pm, edited 1 time in total.
I can see here 2 possible reasons:
1. Permissions issue. HostMontior Service may require BUILT-IN Administrator account.
2. working directory or path issue.
Try to specify full path to dnscmd and specify Working directory for "Execute external program" action.
HostMonitor is already running on the administrator account. Both when working as a services and when run as an application inside an administrator session.
Where do you set that working directory on HostMonitor Execute External Command action? I don't see it on the interface.
Setting the full path did nothing to change the issue.
Where do you set that working directory on HostMonitor Execute External Command action? I don't see it on the interface.
Option implemented in version 10.00 - its not available for download yet.
We did not change this action for a long time.
So, the log file is written and the first command is run (changing ftp entry), but the rest is ignored. That's is what lead me to believe that maybe you call the batch and opens a process, and the batch calls the app and opens a new process but when it exits HM thinks the processing ended
HostMonitor does not care. Its action, not "External" test (test processed in different way). So HostMonitor just starts process and that's it.
If you use command line like "cmd /c c:\scripts\batfile1.BAT", HostMonitor starts CMD and don't care about results.
dnscmd requirements?
special user account? some special environ variables?
The funny thing is we workarounded this by creating manually Scheduled Tasks and running those tasks in HM instead of directly the batch file. This works perfectly so I think it should have something to do with how HM runs the batch files.
We tried running with cmd /c but it was worse. It doesn't even register the first line.
No, it runs with the administrator. I repeat that the batch works if run from command prompt. It fails when you run it from HM only.
Variables could be but I suppose you load the user's (in this case administrator) user variables when you run the command.
It is quite strange. I should install an old version on another server setup to try and see when it started to fail. Don't have much time now but might try later.
The funny thing is we workarounded this by creating manually Scheduled Tasks and running those tasks in HM instead of directly the batch file.
Scheduled task? But you are using "Execute external program" action anyway, just assigned it to HostMonitor Scheduler instead test item, right?
Then it should work exactly the same way (unless you are using some test related variables in command line)
What exactly command line do you use?
This works perfectly so I think it should have something to do with how HM runs the batch files.
HostMonitor does not run batch files at all. Batch files are not executable files. Such files processed by cmd.exe, that's why you should use command line like "cmd batchfile.bat"
The funny thing is we workarounded this by creating manually Scheduled Tasks and running those tasks in HM instead of directly the batch file.
Scheduled task? But you are using "Execute external program" action anyway, just assigned it to HostMonitor Scheduler instead test item, right?
Then it should work exactly the same way (unless you are using some test related variables in command line)
What exactly command line do you use?
I'm using Windows Task Scheduler that runs the batch file and then I call from HostMonitor's Execute External Program the task with schtasks.exe /Run /TN "\TaskName"
KS-Soft wrote:
This works perfectly so I think it should have something to do with how HM runs the batch files.
HostMonitor does not run batch files at all. Batch files are not executable files. Such files processed by cmd.exe, that's why you should use command line like "cmd batchfile.bat"
Regards
Alex
Running with "cmd batchfile.bat" produces this result I'm reporting. It runs only the start of the code and after the first dnscmd it ends/hangs/whatever.
c:\>C:\Windows\sysnative\dnscmd.exe
The system cannot find the path specified.
You'll get this error from 64bit cmd.exe console.
Do you use 64-bit OS on HostMontior system?
Test is performed by HostMontior or RMA?
If you are using 64-bit Windows, could you please start 32-bit cmd.exe (location C:\Windows\SysWow64\cmd.exe)
and try to start
C:\Windows\sysnative\dnscmd.exe
and test bat file.