1 | #!/usr/bin/python26
|
---|
2 | ###
|
---|
3 | ### backmon.commands.summary.backups
|
---|
4 | ###
|
---|
5 |
|
---|
6 | import sys
|
---|
7 | import os
|
---|
8 | import os.path
|
---|
9 | import glob
|
---|
10 | import re
|
---|
11 |
|
---|
12 | from optparse import OptionParser
|
---|
13 | from guppy import hpy
|
---|
14 |
|
---|
15 | from ....lib import *
|
---|
16 |
|
---|
17 | from backup_monitoring.debug import *
|
---|
18 | from backup_monitoring.math import *
|
---|
19 |
|
---|
20 | from backup_monitoring.parsing.parsers import bpstulist
|
---|
21 | from backup_monitoring.parsing.parsers import nbdevquery
|
---|
22 | from backup_monitoring.parsing.parsers import bpdbjobs
|
---|
23 |
|
---|
24 | usage = 'usage: %prog -e environment status backups'
|
---|
25 |
|
---|
26 | parser = OptionParser(usage=usage)
|
---|
27 | #parser.add_option('-s', '--include-staging', action='store_true', default=False, dest='include_staging', help='include staging storage units')
|
---|
28 |
|
---|
29 | def 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 |
|
---|