' logticker.vbs ' updated by WIPAT 2554-12-29 ' log server ip MyHost = "10.0.6.2" ' wait time send ticket in msec defualt 120000 msec = 120 sec = 2 minute WaitMsec = 120000 ' change log header MyMessage = "LOGTICKER:" strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 'check curl.exe MyFile="C:\curl.exe" Set fs = CreateObject("Scripting.FileSystemObject") if (fs.FileExists(MyFile)) then MyWget = "C:\curl -o NUL -s " else wscript.quit() End if 'Get DATE and TIME Set colItems = objWMIService.ExecQuery( _ "Select * from Win32_LocalTime") For Each objItem in colItems exit for Next StartTime = objItem.Year & Right("0" & objItem.Month,2) _ & Right("0" & objItem.Day,2) & Right("0" & objItem.Hour,2) _ & Right("0" & objItem.Minute,2) & Right("0" & objItem.Second,2) MyMessage = MyMessage & StartTime 'Get MAC and IP address Set colItems = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") CheckOK = "" For Each objItem in colItems For i=0 to UBound(objItem.IPAddress) if not isnull(objItem.DefaultIPGateway) then CheckOK="YES" exit for end if Next if CheckOK <> "" then exit for end if Next strMACAddress = objItem.MACAddress Mac = split(objItem.MACAddress,":") MAC_address = Mac(0)+Mac(1)+Mac(2)+Mac(3)+Mac(4)+Mac(5) Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") For Each objItem in colItems If objItem.MACAddress = strMACAddress Then For Each strIPAddress in objItem.IPAddress exit for Next End If Next MyMessage = MyMessage & ":" & MAC_address & ":" & strIPAddress Set WshShell = WScript.CreateObject("WScript.Shell") MyMessage = MyMessage + ":" + WshShell.Environment("PROCESS").Item("USERNAME") + ":"_ + WshShell.Environment("PROCESS").Item("COMPUTERNAME") Header = MyMessage TickerFile= WshShell.Environment("PROCESS").Item("TEMP") _ + "\ticker-" + WshShell.Environment("PROCESS").Item("USERNAME") + ".txt" Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.CreateTextFile(TickerFile, True) a.WriteLine(Header) a.Close MyMessage = Header & ":LOGON:" & StartTime & ":0:" ' Wscript.Echo MyMessage 'MyWget = """C:\Program Files\GnuWin32\bin\wget"" -O NUL -q " MyURL = "http://" + Myhost +"/ticker/myticker.php?LOG=" + MyMessage Set WshShell = wscript.createobject("wscript.shell") 'Set oExec = WshShell.Exec(MyWget + " " + MyURL) wshshell.run MyWget + " " + MyURL,0, false Do While 1 WScript.Sleep WaitMsec 'Get DATE and TIME Set colItems = objWMIService.ExecQuery( _ "Select * from Win32_LocalTime") For Each objItem in colItems exit for Next CurrentTime = objItem.Year & Right("0" & objItem.Month,2) _ & Right("0" & objItem.Day,2) & Right("0" & objItem.Hour,2) _ & Right("0" & objItem.Minute,2) & Right("0" & objItem.Second,2) AA = 3600*Mid(StartTime,9,2) + 60*Mid(StartTime,11,2) + Right(StartTime,2) BB = 3600*Mid(CurrentTime,9,2) + 60*Mid(CurrentTime,11,2) + Right(currentTime,2) if AA > BB Then BB = BB + 86400 Usage = BB - AA MyMessage = Header & ":ALIVE:" & CurrentTime & ":" & Usage & ":" ' Wscript.Echo MyMessage MyURL = "http://" + Myhost +"/ticker/myticker.php?LOG=" + MyMessage Set WshShell = wscript.createobject("wscript.shell") ' Set oExec = WshShell.Exec(MyWget + " " + MyURL) wshshell.run MyWget + " " + MyURL,0, false Loop