'====================================== ' check_mcafee_datdate.vbs ' ' Original Author: Jimmy Alesjö ' Rewritten by: Mattias Bergsten ' Created: 2009-05-29 ' Updated: 2009-11-04 ' Version: 1.5.0 ' Description: Check McAfee VirusScan DatDate and compare the difference between today's date and the command line parameters ' '====================================== On Error Resume Next const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set Args = WScript.Arguments Set StdOut = WScript.StdOut Sub ExitWithUnknown() WScript.StdOut.Write "UNKNOWN - Something went wrong!" WScript.Quit 3 End Sub Sub ExitWithHelptext() WScript.StdOut.WriteLine("ERROR - Wrong number of parameters specified") WScript.StdOut.WriteLine("") WScript.StdOut.WriteLine("check_mcafee_datdate.vbs v1.5.0") WScript.StdOut.WriteLine("") WScript.StdOut.WriteLine("Checks the registry for McAfee VirusScan's DAT date and compares it to today's date. If the difference in days exceeds the parameters, exits with appropriate status.") WScript.StdOut.WriteLine("") WScript.StdOut.WriteLine("Parameters:") WScript.StdOut.WriteLine("") WScript.StdOut.WriteLine("check_mcafee_datdate.vbs ") WScript.Quit 3 End Sub If Len(Args.Item(0)) < 1 Then ExitWithHelptext() If Len(Args.Item(1)) < 1 Then ExitWithHelptext() If IsNull(CInt(Args.Item(0))) Then ExitWithHelptext() If IsNull(CInt(Args.Item(1))) Then ExitWithHelptext() Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\McAfee\AVEngine" strValueName = "AVDatDate" oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue If IsEmpty(strValue) Then ExitWithUnknown() If IsDate(strValue) Then strRegistryDate = CDate(strValue) Else WScript.StdOut.WriteLine("CRITICAL - Registry value '" & strValue & "' is not a date!") WScript.Quit 2 End If strDateDiff = DateDiff("d",strRegistryDate,Date) If CInt(strDateDiff) => CInt(Args.Item(1)) Then WScript.StdOut.WriteLine("CRITICAL - DAT date (" & strRegistryDate & ") is " & strDateDiff & " days old!") WScript.Quit 2 ElseIf CInt(strDateDiff) => CInt(Args.Item(0)) Then WScript.StdOut.WriteLine("WARNING - DAT date (" & strRegistryDate & ") is " & strDateDiff & " days old!") WScript.Quit 1 ElseIf CInt(strDateDiff) < CInt(Args.Item(0)) Then If CInt(strDateDiff) < CInt(Args.Item(1)) Then WScript.StdOut.WriteLine("OK - DAT date (" & strRegistryDate & ") is below the threshold (diff " & strDateDiff & ", warning " & Args.Item(0) & ", critical " & Args.Item(1) & ")!") WScript.Quit 0 End If Else ExitWithUnknown() End If