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 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| 'Définition de la période d'étude, en l'occurence le jour actuel, moins 1
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = Date -3
dtmStartDate.SetVarDate DateToCheck, CONVERT_TO_LOCAL_TIME
dtmEndDate.SetVarDate DateToCheck + 1, CONVERT_TO_LOCAL_TIME
dtmEndDate.SetVarDate Date, True
dtmStartDate.SetVarDate DateToCheck, True
'Affichage année, date, heure, à partir de la machine locale, qui est référente
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LocalTime")
For Each objItem in colItems
Wscript.Echo ("Annee: " & objItem.Year) & (" Mois: " & objItem.Month) & (" Jour: " & objItem.Day) & (" Heure: " & objItem.Hour)
Wscript.Echo ""
Next
'Définition de la zone sur laquelle sera utilisé le script (exemple)
arrComputers = Array("127.0.0.1")
For Each strComputer In arrComputers
'Affichage du nom de la machine et de son adresse IP
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_ComputerSystem")
For Each objItem in colItems
Wscript.Echo objItem.Name
WScript.Echo "" & strComputer
WScript.Echo ""
next
'Relevé des coupures de courant
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'System' and " _
& "EventCode = '1165' and TimeWritten >= '" _
& dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'")
Wscript.Echo "Coupures avec bascule sur onduleur depuis hier, minuit : " & colLoggedEvents.Count
Wscript.Echo ""
'Relevé des coupures suite à l'épuisement de la batterie de l'onduleur
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'System' and " _
& "EventCode = '6008' and TimeWritten >= '" _
& dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'")
Wscript.Echo "Arrets secs du serveur suite epuisement onduleur depuis hier, minuit : " & colLoggedEvents.Count
Wscript.Echo ""
next |
Partager