source: people/peter.buschman/backup_monitoring/backmon/commands/status/subcommands/filesystem.py@ 1071

Last change on this file since 1071 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: 1.6 KB
Line 
1#!/usr/bin/python26
2###
3### backmon.commands.status.filesystem
4###
5
6import sys
7import os
8import os.path
9import glob
10import re
11
12from optparse import OptionParser
13
14from ....lib import *
15
16from backup_monitoring.parsing.parsers import df
17
18usage = 'usage: %prog -s server status filesystem [filesystem]'
19
20parser = OptionParser(usage=usage)
21
22def run(args, kwargs):
23
24 #
25 # add kwargs to local namespace
26 #
27 for key in kwargs.keys():
28
29 if re.compile('^[A-Z][A-Z_]+$').match(key):
30 exec(key + ' = kwargs[\'' + key + '\']')
31
32 (options, args) = parser.parse_args(args)
33
34 if not OPTIONS.server:
35 ERROR('Please specify a server to use the status fileystem command.')
36 sys.exit(1)
37 elif( len(args) == 0 ):
38 ERROR('No filesystem specified.')
39 sys.exit(1)
40 else:
41 filesystem = args.pop(0)
42 filesystems = {}
43 DEBUG('FILESYSTEM=%s' % (filesystem))
44 updates = Updates(LOGGER, SERVER_PATH)
45
46 try:
47
48 stream = df.stream(updates.feed('df'))
49
50 for record in stream:
51 dfk = df.parse(record, format='df -k')
52 mountpoint = dfk['mountpoint']
53 filesystems[mountpoint] = dfk
54
55 if filesystem in filesystems:
56 print('filesystem=%(mountpoint)s, pct_full=%(pct_full)s' % filesystems[filesystem])
57 else:
58 ERROR('Could not locate filesystem %s on server %s!' % (filesystem, SERVER))
59
60 except Exception, e:
61 raise BackmonError, e
62
Note: See TracBrowser for help on using the repository browser.