gdijim Posted March 7, 2007 Share Posted March 7, 2007 I work for an orginization that has lots and lots of multiple sites. Right now, I use a simple batch file to check connectivity to several site devices that we know exist on every site when users call in and complain - this helps narrow down troubleshooting. batch code: CODE pingsite.bat @if "%1"=="" goto usage @echo You are looking for store number %1... @echo Checking... START "rtr%1a" ping rtr%1a -t START "nt%1a" ping nt%1a -t START "cat%1a" ping cat%1a -t START "pc%1b" ping pc%1b -t START "pc%1c" ping pc%1c -t START "air%1a" ping air%1a -t START "air%1b" ping air%1b -t START "air%1c" ping air%1c -t GOTO End :usage @cls @echo. @echo Network Analyzing Tool @echo %0 automates pinging routers, switches, nt server, pc's, etc @echo at any 4 digit site. Enter 4 digit site number @echo on command line, adding leading zeroes as needed. @echo Examples: @echo to check 1853, enter %0 1853 on the command line @echo to check 342, enter %0 0342 on the command line @echo to check 20, enter %0 0020 on the command line @echo A DOS command box will open for each ping command issued @echo To see all open command boxes at once in Windows 2000, @echo right-click on the taskbar and select Tile Vertically. To @echo restore, right-click on the taskbar and select Undo Tile. @echo. :end Esentially, you type in pingnet.bat <four digit site number> and it pings the devices listed by replacing the %1 variable with the XXXX argument you fed after the command. Because all our devices contain the four digit site number in their names, this works pretty well. I can't tile and close the opened windows effectively with native Windows 2000, which my orginization uses in Support (VERY big ) so I'm trying to develop a work around. I also have some other commands that mimic this output, such as a PSinternals batch to check all users on all PC's for a site that could also benefit from this logic. My searching of the forums and help file tell me that WinList is probably what I'm going to want to use. This bit of uber code came from Smoke_N, minorly modified with my settings and I think it's pretty much what I need to find all the windows: CODE$var = WinList() For $i = 1 To $var[0][0] If $var[$i][0] <> "" And BitAND(WinGetState($var[$i][1]), 2) Then If StringInStr($var[$i][0], 'rtr') Then _rtrCheck($var[$i][0], $var[$i][1]) ElseIf StringInStr($var[$i][0], 'pc') Then _pcCheck($var[$i][0], $var[$i][1]) ElseIf StringInStr($var[$i][0], 'air') Then _airCheck($var[$i][0], $var[$i][1]) ElseIf StringInStr($var[$i][0], 'nt') Then _ntCheck($var[$i][0], $var[$i][1]) EndIf EndIf Next Func _rtrCheck($sWin, $hWnd) ;If Title reads("rtr") then MsgBox(0, "title", "rtr was found" & @CR & 'WinName = ' & $sWin & @CR & 'Handle = ' & $hWnd) EndFunc ;==>_rtrCheck Func _pcCheck($sWin, $hWnd) ;If Title reads("pc") then MsgBox(0, "title", "pc was found" & @CR & 'WinName = ' & $sWin & @CR & 'Handle = ' & $hWnd) EndFunc ;==>_pcCheck Func _airCheck($sWin, $hWnd) ;If Title reads("air") then MsgBox(0, "title", "air was found" & @CR & 'WinName = ' & $sWin & @CR & 'Handle = ' & $hWnd) EndFunc ;==>_airCheck Func _ntCheck($sWin, $hWnd) ;If Title reads("nt") then MsgBox(0, "title", "COM was found" & @CR & 'WinName = ' & $sWin & @CR & 'Handle = ' & $hWnd) EndFunc ;==>_ntCheck So this gets me the WinNames of all the windows that contain this information. Really nifty! Couple questions - How can I make the macro detect how many windows opened when I ran the batch and grab only those windows information? Can I make it compare the first 3 characters of the window rather than the whole window's name? I need to be able to have the macro tile the windows horizonitally - I've hunted high and low, and found only a couple people who were interested in this, but I really really am!! It looks like I need to create an array and then have it generate cooirdinates based on the amount of windows opened and compared against the screen's resolution, and then winmove them one at a time. Can ANYONE tell me where I might get started with this part? I also need a command to close all the windows at once. Thanks very much, Jim Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 7, 2007 Moderators Share Posted March 7, 2007 I'm curioius... why not just use the internal Ping command and do everything internally without the cmd windows? You could store your results however you want that way. Also you could use @Comspec + ping and whatever you wanted with stdoutread and store even more details if you wanted. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gdijim Posted March 7, 2007 Author Share Posted March 7, 2007 I need a real-time display of all those devices - that way, say I'm troubleshooting with a customer to bring a site up after a power outage or something, I can watch as the devices come up, bounce, show bad latency, etc. This gives me lots of visibility into what's going on real time. Plus, since some devices are plugged into other devices (switches, routers, etc) it shows me where the failure point may be. Is there a way to do that with those commands? Thanks! Jim Link to comment Share on other sites More sharing options...
PaulIA Posted March 7, 2007 Share Posted March 7, 2007 I need a real-time display of all those devices - that way, say I'm troubleshooting with a customer to bring a site up after a power outage or something, I can watch as the devices come up, bounce, show bad latency, etc. This gives me lots of visibility into what's going on real time. Plus, since some devices are plugged into other devices (switches, routers, etc) it shows me where the failure point may be.Is there a way to do that with those commands?Thanks!JimThere is a way to run a console command and read resultant output of that command in AutoIt. What I would do is make a GUI where I could put in the store number, parse the results and display them. With a little work, you could put the results in a ListView and view real time stats on all your stores.I did a demo in Auto3Lib that shows how to execute a console command and read the ouput in real time using pipes. It might not be what you're looking for, but it might also give you some ideas. It's the Console.au3 file in the Pipes directory of Auto3Lib if you're interested. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 7, 2007 Moderators Share Posted March 7, 2007 This might give you an idea:http://www.autoitscript.com/forum/index.ph...st&p=313340 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gdijim Posted March 8, 2007 Author Share Posted March 8, 2007 Smoke_n, you're awsome sir - Going to play with this for awhile and see if I can't get what I'm looking for out of it. Thanks! Jim Link to comment Share on other sites More sharing options...
Shevilie Posted March 8, 2007 Share Posted March 8, 2007 Sorry Smoke_N but I just HAD to... I had too see if I could make the program This is scraps, and a lot of testing should be done and a lot of checking the user for input etc should be done - but this should work Pinger.exe expandcollapse popup#NoTrayIcon $ip = $CmdLine[1] $box = $CmdLine[2] $box = Int($box) $winname = $CmdLine[3] While WinExists("Pingstat - RUNNING") $iPID = Run(@ComSpec & ' /c ping ' & $ip & ' -n 1', '', @SW_HIDE, 2) $sHold = '' While Not @error $sHold &= StdoutRead($iPID) WEnd $pos = StringInStr($sHold, @CRLF, 0, 3) $sHold = StringTrimLeft($sHold, $pos) $pos = StringInStr($sHold, @CRLF) $sHold = StringLeft($sHold, $pos - 2) $temptext = ControlGetText("Pingstat", "", $box) If WinExists("Pingstat - RUNNING") Then ControlSetText("Pingstat", "", $box, @HOUR & ":" & @MIN & ":" & @SEC & " - " & $sHold & @CRLF & $temptext) ControlSend("Pingstat", "", $box, "{END}") EndIf WEndoÝ÷ ØÆ¢ì^jëh×6#include <GUIConstants.au3> GUICreate("Pingstat", 320, 530) $number = GUICtrlCreateInput('', 10, 10, 100, 20) $btnStart = GUICtrlCreateButton ('Start Ping', 120, 9 , 60, 22) $output1 = GUICtrlCreateEdit('', 10, 40, 300, 50, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) $output2 = GUICtrlCreateEdit('', 10, 100, 300, 50, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) $output3 = GUICtrlCreateEdit('', 10, 160, 300, 50, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) $output4 = GUICtrlCreateEdit('', 10, 220, 300, 50, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) $output5 = GUICtrlCreateEdit('', 10, 280, 300, 50, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) $output6 = GUICtrlCreateEdit('', 10, 340, 300, 50, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) $output7 = GUICtrlCreateEdit('', 10, 400, 300, 50, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) $output8 = GUICtrlCreateEdit('', 10, 460, 300, 50, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY) $winname = AutoItWinGetTitle() GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE;Exit form GUI ExitLoop Case $msg = $btnStart If WinExists("Pingstat - RUNNING") Then WinSetTitle("Pingstat - RUNNING", "", "Pingstat - STOPPED") Else WinSetTitle("Pingstat", "", "Pingstat - RUNNING") Run("pinger.exe rtr" & GUICtrlRead($number) & "a " & $output1 & " Pingstat") Run("pinger.exe nt" & GUICtrlRead($number) & "a " & $output2 & " Pingstat") Run("pinger.exe cat" & GUICtrlRead($number) & "a " & $output3 & " Pingstat") Run("pinger.exe pc" & GUICtrlRead($number) & "b " & $output4 & " Pingstat") Run("pinger.exe pc" & GUICtrlRead($number) & "c " & $output5 & " Pingstat") Run("pinger.exe air" & GUICtrlRead($number) & "a " & $output6 & " Pingstat") Run("pinger.exe air" & GUICtrlRead($number) & "b " & $output7 & " Pingstat") Run("pinger.exe air" & GUICtrlRead($number) & "c " & $output8 & " Pingstat") EndIf EndSelect WEnd Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 8, 2007 Moderators Share Posted March 8, 2007 Why are you sorry? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Shevilie Posted March 8, 2007 Share Posted March 8, 2007 Give fish - Teach to fish Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
dabus Posted March 9, 2007 Share Posted March 9, 2007 You may have a look at http://www.nagios.org if you want to have more monitoring.I know it's much more than you have asked for, but the possibillities are insane. I use it to watch all our computers here, so I know when services are up/down, apache and tomcat are running, drives are getting "full", get escalation-mails and sms... so that's pretty cool. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now