Server Monitor (GUI Ping Tool with RDP and TRACERT)
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
Github repo is here: https://github.com/DThomas44/Host-Monitor
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
Here is a flushdns function: FlushDNS.ahk
So there is no need to call cmd
So there is no need to call cmd
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
Thinking about the colored blocks, and Nextron's request to have the graphs next to the colored blocks.
What would you think about using the graphs as the background to the host name, with the colored border around it all? Perhaps with an option to turn the graph backgrounds on/off?
What would you think about using the graphs as the background to the host name, with the colored border around it all? Perhaps with an option to turn the graph backgrounds on/off?
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
jNizM: Thanks, I'll work on getting that changed out. I did change over to the Ping4 function yesterday in my test branch, but am having some issues with IP -> Name resolution. It isn't really used in this script, but I have another script that uses the same PingMsg.ahk file that relies heavily on it. It is quite a bit faster, just gotta figure out the name res and it'll be good.
Grendahl: I had thought about that as well, but haven't looked into it yet.
Grendahl: I had thought about that as well, but haven't looked into it yet.
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
repo updated:
Finished implementing Ping4() as well as put in FlushDNS()
Removed reload requirement for a couple of settings
Added screenshots to the README.md
Finished implementing Ping4() as well as put in FlushDNS()
Removed reload requirement for a couple of settings
Added screenshots to the README.md
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
A couple questions, as I can't decide on how I want to do a few things:
- Should logging be per session, per host, or per host & per session? Only warnings & errors will be logged for the normal window.
On the graph window, if logging is enabled, should it be a full log, or only warnings/errors? I'm thinking full, as it is a more intensive monitoring...pinging much more often than the main window (at least by default).
Should we change to prompting for a host list at startup, so you could have several different text files of system names depending on what you want to monitor? (I'm going yes here, but just barely. I could see how it would be inconvenient if someone didn't need that feature.)
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
@Elesar:
There seems to be a problem with yout latest github-version [at least here with me):
I put some machines from our local network into the hosts file. Starting HostMonitor.ahk displays some of those machines with a red border and "Last Seen: Never".
But: These machines are reachable for sure - opening a command shell and doing a "ping -t ...." on these machines, shows that those machines are reachable and healthy.
Running the scripts for several minutes makes changing the state of almost all machines from red to green or from green to red - but all machines are healthy at any time
Former versions of your script worked fine (as far as I tested).
-----
Edit: My added machines all live in our domain <computername>.<ourdomain>.de. I added the full qualified machinename (<computername>.<ourdomain>.de) into hosts-file.
There seems to be a problem with yout latest github-version [at least here with me):
I put some machines from our local network into the hosts file. Starting HostMonitor.ahk displays some of those machines with a red border and "Last Seen: Never".
But: These machines are reachable for sure - opening a command shell and doing a "ping -t ...." on these machines, shows that those machines are reachable and healthy.
Running the scripts for several minutes makes changing the state of almost all machines from red to green or from green to red - but all machines are healthy at any time
Former versions of your script worked fine (as far as I tested).
-----
Edit: My added machines all live in our domain <computername>.<ourdomain>.de. I added the full qualified machinename (<computername>.<ourdomain>.de) into hosts-file.
Last edited by hoppfrosch on 11 Oct 2016, 07:42, edited 1 time in total.
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
I'd think that per session logging of only warnings and errors is enough. There are enough log parsing options out there that folks can use if they want finer detail.Elesar wrote:A couple questions, as I can't decide on how I want to do a few things:
- Should logging be per session, per host, or per host & per session? Only warnings & errors will be logged for the normal window.On the graph window, if logging is enabled, should it be a full log, or only warnings/errors? I'm thinking full, as it is a more intensive monitoring...pinging much more often than the main window (at least by default).
Maybe we don't have to choose... Make it a settings option to prompt for host file on each load? That way, for those of us who don't want that feature, we won't get bugged on each launch, and for those that do, they can enable it.
- Should we change to prompting for a host list at startup, so you could have several different text files of system names depending on what you want to monitor? (I'm going yes here, but just barely. I could see how it would be inconvenient if someone didn't need that feature.)
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
I'm seeing the same issues. Some hosts work normally (like http://www.msn.com), but others (like http://www.google.com) never return, and stay yellow.hoppfrosch wrote:@Elesar:
There seems to be a problem with yout latest github-version [at least here with me):
I put some machines from our local network into the hosts file. Starting HostMonitor.ahk displays some of those machines with a red border and "Last Seen: Never".
But: These machines are reachable for sure - opening a command shell and doing a "ping -t ...." on these machines, shows that those machines are reachable and healthy.
Running the scripts for several minutes makes changing the state of almost all machines from red to green or from green to red - but all machines are healthy at any time
Former versions of your script worked fine (as far as I tested).
www.google.com never returns (stays yellow), but google.com does. msn.com returns red, but www.msn.com returns green. Other hosts I've tested don't seem to return at all, they just stay yellow)
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
Yes, I've noticed the same name resolution issues since changing to the Ping4 function. I'm trying to find how to improve it's reliability, as it is quite a bit faster.
If anybody know anything about Winsock and cares to take a look, please do. I'll post in the thread for that function as well to see if they can figure out what is going on.
If anybody know anything about Winsock and cares to take a look, please do. I'll post in the thread for that function as well to see if they can figure out what is going on.
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
If tested it with cmd console ->
amazon.com [54.239.25.192] -> no ping
www amazon.com [54.239.25.200] -> no ping
So it looks like they just disabled ICMP to prevent ping requests. Has nothing to do with the Ping4 function.
amazon.com [54.239.25.192] -> no ping
www amazon.com [54.239.25.200] -> no ping
So it looks like they just disabled ICMP to prevent ping requests. Has nothing to do with the Ping4 function.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
jNizM, the issue is with more than just external websites. Computers on my LAN that I CAN ping in console will randomly not resolve their names, or not return. I have tested this quite extensively now and am confident that the Ping4 function is where the issue is, now its just a matter of trying to resolve the issue.
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
Elesar - I fixed the <1 ms response on my test version.
Change PingMsg.ahk Line 98 to:
Change PingMsg.ahk Line 98 to:
Code: Select all
Result.RTTime := ((NumGet(Reply, 8, "UInt")<1) ? 1 : Numget(Reply, 8, "UInt"))
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
Thanks! Going to update that one in several utility scripts I have.jNizM wrote:Here is a flushdns function: FlushDNS.ahk
So there is no need to call cmd
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
Can you test this version of ping?
Diff:
- Changed gethostbyname to getaddrinfo
- WSAStartup & WSACleanup only called when needed
Code: Select all
#NoEnv
SetBatchLines, -1
icmp := Ping("www.autohotkey.com")
MsgBox % icmp.ipaddr " | " icmp.rttime
icmp := Ping("8.8.8.8")
MsgBox % icmp.ipaddr " | " icmp.rttime
icmp := Ping("127.0.0.1")
MsgBox % icmp.ipaddr " | " icmp.rttime
Ping(addr, timeout := 1024)
{
static hWS2_32 := DllCall("LoadLibrary", "str", "ws2_32.dll", "ptr")
static hIPHLPAPI := DllCAll("LoadLibrary", "str", "iphlpapi.dll", "ptr")
static WSASIZE := 394 + (A_PtrSize - 2) + A_PtrSize, ECHO := {}
if !(RegExMatch(addr, "^((|\.)\d{1,3}){4}$")) {
VarSetCapacity(WSADATA, WSASIZE, 0)
if (DllCall("ws2_32\WSAStartup", "ushort", 0x0202, "ptr", &WSADATA))
throw Exception("WSAStartup failed", -1)
VarSetCapacity(hints, 16 + 4 * A_PtrSize, 0) && NumPut(2, hints, 4, "int") && NumPut(1, hints, 8, "int") && NumPut(6, hints, 12, "int")
if (DllCall("ws2_32\getaddrinfo", "astr", addr, "ptr", 0, "ptr", &hints, "ptr*", result) != 0)
throw Exception("getaddrinfo failed", -1)
addr := StrGet(DllCall("ws2_32\inet_ntoa", "uint", NumGet(NumGet(result+0, 16 + 2 * A_PtrSize) + 4, 0, "uint"), "ptr"), "cp0")
DllCall("ws2_32\WSACleanup")
}
inaddr := DllCall("ws2_32\inet_addr", "astr", addr, "uint")
if !(inaddr) || (inaddr = 0xFFFFFFFF)
throw Exception("inet_addr failed", -1)
if !(hICMP := DllCall("iphlpapi\IcmpCreateFile", "ptr"))
throw Exception("IcmpCreateFile failed", -1)
size := VarSetCapacity(buf, 32 + 8, 0)
if !(DllCall("iphlpapi\IcmpSendEcho", "ptr", hICMP, "uint", inaddr, "ptr", 0, "ushort", 0, "ptr", 0, "ptr", &buf, "uint", size, "uint", timeout, "uint"))
throw Exception("IcmpSendEcho failed", -1)
ECHO.IPAddr := StrGet(DllCall("ws2_32.dll\inet_ntoa", "uint", NumGet(buf, 0, "uint"), "ptr"), "cp0")
ECHO.Status := NumGet(buf, 4, "uint")
ECHO.RTTime := ((rtt := NumGet(buf, 8, "uint")) < 1 ? 1 : rtt)
return ECHO, DllCall("iphlpapi\IcmpCloseHandle", "ptr", hICMP)
}
- Changed gethostbyname to getaddrinfo
- WSAStartup & WSACleanup only called when needed
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
@jNizM:
Seems to work perfectly within my first tests (I tested your standalone-demo and integrated it into Elesars Host-Monitor) - unless the Member-Variable "name" is missing in your returned value (name is filled via gethostbyaddr in the original function ...)
@elesar
New version of PingMsg.ahk:
Seems to work perfectly within my first tests (I tested your standalone-demo and integrated it into Elesars Host-Monitor) - unless the Member-Variable "name" is missing in your returned value (name is filled via gethostbyaddr in the original function ...)
@elesar
New version of PingMsg.ahk:
Code: Select all
/*
PingMsg.ahk
Author: Daniel Thomas
***************************************************************************************************************
**** New ping by jNizM ************************************************************************************
**** New ping integrated by hoppfrosch *****************************************************************
***************************************************************************************************************
This script takes a target script name host name or IP address and hostID as
parameters and sends a system message to the target script with the reply
time of the provided host name or IP address. Returns TIMEOUT if no reply.
Reply is in the format of: hostID|hostName|latency|IPv4Address
Hostname is only provided if it was used as a parameter. Currently no
reverse lookup available.
*/
;<===== System Settings =====================================================>
#SingleInstance Off
#NoEnv
#NoTrayIcon
;<===== Parameters ==========================================================>
targetScript = %1%
host = %2%
hostID = %3%
;<===== Main ================================================================>
result := Object()
try {
result := Ping(host, 2500)
reply := hostID . "|" . result.Name . "|" . result.RTTime . "ms|" . result.IPAddr
}
catch e
reply := hostID . "||TIMEOUT"
Send_WM_COPYDATA(reply, targetScript . " ahk_class AutoHotkey")
ExitApp
;<===== Functions ===========================================================>
Ping(addr, timeout := 1024)
{
static hWS2_32 := DllCall("LoadLibrary", "str", "ws2_32.dll", "ptr")
static hIPHLPAPI := DllCAll("LoadLibrary", "str", "iphlpapi.dll", "ptr")
static WSASIZE := 394 + (A_PtrSize - 2) + A_PtrSize, ECHO := {}
if !(RegExMatch(addr, "^((|\.)\d{1,3}){4}$")) {
VarSetCapacity(WSADATA, WSASIZE, 0)
if (DllCall("ws2_32\WSAStartup", "ushort", 0x0202, "ptr", &WSADATA))
throw Exception("WSAStartup failed", -1)
VarSetCapacity(hints, 16 + 4 * A_PtrSize, 0)&& NumPut(2, hints, 4, "int") && NumPut(1, hints, 8, "int") && NumPut(6, hints, 12, "int")
if (DllCall("ws2_32\getaddrinfo", "astr", addr, "ptr", 0, "ptr", &hints, "ptr*", result) != 0)
throw Exception("getaddrinfo failed", -1)
addr := StrGet(DllCall("ws2_32\inet_ntoa", "uint", NumGet(NumGet(result+0, 16 + 2 * A_PtrSize) + 4, 0, "uint"), "ptr"), "cp0")
DllCall("ws2_32\WSACleanup")
}
inaddr := DllCall("ws2_32\inet_addr", "astr", addr, "uint")
if !(inaddr) || (inaddr = 0xFFFFFFFF)
throw Exception("inet_addr failed", -1)
if !(hICMP := DllCall("iphlpapi\IcmpCreateFile", "ptr"))
throw Exception("IcmpCreateFile failed", -1)
size := VarSetCapacity(buf, 32 + 8, 0)
if !(DllCall("iphlpapi\IcmpSendEcho", "ptr", hICMP, "uint", inaddr, "ptr", 0, "ushort", 0, "ptr", 0, "ptr", &buf, "uint", size, "uint", timeout, "uint"))
throw Exception("IcmpSendEcho failed", -1)
ECHO.IPAddr := StrGet(DllCall("ws2_32.dll\inet_ntoa", "uint", NumGet(buf, 0, "uint"), "ptr"), "cp0")
ECHO.RTTime := ((rtt := NumGet(buf, 8, "uint")) < 1 ? 1 : rtt)
return ECHO, DllCall("iphlpapi\IcmpCloseHandle", "ptr", hICMP)
}
Send_WM_COPYDATA(ByRef StringToSend, ByRef TargetScriptTitle){
VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0)
SizeInBytes := (StrLen(StringToSend) + 1) * (A_IsUnicode ? 2 : 1)
NumPut(SizeInBytes, CopyDataStruct, A_PtrSize)
NumPut(&StringToSend, CopyDataStruct, 2*A_PtrSize)
Prev_DetectHiddenWindows := A_DetectHiddenWindows
Prev_TitleMatchMode := A_TitleMatchMode
DetectHiddenWindows On
SetTitleMatchMode 2
SendMessage, 0x4a, 0, &CopyDataStruct,, %TargetScriptTitle%,,,, 10000
DetectHiddenWindows %Prev_DetectHiddenWindows%
SetTitleMatchMode %Prev_TitleMatchMode%
return ErrorLevel
}
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
I can add this, if needed.hoppfrosch wrote:... unless the Member-Variable "name" is missing in your returned value (name is filled via gethostbyaddr in the original function ...)
I am considering adding my ReverseLookup script into this too.
e.g. 8.8.8.8 -> google-public-dns-a.google.com
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
I'm not sure whether it's needed - just wanted to note this ...jNizM wrote:I can add this, if needed.hoppfrosch wrote:... unless the Member-Variable "name" is missing in your returned value (name is filled via gethostbyaddr in the original function ...)
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
jNizm: I would appreciate a reverse lookup option, as the PingMsg script is also used in another script I am writing, and it relies on that functionality. That script is currently still using the comspec method as I can parse out the hostname when available in the results. Having it as part of this function would be nice.jNizM wrote:I am considering adding my ReverseLookup script into this too.
e.g. 8.8.8.8 -> google-public-dns-a.google.com
Re: Server Monitor (GUI Ping Tool with RDP and TRACERT)
PingMsg.ahk:
You might try
- see here
- Because you know for sure that Ping4() will be called you simply can load both DLLs when the script starts to run and remove the LoadLibrary and FreeLibrary calls from the function.
You might try
Code: Select all
; ==================================================================================================================================
; Query DNS to get the host or domain name for the given IPv4 address (reverse lookup).
; ==================================================================================================================================
DNS_QueryName(IP, ByRef NameArray := "") {
Static OffRR := (A_PtrSize * 2) + 16 ; offset of resource record (RR) within the DNS_RECORD structure
HDLL := DllCall("LoadLibrary", "Str", "Dnsapi.dll", "UPtr")
NameArray := []
IPArray := StrSplit(IP, ".")
RevIP := IPArray.4 . "." . IPArray.3 . "." . IPArray.2 . "." . IPArray.1 . ".IN-ADDR.ARPA"
If !DllCall("Dnsapi.dll\DnsQuery_", "Str", RevIP, "Short", 0x0C, "UInt", 0, "Ptr", 0, "PtrP", PDNSREC, "Ptr", 0, "Int") {
REC_TYPE := NumGet(PDNSREC + 0, A_PtrSize * 2, "UShort")
If (REC_TYPE = 0x0C) { ; DNS_TYPE_PTR = 0x0C
PDR := PDNSREC
While (PDR) {
Name := StrGet(NumGet(PDR + 0, OffRR, "UPtr"))
NameArray.Insert(Name)
PDR := NumGet(PDR + 0, "UPtr")
}
}
DllCall("Dnsapi.dll\DnsRecordListFree", "Ptr", PDNSREC, "Int", 1) ; DnsFreeRecordList = 1
}
DllCall("FreeLibrary", "Ptr", HDLL)
Return NameArray[1] ; returnes the first name from the NameArray on success, otherwise an empty string
}