#36737 - 2003-02-21 12:30 AM
Re: Monitor Connectivity on My Own Network ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Here is a script that will do it for you:
code:
Break ON
$sIPAddress="a.b.c.d"
While "true" Shell '%COMSPEC% /C ping -n 1 ' + $sIPAddress + ' | find "TTL=" >/dev/null' If @ERROR=0 $Null=MessageBox("IP Address " + $sIPAddress + " is responding","It's Alive!") Exit 0 EndIf Sleep(60) Loop
Set $sIPAddress to the address you want to monitor.
This will check every 60 seconds, and popup a window when the IP address responds then exit.
Change the MessageBox() to "Beep" or "Play" to have a sound instead.
|
|
Top
|
|
|
|
#36739 - 2003-02-20 02:23 PM
Re: Monitor Connectivity on My Own Network ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
quote: I was thinking as soon as there address starts to ping
I assumed from this means he knows the IP address.
Net send from the login script is ok, however if the user in question doesn't log in of course there is no login script to put it in.
If the client uses DHCP there are two options 1) If he has a modern DHCP/DNS combination the leased address will be added via DDNS update, so he can ping via the host name instead. 2) If a cranky old NT4.0 solution switch on logging and simply poll todays log file waiting for the lease to appear.
The other problem with using login scripts or polling the DHCP log file is that it won't tell you if the PC is already there.
|
|
Top
|
|
|
|
#36740 - 2003-02-20 02:24 PM
Re: Monitor Connectivity on My Own Network ?
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
look for kpinger on my kix site...
|
|
Top
|
|
|
|
#36741 - 2003-02-20 02:25 PM
Re: Monitor Connectivity on My Own Network ?
|
Austin
Seasoned Scripter
Registered: 2002-01-24
Posts: 439
|
You could also use Ping() UDF and ping the computer name which would use whatever resolution service you are running.. but I think that I like the idea of doing it in loginscript and combining with postie.exe to send you an email in that case of the desired computer logging in.. or if one of multiple computers logs in.. something like.
code:
$TO = you@company.com $FROM = you@company.com $SUB = "Login Alert From @WKSTA By @USERID" $IMP = "high" $MSG = "User: @USERID has logged into workstation: @WKSTA."
if @WKSTA = "COMPUTER1" OR @WKSTA = "COMPUTER2" $ShellString='@ScriptDir\postie.exe -host:smtp.company.com -to:$TO -from:$FROM -replyto:$FROM -s:"$SUB" -msg:"$MSG" -$IMP' Shell $ShellString endif
_________________________
Austin Henderson
|
|
Top
|
|
|
|
#36742 - 2003-02-20 02:27 PM
Re: Monitor Connectivity on My Own Network ?
|
Austin
Seasoned Scripter
Registered: 2002-01-24
Posts: 439
|
Have the machine run a startup script that send an email is also an option if we are worried about the machine not actually logging into a network.
_________________________
Austin Henderson
|
|
Top
|
|
|
|
#36749 - 2003-02-21 10:11 AM
Re: Monitor Connectivity on My Own Network ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Ok, if the IP address you are looking for is 176.4.16.23 your script should look like this:
code:
Break ON $sIPAddress="176.4.16.23" While "true" Shell '%COMSPEC% /C ping -n 1 ' + $sIPAddress + ' | find "TTL=" >/dev/null' If @ERROR=0 $Null=MessageBox("IP Address " + $sIPAddress + " is responding","It's Alive!") Exit 0 EndIf Sleep(60) Loop
If you know the host name it will look like this (assuming the host is called "thehost.acme.com):
code:
Break ON $sIPAddress="thehost.acme.com" While "true" Shell '%COMSPEC% /C ping -n 1 ' + $sIPAddress + ' | find "TTL=" >/dev/null' If @ERROR=0 $Null=MessageBox("IP Address " + $sIPAddress + " is responding","It's Alive!") Exit 0 EndIf Sleep(60) Loop
quote: Adn this will put you into a continous loop: While "true"
It's supposed to
The "Exit 0" will exit the script once the ping succeeds, so the alert will only appear once. If the "Exit 0" is removed, the script will message (or beep or whatever) every 60 seconds.
AzzerShaw, the error you are getting probably means one of three things: 1) You don't have "ping" in your PATH 2) You don't have "find" in your PATH 3) You don't have %COMSPEC% set correctly
|
|
Top
|
|
|
|
#36753 - 2003-02-21 11:11 AM
Re: Monitor Connectivity on My Own Network ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
You want to swap the order so that it runs:
code:
PLAY "v:\asterix.wav" $Null=MessageBox("IP Address" + $sIPAddress + " is responding!", "Your box title")
Otherwise the sound won't play until you've confirmed the dialogue prompt. [ 21. February 2003, 11:12: Message edited by: Richard H. ]
|
|
Top
|
|
|
|
#36754 - 2003-02-21 11:44 AM
Re: Monitor Connectivity on My Own Network ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Ok, lots of enhancements:
code:
Updated code in later post
Change the value for $sSound to the path to your sound file. Change the values for $sAddressList to all the host names or IP addresses you want to monitor.
When you run the script it will check every $iInterval seconds for the hosts. If it finds any it will 1) Play your sound 2) Display a list of all the machines which responded on the console with the time. 3) Pop-up the same message in a message-box, which will stay on screen for 5 seconds. [ 21. February 2003, 12:45: Message edited by: Richard H. ]
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1110 anonymous users online.
|
|
|