[Bacula-users] Updates to bacula_mail_summary.sh

2009-03-26 Thread John Lockard
Attached, please find updates to bacula_mail_summary.sh which
was in the examples/reports directory in the source distribution.
I run this script once a week, after the log has been rotated
by my systems logrotate script.

I've tweaked the display formatting quite a bit.  Rather than
displaying the full job level I've done:
 F   = Full
 D   = Differential
 I   = Incrmental
 I2F = Full (upgraded from Incremental)
 D2F = Full (upgraded from Incremental)

For completion status I've shorted these as well to:
 OK= OK
 OK-Verify = Verify OK
 OK-Warn   = Ok -- with warnings
 M-OK  = Migration OK
 M-Error   = Migration Error

I've changed the Start and End times to include the day
and month, to cover jobs that run long (more than 24 hours).

Sample output (excerpts):

Client StatusType  StartTimeEndTime  Files  
Bytes
homer  OK-Warn   I 01-Mar-22:00:03  01-Mar-22:20:28  1,049  
637,371,688(637.3  MB)
wiggum OKI 02-Mar-02:01:03  02-Mar-02:02:11  26 
73,035 (73.03  KB)
harvbannister  OK-Warn   F 02-Mar-02:30:02  02-Mar-02:40:16  298,076
8,937,733,774  (8.937  GB)
dataless   OKF 02-Mar-03:00:00  02-Mar-06:13:48  212,695
129,185,742,611(129.1  GB)
bart   OKI2F   06-Mar-20:00:02  06-Mar-22:59:04  1,484,236  
91,154,841,692 (91.15  GB)
homer  OK-Warn   I2F   06-Mar-22:59:06  07-Mar-07:01:35  2,147,092  
765,068,201,965(765.0  GB)
mrlombardo OKD2F   12-Mar-21:00:00  12-Mar-23:48:29  1,277  
60,076,971,159 (60.07  GB)
tibor  Canceled  F 12-Mar-23:50:31  13-Mar-10:32:35  0  0   
   (0  B)
tibor  M-OK  F 17-Mar-17:19:42  17-Mar-17:21:09  58,134 
2,477,312,248  (2.477  GB)
tibor  M-Error   F 17-Mar-17:23:01  17-Mar-17:23:01  0  0   
   (0  B)
bart   OKD 17-Mar-20:00:02  17-Mar-20:10:35  756
535,593,805(535.5  MB)
sherri Error F 19-Mar-12:25:59  20-Mar-22:24:01  147,641
1,390,032,423,344  (1.390  TB)
centra OK-Warn   D 23-Mar-17:00:03  23-Mar-17:00:21  0  0   
   (0  B)
adilhoxha  OKI 23-Mar-18:30:56  23-Mar-18:36:23  65 
3,456,362,879  (3.456  GB)


I hope someone finds this to be useful.

-John


-- 
Four Horsemen Of The Apocalypse Unveil New Alert System
 - Subject of recent SPAM message
---
 John M. Lockard |  U of Michigan - School of Information
 Unix and Security Admin |  1214 SI North - 1075 Beal Ave.
  jlock...@umich.edu |Ann Arbor, MI  48109-2112
 www.umich.edu/~jlockard | 734-615-8776 | 734-647-8045 FAX
---


bacula_mail_summary.sh
Description: Bourne shell script
--
___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


[Bacula-users] Updates to bacula_mail_summary.sh

2009-03-26 Thread John Lockard
Attached, please find updates to bacula_mail_summary.sh which
was in the examples/reports directory in the source distribution.
I run this script once a week, after the log has been rotated
by my systems logrotate script.

I've tweaked the display formatting quite a bit.  Rather than
displaying the full job level I've done:
 F   = Full
 D   = Differential
 I   = Incrmental
 I2F = Full (upgraded from Incremental)
 D2F = Full (upgraded from Incremental)

For completion status I've shorted these as well to:
 OK= OK
 OK-Verify = Verify OK
 OK-Warn   = Ok -- with warnings
 M-OK  = Migration OK
 M-Error   = Migration Error

I've changed the Start and End times to include the day
and month, to cover jobs that run long (more than 24 hours).

Sample output (excerpts):

