cancel
Showing results for 
Search instead for 
Did you mean: 

Can a Linux NetBackup Appliance Media Server write to Windows Event Log?

Marquez
Level 3

My current monitoring software scrapes the windows Event Viewer, problem is all netbackup jobs are recorded on a Linux Media Server.

Is there a way to send stats of the backups from the Linux Server to a Windows server to be viewed in event viewer?
Or perhaps set it up so that each server with netbackup installed will write to its own event log rather than send the stats to the Media Server?

 

1 ACCEPTED SOLUTION

Accepted Solutions

sdo
Moderator
Moderator
Partner    VIP    Certified

If you have a Windows Media Server or Windows Admin Host, then you could try this:

1) Start a DOS/CMD box, and enter:

bpdbjobs -stay_alive -autorefresh -most_columns > a.txt

2) cscript a.vbs

...to run the script in the text box below:

Option Explicit
' Written by sdo, 26-Aug-2014.
Dim go_fso, go_wsh, gs_fields
Set go_fso = CreateObject( "Scripting.FileSystemObject" )
Set go_wsh = CreateObject( "WScript.Shell" )
Call s_main()
WScript.Quit(0)

Sub s_main()
  Dim ls_file, lo_file, ls_rec, ll_recs, ll_err, lb_sleep, ls_fields
  ls_file = "a.txt"
  Set lo_file = go_fso.OpenTextFile( ls_file )
  ll_recs = 0
  lb_sleep = False
  While True
    On Error Resume Next
      ls_rec = lo_file.ReadLine()
      ll_err = Err.Number
    On Error Goto 0
    Select Case ll_err
    Case 0
      ll_recs = ll_recs + 1
      lb_sleep = False
      Set ls_fields = Nothing
      gs_fields = Split( ls_rec, "," )
      WScript.Echo "rec: " & ll_recs & "  fields: " & UBound( gs_fields ) & "  " & ls_rec
      If UBound( gs_fields ) = 58 Then
        Call s_process()
      Else
        WScript.Echo "...ignoring fragmented record..."
      End If
    Case 62
      If Not lb_sleep Then WScript.Echo "...sleeping..."
      lb_sleep = True
      WScript.Sleep 10
    Case Else
      WScript.Echo "Error " & ll_err
      WScript.Quit( ll_err )
    End Select
  Wend
End Sub

Sub s_process()
  Dim ls_job_id, ls_job_type, ls_job_state, ls_job_status
  Dim ls_job_policy, ls_job_schedule, ls_job_client, ls_job_schedule_type
  Dim ls_log
  ls_job_id     = gs_fields( 0 )
  ls_job_type   = gs_fields( 1 )
  ls_job_state  = gs_fields( 2 )
  ls_job_status = gs_fields( 3 ) 
  Select Case ls_job_state
  Case "3" 'done
    Select Case ls_job_type
    Case "0", "6" '0=backup 6=catalog-backup
      Select Case ls_job_status
      Case "0", "1"
      Case Else
        ls_job_policy   = gs_fields( 4 )
        ls_job_schedule = gs_fields( 5 )
        ls_job_client   = gs_fields( 6 )
        ls_job_schedule_type = gs_fields( 22 )
        If ls_job_schedule = "-" Then
          Select Case ls_job_schedule_type
          Case "0" : ls_job_schedule = "(full)"
          Case "1" : ls_job_schedule = "(diff)"
          Case "2" : ls_job_schedule = "(user-backup)"
          Case "3" : ls_job_schedule = "(user-archive)"
          Case "4" : ls_job_schedule = "(cinc)"
          Case Else: ls_job_schedule = "(unknown)"
          End Select
        End If
        ls_log = "backup failed, job: " & ls_job_id
        ls_log = ls_log & ", status: " & ls_job_status
        ls_log = ls_log & ", client: " & ls_job_client
        ls_log = ls_log & ", policy: " & ls_job_policy
        ls_log = ls_log & ", schedule: " & ls_job_schedule
        WScript.Echo ls_log
        go_wsh.LogEvent "1", ls_log
      End Select
    End Select
  End Select
End Sub

 

I'm not sure how much more time I can put in to this, or whether it will be suitable in the long term, or whether it will work in the real world (but it did seem to run ok in my test area) - and it is unsupported, and uses undocumented features of bpdbjobs, so Symantec won't support you.

I might be able to help further, but I think you'll have more fun tweaking the script for yourself.  :)

One thing that could be done - is to keep a record of which jobs have already 'logged' to the event log, so that if you restart it then it doesn't splat the event log with multiple entries, and use better file names, keep the logs, or filter selected records in to a permanent record, or just better logging, - ah, so many ideas...

And watch out for line wrap - it should be fairly obvious which lines are wrapped.

HTH.

View solution in original post

8 REPLIES 8

TomerG
Level 6
Partner Employee Accredited Certified

