Bonjour,

J'ai besoin de vos lumières ...

Jai une liste de machines générés chaque jour :

Liste_Machines.txt
1@toto
2@titi
3@tata
4@tutu
J'effectue un ping de cette liste chaque jour et je met en forme une page html qui donne :

toto OK
titi NOK
tata NOK
tutu NOK
toto OK
titi NOK
tata NOK
tutu NOK
toto OK
titi NOK
tata NOK
tutu NOK
ci dessous le script :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
Const ForReading = 1
Const ForWriting = 2 
Const ForAppending = 8
 
Set objFile = objFSO.OpenTextFile("Liste_Machines.txt", ForReading, True)
 
Set objRes = objFSO.OpenTextFile("Histo_ping.html", ForAppending,True)
 
strHTML = strHTML & "<html>" & vbCRLF
strHTML = strHTML & "<head>" & vbCRLF
strHTML = strHTML & "<title>DHCP Stats Report : " & Now & "</title>" & vbCRLF
strHTML = strHTML & "</head>" & vbCRLF
strHTML = strHTML & "<body>" & vbCRLF
strHTML = strHTML & "<table>" & vbCRLF
 
Do While objFile.AtEndOfStream <> True  
 
	Ligne = objFile.ReadLine
 
	tableau = Split(Ligne, "@")
 
	Machine = tableau(1)
 
	Set WSHShell = CreateObject("WScript.Shell")
	Set WshExec = WshShell.Exec("ping -n 1 -w 200 " & Machine)
 
	PingResult = LCase(WshExec.StdOut.ReadAll)
	wscript.echo PingResult
	strHTML = strHTML & "<tr>" & vbCRLF	
	If InStr(PingResult, "octets=") Then
		'Ping OK		
		strHTML = strHTML & "<td>" & Machine & "</td>" & "<td>OK</td>"& vbCRLF	
	Else
		'Ping NOK
		strHTML = strHTML & "<td>" & Machine & "</td>" & "<td>NOK</td>"& vbCRLF	
	End If
 
	strHTML = strHTML & "</tr>" & vbCRLF
 
Loop
 
strHTML = strHTML & "</table>" & vbCRLF
strHTML = strHTML & "</body>" & vbCRLF	
strHTML = strHTML & "</html>" & vbCRLF
 
objRes.writeLine strHTML
Comment faire pour obtenir un historique en ligne de mes pings sous cette forme :

toto OK OK OK
titi NOK NOK NOK
tata NOK NOK NOK
tutu NOK NOK NOK
Je ne vois pas comment faire ...

Il faut passer par un fichier temp de toute facon ... pour comparer si la machine existe deja, sinon creer une autre ligne ...

Merci à vous d'avance.