Difference between revisions of "OPS435 A1 Usage Report Template"
(→Usage Report Template) |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:OPS435]][[Category:rchan]] | [[Category:OPS435]][[Category:rchan]] | ||
− | = | + | = Usage Report Template = |
Please note that the following listing contains some actual python codes, but mostly are pseudo code. | Please note that the following listing contains some actual python codes, but mostly are pseudo code. | ||
<pre> | <pre> | ||
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||
− | + | ''' | |
− | + | authorship declaration | |
− | + | ||
− | + | __author__ Raymond Chan | |
− | + | __date__ March 2019 | |
− | + | __version__ 1.0 | |
+ | |||
+ | text to describe the purpose of this script | ||
+ | ''' | ||
import os | import os | ||
import sys | import sys | ||
− | + | import time | |
− | import | + | import argparse |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
def get_login_rec(): | def get_login_rec(): | ||
− | + | ''' docstring for this fucntion | |
− | + | get records from the last command | |
− | + | filter out the unwanted records | |
+ | add filtered record to list (login_recs)''' | ||
+ | [ put your python code for this function here ] | ||
return login_recs | return login_recs | ||
def read_login_rec(filelist): | def read_login_rec(filelist): | ||
− | + | ''' docstring for this function | |
− | + | get records from given filelist | |
− | + | open and read each file from the filelist | |
− | + | filter out the unwanted records | |
+ | add filtered record to list (login_recs)''' | ||
+ | [ put your python code for this function here ] | ||
return login_rec | return login_rec | ||
− | def cal_daily_usage(subject,login_recs) | + | def cal_daily_usage(subject,login_recs): |
− | + | ''' docstring for this function | |
− | + | generate daily usage report for the given | |
− | + | subject (user or remote host)''' | |
− | + | [ put your python code for this function here ] | |
− | return | + | return daily_usage |
− | def cal_weekly_usage(subject,login_recs) | + | def cal_weekly_usage(subject,login_recs): |
− | + | ''' docstring for this function | |
− | + | generate weekly usage report for the given | |
− | + | subject (user or remote host)''' | |
− | + | [ put your python code for this function here ] | |
− | return | + | return weekly_usage |
− | def cal_monthly_usage(subject,login_recs) | + | def cal_monthly_usage(subject,login_recs): |
− | + | ''' docstring for this function | |
− | + | generate monthly usage report fro the given | |
− | + | subject (user or remote host)''' | |
− | + | [ put your python code for this function here ] | |
− | return | + | return monthly_usage |
if __name__ == '__main__': | if __name__ == '__main__': | ||
− | + | ||
− | + | [ code to retrieve command line argument using the argparse module [ | |
− | + | ... | |
− | + | [ based on the command line option, | |
− | + | call the appropriate functions defined about | |
− | + | to read the login records, | |
− | + | to process the login records | |
− | + | to generate and print | |
− | + | the requested usage report ] | |
− | + | ... | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> |
Latest revision as of 10:39, 14 March 2019
Usage Report Template
Please note that the following listing contains some actual python codes, but mostly are pseudo code.
#!/usr/bin/env python3 ''' authorship declaration __author__ Raymond Chan __date__ March 2019 __version__ 1.0 text to describe the purpose of this script ''' import os import sys import time import argparse def get_login_rec(): ''' docstring for this fucntion get records from the last command filter out the unwanted records add filtered record to list (login_recs)''' [ put your python code for this function here ] return login_recs def read_login_rec(filelist): ''' docstring for this function get records from given filelist open and read each file from the filelist filter out the unwanted records add filtered record to list (login_recs)''' [ put your python code for this function here ] return login_rec def cal_daily_usage(subject,login_recs): ''' docstring for this function generate daily usage report for the given subject (user or remote host)''' [ put your python code for this function here ] return daily_usage def cal_weekly_usage(subject,login_recs): ''' docstring for this function generate weekly usage report for the given subject (user or remote host)''' [ put your python code for this function here ] return weekly_usage def cal_monthly_usage(subject,login_recs): ''' docstring for this function generate monthly usage report fro the given subject (user or remote host)''' [ put your python code for this function here ] return monthly_usage if __name__ == '__main__': [ code to retrieve command line argument using the argparse module [ ... [ based on the command line option, call the appropriate functions defined about to read the login records, to process the login records to generate and print the requested usage report ] ...