Rev | Line | |
---|
[976] | 1 | #!/usr/bin/python26
|
---|
| 2 | ###
|
---|
| 3 | ### backmon.commands.status.filesystem
|
---|
| 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 |
|
---|
| 14 | from ....lib import *
|
---|
| 15 |
|
---|
| 16 | from backup_monitoring.parsing.parsers import df
|
---|
| 17 |
|
---|
| 18 | usage = 'usage: %prog -s server status filesystem [filesystem]'
|
---|
| 19 |
|
---|
| 20 | parser = OptionParser(usage=usage)
|
---|
| 21 |
|
---|
| 22 | def 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.