#include 'Array.au3'
#include <GuiListView.au3>
Opt('GUIOnEventMode', 1)
_init()
AdlibRegister("_ping_srv", 300000)
_ping_srv()
Global $timer = TimerInit()
Do
Until 0
;===============================================================================
; Description: Инициализация программы
;===============================================================================
Func _init()
Global Const $Green = 0x00ff00
Global Const $Yellow = 0xffff00
Global Const $Red = 0xff0000
Global Const $ES_AUTOVSCROLL = 64
Global Const $ES_READONLY = 2048
Global Const $WS_VSCROLL = 0x00200000
Global Const $WS_EX_STATICEDGE = 0x00020000
Global Const $GUI_DOCKRIGHT = 0x0004
Global Const $GUI_EVENT_CLOSE = -3
;~ размеры рабочей части окна
Const $lw_name_width = 110
Const $lw_ip_width = 100
Const $lw_width = 5 + $lw_name_width + $lw_ip_width
Const $edit_width = 200
Const $global_width = $lw_width + $edit_width + 15
Const $global_height = 950
Global $Form1 = GUICreate("Тест соединения", $global_width, $global_height, -1, -1)
Global $listview = GUICtrlCreateListView("имя|ip", 5, 5, $lw_width, $global_height - 10)
_GUICtrlListView_RegisterSortCallBack($listview);сортировка столбцов
_GUICtrlListView_SetColumnWidth($listview, 0, $lw_name_width)
_GUICtrlListView_SetColumnWidth($listview, 1, $lw_ip_width)
;~ читаем список оборудования
Global $serverslist = IniReadSection('test_Servers.ini', 'servers')
_ArrayDelete($serverslist, 0) ; удаляем строку с размерностью массива
ReDim $serverslist[UBound($serverslist)][3]
Local $i
For $i = 0 To UBound($serverslist) - 1
$serverslist[$i][2] = GUICtrlCreateListViewItem($serverslist[$i][0] & "|" & $serverslist[$i][1], $listview)
Next
;~ окно вывода статистики
Global $Edit1 = GUICtrlCreateEdit("", $lw_width + 10, 5, $edit_width, $global_height - 10, $ES_AUTOVSCROLL + $ES_READONLY + $WS_VSCROLL, $WS_EX_STATICEDGE)
GUICtrlSetData($Edit1, @YEAR & '.' & @MON & '.' & @MDAY & ' ' & @HOUR & ':' & @MIN & ' ' & '> начало работы')
;~ GUICtrlSetResizing($Edit1, $GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
;~ котекстное меню
Global $contextmenu = GUICtrlCreateContextMenu($listview)
GUICtrlSetOnEvent($listview, '_sort_listview')
Global $remoteconnect_term = GUICtrlCreateMenuItem("Подключить MSTSC", $contextmenu)
GUICtrlSetOnEvent($remoteconnect_term, '_remote_connect_term')
GUICtrlCreateMenuItem("", $contextmenu) ; create a separator line
Global $Call_Contacts = GUICtrlCreateMenuItem("Контактное лицо", $contextmenu)
GUICtrlSetOnEvent($Call_Contacts, '_Call_Contacts')
GUICtrlCreateMenuItem("", $contextmenu) ; create a separator line
Global $ping_short = GUICtrlCreateMenuItem("Ping короткий", $contextmenu)
GUICtrlSetOnEvent($ping_short, '_ping_vserv')
Global $ping_long = GUICtrlCreateMenuItem("Ping длинный", $contextmenu)
GUICtrlSetOnEvent($ping_long, '_ping_vserv_long')
GUICtrlCreateMenuItem("", $contextmenu) ; create a separator line
Global $tracert = GUICtrlCreateMenuItem("Tracert", $contextmenu)
GUICtrlSetOnEvent($tracert, '_tracert')
GUICtrlCreateMenuItem("", $contextmenu) ; create a separator line
Global $porttestselected = GUICtrlCreateMenuItem("проверка портов: набор портов", $contextmenu)
GUICtrlSetOnEvent($porttestselected, '_porttestselected')
Global $porttest = GUICtrlCreateMenuItem("проверка портов: 1-1024 ~ 2 минуты", $contextmenu)
GUICtrlSetOnEvent($porttest, '_porttest')
Global $contextmenu2 = GUICtrlCreateContextMenu($Edit1)
Global $remoteconnect_term = GUICtrlCreateMenuItem("Очистить", $contextmenu2)
GUISetOnEvent($GUI_EVENT_CLOSE, '_IC_Exit')
GUISetState(@SW_SHOW)
EndFunc ;==>_init
;===============================================================================
; Description: Выход
;===============================================================================
Func _IC_Exit()
Exit
EndFunc ;==>_IC_Exit
;===============================================================================
; Description: Ping выбранного видеосервера
;===============================================================================
Func _ping_vserv()
Local $temp = StringSplit(GUICtrlRead(GUICtrlRead($listview)), '|')
Run(@ComSpec & " /c " & "echo connect test " & $temp[1] & "& ping " & $temp[2] & " & pause")
$temp = ''
EndFunc ;==>_ping_vserv
Func _ping_vserv_long()
Local $temp = StringSplit(GUICtrlRead(GUICtrlRead($listview)), '|')
Run(@ComSpec & " /c " & "echo connect test " & $temp[1] & " & ping -t " & $temp[2])
$temp = ''
EndFunc ;==>_ping_vserv_long
;===============================================================================
; Description: Трассировка
;===============================================================================
Func _tracert()
Local $temp = StringSplit(GUICtrlRead(GUICtrlRead($listview)), '|')
Run(@ComSpec & " /c " & "echo tracert test " & $temp[1] & "& tracert " & $temp[2] & " & pause")
$temp = ''
EndFunc ;==>_tracert
;===============================================================================
; Description: подключение к терминальному серверу
;===============================================================================
Func _remote_connect_term()
Local $temp = StringSplit(GUICtrlRead(GUICtrlRead($listview)), '|')
Run("mstsc.exe /v:" & $temp[2])
EndFunc ;==>_remote_connect_term
;===============================================================================
; Description: отсортировать ListView
;===============================================================================
Func _sort_listview()
_GUICtrlListView_SortItems($listview, GUICtrlGetState($listview))
EndFunc ;==>_sort_listview
;===============================================================================
; Description: проверка связи пингом
;===============================================================================
Func _ping_srv()
Local $i
For $i = 0 To UBound($serverslist) - 1
If Ping($serverslist[$i][1], 50) Or Ping($serverslist[$i][1], 200) Or Ping($serverslist[$i][1], 500) Or Ping($serverslist[$i][1], 2000) Then
GUICtrlSetBkColor($serverslist[$i][2], $Green) ; зеленый - пингуется
Else
GUICtrlSetBkColor($serverslist[$i][2], $Yellow) ; желтый - не пингуется
GUICtrlSetData($Edit1, @YEAR & '.' & @MON & '.' & @MDAY & ' ' & @HOUR & ':' & @MIN & ' > ' & $serverslist[$i][0] & @CRLF & GUICtrlRead($Edit1))
TrayTip('', 'нет связи c ' & $serverslist[$i][0], 5)
;~ Beep(500, 150)
;~ Beep(400, 150)
;~ Beep(900, 150)
;~ Beep(600, 150)
;~ Beep(700, 150)
;~ Beep(800, 150)
;~ Beep(900, 150)
EndIf
Next
;~ Local $temp=IniRead('Servers.ini','Video_call',$vserverslist[$number][1],"")
;~ $temp=StringSplit($temp,',')
;~ if $temp[0]=4 Then TrayTip('проблемы с сервером ' & $vserverslist[$number][1] & ' просьба связаться c:', _
;~ 'контактное лицо :' & @TAB & $temp[1] & @CRLF & _
;~ 'мобильный телефон:' & @TAB & $temp[2] & @CRLF & _
;~ 'IP телефон:' & @TAB & @TAB & $temp[3] & @CRLF & _
;~ 'городской телефон:' & @TAB & $temp[4] & @CRLF, 30, 2)
;~ if IniRead('Servers.ini','Video_gate',$vserverslist[$number][0],"") And not ping(IniRead('Servers.ini','Video_gate',$vserverslist[$number][0],"")) Then; сопоставляем имена с IP
;~ GUICtrlSetBkColor($vserverslist[$number][3],$Red) ; Красный - нет канала
;~ EndIf
;~ EndIf
;~ EndIf
EndFunc ;==>_ping_srv
;===============================================================================
; Description: сканер открытых портов
;===============================================================================
Func _porttest()
Local $sIPAddress = StringSplit(GUICtrlRead(GUICtrlRead($listview)), '|')[2]
Local $i, $j=0, $ports[0][2]
TCPStartup()
For $i = 1 To 1024
Local $iSocket = TCPConnect($sIPAddress, $i)
If Not @error Then
ReDim $ports[UBound($ports) + 1][2]
$ports[$j][0] = $i
$ports[$j][1] = IniRead('test_servers.ini', 'ports',$i,'')
$j = $j + 1
EndIf
TCPCloseSocket($iSocket)
Next
TCPShutdown()
_ArrayDisplay($ports)
EndFunc ;==>_porttest
Func _porttestselected()
Local $sIPAddress = StringSplit(GUICtrlRead(GUICtrlRead($listview)), '|')[2]
local $portslist = IniReadSection('test_Servers.ini', 'portsselected')
Local $i, $j=0, $ports[0][2]
TCPStartup()
For $i=1 to $portslist[0][0]
Local $iSocket = TCPConnect($sIPAddress, $portslist[$i][0])
If Not @error Then
ReDim $ports[UBound($ports) + 1][2]
$ports[$j][0] = $portslist[$i][0]
$ports[$j][1] = $portslist[$i][1]
$j = $j + 1
EndIf
TCPCloseSocket($iSocket)
Next
TCPShutdown()
_ArrayDisplay($ports)
EndFunc
;===============================================================================
; Description: контакты
;===============================================================================
Func _Call_Contacts()
Local $look_for = StringSplit(IniRead('test_servers.ini', 'contacts', StringSplit(GUICtrlRead(GUICtrlRead($listview)), '|')[1], ""), ',')
If $look_for[0] = 3 Then MsgBox('', 'контактные данные на ' & StringSplit(GUICtrlRead(GUICtrlRead($listview)), '|')[1], _
'контактное лицо :' & @TAB & @TAB & $look_for[1] & @CRLF & _
'мобильный телефон:' & @TAB & $look_for[2] & @CRLF & _
'городской телефон:' & @TAB & @TAB & $look_for[3] & @CRLF)
EndFunc ;==>_Call_Contacts