Knowledge Base & Discussion Forum

[Feature][3240][OBM][NS]Logging of ahsay events to windows eventlog

Past technical discussions on Ahsay's Products

Moderator: Support Team

Event Log HomeBrew

Postby Andreasbe » Mon Feb 15, 2010 2:41 pm

Dear All,

I am working on a VBS script as a pre and post backup action.

I have one little issue but otherwise by VB Script is water tight:

it runs in pre command and generates a windows event log entry to determin active log file, then in the post it runs a TSR script that digs out the last line of the log and injects into the windows event log.

This is 90% working, I just have a problem with the TSR process.


Let me know if anyone wants to collaborate on this as I cant wait for AHSAY anymore. (We also monitor event logs via out MSP solution)
Andreasbe
 
Posts: 77
Joined: Tue Jul 22, 2008 3:57 pm
Location: South Africa

Postby vtphilk » Mon Feb 15, 2010 11:19 pm

I would be interested in your vb script if you would be willing to share. What is the 10% problem...maybe I can help.
vtphilk
 
Posts: 64
Joined: Sun Sep 23, 2007 11:59 pm

Postby Andreasbe » Tue Feb 16, 2010 2:28 pm

vtphilk wrote:I would be interested in your vb script if you would be willing to share. What is the 10% problem...maybe I can help.


I resolved it, the problem was to spawn a process outside of the main PID, but managed to get this working, the only snag/pitfall with this is that the backupset ID is what I extract not the friently name.

I have a mechanism to do this in reporting services (VIA SSIS packages) but you will have to figure out your own solution on the reporting.

send me a mail at andreasb[at]netsurit[dot]com and i will send you my code.!
Andreasbe
 
Posts: 77
Joined: Tue Jul 22, 2008 3:57 pm
Location: South Africa

Postby vtphilk » Wed Feb 17, 2010 1:19 am

Andreasbe wrote:
vtphilk wrote:I would be interested in your vb script if you would be willing to share. What is the 10% problem...maybe I can help.


I resolved it, the problem was to spawn a process outside of the main PID, but managed to get this working, the only snag/pitfall with this is that the backupset ID is what I extract not the friently name.

I have a mechanism to do this in reporting services (VIA SSIS packages) but you will have to figure out your own solution on the reporting.

send me a mail at andreasb[at]netsurit[dot]com and i will send you my code.!


cool..i sent you an email. thanks!
vtphilk
 
Posts: 64
Joined: Sun Sep 23, 2007 11:59 pm

Univesal script done!

Postby Andreasbe » Thu Feb 18, 2010 8:37 pm

Here is the Code please note that MAIN.BAT is the scrpt you run in the pre backup command:
***************************
FILENAME: MAIN.BAT
***************************
@Echo Off
Rem This is the main script that calls the Subscripts for the Backup reporting
REM This Batchfile was created on the 18th of Feb 2010
REM All Scripting curtesy of Andreas Bergstedt (Andreasbe@gmail.com)
REM This batchfile must be executed as a pre backup job command.
REM be careful not to run backup jobs in the same minute,
REM jobs must be staggered by a minimum of 1 minute for this script to work
ECHO Scripting by: Andreas Bergstedt
ECHO Andreasb@netsurit.com
ECHO Starting scripts
CSCRIPT Main.VBS %date%-%time%
Echo Script fired.
ECHO Please check your event log for job outcomes(Application log, Souce=WSH, Event ID =2)

************************
FILENAME: MAIN.VBS
************************
'SCRIPT NAME: MAIN.VBS
'USAGE MAIN.VBS %date%-%time%
'This is a script that is called by MAIN.BAT
'This script should be run during the Pre Backup command on a NetOPS backup set
'It digs out the log file for the running backup set that was executed and writes into windows event log
'Created by Andreas Bergstedt on the 18th of Feb 2010
'andreasbe@gmail.com
'Get Installation folder from service registry entry
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "System\CurrentControlSet\services\OBScheduler"
strValueName = "ImagePath"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strHome = Replace(strValue, "bin\Scheduler.exe", "home.txt")
WScript.Echo strHome
Const FOR_READING = 1
strFilePath = strHome
iLineNumber = 1
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(strFilePath, FOR_READING)
For i=1 To (iLineNumber-1)
objTS.SkipLine
Next
ProfileHomestr = objTS.ReadLine

