Difference between revisions of "OPS435 Assignment 1 A"

From CDOT Wiki
Jump to: navigation, search
Line 1: Line 1:
 
[[Category:OPS435-Python]][[Category:rchan]]
 
[[Category:OPS435-Python]][[Category:rchan]]
'''DRAFT - Under Construction'''
+
<font color='red'>'''DRAFT - Under Construction'''</font>
 
=Assignment 1 - Users' Usage Report=
 
=Assignment 1 - Users' Usage Report=
 
'''Weight:''' 20% of the overall grade
 
'''Weight:''' 20% of the overall grade

Revision as of 23:20, 13 February 2018

DRAFT - Under Construction

Assignment 1 - Users' Usage Report

Weight: 20% of the overall grade

Due Date: Ask your professor for exact date

Late Penalty: 10% per school day, and note that this assignment must be completed satisfactorily in order to pass the course even if you get zero mark for this assignment.

Overview

Most system administrators would like to know the utilization of their systems by their users. On a Linux system, the users' login records are normally stored in the binary file /var/log/wtmp. The login records in this binary file can not be viewed or edited directly using normal Linux commands like 'less', 'cat', etc. The 'last' command is often used to display the login records stored in this file in a human readable form. The following listing is a sample output of running the 'last' command:

$ last -F
rchan    pts/0        :0               Mon Jan  8 22:40:02 2018 - Tue Jan  9 17:31:50 2018  (18:51)    
rchan    pts/0        :0               Mon Jan  8 21:47:32 2018 - Mon Jan  8 21:47:38 2018  (00:00)    
rchan    :0           :0               Mon Jan  8 21:46:36 2018 - Tue Jan  9 17:36:18 2018  (19:49)    
(unknown :0           :0               Mon Jan  8 20:25:13 2018 - Mon Jan  8 21:46:36 2018  (01:21)    
reboot   system boot  3.10.0-514.10.2. Mon Jan  8 15:25:07 2018 - Fri Jan 12 01:31:18 2018 (3+10:06)   
rchan    :0           :0               Mon Jan  8 17:19:04 2018 - Mon Jan  8 17:34:29 2018  (00:15)    
(unknown :0           :0               Mon Jan  8 16:48:02 2018 - Mon Jan  8 17:19:03 2018  (00:31)    
reboot   system boot  3.10.0-514.10.2. Mon Jan  8 11:47:56 2018 - Mon Jan  8 17:34:30 2018  (05:46)    
rchan    :0           :0               Mon Jan  8 13:55:51 2018 - Mon Jan  8 14:01:26 2018  (00:05)    
(unknown :0           :0               Mon Jan  8 13:55:37 2018 - Mon Jan  8 13:55:51 2018  (00:00)    
...

In this assignment, your task is to create a python program with well designed functions to produce daily, weekly, and monthly usage report by user (and/or by other criteria) based on the information obtained from the 'last' command.

Instructions

Program Name and valid command line arguments

Name your Python3 program as usage_report.py. The program should accept the following command line parameters:

  • --user or -u as an optional first argument, followed by:
  • filename, or
  • filename1 filename2 etc ... - any number of filenames from 1 to as many as the command-line supports.

If the first argument is --user or -u, then all the usage report to be generated should be based on user only.

If there is no filename provided at the command line, your program should get the login records from the 'last' command with the appropriate flags.

If there is more than one filename provided, merged all the files together with the first one at the top and the last one at the bottom. Read and process the file contents in that order in your program.

Header

All your Python codes for this program must be placed in a single source file. Please include the following declaration by you as comment in your Python source code file (replace "Student Name" with your own name):

OPS435 Assignment 1 - Winter 2018
Program: usage_report.py
Author: "Student Name"
The python code in this file (usage_report.py) is original work written by
"Student Name". No code in this file is copied from any other source 
including any person, textbook, or on-line resource. I have not shared
this python program with anyone or anything except for submission for grading.  
I understand that the Academic Honesty Policy will be enforced and violators 
will be reported and appropriate action will be taken.

Main Menu

Daily Usage Menu

Weekly Usage Menu

Monthly Usage Menu

Sample login records file

Submission

After fully testing your program, submit the .py file on Blackboard