source: people/peter.buschman/backup_monitoring/backmon/commands/check/subcommands/scratch.py@ 976

Last change on this file since 976 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.4 KB
Line 
1#!/usr/bin/python26
2###
3### backmon.commands.check.scratch
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 vmpool
21from backup_monitoring.parsing.parsers import vmquery
22from backup_monitoring.parsing.parsers import bpmedialist
23
24usage = 'usage: %prog -e [environment] check scratch [robot_number]'
25
26parser = OptionParser(usage=usage)
27
28def run(args, kwargs):
29
30 #
31 # add kwargs to local namespace
32 #
33 for key in kwargs.keys():
34
35 if re.compile('^[A-Z][A-Z_]+$').match(key):
36 exec(key + ' = kwargs[\'' + key + '\']')
37
38 (options, args) = parser.parse_args(args)
39
40 if len(args) == 0:
41 ERROR('No robot number specified!')
42 sys.exit(3)
43
44 ROBOT_NUMBER = int(args[0])
45
46 master_feeds = ['nbemmcmd_machinealias_getaliases', 'vmpool', 'vmpool_list_scratch', 'vmquery', 'bpmedialist']
47 media_feeds = [ ]
48
49 if not ENVIRONMENT:
50 ERROR('Must specify backup environment!')
51 sys.exit(1)
52
53 try:
54
55 environment = ENVIRONMENTS[ENVIRONMENT]
56
57 hp = hpy()
58
59 DEBUG('HEAPSIZE=%s' % (heapsize()))
60
61 volume_count = 0
62 scratch_count = 0
63
64 environment.load_feeds(master=master_feeds, media=media_feeds)
65 environment.parse_pools()
66 environment.parse_scratch()
67 environment.parse_volumes()
68 #environment.parse_media()
69
70 DEBUG('HEAPSIZE=%s' % (heapsize()))
71
72 for volume in environment.volumes:
73
74 if volume.robot_number == ROBOT_NUMBER:
75
76 volume_count += 1
77
78 if volume.pool_name == environment.scratch_pool:
79
80 scratch_count += 1
81
82 if scratch_count > 0 and volume_count > 0:
83 pct_scratch = float(scratch_count) / float(volume_count) * 100.0
84 else:
85 pct_scratch = 0.0
86
87 perfdata = 'scratch=%d%%;95;99;0;100' % (pct_scratch)
88 print 'OK: %d scratch volumes out of %d in robot %d | %s' % (scratch_count, volume_count, ROBOT_NUMBER, perfdata)
89
90 except Exception, e:
91
92 raise
93
94 #perfdata = 'scratch=0%;95;99;0;100'
95 #print 'scratch volume monitoring data unavailable! | %s' % (perfdata)
96
Note: See TracBrowser for help on using the repository browser.