'Sleep for 6 seconds for logfile to be created.
WScript.sleep 6000
'Start Get Estimated file name
Dim strX
Dim PatternDate, sourcefolder
Set ArgObj = Wscript.Arguments
PatternDate = ArgObj(0)
sourcefolder = ProfileHomestr
'Replace date separators
var1 = Replace(PatternDate, "/", "-")
var2 = Replace(Var1, ":", "-")
Var3 = left(var2,16)

'Start Search from root folder
strDir = sourcefolder
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDir = objFSO.GetFolder(strDir)
RecursiveFunc(objDir)
Sub RecursiveFunc(Dir_Passed)
For Each Item_File In Dir_Passed.Files
On Error Resume Next
If Instr(Item_File.Name, Var3) Then
strX = Dir_Passed & "\" & Item_File.Name
End If
Next

For Each Item_Fldr In Dir_Passed.SubFolders
RecursiveFunc (Item_Fldr)
Next
End Sub
'Get Backup Set ID and Full filename (With path)
strY=right(strX,44)
wscript.Echo strX
strZ=left(strY,13)
wscript.Echo StrY
'The following 6 lines have been remarked out as they are no longer needed
'Set objFile = objFSO.CreateTextFile("out.txt")
'objFile.WriteLine(strX)
'objFile.Close
'Set objFile = objFSO.CreateTextFile("ID.TXT")
'objFile.WriteLine(strZ)
'objFile.Close

'clear out residual
set ArgObj = Nothing

'The Following 5 lines are left as comments for debugging purposes
' Create String Values in registry for logging
'Const HKEY_LOCAL_MACHINE = &H80000002
'strComputer = "."
'Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
' strComputer & "\root\default:StdRegProv")


'Write data into the registry,
'this data will be passed to the Getstatus.vbs script
strKeyPath = "SOFTWARE\NetOPSLog"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strValueName = strZ
strValue = strX
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

'Call Getstatus.vbs to be executed in seperate process,
'getstatus will automatically terminate itself if it runs for aproximatly 24h
'this is to protect itself from unknown statuses or crashed backup.
'getstatus.vbs only uses aproximatly 1.8kb of memory
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("getstatus.vbs" & " " & strZ)
'End of Code

**************************
FILENAME: getstatus.vbs
**************************
'Script Name: Getstatus.vbs
'Usage: Getstatus.vbs Backupset-ID
'This is a subscript that gets fired by MAIN.VBS
'Script Created by Andreas Bergstedt on the 18th of Feb 2010
'Andreasbe@gmail.com
'Start of script
Set ArgObj = Wscript.Arguments
strValueName = ArgObj(0)
Const SUCCESS = 0
const ERROR = 1
const WARNING = 2
const INFORMATION = 4
const AUDIT_SUCCESS = 8
const AUDIT_FAILURE = 16

Y = 0
'GET LATEST BACKUP SET AND GET BACKUP LOG LOCATION from registry
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\NetOPSLog"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
ProfileHomestr = strValue


'Start interogateing last line backup log
Fstatus = 0
Do Until Fstatus > 0
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(ProfileHomestr , 1)

Do Until objFile.AtEndOfStream
ReDim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close

For l = Ubound(arrFileLines)-0 to Ubound(arrFileLines)
StrLast=arrFileLines(l)
Next

'Determin if the backup job has Completed (English only)
If mid(StrLast,30) = "BS_STOP_SUCCESS" then
Fstatus = 1
End If
If mid(StrLast,30) = "BS_STOP_BY_USER" then
Fstatus = 2
End If
If mid(StrLast,30) = "BS_STOP_SUCCESS_WITH_ERROR" then
Fstatus = 3
End If
If mid(StrLast,30) = "BS_STOP_SUCCESS_WITH_WARNING" then
Fstatus = 4
End If
If mid(StrLast,30) = "BS_STOP_BY_SYSTEM_ERROR" then
Fstatus = 5
End If
If mid(StrLast,30) = "BS_STOP_BY_SCHEDULER" then
Fstatus = 6
End If
If mid(StrLast,30) = "BS_STOP_BY_QUOTA_EXCEEDED" then
Fstatus = 7
End If
If mid(StrLast,30) = "Backup Completed Successfully" then
Fstatus = 1
End If
If mid(StrLast,30) = "Backup Interrupted by User" then
Fstatus = 2
End If
If mid(StrLast,30) = "Backup completed with error(s)" then
Fstatus = 3
End If
If mid(StrLast,30) = "Backup completed with warning(s)" then
Fstatus = 4
End If
If mid(StrLast,30) = "Backup Interrupted by System Error" then
Fstatus = 5
End If
If mid(StrLast,30) = "Backup Interrupted by Scheduler" then
Fstatus = 6
End If
If mid(StrLast,30) = "Backup Interrupted By Quota Exceeded" then
Fstatus = 7
End If

