Question regarding DNS MX Test

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).
Post Reply
sysadmber
Posts: 50
Joined: Tue Dec 08, 2015 1:26 am

Question regarding DNS MX Test

Post by sysadmber »

Hello,

i setup a Test to query the MX Record. However I fail to present valuable infos upon failure.

Default Result is "xxx ms". Die Docs say that the variable %object2% delivers infos but on my system it shows the String %Object2%.

What I need / wish:

A Variable which contains the result to test and a variable with the current record.

Example:

Request: domain.tld
Test result for: mailserver.domain.tld

On Error Reply value: "ERROR: Tested for %Test% but got %Answer% instead !!!"

Is this already possible?

HM Version 11.54 on a german Server 2016
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

What exactly means "present valuable infos upon failure"?
Are you using some actions assigned to the test, like Send e-mail action?
Then you can use variables designed for the actions
E.g. %DnsResult% or %DnsResults%
https://www.ks-soft.net/hostmon.eng/mfr ... .htm#macro

%Object2% is variable that can be used in test name or test comment so you can setup patterns and HostMonitor will set test name automatically.

Regards
Alex
Kris
Posts: 375
Joined: Wed May 12, 2010 3:22 am

Post by Kris »

You can use External Shell script (VBscript) like this:

Code: Select all

strDomain	= WScript.Arguments(0)
Set oShell	= CreateObject("WScript.Shell")
Set oExec	= oShell.Exec("nslookup -q=mx " & strDomain & " 8.8.8.8")

Do Until oExec.StdOut.AtEndOfStream
	strLine = oExec.StdOut.ReadLine()
	If InStr(strLine, "MX preference") > 0 then
		strResult = strResult & strLine & " | "
	End If
Loop 

If trim(strResult) <> "" then
	WScript.StdOut.Write "ScriptRes:Ok:" & strResult
Else
	WScript.StdOut.Write "ScriptRes:Unknown: No MX records found for domain '" & strDomain & "'"
End If
It takes the domain name as parameter.
It will use Windows 'nslookup' and query a DNS server (8.8.8.8 in this case) to return MX records.
Tweak to your own needs.
sysadmber
Posts: 50
Joined: Tue Dec 08, 2015 1:26 am

Post by sysadmber »

Hello,

thanks for the hint. The Variable %DNSResult% was exactly what I needed. Sometimes its not so easy to find the corresponing infos in the docs.

Also thanks for the script. Ich use a couple of scripts to overcome hostmon's limit but I prefer a buildin command as I guess that calling an external programm like cscript.exe or powershell.exe is more expensive in terms of I/O, RAM and CPU use than the hostmon calls.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

but I prefer a buildin command as I guess that calling an external programm like cscript.exe or powershell.exe is more expensive in terms of I/O, RAM and CPU use than the hostmon calls.
That's true.
External tests can be used if you don't need to start them often, but 50 powershell.exe processes started every sec is pretty heavy for the system

Regards
Alex
Post Reply