KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Question regarding DNS MX Test

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
sysadmber



Joined: 08 Dec 2015
Posts: 50

PostPosted: Wed Sep 05, 2018 4:02 am    Post subject: Question regarding DNS MX Test Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12791
Location: USA

PostPosted: Wed Sep 05, 2018 8:04 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Kris



Joined: 12 May 2010
Posts: 375

PostPosted: Fri Sep 07, 2018 12:59 am    Post subject: Reply with quote

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
View user's profile Send private message
sysadmber



Joined: 08 Dec 2015
Posts: 50

PostPosted: Mon Sep 10, 2018 7:09 am    Post subject: Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12791
Location: USA

PostPosted: Mon Sep 10, 2018 9:49 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index