Jump to content
Sign in to follow this  
autoitxp

Ip Monitor

Recommended Posts

autoitxp

Hi

well my home computer connected to LAN with 12 users . we r using outlook messegner for chat purpose now i want to make tool that tell which pc is online and goes offline using PING command. but not only 1 ip . i want to monitor ip range like 192.168.1.1 to 192.168.1.254 . how can i accomplish this ?

Regards

Share this post


Link to post
Share on other sites
GEOSoft

Hi

well my home computer connected to LAN with 12 users . we r using outlook messegner for chat purpose now i want to make tool that tell which pc is online and goes offline using PING command. but not only 1 ip . i want to monitor ip range like 192.168.1.1 to 192.168.1.254 . how can i accomplish this ?

Regards

Something along the line of

$bAddr = like 192.168.1
For $I = .1 To .254
   Ping($bAddr & $I);; Or whatever function you decide to use.
Next
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
jlorenz1

Hi

well my home computer connected to LAN with 12 users . we r using outlook messegner for chat purpose now i want to make tool that tell which pc is online and goes offline using PING command. but not only 1 ip . i want to monitor ip range like 192.168.1.1 to 192.168.1.254 . how can i accomplish this ?

Regards

Make on each pc a shared folder and then use Stdout() and the Dos-command net view. This works faster then pinging all possible IPs of the PCs. But if you want to ping, then please use their hostname e.g. ping -n 2 xp-host Johannes Edited by jlorenz1

Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]

Share this post


Link to post
Share on other sites
autoitxp

Well its taking lots off time not fast enough ? jlorenz1 ur right

While 1
    For $i=1 To 254
        If Ping("192.168.1."&$i,1000)<>0 Then
            MsgBox(0,"","192.168.1."&$i&" is online")
        EndIf
    Next
WEnd
Edited by autoitxp

Share this post


Link to post
Share on other sites
GEOSoft

Well its taking lots off time not fast enough ? jlorenz1 ur right

While 1
    For $i=1 To 254
        If Ping("192.168.1."&$i,1000)<>0 Then
            MsgBox(0,"","192.168.1."&$i&" is online")
        EndIf
    Next
WEnd
Ping is very slow at any time.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
jlorenz1

While 1

For $i=1 To 254

If Ping("192.168.1."&$i,1000)<>0 Then

MsgBox(0,"","192.168.1."&$i&" is online")

EndIf

Next

WEnd

better & faster

$aArray('PC1|PC2|PC3', '|')
While 1
    For $i=1 to $aArray[0]
        If Ping($aArray[$i],1000)<>0 Then
            MsgBox(0,"", $aArray & " is online")
        EndIf
    Next
WEnd
Edited by jlorenz1

Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]

Share this post


Link to post
Share on other sites
spudw2k

better & faster

$aArray('PC1|PC2|PC3', '|')
While 1
    For $i=1 to $aArray[0]
        If Ping($aArray[$i],1000)<>0 Then
            MsgBox(0,"", $aArray & " is online")
        EndIf
    Next
WEnd
Why/how is it faster to declare/define a array rather than just pinging a range of ips? I believe he wants to scan a whole subnet. so making an array with every host/ip is just extra work. Edited by spudw2k

Share this post


Link to post
Share on other sites
weaponx

Of course its going to be slow with a timeout that big. Active computers should only take a few milliseconds to respond, the invalid IP's are going to use that entire timeout.

For $i=1 To 254
    $result = Ping("192.168.1."&$i,1)
    If NOT @ERROR Then
        ConsoleWrite("192.168.1."&$i & " ONLINE" & @CRLF)
    Else
        ConsoleWrite("192.168.1."&$i & " OFFLINE" & @CRLF)
    EndIf
Next
Edited by weaponx

Share this post


Link to post
Share on other sites
autoitxp

yaa this one is pretty better and faster then previous but still thread is about real time monitoring ips ? now there is problem how to detect if pc goes offline for this we need to scan all ip again and it take lots of time to scan and tell user these pc offline or online so think we need to change method then ip ping scan ?

can we do this using netbios or netstat ?

Make on each pc a shared folder and then use Stdout() and the Dos-command net view. This works faster then pinging all possible IPs of the PCs. But if you want to ping, then please use their hostname e.g. ping -n 2 xp-host Johannes

yaa IPc$ scan or admin$ would be better but how can we accomplish this seem better option

Edited by autoitxp

Share this post


Link to post
Share on other sites
autoitxp

I found nbtstat -c and nbtstat -r command very usefull it shows netbios name currently online users scanning nbstat -r every xxx sec sounds faster and more relaible

any suggestions ?

.

Edited by autoitxp

Share this post


Link to post
Share on other sites
autoitxp

Hi

This wat i have done so far this will show current online users

but have some problems in it

First : GUICtrlSetImage set images wrong way donno why?

Second: some time it show half users online even my name doesnt appear

code need optimization any one like to optimize and correct this will be very appreciated

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
#include "array.au3"
#include <GUIConstants.au3>
Dim $line 
Dim $item
$GUI = GUICreate("My GUI" , 800 , 600) 

$listview = GuiCtrlCreateListView ("Indication|Computer|Ip|Status  ", 40,40,400,500)


GUISetState (@SW_SHOW)  

$foo = Run(@ComSpec & " /c net view ", @SystemDir, @SW_HIDE,2)

