??ÔÚ´óÖÐÐÍÆóÒµÐÅϢϵͳÖУ¬¶Ô¿Í»§¶ËPCµÄ¹ÜÀí£¬ÍùÍùÊÇÈÝÒ׳öÏÖÎÊÌâµÄ»·½Ú¡£Òò´Ë£¬ºÜ¶à´ó¹«Ë¾ÒýÈëÁ˸÷ÖÖ·Ö²¼Ê½µÄ¹ÜÀíϵͳ£¬ÀýÈç·À²¡¶¾·½ÃæµÄNorton AntiVirus£¬BlackICE·À»ðǽ£¬Î¢ÈíµÄ SMS (System Management Server)£¬µÈµÈ£¬ÕâЩϵͳ¶¼»áÔÚ¿Í»§¶ËµÄϵͳ°²×°ÏàÓ¦µÄ¿Í»§¶ËÈí¼þ£¬Ò»°ã¶¼ÊÇÒÔ·þÎñµÄÐÎʽ³öÏÖ£¬µ«ÊÇÓÉÓÚÖÖÖÖÔÒò£¬ÕâЩ·þÎñ»áÍ£Ö¹ÔËÐлòÕ߸ÿͻ§»ú¸ù±¾Ã»Óа²×°ÕâЩ¿Í»§¶Ë·þÎñ£¬ÕâÑù¹ÜÀíϵͳ¾Í³öÏÖÁËÊè©£¬ÓпÉÄÜÔì³ÉÎÊÌ⣬ÈçÒòÎÞ·¨·ÀÓù²¡¶¾¶ø³ÉΪ²¡¶¾Ô´£¬ÎÞ·¨Îª¸Ã¿Í»§¶Ë·¢²¼Èí¼þ£¬ÎÞ·¨¹ÜÀí¿Í»§PCµÈµÈ¡£ÔÚ´Ë£¬ÎÒÃÇÌṩһ¸ö·½°¸£¬¿ÉÒÔ¶¨Ê±°´ÕÕIPµØַɨÃèÍøÂ磬±¨¸æ³öÄÇЩϵͳµÄÌض¨µÄ·þÎñµÄ״̬¡£ ??Õâ¸ö·½°¸Ê¹ÓÃÁËMicrosoft.NET¼¼Êõ£¬Í¬Ê±Ò²Óõ½ÁË.NET FrameworkÖеģ¬ADO.NET £¬WMI management£¬XML¡£ÆäºËÐÄÊÇÒ»¸öÓÉVB.NETдµÄ³ÌÐòÒÔ¼°ËüµÄÁ½¸öÅäÖÃÎļþ£¬ÅäÖÃÎļþΪXML¸ñʽ£¬¸Ã³ÌÐò°´IPɨÃèÍøÂ磬µÃµ½Ã¿¸öϵͳµÄ·þÎñ µÄ״̬£¬Èç¹ûIPµØַûÓжÔӦϵͳ£¬ÔòºöÂÔ¸ÃIP£¬Õë¶ÔûÓа²×°·þÎñ»ò·þÎñÍ£Ö¹µÄϵͳÎÒÃÇÔÚÁíÒ»¸öÏß³ÌÖÐÔËÐÐNBTSTATÃüÁµÃµ½Æä»úÆ÷Ãû£¬Óû§Ãû£¬MACµØÖ·ÓòµÈÐÅÏ¢£¬ÒÔ±ãÎÒÃÇÕÒµ½»úÆ÷½â¾öÎÊÌâ¡£Æä´ÎΪÁ˱£´æɨÃèµÄ½á¹û£¬ÎÒÃÇÐèÒªÒ»¸öºÜСµÄÊý¾Ý¿âMS-Access»òMS-SQL server¶¼¿ÉÒÔ£¬±¾ÎÄʹÓÃSQL2000 ¡£×îºóΪÁ˳ÊÏÖ³öɨÃèµÄ½á¹û£¬ÒÔ±ãÎÒÃDzÉÈ¡Ðж¯£¬ÕâÀïÎÒÃÇʹÓÃÍøÒ³µÄÐÎʽ°ÑÊý¾Ý¿âÖеĽá¹ûÕ¹ÏÖ³öÀ´¡£ ??1£® VB.NET³ÌÐò ??¸Ã³ÌÐòʹÓÃÁ½¸öXML¸ñʽµÄÅäÖÃÎļþ£¬µ±³ÌÐòÆô¶¯Ê±»á¶ÁÈëÕâЩÅäÖá£ÆäÖÐÒ»¸öÎļþ¶¨ÒåÁËÐèҪɨÃèµÄÍø¶Î£¬°üÀ¨ÅųýÔÚÍâµÄµØÖ·¶Î¡£ÁíÒ»¸öÎļþ¶¨ÒåÁËÁ¬½ÓÊý¾Ý¿âµÄÐÅÏ¢£¬ÒÔ¼°Êý¾Ý±íµÄ¶¨Òå¡£ÕâÁ½¸öÎļþµÄÄÚÈÝÈçÏ£º ??£¼IPLIST£¾ £¼IP LANID="192.168.100." £¾£¼EXP L="1" H="30"/£¾£¼/IP£¾ £¼IP LANID="192.168.101." /£¾ £¼IP LANID="192.168.102." /£¾ £¼IP LANID="192.168.103." /£¾ £¼IP LANID="192.168.104." £¾£¼EXP L="1" H="40"/£¾£¼/IP£¾ ??£¼/IPLIST£¾ ??¸ÃÎļþ¶¨Ò彫ҪɨÃè5¸öÍø¶Î£¬ÆäÖÐÁ½¸öÍø¶ÎÓÐЩµØÖ·ÐèÒªÅųýÔÚÍ⣨·ÖÅä¸ø´òÓ¡»úµÈÉ豸£©£¬¶ÔÓÚ192.168.100¶Î£¬ÎÒÃÇÅųý´Ó1µ½30£¬¶ÔÓÚ192.168.104¶ÎÎÒÃÇÅųý1µ½40¡£ ?? DBServer DB REPORT REPORT SERVICE ?? ??¸ÃÎļþ¶¨ÒåÁËÁ¬½ÓÊý¾Ý¿âËùÐèµÄÐÅÏ¢¡£ ??: SCANSERVICEÊý¾Ý¿âµÄ·þÎñÆ÷Ãû ??: SCANSERVICEÊý¾Ý¿âÃû ??:ÓÃÓÚ¸üÐÂSCANSERVICEÊý¾Ý¿âµÄÊý¾Ý¿âÓû§Ãû ??:ÓÃÓÚ¸üÐÂSCANSERVICEÊý¾Ý¿âµÄÊý¾Ý¿âÓû§µÄÃÜÂë ??:¸ÃTAGµÄ inner ¶¨ÒåÁËÎÒÃÇÏ£ÍûɨÃèµÄServiceµÄÃû×Ö£¬ÕâÀïÎÒÃǼٶ¨Ï£ÍûɨÃè·þÎñÃûΪSERVICE ??¸ÃTAGµÄÊôÐÔ¶¨ÒåÁËÊý¾Ý¿âÖбíÃû£¬¸Ã±íÓÃÓÚ±£´æɨÃè½á¹û ??ÒÔÏÂÊdzÌÐò´úÂ룺 Imports System.Xml Imports System.Threading Public Class GetStatus Private IServiceName As String ¡®·þÎñµÄÃû³Æ Private IMachineIP As String ¡®IPµØÖ· Private ITable As String ¡®ÔÚDATESETÖеıíÃû '¹¹Ô캯Êý Sub New(ByVal Ip As String, ByVal SvcName As String, ByVal updatetable As String) IMachineIP = Ip IServiceName = SvcName ITable = updatetable End Sub ¡®Ã¿¸öÏß³ÌËùÔËÐеķ½·¨£¬ÓÃÓڵõ½·þÎñµÄ״̬£¬Èç¹û״̬²»Õý³£Ôò´¥·¢ÁíÒ»Ï̵߳õ½¸ÃIPµÄÐÅÏ¢ Sub GetStausF() Dim ServiceP As New ServiceController() ¡®ÊµÀý»¯Ò»¸öServiceControllerÀà ServiceP.MachineName = IMachineIP ServiceP.ServiceName = IServiceName Dim myRow As DataRow Dim status As String Dim Run As Boolean = False myRow = ds.Tables(ITable).NewRow Try If ServiceP.Status.ToString <> "Running" Then status = ServiceP.Status.ToString¡®Èç¹û״̬²»ÊÇRUNNINGÔò½«×´Ì¬¸³Óè×Ö·û´®±äÁ¿ Else Run = True ¡®Èç¹û״̬ΪRUNNING,Ôò²»×öÈκÎÊ End If Catch er As Exception ¡®ÒÔÏ´¦ÀíÈ¡µÃ״̬ʱºò·¢ÉúµÄÒì³£ status = Left(er.Message, 35) If InStr(status, "Service Control Manager") = 0 Then status = "Not installed or open service failed" ¡®Ã»Óа²×°¸Ã·þÎñ ElseIf InStr(er.Message, "Manager") > 0 Then status = "Can not detected" ¡®·þÎñµÄ״̬²»¿ÉµÃ End If End Try ServiceP.Close() ¡®¹Ø±ÕServiceControllerʵÀý ¡®ÒÔÏÂÅжÏÈç¹û״̬²»ÊÇRUNNING,Ôò¼Ç¼¸Ãϵͳ£¬²¢´¥·¢Ï̵߳õ½ËüµÄÏêϸÐÅÏ¢¡£ If Not Run Then myRow("msg") = status myRow("ip") = IMachineIP SyncLock GetType(AddRow) ¡®Îª±£Ö¤¶àÏß³ÌÇé¿öÏ£¬¶ÔDataSetÖ»ÓÐÒ»¸öд²Ù×÷£¬Ëø¶¨AddRowÀà Dim AddRowIns As New AddRow(myRow) '½«IPºÍ״̬ͨ¹ýÎÒÃÇ×Ô¼ºÐ´µÄAddRowÀà²åÈëDataSet End SyncLock ¡®´¥·¢ÁíÒ»Ïß³ÌÈ¡µÃ»úÆ÷ÐÅÏ¢ Dim HostInfo2 As New HostInfo(IMachineIP) Dim HostThr2 As New Thread(New ThreadStart(AddressOf HostInfo2.sysInfo)) HostThr2.Start() SyncLock GetType(HostInfoThreadCounter) HostInfoThreadCounter.counter += 1 ¡®Æô¶¯Ïß³ÌÊý¼Ó1 End SyncLock End If SyncLock GetType(StoppCounter) StopThr.AddStop() End SyncLock End Sub End Class ¡®¸ÃÀàÖ»ÓÐÒ»¸ö·½·¨£¬¾ÍÊǽ«Í£Ö¹µÄÏß³ÌÊý¼õ1 Class StoppCounter Sub AddStop() ThreadCounterStopped = ThreadCounterStopped + 1 End Sub End Class ¡®´ËÀàÓÃÓÚ½«ÒÑÓеÄÐвåÈëDataSet Class AddRow ¡®µÚÒ»¸ö¹¹Ô캯Êý£¬ÒÔ¹¹ÔìºÃµÄÐÐΪÊäÈë²ÎÊý Sub New(ByVal row As DataRow) Try ds.Tables(0).Rows.Add(row) Catch ee As Exception End Try End Sub ¡®µÚ¶þ¸ö¹¹Ô캯Êý£¬ÒÔ»úÆ÷ÃûÓû§ÃûµÈ×Ö·û´®Îª²ÎÊý£¬¸üÐÂÒÑÓеÄÐÐ Sub New(ByVal IP As String, ByVal user As String, ByVal hostname As String, ByVal Mac As String, ByVal domain As String, ByVal timeout As Char) Dim RowTimeOut As DataRow Try For Each RowTimeOut In ds.Tables(0).Select("IP='" & IP & "'") RowTimeOut.Item("LastUID") = user RowTimeOut.Item("Name") = hostname RowTimeOut.Item("Mac") = Mac RowTimeOut.Item("Domain") = domain RowTimeOut.Item("Timeout") = timeout 'Set timeout flag to this item Exit For 'just run once Next Catch er As Exception End Try End Sub End Class ¡®ÓÉÓÚƪ·ùÏÞÖÆ£¬ÕâÀïÊ¡ÂÔÁ˸ù¾ÝIPÈ¡µÃ»úÆ÷ÐÅÏ¢µÄÀàµÄ´úÂë¡£ Imports System.Threading ¡®ÓÃÓÚÖ§³Ö¶àÏß³Ì Imports System.Xml ¡®ÓÃÓÚ·ÖÎöXML¸ñʽµÄ²ÎÊýÎļþ Imports System.Data ¡®ÓÃÓÚ±£´æ½á¹ûµ½Êý¾Ý¿â Module Module1 Public ds As New DataSet() Public conn1 As SqlClient.SqlConnection ¡®Êý¾Ý¿âÁ¬½Ó Public ipf As String ¡®IPÁбíÎļþÃû Public dbf As String ¡®Êý¾Ý¿âÐÅÏ¢Îļþ Public ThreadCounterStopped As Integer Public StopThr As New StoppCounter() Sub Main() ¡®³ÌÐòÖ÷³ÌÐò Dim machineIP As String Dim iplistF As New Xml.XmlDocument() Dim iplist As Xml.XmlNode Dim ipitem As Xml.XmlNode Dim DBinfoF As New Xml.XmlDocument() Dim DBinfo As Xml.XmlNode Dim LanID As String Dim i As Integer Dim timestart As Integer Dim ThreadCounterStarted As Integer ThreadCounterStarted = 0 ThreadCounterStopped = 0 Dim server As String Dim database As String Dim uid As String Dim pwd As String Dim table As String Dim connstr, connstr1 As String Dim ServiceName As String Dim Purgestr As String Try DBinfoF.Load(dbf) ¡®¶ÁÈ¡Êý¾Ý¿âÐÅÏ¢Îļþ Catch nodb As Exception MsgBox(nodb.Message & "Wrong DB info file name.") Exit Sub End Try Try iplistF.Load(ipf) ¡®¶ÁÈ¡IPÁбíÎļþ Catch noip As Exception MsgBox(noip.Message & "Wrong IP list file name.") Exit Sub End Try ¡®·ÖÎöÊý¾Ý¿âÐÅÏ¢Îļþ DBinfo = DBinfoF.ChildNodes(0) server = DBinfo.ChildNodes(0).InnerText database = DBinfo.ChildNodes(1).InnerText uid = DBinfo.ChildNodes(2).InnerText pwd = DBinfo.ChildNodes(3).InnerText ServiceName = DBinfo.ChildNodes(4).InnerText table = DBinfo.ChildNodes(4).Attributes(0).Value ¡®¸ù¾Ý·ÖÎöËùµÃ£¬¹¹ÔìÁ¬½Ó×Ö·û´® connstr1 = "server=" & server & ";database=" & database & ";uid=" & uid & ";password=" & pwd conn1 = New SqlClient.SqlConnection(connstr1) ¡®ÊµÀý»¯Êý¾Ý¿âÁ¬½Ó conn1.Open() ¡®´ò¿ªÊý¾Ý¿âÁ¬½Ó Dim sa As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("select * from " & table, conn1) Dim combu As New SqlClient.SqlCommandBuilder(sa) sa.Fill(ds, table) ¡®Ìî³äDataSet ds.Clear() ¡®Çå¿Õ¾ÉµÄÊý¾Ý Dim IPAddress As String ¡®·ÖÎöIPÁбíÎļþ iplist = iplistF.ChildNodes(0) Dim Ai As Integer Dim ipexcepCount As Integer Dim ipexcep As Xml.XmlNode For Each ipitem In iplist.ChildNodes Dim Excep(2, 83) As Integer LanID = ipitem.Attributes(0).Value¡®µÃµ½ÍøÂçID For i = 2 To 254 '´Ó2µ½254£¬¸ù¾Ýÿ¸öÍøÂçID¹¹ÔìIPµØÖ· Ai = 0 ¡®ÒÔÏÂÅжÏÊÇΪÁËÌø¹ý±£ÁôµØÖ·¶Î If ipitem.HasChildNodes Then ipexcepCount = ipitem.ChildNodes.Count ReDim Excep(2, ipexcepCount - 1) For Each ipexcep In ipitem.ChildNodes Excep(0, Ai) = CInt(ipexcep.Attributes(0).Value) Excep(1, Ai) = CInt(ipexcep.Attributes(1).Value) Ai = Ai + 1 Next End If For Ai = 0 To ipexcepCount - 1 If i >= Excep(0, Ai) And i <= Excep(1, Ai) Then Console.WriteLine("Ìø¹ý±£ÁôµØÖ·£º " & LanID & i.ToString) GoTo SkipIP End If Next machineIP = LanID & i.ToString ¡®IPµØÖ· ¡®ÒÔÏ´¥·¢Ïß³ÌÒÔ£¬µÃµ½·þÎñ״̬ Dim getSt As New GetStatus(machineIP, ServiceName, table) Dim GetStThread As New Thread(New ThreadStart(AddressOf getSt.GetStausF)) GetStThread.Start() ThreadCounterStarted = ThreadCounterStarted + 1¡®Æô¶¯Ïß³ÌÊý¼Ó1 Console.WriteLine("Ïß³Ì" & machineIP & " Æô¶¯¡£¼ì²â " & ServiceName) ¡®Ã¿Æô¶¯100¸öỊ̈߳¬³ÌÐòÖ÷Ïß³ÌÍ£Ö¹15Ã룬±ÜÃâÌ«¶àÏß³ÌÔì³ÉÄÚ´æÒç³ö If (ThreadCounterStarted Mod 100) = 0 Then Console.WriteLine("µÈ´ý .......") Thread.CurrentThread.Sleep(15000) GC.Collect() 'force garbage collection to aviod outOfMemory when run with long IP list End If SkipIP: Next Next Console.WriteLine("Exiting program ...") 'ËùÓÐÏ̶߳¼ÒÑ´¥·¢ Finish: Thread.CurrentThread.Sleep(5000) ¡®ÒÔϳÌÐòµÈ´ýËùÓÐÏ߳̽áÊø GC.Collect() If ThreadCounterStopped = ThreadCounterStarted And HostInfoThreadCounter.counter = HostInfoThreadCounter.counterSTOP Then¡®Èç¹û´¥·¢Ï̵߳ÈÓÚ½áÊøÏß³Ì Dim row As Data.DataRow For Each row In ds.Tables(table).Rows row.Item("SysTime") = Now Next Purgestr = "delete " & table Dim com1 As New SqlClient.SqlCommand(Purgestr, conn1) com1.ExecuteNonQuery() ¡®É¾³ý¾É¼Ç¼ sa.InsertCommand = combu.GetInsertCommand sa.Update(ds, table) ' ½«Ð¼Ç¼дÈëÊý¾Ý¿â Else GoTo Finish ' goto finish and wait another 30 seconds End If End Sub ??¿ÉÒÔÀûÓÃÈçÏÂÃüÁîÔÚDOS´°¿ÚÆô¶¯¸Ã³ÌÐò¡£ ??Scanservice -i iplist.xml -d dbinfo.xml ??2£® SCANSERVICE Êý¾Ý¿â ??¸ÃÊý¾Ý¿â±£´æ±£´æ³ÌÐòÔËÐнá¹û£¬ÒÔ±ãÓÃWEBµÈ·½Ê½Õ¹ÏÖ³öÀ´¡£ÒÔÏÂÊǽ¨Á¢±íµÄ½Å±¾£¬°üº¬ÓòÃû£¬Óû§Ãû£¬»úÆ÷Ãû£¬IPÒÔ¼°·þÎñ״̬¡£ ??CREATE TABLE [dbo].[Service] ( [IP] [varchar] (50) NULL , [״̬] [varchar] (50) NULL , [Óû§Ãû] [varchar] (50) NULL , [»úÆ÷Ãû] [varchar] (50) NULL , [MACµØÖ·] [varchar] (50) NULL , [Óò] [varchar] (50) NULL , [³¬Ê±] [varchar] (10) NULL , [ʱ¼ä°²] [DateTime] (8) NULL , ) ??×ܽá: ??ÒÔÉÏÊÇÒ»¸öÍêÕûµÄ·½·¨£¬Ò²ÊDZȽϼòµ¥Ã÷ÎúµÄ½â¾ö·½·¨£¬Èç¹ûÒªÇó¼¼ÇɺÍÐÔÄܵĻ°£¬»¹ÓÐһЩµØ·½¿ÉÒÔ×öЩ¸Ä½ø£¬±ÈÈç¶ÔÏ̳߳صÄʹÓá£ÁíÍ⻹ÓÐһЩ·½ÃæÐèÒª´ó¼Ò×Ô¼ºÍê³É£¬±ÈÈ罫Êý¾Ý¿âÖеÄÐÅÏ¢ÒÔWEBµÄ·½Ê½Õ¹ÏÖ³öÀ´¡£ |