PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > RE: Getting eventlogs in last 24 hours
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
RE: Getting eventlogs in last 24 hours

Réponse
 
LinkBack Outils de la discussion
Vieux 24/09/2007, 20h28   #1
urkec
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Getting eventlogs in last 24 hours

"Oliver Marshall" wrote:

> Hi,
>
> I have a script that returns the eventlogs that have occurred on a specified
> day. However, i have a need to mod the script so that it returns the logs
> that have occurred within the last 24 hours (this being different to on a
> specified day). ie if it runs at 07:30 monday it should return logs between
> 07:30 sunday and 07:30 monday.
>
> How should I phrase the SQL for this ? Currently I have...
>
> Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
> Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
> DateToCheck = CDate("9/24/2007")
> dtmStartDate.SetVarDate DateToCheck, CONVERT_TO_LOCAL_TIME
> dtmEndDate.SetVarDate DateToCheck + 1, CONVERT_TO_LOCAL_TIME
>
> ...
>
> Set colEvents = objWMIService.ExecQuery _
> ("Select * from Win32_NTLogEvent Where Logfile = 'Application' and
> TimeWritten >= '" & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'
> and Type='Error'")
>
> ...
>


You can try setting DateToCheck to Now() and use DateToCheck - 1 (Didn't
test this):

Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = Now
dtmStartDate.SetVarDate DateToCheck - 1, CONVERT_TO_LOCAL_TIME

Set colEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application' and
TimeWritten >= '" & dtmStartDate & "' and Type='Error'")


--
urkec
  Réponse avec citation
Vieux 24/09/2007, 20h58   #2
Oliver Marshall
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Getting eventlogs in last 24 hours

That would give logs between yesterday morning and now. So if the check
happened at 8pm today, it would return anything from yesterday at 00:01 to
today which is more than 24 hours

Thanks anyway

"urkec" wrote:

> "Oliver Marshall" wrote:
>
> > Hi,
> >
> > I have a script that returns the eventlogs that have occurred on a specified
> > day. However, i have a need to mod the script so that it returns the logs
> > that have occurred within the last 24 hours (this being different to on a
> > specified day). ie if it runs at 07:30 monday it should return logs between
> > 07:30 sunday and 07:30 monday.
> >
> > How should I phrase the SQL for this ? Currently I have...
> >
> > Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
> > Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
> > DateToCheck = CDate("9/24/2007")
> > dtmStartDate.SetVarDate DateToCheck, CONVERT_TO_LOCAL_TIME
> > dtmEndDate.SetVarDate DateToCheck + 1, CONVERT_TO_LOCAL_TIME
> >
> > ...
> >
> > Set colEvents = objWMIService.ExecQuery _
> > ("Select * from Win32_NTLogEvent Where Logfile = 'Application' and
> > TimeWritten >= '" & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'
> > and Type='Error'")
> >
> > ...
> >

>
> You can try setting DateToCheck to Now() and use DateToCheck - 1 (Didn't
> test this):
>
> Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
> DateToCheck = Now
> dtmStartDate.SetVarDate DateToCheck - 1, CONVERT_TO_LOCAL_TIME
>
> Set colEvents = objWMIService.ExecQuery _
> ("Select * from Win32_NTLogEvent Where Logfile = 'Application' and
> TimeWritten >= '" & dtmStartDate & "' and Type='Error'")
>
>
> --
> urkec

  Réponse avec citation
Vieux 24/09/2007, 22h06   #3
urkec
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Getting eventlogs in last 24 hours

"Oliver Marshall" wrote:

> That would give logs between yesterday morning and now. So if the check
> happened at 8pm today, it would return anything from yesterday at 00:01 to
> today which is more than 24 hours
>
> Thanks anyway
>


I tested this:

Set dtmStartDate = CreateObject ("WbemScripting.SWbemDateTime")
DateToCheck = Now
dtmStartDate.SetVarDate DateToCheck - 1, True
WScript.Echo dtmStartDate

It gave me 20070923220056.000000+120 , which is about 24 hours from now (CET).


--
urkec
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h29.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10551 seconds with 11 queries