source: people/peter.buschman/backup_monitoring/parsing/parsers/ontap_df/_ontap_df.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: 1.1 KB
Line 
1import re
2
3from ....builtins import *
4
5from ...exceptions import *
6from ...expressions import *
7from ...streams import *
8
9##
10## ontap df has one record per-line
11##
12def stream(stream, format='df -s'):
13
14 if format in ['df -s']:
15 return NewLineStream(stream, header=1)
16 else:
17 raise ParseError, 'Unknown format %s' % (format)
18
19
20##
21## Parse an ontap df record
22##
23def parse(record, format='df -s', version=None, tz=None):
24
25 fs = ExtendedDict()
26
27 if format == 'df -s':
28
29 regex = re.compile('^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)%.*$')
30
31 try:
32
33 match = regex.match(record)
34
35 filesystem = match.group(1)
36
37 if filesystem[-1] == '/':
38 filesystem = filesystem[:-1]
39
40 fs['filesystem'] = filesystem
41 fs['used'] = long(match.group(2))
42 fs['saved'] = long(match.group(3))
43 fs['pct_saved'] = int(match.group(4))
44
45 return fs
46
47 except Exception, e:
48
49 raise ParseError, e
50
51 else:
52
53 raise ParseError, 'Unknown format %s' % (format)
Note: See TracBrowser for help on using the repository browser.