|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | # -*- coding: utf-8 -*- |
3 | 3 |
|
| 4 | +""" |
| 5 | +
|
| 6 | +LoggedFS-python |
| 7 | +Filesystem monitoring with Fuse and Python |
| 8 | +https://github.com/pleiszenburg/loggedfs-python |
| 9 | +
|
| 10 | + fsx_analyze.py: Merge the output of fsx-linux and LoggedFS and display result |
| 11 | +
|
| 12 | + Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]> |
| 13 | +
|
| 14 | +<LICENSE_BLOCK> |
| 15 | +The contents of this file are subject to the Apache License |
| 16 | +Version 2 ("License"). You may not use this file except in |
| 17 | +compliance with the License. You may obtain a copy of the License at |
| 18 | +https://www.apache.org/licenses/LICENSE-2.0 |
| 19 | +https://github.com/pleiszenburg/loggedfs-python/blob/master/LICENSE |
| 20 | +
|
| 21 | +Software distributed under the License is distributed on an "AS IS" basis, |
| 22 | +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the |
| 23 | +specific language governing rights and limitations under the License. |
| 24 | +</LICENSE_BLOCK> |
| 25 | +
|
| 26 | +""" |
| 27 | + |
| 28 | + |
| 29 | +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 30 | +# IMPORT |
| 31 | +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 | 32 |
|
5 | 33 | import datetime |
6 | 34 | import os |
7 | 35 | import sys |
8 | 36 |
|
9 | 37 |
|
| 38 | +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 39 | +# CONST |
| 40 | +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 41 | + |
10 | 42 | # https://en.wikipedia.org/wiki/ANSI_escape_code |
11 | 43 | c = { |
12 | 44 | 'RESET': '\033[0;0m', |
|
23 | 55 | } |
24 | 56 |
|
25 | 57 |
|
| 58 | +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 59 | +# ROUTINES |
| 60 | +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 61 | + |
26 | 62 | def print_line(line_dict): |
27 | 63 | t = str(line_dict['t']) |
28 | 64 | sys.stdout.write(c['GREY'] + t[:-9] + '.' + t[-9:] + c['RESET'] + ' ') |
@@ -76,10 +112,10 @@ def split_at(in_str, separator, position): |
76 | 112 | def parse_fs_line(line): |
77 | 113 |
|
78 | 114 | ts, payload = split_at(line, ' ', 2) |
79 | | - if payload.startswith('INFO [default] '): # original loggedfs |
| 115 | + if payload.startswith('INFO [default] '): # original LoggedFS |
80 | 116 | _, payload = split_at(payload, ' ', 2) |
81 | 117 | _original_loggedfs = True |
82 | | - else: |
| 118 | + else: # LoggedFS-python |
83 | 119 | _, payload = split_at(payload, ' ', 1) |
84 | 120 | _original_loggedfs = False |
85 | 121 | command, payload = payload.split(' ', 1) |
@@ -148,5 +184,10 @@ def main(): |
148 | 184 | print_line(line) |
149 | 185 |
|
150 | 186 |
|
| 187 | +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 188 | +# ENTRY POINT |
| 189 | +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 190 | + |
151 | 191 | if __name__ == '__main__': |
| 192 | + |
152 | 193 | main() |
0 commit comments