While 1

    
    
   $sActiveLine = StdoutRead($foo)
    If @error Then ExitLoop

  If StringLeft($sActiveLine, 2) = "\\" Then
        $line &= StringReplace($sActiveLine, "\\" , "") & @CRLF
    EndIf
    
Wend


;$line = StringReplace($line, "\\" , "") 
$line = StringReplace($line, " " , "")
$line = StringReplace($line, @LF,"")
$line = StringSplit ($line, @CR)

;ConsoleWrite($line[0])
TCPStartup()

For $i = 1 To $line[0] - 1
    $result = Ping($line[$i] ,1)
    If NOT @ERROR Then

        
$line[$i] = GuiCtrlCreateListViewItem(GUICtrlSetImage(-1, "shell32.dll",21) & "|" & $line[$i] & "|" & TCPNameToIP($line[$i]) &"|ONLINE",$listview)
;ConsoleWrite($line[$i] & " " & TCPNameToIP($line[$i])  & " ONLINE" & @CRLF)
    Else
$line[$i]=   GuiCtrlCreateListViewItem( GUICtrlSetImage(-1, "shell32.dll",22) & "|" & $line[$i] & "|" & TCPNameToIP($line[$i]) &"|OFFLINE",$listview)
;     ConsoleWrite($line[$i]  & " OFFLINE" & @CRLF)
   EndIf
    Next




while 1 
        $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
Edited by autoitxp

Share this post


Link to post
Share on other sites
evilertoaster

Try this-

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
#include "array.au3"
#include <GUIConstants.au3>

Dim $line 
Dim $item
$GUI = GUICreate("My GUI" , 800 , 600) 
$listview = GuiCtrlCreateListView ("Indication|Computer|Ip|Status  ", 40,40,400,500)

GUISetState (@SW_SHOW)  

$foo = Run(@ComSpec & " /c net view ", @SystemDir, @SW_HIDE,2)

While 1 
    $sActiveLine = StdoutRead($foo)
    If @error Then ExitLoop
    If StringLeft($sActiveLine, 2) = "\\" Then
        $line &= StringReplace($sActiveLine, "\\" , "") & @CRLF
    EndIf
Wend

$line = StringReplace($line, " " , "")
$line = StringReplace($line, @LF,"")
$line = StringSplit ($line, @CR)

TCPStartup()

For $i = 1 To $line[0] - 1
    $result = Ping($line[$i] ,1)
    If NOT @ERROR Then
        $line[$i] = GuiCtrlCreateListViewItem($line[$i] & "|" & TCPNameToIP($line[$i]) &"|ONLINE",$listview)
        GUICtrlSetImage(-1, "shell32.dll",21)
    Else
        $line[$i] = GuiCtrlCreateListViewItem($line[$i] & "|" & TCPNameToIP($line[$i]) &"|OFFLINE",$listview)
        GUICtrlSetImage(-1, "shell32.dll",22)
    EndIf
Next

TCPShutdown()

while 1 
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Share this post


Link to post
Share on other sites
jlorenz1

If you want convert hostname in IPs then you should use the dos command nslookup. Better than net view and afterwards ping. Johannes

Edited by jlorenz1

Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]

Share this post


Link to post
Share on other sites
JellyFish666

Net View?

Cmd command?

Share this post


Link to post
Share on other sites
Triblade

See my post <Link> for hints.

I had the same slow timeout problem. This is because Autoit ping has a default timeout of 4000ms (4sec)

I got a suggestion (read the topic) for a dos command. I've implemented this as a feature in my program.

I now use a default of 1000ms because when I set it to 15ms it gives a lot of timeout's.


My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites
jlorenz1

@JellyFish666

Yes, nslookup (convert IP into Hostname and reverse), net view (shows shared folder in the network) and ping are all cmd commands. Greetings Johannes

@Triblade

Forget the next words, I saw that you are using the -w switch of ping.

You want wait longer for a ping. Well, look in the help of the ping command. In german you'll get this help:

CODE
Syntax: ping [-t] [-a] [-n Anzahl] [-l Größe] [-f] [-i Gültigkeitsdauer]

[-v Diensttyp] [-r Anzahl] [-s Anzahl] [[-j Hostliste] |

[-k Hostliste]] [-w Zeitlimit] Zielname

Optionen:

-t Sendet fortlaufend Ping-Signale zum angegebenen Host.

Geben Sie STRG-UNTRBR ein, um die Statistik anzuzeigen.

Geben Sie STRG-C ein, um den Vorgang abzubrechen.

-a Löst Adressen in Hostnamen auf.

-n n Anzahl Anzahl zu sendender Echoanforderungen

-l Länge Pufferlänge senden

-f Setzt Flag für "Don't Fragment".

-i TTL Gültigkeitsdauer (Time To Live)

-v TOS Diensttyp (Type Of Service)

-r Anzahl Route für Anzahl der Abschnitte aufzeichnen

-s Anzahl Zeiteintrag für Anzahl Abschnitte

-j Hostliste "Loose Source Route" gemäß Hostliste

-k Hostliste "Strict Source Route" gemäß Hostliste

-w Zeitlimit Zeitlimit in Millisekunden für eine Rückmeldung

e.g. ping -w 6000 www.google.com will wait 6000 Milliseconds for a reply of google. Is this what you mean? Johannes

Edited by jlorenz1

Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×