-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
336 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,285 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import re\n", | ||
"import pandas as pd\n", | ||
"\n", | ||
"import loggedfs # Python pass-through filesystem: pip install loggedfs" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"demo_filter = loggedfs.filter_pipeline_class(include_list = [loggedfs.filter_item_class([loggedfs.filter_field_class(\n", | ||
" name = 'proc_cmd', value = re.compile('.*kate.*').match\n", | ||
" )])]) # filter pipeline for filesystem actions coming from commands containing the string \"kate\" (the KDE text editor)\n", | ||
"\n", | ||
"demo_data, demo_err = [], [] # dump logging data here\n", | ||
"\n", | ||
"demo = loggedfs.loggedfs_notify(\n", | ||
" 'demo_dir', # relative path to mountpoint\n", | ||
" background = True, # log in background thread\n", | ||
" log_filter = demo_filter, # apply filter pipeline\n", | ||
" log_only_modify_operations = True, # only log operations that have the potential to modify the filesystem\n", | ||
" log_buffers = True, # include read and write buffers into log\n", | ||
" consumer_out_func = demo_data.append, # consume logging data\n", | ||
" consumer_err_func = demo_err.append # consume potential errors\n", | ||
" ) # MOUNT (and start logging)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"27" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"demo.terminate() # UMOUNT (and stop logging)\n", | ||
"\n", | ||
"assert isinstance(demo_data[-1], loggedfs.end_of_transmission)\n", | ||
"demo_data = demo_data[:-1]\n", | ||
"\n", | ||
"len(demo_data)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<div>\n", | ||
"<style scoped>\n", | ||
" .dataframe tbody tr th:only-of-type {\n", | ||
" vertical-align: middle;\n", | ||
" }\n", | ||
"\n", | ||
" .dataframe tbody tr th {\n", | ||
" vertical-align: top;\n", | ||
" }\n", | ||
"\n", | ||
" .dataframe thead th {\n", | ||
" text-align: right;\n", | ||
" }\n", | ||
"</style>\n", | ||
"<table border=\"1\" class=\"dataframe\">\n", | ||
" <thead>\n", | ||
" <tr style=\"text-align: right;\">\n", | ||
" <th></th>\n", | ||
" <th>action</th>\n", | ||
" <th>proc_pid</th>\n", | ||
" <th>param_path</th>\n", | ||
" <th>param_old_path</th>\n", | ||
" <th>param_new_path</th>\n", | ||
" <th>param_fip</th>\n", | ||
" <th>param_buf_len</th>\n", | ||
" <th>param_offset</th>\n", | ||
" <th>param_mode</th>\n", | ||
" <th>return</th>\n", | ||
" <th>status</th>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>time</th>\n", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <th>1556736520813215826</th>\n", | ||
" <td>mknod</td>\n", | ||
" <td>30977</td>\n", | ||
" <td>/tmp/ernst/demo_dir/.demo_file.txt.kate-swp</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>33188.0</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>True</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>1556736520814149530</th>\n", | ||
" <td>chmod</td>\n", | ||
" <td>30977</td>\n", | ||
" <td>/tmp/ernst/demo_dir/.demo_file.txt.kate-swp</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>33152.0</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>True</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>1556736524870363873</th>\n", | ||
" <td>mknod</td>\n", | ||
" <td>30977</td>\n", | ||
" <td>/tmp/ernst/demo_dir/demo_file.txt.X30977</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>33152.0</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>True</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>1556736524871304006</th>\n", | ||
" <td>chmod</td>\n", | ||
" <td>30977</td>\n", | ||
" <td>/tmp/ernst/demo_dir/demo_file.txt.X30977</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>33188.0</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>True</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>1556736524872197836</th>\n", | ||
" <td>rename</td>\n", | ||
" <td>30977</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>/tmp/ernst/demo_dir/demo_file.txt.X30977</td>\n", | ||
" <td>/tmp/ernst/demo_dir/demo_file.txt</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>True</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>1556736524872611868</th>\n", | ||
" <td>unlink</td>\n", | ||
" <td>30977</td>\n", | ||
" <td>/tmp/ernst/demo_dir/.demo_file.txt.kate-swp</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>NaN</td>\n", | ||
" <td>True</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>\n", | ||
"</div>" | ||
], | ||
"text/plain": [ | ||
" action proc_pid \\\n", | ||
"time \n", | ||
"1556736520813215826 mknod 30977 \n", | ||
"1556736520814149530 chmod 30977 \n", | ||
"1556736524870363873 mknod 30977 \n", | ||
"1556736524871304006 chmod 30977 \n", | ||
"1556736524872197836 rename 30977 \n", | ||
"1556736524872611868 unlink 30977 \n", | ||
"\n", | ||
" param_path \\\n", | ||
"time \n", | ||
"1556736520813215826 /tmp/ernst/demo_dir/.demo_file.txt.kate-swp \n", | ||
"1556736520814149530 /tmp/ernst/demo_dir/.demo_file.txt.kate-swp \n", | ||
"1556736524870363873 /tmp/ernst/demo_dir/demo_file.txt.X30977 \n", | ||
"1556736524871304006 /tmp/ernst/demo_dir/demo_file.txt.X30977 \n", | ||
"1556736524872197836 NaN \n", | ||
"1556736524872611868 /tmp/ernst/demo_dir/.demo_file.txt.kate-swp \n", | ||
"\n", | ||
" param_old_path \\\n", | ||
"time \n", | ||
"1556736520813215826 NaN \n", | ||
"1556736520814149530 NaN \n", | ||
"1556736524870363873 NaN \n", | ||
"1556736524871304006 NaN \n", | ||
"1556736524872197836 /tmp/ernst/demo_dir/demo_file.txt.X30977 \n", | ||
"1556736524872611868 NaN \n", | ||
"\n", | ||
" param_new_path param_fip \\\n", | ||
"time \n", | ||
"1556736520813215826 NaN NaN \n", | ||
"1556736520814149530 NaN NaN \n", | ||
"1556736524870363873 NaN NaN \n", | ||
"1556736524871304006 NaN NaN \n", | ||
"1556736524872197836 /tmp/ernst/demo_dir/demo_file.txt NaN \n", | ||
"1556736524872611868 NaN NaN \n", | ||
"\n", | ||
" param_buf_len param_offset param_mode return status \n", | ||
"time \n", | ||
"1556736520813215826 NaN NaN 33188.0 NaN True \n", | ||
"1556736520814149530 NaN NaN 33152.0 NaN True \n", | ||
"1556736524870363873 NaN NaN 33152.0 NaN True \n", | ||
"1556736524871304006 NaN NaN 33188.0 NaN True \n", | ||
"1556736524872197836 NaN NaN NaN NaN True \n", | ||
"1556736524872611868 NaN NaN NaN NaN True " | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"data_df = pd.DataFrame.from_records(demo_data, index = 'time')\n", | ||
"\n", | ||
"data_df[data_df['action'] != 'write'][['action', 'proc_pid', 'param_path', 'param_old_path', 'param_new_path', 'param_fip', 'param_buf_len', 'param_offset', 'param_mode', 'return', 'status']]" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.