source: people/peter.buschman/backup_monitoring/backmon/commands/summary/subcommands/backups.py

Last change on this file was 976, checked in by peter, on Dec 6, 2011 at 10:19:33 AM

Raw checkin of current NetBackup / TSM parsing code.

File size: 2.6 KB
Line 
1#!/usr/bin/python26
2###
3### backmon.commands.summary.backups
4###
5
6import sys
7import os
8import os.path
9import glob
10import re
11
12from optparse import OptionParser
13from guppy import hpy
14
15from ....lib import *
16
17from backup_monitoring.debug import *
18from backup_monitoring.math import *
19
20from backup_monitoring.parsing.parsers import bpstulist
21from backup_monitoring.parsing.parsers import nbdevquery
22from backup_monitoring.parsing.parsers import bpdbjobs
23
24usage = 'usage: %prog -e environment status backups'
25
26parser = OptionParser(usage=usage)
27#parser.add_option('-s', '--include-staging', action='store_true', default=False, dest='include_staging', help='include staging storage units')
28
29def run(args, kwargs):
30
31 #
32 # add kwargs to local namespace
33 #
34 for key in kwargs.keys():
35
36 if re.compile('^[A-Z][A-Z_]+$').match(key):
37 exec(key + ' = kwargs[\'' + key + '\']')
38
39 (options, args) = parser.parse_args(args)
40
41 master_feeds = ['nbemmcmd_machinealias_getaliases', 'bpdbjobs_most_columns']
42 media_feeds = [ ]
43
44 try:
45
46 environments = ENVIRONMENTS.values()
47
48 hp = hpy()
49
50 DEBUG('HEAPSIZE=%s' % (heapsize()))
51
52 for environment in environments:
53 environment.load_feeds(master=master_feeds, media=media_feeds)
54 environment.parse_jobs()
55
56 DEBUG('HEAPSIZE=%s' % (heapsize()))
57
58 print('%s %s %s %s %s %s' % ('ENVIRONMENT'.center(15), 'ACTIVE'.center(6), 'QUEUED'.center(6), 'RETRYING'.center(8), 'SUSPENDED'.center(9), 'INCOMPLETE'.center(10)))
59 print('=============== ====== ====== ======== ========= ==========')
60
61 active = 0
62 queued = 0
63 retrying = 0
64 suspended = 0
65 incomplete = 0
66 foo = 0
67
68 for environment in environments:
69
70 for job in environment.jobs:
71
72 if job.active:
73 active += 1
74
75 if job.queued:
76 queued += 1
77
78 if job.state == 'wait for retry':
79 retrying += 1
80
81 if job.state == 'suspended':
82 suspended += 1
83
84 if job.state == 'incomplete':
85 incomplete += 1
86
87 if job.state in ['6', '7']:
88 foo += 1
89
90 #
91 # print backup status
92 #
93 print('%s %6d %6d %8d %9d %10d' % (environment.name.center(15), active, queued, retrying, suspended, incomplete))
94
95 except Exception, e:
96
97 raise
98
Note: See TracBrowser for help on using the repository browser.