My suggestion would be to first install the Windows or Java NetBackup Admin Console (GUI) on a Windows box (and ensure the system is giving permission to run commands, i.e. add it to the NetBackup "server" list on the master server's host properties). This provides all commandline stuff on the Windows system... you could then run the appropriate commands to "log" things onto the system in some manner. Use the NetBackup Commands guide to find which command and options you need, e.g. bpdbjobs for Activity Monitor / job details. Most have a "-U" option that provides user readable output. Often the default output if very compressed, heavy, and comma-separated (which can also be good, depending on what you are doing). 

If you run the command via a regularly running script, you could run it with options to only gather data from the last few minutes (i.e. since the last time it ran) so you don't have overlapping output, or use some other scripting to provent logging the same jobs over and over again.

Regardless, it would require some serious scripting, however if you are already consolidating to one place for logging, you may already be used to that sort of thing for some applications.

Marianne
Level 6
Partner    VIP    Accredited Certified
Use OpsCenter. It was designed for monitoring, alerting and notification. It uses smtp and/or snmp.

sdo
Moderator
Moderator
Partner    VIP    Certified
Maybe this to act as the syslog receiver that then writes to windows event log: http://hcml.demon.co.uk/LogLady.pdf Tweak and compile your own: http://www.codeproject.com/Articles/18086/Syslog-daemon-for-Windows-Eventlog

Marianne
Level 6
Partner    VIP    Accredited Certified

Not sure why you started another discussion for the same question?

https://www-secure.symantec.com/connect/forums/netbackup-failures-write-windows-event-log 

Sorry the answers will not be different...

sdo
Moderator
Moderator
Partner    VIP    Certified

Mr Marquez - I might have an idea for you, but no promises, and not sure if it will work yet...

...but, first things first...

Do you have a Windows host that is either a Windows NetBackup Media server, or a Windows Admin Console?

sdo
Moderator
Moderator
Partner    VIP    Certified

If you have a Windows Media Server or Windows Admin Host, then you could try this:

1) Start a DOS/CMD box, and enter:

bpdbjobs -stay_alive -autorefresh -most_columns > a.txt

2) cscript a.vbs

...to run the script in the text box below:

Option Explicit
' Written by sdo, 26-Aug-2014.
Dim go_fso, go_wsh, gs_fields
Set go_fso = CreateObject( "Scripting.FileSystemObject" )
Set go_wsh = CreateObject( "WScript.Shell" )
Call s_main()
WScript.Quit(0)

Sub s_main()
  Dim ls_file, lo_file, ls_rec, ll_recs, ll_err, lb_sleep, ls_fields
  ls_file = "a.txt"
  Set lo_file = go_fso.OpenTextFile( ls_file )
  ll_recs = 0
  lb_sleep = False
  While True
    On Error Resume Next
      ls_rec = lo_file.ReadLine()
      ll_err = Err.Number
    On Error Goto 0
    Select Case ll_err
    Case 0
      ll_recs = ll_recs + 1
      lb_sleep = False
      Set ls_fields = Nothing
      gs_fields = Split( ls_rec, "," )
      WScript.Echo "rec: " & ll_recs & "  fields: " & UBound( gs_fields ) & "  " & ls_rec
      If UBound( gs_fields ) = 58 Then
        Call s_process()
      Else
        WScript.Echo "...ignoring fragmented record..."
      End If
    Case 62
      If Not lb_sleep Then WScript.Echo "...sleeping..."
      lb_sleep = True
      WScript.Sleep 10
    Case Else
      WScript.Echo "Error " & ll_err
      WScript.Quit( ll_err )
    End Select
  Wend
End Sub

Sub s_process()
  Dim ls_job_id, ls_job_type, ls_job_state, ls_job_status
  Dim ls_job_policy, ls_job_schedule, ls_job_client, ls_job_schedule_type
  Dim ls_log
  ls_job_id     = gs_fields( 0 )
  ls_job_type   = gs_fields( 1 )
  ls_job_state  = gs_fields( 2 )
  ls_job_status = gs_fields( 3 ) 
  Select Case ls_job_state
  Case "3" 'done
    Select Case ls_job_type
    Case "0", "6" '0=backup 6=catalog-backup
      Select Case ls_job_status
      Case "0", "1"
      Case Else
        ls_job_policy   = gs_fields( 4 )
        ls_job_schedule = gs_fields( 5 )
        ls_job_client   = gs_fields( 6 )
        ls_job_schedule_type = gs_fields( 22 )
        If ls_job_schedule = "-" Then
          Select Case ls_job_schedule_type
          Case "0" : ls_job_schedule = "(full)"
          Case "1" : ls_job_schedule = "(diff)"
          Case "2" : ls_job_schedule = "(user-backup)"
          Case "3" : ls_job_schedule = "(user-archive)"
          Case "4" : ls_job_schedule = "(cinc)"
          Case Else: ls_job_schedule = "(unknown)"
          End Select
        End If
        ls_log = "backup failed, job: " & ls_job_id
        ls_log = ls_log & ", status: " & ls_job_status
        ls_log = ls_log & ", client: " & ls_job_client
        ls_log = ls_log & ", policy: " & ls_job_policy
        ls_log = ls_log & ", schedule: " & ls_job_schedule
        WScript.Echo ls_log
        go_wsh.LogEvent "1", ls_log
      End Select
    End Select
  End Select
End Sub

 

I'm not sure how much more time I can put in to this, or whether it will be suitable in the long term, or whether it will work in the real world (but it did seem to run ok in my test area) - and it is unsupported, and uses undocumented features of bpdbjobs, so Symantec won't support you.

I might be able to help further, but I think you'll have more fun tweaking the script for yourself.  :)

One thing that could be done - is to keep a record of which jobs have already 'logged' to the event log, so that if you restart it then it doesn't splat the event log with multiple entries, and use better file names, keep the logs, or filter selected records in to a permanent record, or just better logging, - ah, so many ideas...

And watch out for line wrap - it should be fairly obvious which lines are wrapped.

HTH.

Marquez
Level 3

Thanks for the suggestion, but all media servers and master server are Linux. I think at this point i'll need to explore options in monitoring the Linux syslog instead, rather than doing it through Windows Event Viewer.

Marianne
Level 6
Partner    VIP    Accredited Certified

Backup failures are not logged to syslog.

You will need some sort of integration with NBU error db (Backup status report (bperror))  or jobs db (Activity Monitor (bpdbjobs)) .

This is what sdo was trying to do with his excellent scripting skills.