View previous topic :: View next topic |
Author |
Message |
sysadmber
Joined: 08 Dec 2015 Posts: 50
|
Posted: Wed Sep 05, 2018 4:02 am Post subject: Question regarding DNS MX Test |
|
|
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 |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12794 Location: USA
|
Posted: Wed Sep 05, 2018 8:04 am Post subject: |
|
|
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/mframe.htm#actions.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 |
|
Back to top |
|
|
Kris
Joined: 12 May 2010 Posts: 375
|
Posted: Fri Sep 07, 2018 12:59 am Post subject: |
|
|
You can use External Shell script (VBscript) like this:
Code: |
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. |
|
Back to top |
|
|
sysadmber
Joined: 08 Dec 2015 Posts: 50
|
Posted: Mon Sep 10, 2018 7:09 am Post subject: |
|
|
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. |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12794 Location: USA
|
Posted: Mon Sep 10, 2018 9:49 am Post subject: |
|
|
Quote: | 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 |
|
Back to top |
|
|
|