Client StatusType  StartTimeEndTime  Files  
Bytes
homer  OK-Warn   I 01-Mar-22:00:03  01-Mar-22:20:28  1,049  
637,371,688(637.3  MB)
wiggum OKI 02-Mar-02:01:03  02-Mar-02:02:11  26 
73,035 (73.03  KB)
harvbannister  OK-Warn   F 02-Mar-02:30:02  02-Mar-02:40:16  298,076
8,937,733,774  (8.937  GB)
dataless   OKF 02-Mar-03:00:00  02-Mar-06:13:48  212,695
129,185,742,611(129.1  GB)
bart   OKI2F   06-Mar-20:00:02  06-Mar-22:59:04  1,484,236  
91,154,841,692 (91.15  GB)
homer  OK-Warn   I2F   06-Mar-22:59:06  07-Mar-07:01:35  2,147,092  
765,068,201,965(765.0  GB)
mrlombardo OKD2F   12-Mar-21:00:00  12-Mar-23:48:29  1,277  
60,076,971,159 (60.07  GB)
tibor  Canceled  F 12-Mar-23:50:31  13-Mar-10:32:35  0  0   
   (0  B)
tibor  M-OK  F 17-Mar-17:19:42  17-Mar-17:21:09  58,134 
2,477,312,248  (2.477  GB)
tibor  M-Error   F 17-Mar-17:23:01  17-Mar-17:23:01  0  0   
   (0  B)
bart   OKD 17-Mar-20:00:02  17-Mar-20:10:35  756
535,593,805(535.5  MB)
sherri Error F 19-Mar-12:25:59  20-Mar-22:24:01  147,641
1,390,032,423,344  (1.390  TB)
centra OK-Warn   D 23-Mar-17:00:03  23-Mar-17:00:21  0  0   
   (0  B)
adilhoxha  OKI 23-Mar-18:30:56  23-Mar-18:36:23  65 
3,456,362,879  (3.456  GB)


I hope someone finds this to be useful.

-John


- start bacula_mail_summary.sh -

#!/bin/sh

# $Id: bacula_mail_summary.sh,v 1.5 2009/03/26 19:04:11 root Exp $
# $Locker:  $

# This script is to create a summary of the job notifications from bacula
# and send it to people who care.
#
# For it to work, you need to have all Bacula job report
# logging to a file, edit LOGFILE to match your setup.
# This should be run after all backup jobs have finished.
# Tested with bacula-2.4.4

# Some improvements by: John Lockard jlock...@umich.edu
#   (University of Michigan - School of Information)
#   Changed Date format to better sort
#   Reformatted Levels to fit better
#   Caught more job completion types
#   Added From addressing to the outgoing email
#   Removed log rotation.  I'll leave that up to a system utility (logrotate)
#   Added partial date to Start and End times to cover long running jobs
# Some improvements by: Andrey Yakovlev free...@kiev.farlep.net  (ISP Farlep)
# Contributed by Andrew J. Millar and...@alphajuliet.org.uk
# Patched by Andrey A. Yakovlev free...@kiev.farlep.net

# Use awk to create the report, pass to column to be
# formatted nicely, then on to mail to be sent to
# people who care.

LOGFILE='/var/log/bacula/standard'

EMAIL_TO=backup-adm...@example.com
EMAIL_FROM=bacula-ser...@example.com
#EMAIL_FROM=${EMAIL_TO}
EMAIL_SUBJECT=Bacula Job Summary: `date +'%F - %a'`

#-

awk -F\:\  'BEGIN {
print Client Status Type StartTime EndTime Files Bytes
}

/director-dir: New file:/ {
print $3
}

/director-dir: File:/ {
print $3
}

/Client/ {
CLIENT=$2; sub(//, , CLIENT) ; sub(/.*$/, , CLIENT)
}
/Backup Level/ {
TYPE=$2 ;
sub(/,.*$/, , TYPE)
sub(/Full \(upgraded from Incremental\)/, I2F, TYPE);
sub(/Full \(upgraded from Differential\)/, D2F, TYPE);
sub(/Full/, F, TYPE);
sub(/Incremental/, I, TYPE);
sub(/Differential/, D, TYPE);
}
/Start time/ {
STARTTIME=$2;
sub(/-[0-9]* /, -, STARTTIME)
sub(/^ */, , STARTTIME)
gsub(/ /, -, STARTTIME)
}
/End time/ {
ENDTIME=$2;
sub(/-[0-9]* /, -, ENDTIME)
sub(/^ */, , ENDTIME)
gsub(/ /, -, ENDTIME)
}
/Files Examined/ {
SDFILES=$2
SDBYTES=0
}
/SD Files Written/ {
SDFILES=$2
}
/SD Bytes Written/ {
SDBYTES=$2
}
/Termination/ {
TERMINATION=$2 ;