Y = Y+1
'Determin if script has run for aproximatly 24h,
'if script has run for aproximatly 24h the write event log entry and quit.
If Y > 1435 Then
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Logevent WARNING, "NETOPS: Backup " & strValueName & " Never completed"
Set wshshell=nothing
WScript.Quit
End If
'OK go ahead and sleep for 60 seconds
WScript.sleep 60000
Loop

'Write Final backup status in the Windows event log (Application log, Source WSH, Event ID 2
'Fstatus represent the following:
'Backup Completed Successfully = 1
'Backup Interrupted by User = 2
'Backup completed with error(s) = 3
'Backup completed with warning(s) = 4
'Backup Interrupted by System Error = 5
'Backup Interrupted by Scheduler = 6
'Backup Interrupted By Quota Exceeded = 7

Set WshShell = CreateObject("WScript.Shell")
WshShell.Logevent WARNING, "NETOPS: " & ProfileHomestr & " : " & StrLast & " , OBS_STATUS: " & Fstatus & ", OBS_JOB_ID:" & strValueName
set wshshell=Nothing
'End of code

*****************
FILENME: Readme.txt
*****************

Installation:
copy all files(Main.BAT, MAIN.VBS and GETSTATUS.VBS into the Online backup program folder.
In each backup set, create a pre backup command that Runs the MAIN.BAT file.


WARNING!!!!!!!!!!
Jobs must be staggered by a minimum of 1 minute for this script to work,
as the script only uses the following search string to determn backup job ID and LOg file
YYYY-MM-DD-hh-mm and will break if backup jobs are run in the same minute.

WARNING!!!!!!!!!!!!!!!
This script only understands AHSAY system codes and standard branded enlish codes!!!!!

Event log outputs:

Please refer to the windows application event log, shource WSH, Event ID 2.
Also look in the getstatus.VBS for explanation of event log entries.

IE:

Log Name: Application
Source: WSH
Date: 2010/02/18 02:23:02 PM
Event ID: 2
Task Category: None
Level: Warning
Keywords: Classic
User: N/A
Computer: XXXXXXXXXX
Description:
NETOPS: C:\Users\andreasb\.obm\log\1266219769697\Backup\2010-02-18-14-20-52.log : [2010/02/18 14:21:42] [info] BS_STOP_SUCCESS , OBS_STATUS: 1, OBS_JOB_ID:1266219769697









Regards,


Andreas Bergstedt
Andreasbe
 
Posts: 77
Joined: Tue Jul 22, 2008 3:57 pm
Location: South Africa

subscript out of range

Postby ikookmaar » Thu May 20, 2010 11:33 pm

hey Andreas,

Thank you for all your work. I would really like to use your script, but I get a "subscript out of range"vb error in line 8 of getstatus.vbs.
I am an almost complete noop when it comes to VB scripting...
Do I have to change anything in the scripts to make it work in our (Windows server 2003) environment with a (standard) branded OBS client? Could you help me to get this to work?

thank you!

Peter
ikookmaar
 
Posts: 3
Joined: Thu May 20, 2010 11:23 pm

Postby ikookmaar » Thu May 27, 2010 10:58 pm

Hi again,

I still do not understand much of vbscribting, but it seems your script should create registry strings and values in HKLM\Software\Netops.
This key ends up being there, but there is only a reg_sz string named "Default" with no values in it, so the remainder of the script fails.
Furthermore, if I uncomment the 6 lines that "are no longer needed" the in.txt and out.txt are also created but remain empty.
If I understand correctly it traces back to the variable strX not being filled..
I do find the home.txt file wich contains the correct path to the prolfile dir containing the subdir with the backuplogs.
What could be the matter?
We are very eager to get this to work....

thnx

Peter Goldstein
ikookmaar
 
Posts: 3
Joined: Thu May 20, 2010 11:23 pm

still not develloped

Postby ikookmaar » Thu May 27, 2010 11:48 pm

Dear Ahsay Devellopers,

It's been more then 3 years now since this feature has been requested and put in to the devellopers queu list....
This is a must have feature for all administrators with monitoring software (and in fact for anybody who check systems using Windows Eventlogs.
Why is there still no news on this request?

Peter Goldstein
ikookmaar
 
Posts: 3
Joined: Thu May 20, 2010 11:23 pm

Postby simone » Sun May 30, 2010 6:57 am

Is there any update on this yet?
We are monitoring ~100 of OBM-systems every day by looking through the e-mail reports. That's crazy because we've got a PRTG central management system with all the health information of all thats servers, EXCEPT for the backupstatus.

PLEASE implement a function in OBM so there will be information in te Windows event viewer about if the backup has gone OK, WARNING or FAILED. That's all most people need...

Come on.. first request on this was in 2006!
simone
 
Posts: 10
Joined: Wed Feb 04, 2009 1:59 pm

VB Script error solved

Postby Stephen » Wed Jun 30, 2010 10:57 pm

I tried the scripts and got the same vbscript errors.
This was due to the date format passed through to the vb script code having the wrong date format

the main.bat file passes the variable in the format
DD/MM/YYYY-HH:MM:SS.xx

but in parsing this to locate the log files it needs it to be
YYYY/MM/DD-HH:MM:SS.xx

run this in the main.bat file
@echo Off
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do set date2=%%k/%%j/%%i
CSCRIPT Main.VBS %date2%-%time%
Stephen
 
Posts: 2
Joined: Wed Jun 30, 2010 10:50 pm

Running the script

Postby mkapz00 » Fri Jul 23, 2010 5:07 am

Hey guys,

I tried running this script and I get the same line 8 error Peter got. I also tried the modification Stephen suggested. Has anyone been able to get this working?

Any help appreciated.

Mike
mkapz00
 
Posts: 1
Joined: Fri Jul 23, 2010 5:02 am

Postby GDRBrian » Wed Sep 28, 2011 4:45 am

Did anyone get anywhere with the above script? Still no eventids...
GDRBrian
 
Posts: 4
Joined: Tue Dec 14, 2010 7:08 am

Postby Support3 » Wed Sep 28, 2011 9:55 am

The feature to log AhsayOBS system event into the Event Viewer log is already implemented in the latest version of AhsayOBS. Please upgrade the server application to the latest version if you want to make use of this new feature.

To upgrade, please refer to the Ahsay Product Upgrade guide at:
viewtopic.php?f=94&t=9775

Thanks.
User avatar
Support3
 
Posts: 6075
Joined: Wed Jan 02, 2008 11:08 am

Postby merijn » Wed Sep 28, 2011 5:59 pm

( thanks for implementing OBS eventlogging, but this thread is about OBM/ACB event logging. )

There is demand for this feature in my client base.
different types of monitoring software will watch the windows event logs.

So i would also like the feature thath OBM and ACB would log the backup results to the windows event log. a simple "backup succesfull", "completed with warnings", ''failed" would be fine to start with.

is there any date planned for this feature?
merijn
 
Posts: 77
Joined: Wed Aug 22, 2007 10:55 pm
Location: Netherlands

Postby Support3 » Thu Oct 06, 2011 2:25 pm

We do have an existing enhancement request of logging backup results to Windows Event Log. Unfortunately, at this point, we do not have the exact date or version which this feature will be implemented.

Thanks.
User avatar
Support3
 
Posts: 6075
Joined: Wed Jan 02, 2008 11:08 am

PreviousNext

Return to Archived - Technical Discussions

Who is online

Users browsing this forum: No registered users and 7 guests

Looking for Rbackup Alternative | Vembu Alternative | Novastor Alternative | Asigra Alternative | BackupAgent Alternative? Try our product.


A wholly owned subsidiary of Ahsay Backup Software Development Company Limited  [HKEx Stock Code: 8290]