IMAT5122 - Computer Networks: Developing a Linux Change Logger Script
VerifiedAdded on 2023/05/30
|26
|4743
|96
Project
AI Summary
This project report details the development of a Linux system change logger script in Ubuntu OS for monitoring user activity. The script, named "mySysMonitor.sh," uses various command-line tools to extract system information, storing the output in a temporary log file and subsequently generating an HTML report. The script monitors current processes, logged-in users, plugged-in devices, disk usage, network interfaces, RAM usage, and the operating system version. It creates a directory to store the HTML reports, which are formatted using Bootstrap for better readability. The report concludes that while the script is useful for system monitoring, it may be slower compared to other programming languages. Desklib provides access to this and other solved assignments for students.

Running head: LINUX SYSTEM CHANGE LOGGER SCRIPT
Computer Systems and Networks
Name of the Student
Name of the University
Author’s Note
Computer Systems and Networks
Name of the Student
Name of the University
Author’s Note
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

2
LINUX SYSTEM CHANGE LOGGER SCRIPT
Table of Contents
Introduction......................................................................................................................................3
Specification....................................................................................................................................3
Design Consideration.......................................................................................................................3
Extensive test result and exemplary log and screen output.............................................................7
Conclusion.....................................................................................................................................24
Bibliography..................................................................................................................................25
LINUX SYSTEM CHANGE LOGGER SCRIPT
Table of Contents
Introduction......................................................................................................................................3
Specification....................................................................................................................................3
Design Consideration.......................................................................................................................3
Extensive test result and exemplary log and screen output.............................................................7
Conclusion.....................................................................................................................................24
Bibliography..................................................................................................................................25

3
LINUX SYSTEM CHANGE LOGGER SCRIPT
Introduction
This report has been focused on developing a change logger script created in Ubuntu OS
and managing of regular activity of user utilizing this system. Therefore, for creating shell script
if the system, it is extracted from different shell command and output has been stored in the
HTML file. IT would help in monitoring the system in a proper manner. The pre-installed
command line tools for utilizing creation of shell script and output has been stored in a
temporary log file for managing changes in the logs.
Specification
The shell script has been created using nano editor and named as “mySysMonitor.sh”,
and proper permission has been added to the shell script for running it. Administrative
permission has been required for running the shell script and “chmod +x mySysMonitor.sh”
command has been utilized for giving appropriate permission and running shell script. “sudo
./mySysMonitor.sh”, command has been used for running the shell script as root user and
generate the output in a HTML file.
Design Consideration
The shell script has been designed for separating command for obtaining information and
data for the development of change logger script. The prior function of the script has been
monitoring current computer system and activity of user in order to develop log with a key. The
script named “mySysMonitor.sh” has been automatically written in the log file named
“mySysMonitor.log”. The output of the shell script has been stored in the HTML file and utilize
“mySysMonitor.log” as temporary file for storing data and result of the command. The contents
if the file has been copied in a temporary file and tail-f command has been used for comparing
LINUX SYSTEM CHANGE LOGGER SCRIPT
Introduction
This report has been focused on developing a change logger script created in Ubuntu OS
and managing of regular activity of user utilizing this system. Therefore, for creating shell script
if the system, it is extracted from different shell command and output has been stored in the
HTML file. IT would help in monitoring the system in a proper manner. The pre-installed
command line tools for utilizing creation of shell script and output has been stored in a
temporary log file for managing changes in the logs.
Specification
The shell script has been created using nano editor and named as “mySysMonitor.sh”,
and proper permission has been added to the shell script for running it. Administrative
permission has been required for running the shell script and “chmod +x mySysMonitor.sh”
command has been utilized for giving appropriate permission and running shell script. “sudo
./mySysMonitor.sh”, command has been used for running the shell script as root user and
generate the output in a HTML file.
Design Consideration
The shell script has been designed for separating command for obtaining information and
data for the development of change logger script. The prior function of the script has been
monitoring current computer system and activity of user in order to develop log with a key. The
script named “mySysMonitor.sh” has been automatically written in the log file named
“mySysMonitor.log”. The output of the shell script has been stored in the HTML file and utilize
“mySysMonitor.log” as temporary file for storing data and result of the command. The contents
if the file has been copied in a temporary file and tail-f command has been used for comparing
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

4
LINUX SYSTEM CHANGE LOGGER SCRIPT
changes in the log file and identification has been made in the current system. For constructing
the shell script the following commands are used such as:
#1) Current Processes
echo "**********Current Process**********
$(ps -aux | sort -rk 3,3 | head -n 6)" >>mySysMonitor.log
current_processes_pid=`ps -ef | awk {'print$2'} | cut -f2 -d'-'`
current_processes_time=`ps -ef | awk {'print$5'} | cut -f2 -d'-'`
current_processes_process=`ps -ef | awk {'print$8'} | cut -f2 -d'-'`
#2) Currently Logged in Users
echo " **********Currently Logged in Users**********
$(who)" >>mySysMonitor.log
current_loggedin_user_name=`who | awk {'print$1'} | cut -f1 -d','`
current_loggedin_user_date=`who | awk {'print$3'} | cut -f1 -d','`
current_loggedin_user_time=`who | awk {'print$4'} | cut -f1 -d','`
LINUX SYSTEM CHANGE LOGGER SCRIPT
changes in the log file and identification has been made in the current system. For constructing
the shell script the following commands are used such as:
#1) Current Processes
echo "**********Current Process**********
$(ps -aux | sort -rk 3,3 | head -n 6)" >>mySysMonitor.log
current_processes_pid=`ps -ef | awk {'print$2'} | cut -f2 -d'-'`
current_processes_time=`ps -ef | awk {'print$5'} | cut -f2 -d'-'`
current_processes_process=`ps -ef | awk {'print$8'} | cut -f2 -d'-'`
#2) Currently Logged in Users
echo " **********Currently Logged in Users**********
$(who)" >>mySysMonitor.log
current_loggedin_user_name=`who | awk {'print$1'} | cut -f1 -d','`
current_loggedin_user_date=`who | awk {'print$3'} | cut -f1 -d','`
current_loggedin_user_time=`who | awk {'print$4'} | cut -f1 -d','`
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

5
LINUX SYSTEM CHANGE LOGGER SCRIPT
#3) Plugged in Devices
echo " **********Plugged in Devices**********
$(ls -l)" >>mySysMonitor.log
device_plugged_in_permissions=`ls -l /dev/ | awk {'print$1'}`
device_plugged_in_UID=`ls -l /dev/ | awk {'print$3'}`
device_plugged_in_number=`ls -l /dev/ | awk {'print$6'}`
device_plugged_in_month=`ls -l /dev/ | awk {'print$7'}`
device_plugged_in_date=`ls -l /dev/ | awk {'print$8'}`
device_plugged_in_time=`ls -l /dev/ | awk {'print$9'}`
device_plugged_in_disk=`ls -l /dev/ | awk {'print$10'}`
#4) Disk Usage
echo "**********Disk Usage**********
LINUX SYSTEM CHANGE LOGGER SCRIPT
#3) Plugged in Devices
echo " **********Plugged in Devices**********
$(ls -l)" >>mySysMonitor.log
device_plugged_in_permissions=`ls -l /dev/ | awk {'print$1'}`
device_plugged_in_UID=`ls -l /dev/ | awk {'print$3'}`
device_plugged_in_number=`ls -l /dev/ | awk {'print$6'}`
device_plugged_in_month=`ls -l /dev/ | awk {'print$7'}`
device_plugged_in_date=`ls -l /dev/ | awk {'print$8'}`
device_plugged_in_time=`ls -l /dev/ | awk {'print$9'}`
device_plugged_in_disk=`ls -l /dev/ | awk {'print$10'}`
#4) Disk Usage
echo "**********Disk Usage**********

6
LINUX SYSTEM CHANGE LOGGER SCRIPT
$(du -sh)" >>mySysMonitor.log
overall_disk_usage=`du -sh | tail -l | awk {'print$1'}`
device_plugged_in_number=`ls -l /dev/ | awk {'print$6'}`
home_directory_disk_usage=`du -sh /home7/P17245067 | tail -l | awk {'print$1'}`
other_directory_disk_usage=`du -sh /home7/P17245067/Downloads | tail -l | awk {'print$1'}`
#5)Network Interfaces
echo "**********Network Interfaces**********
$(ip -s link)" >>mySysMonitor.log
network_interfaces_status=`ip -s link`
#6)RAM Usage
echo "**********RAM Usage**********
$(free -hm)" >>mySysMonitor.log
ram_usage=`free -hm | head -2 | tail -1 | awk {'print$3'}`
LINUX SYSTEM CHANGE LOGGER SCRIPT
$(du -sh)" >>mySysMonitor.log
overall_disk_usage=`du -sh | tail -l | awk {'print$1'}`
device_plugged_in_number=`ls -l /dev/ | awk {'print$6'}`
home_directory_disk_usage=`du -sh /home7/P17245067 | tail -l | awk {'print$1'}`
other_directory_disk_usage=`du -sh /home7/P17245067/Downloads | tail -l | awk {'print$1'}`
#5)Network Interfaces
echo "**********Network Interfaces**********
$(ip -s link)" >>mySysMonitor.log
network_interfaces_status=`ip -s link`
#6)RAM Usage
echo "**********RAM Usage**********
$(free -hm)" >>mySysMonitor.log
ram_usage=`free -hm | head -2 | tail -1 | awk {'print$3'}`
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

7
LINUX SYSTEM CHANGE LOGGER SCRIPT
ram_total=`free -hm | head -2 | tail -1 | awk {'print$2'}`
#7)Current Operating System Version
echo "**********Current Operating System Version**********
$(uname -r)" >>mySysMonitor.log
Current_os=`uname -r `
Extensive test result and exemplary log and screen output
The shell script prepared for management of the change log is given below:
#! /bin/bash
#Author : - Kanan Patel
#Declaring variables
#set -x
#1) Current Processes
echo "**********Current Process**********
$(ps -aux | sort -rk 3,3 | head -n 6)" >>mySysMonitor.log
LINUX SYSTEM CHANGE LOGGER SCRIPT
ram_total=`free -hm | head -2 | tail -1 | awk {'print$2'}`
#7)Current Operating System Version
echo "**********Current Operating System Version**********
$(uname -r)" >>mySysMonitor.log
Current_os=`uname -r `
Extensive test result and exemplary log and screen output
The shell script prepared for management of the change log is given below:
#! /bin/bash
#Author : - Kanan Patel
#Declaring variables
#set -x
#1) Current Processes
echo "**********Current Process**********
$(ps -aux | sort -rk 3,3 | head -n 6)" >>mySysMonitor.log
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

8
LINUX SYSTEM CHANGE LOGGER SCRIPT
current_processes_pid=`ps -ef | awk {'print$2'} | cut -f2 -d'-'`
current_processes_time=`ps -ef | awk {'print$5'} | cut -f2 -d'-'`
current_processes_process=`ps -ef | awk {'print$8'} | cut -f2 -d'-'`
#2) Currently Logged in Users
echo " **********Currently Logged in Users**********
$(who)" >>mySysMonitor.log
current_loggedin_user_name=`who | awk {'print$1'} | cut -f1 -d','`
current_loggedin_user_date=`who | awk {'print$3'} | cut -f1 -d','`
current_loggedin_user_time=`who | awk {'print$4'} | cut -f1 -d','`
#3) Plugged in Devices
echo " **********Plugged in Devices**********
$(ls -l)" >>mySysMonitor.log
LINUX SYSTEM CHANGE LOGGER SCRIPT
current_processes_pid=`ps -ef | awk {'print$2'} | cut -f2 -d'-'`
current_processes_time=`ps -ef | awk {'print$5'} | cut -f2 -d'-'`
current_processes_process=`ps -ef | awk {'print$8'} | cut -f2 -d'-'`
#2) Currently Logged in Users
echo " **********Currently Logged in Users**********
$(who)" >>mySysMonitor.log
current_loggedin_user_name=`who | awk {'print$1'} | cut -f1 -d','`
current_loggedin_user_date=`who | awk {'print$3'} | cut -f1 -d','`
current_loggedin_user_time=`who | awk {'print$4'} | cut -f1 -d','`
#3) Plugged in Devices
echo " **********Plugged in Devices**********
$(ls -l)" >>mySysMonitor.log

9
LINUX SYSTEM CHANGE LOGGER SCRIPT
device_plugged_in_permissions=`ls -l /dev/ | awk {'print$1'}`
device_plugged_in_UID=`ls -l /dev/ | awk {'print$3'}`
device_plugged_in_number=`ls -l /dev/ | awk {'print$6'}`
device_plugged_in_month=`ls -l /dev/ | awk {'print$7'}`
device_plugged_in_date=`ls -l /dev/ | awk {'print$8'}`
device_plugged_in_time=`ls -l /dev/ | awk {'print$9'}`
device_plugged_in_disk=`ls -l /dev/ | awk {'print$10'}`
#4) Disk Usage
echo "**********Disk Usage**********
$(du -sh)" >>mySysMonitor.log
overall_disk_usage=`du -sh | tail -l | awk {'print$1'}`
device_plugged_in_number=`ls -l /dev/ | awk {'print$6'}`
home_directory_disk_usage=`du -sh /home7/P17245067 | tail -l | awk {'print$1'}`
other_directory_disk_usage=`du -sh /home7/P17245067/Downloads | tail -l | awk {'print$1'}`
LINUX SYSTEM CHANGE LOGGER SCRIPT
device_plugged_in_permissions=`ls -l /dev/ | awk {'print$1'}`
device_plugged_in_UID=`ls -l /dev/ | awk {'print$3'}`
device_plugged_in_number=`ls -l /dev/ | awk {'print$6'}`
device_plugged_in_month=`ls -l /dev/ | awk {'print$7'}`
device_plugged_in_date=`ls -l /dev/ | awk {'print$8'}`
device_plugged_in_time=`ls -l /dev/ | awk {'print$9'}`
device_plugged_in_disk=`ls -l /dev/ | awk {'print$10'}`
#4) Disk Usage
echo "**********Disk Usage**********
$(du -sh)" >>mySysMonitor.log
overall_disk_usage=`du -sh | tail -l | awk {'print$1'}`
device_plugged_in_number=`ls -l /dev/ | awk {'print$6'}`
home_directory_disk_usage=`du -sh /home7/P17245067 | tail -l | awk {'print$1'}`
other_directory_disk_usage=`du -sh /home7/P17245067/Downloads | tail -l | awk {'print$1'}`
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

10
LINUX SYSTEM CHANGE LOGGER SCRIPT
#5)Network Interfaces
echo "**********Network Interfaces**********
$(ip -s link)" >>mySysMonitor.log
network_interfaces_status=`ip -s link`
#6)RAM Usage
echo "**********RAM Usage**********
$(free -hm)" >>mySysMonitor.log
ram_usage=`free -hm | head -2 | tail -1 | awk {'print$3'}`
ram_total=`free -hm | head -2 | tail -1 | awk {'print$2'}`
#7)Current Operating System Version
echo "**********Current Operating System Version**********
$(uname -r)" >>mySysMonitor.log
LINUX SYSTEM CHANGE LOGGER SCRIPT
#5)Network Interfaces
echo "**********Network Interfaces**********
$(ip -s link)" >>mySysMonitor.log
network_interfaces_status=`ip -s link`
#6)RAM Usage
echo "**********RAM Usage**********
$(free -hm)" >>mySysMonitor.log
ram_usage=`free -hm | head -2 | tail -1 | awk {'print$3'}`
ram_total=`free -hm | head -2 | tail -1 | awk {'print$2'}`
#7)Current Operating System Version
echo "**********Current Operating System Version**********
$(uname -r)" >>mySysMonitor.log
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

11
LINUX SYSTEM CHANGE LOGGER SCRIPT
Current_os=`uname -r `
#Creating a directory if it doesn't exist to store reports first, for easy maintenance.
if [ ! -d ${HOME}/Linux_System_Monitor ]
then
mkdir ${HOME}/Linux_System_Monitor
fi
html="${HOME}/Linux_System_Monitor/Linux-System-Monitor-`hostname`-`date +%y%m
%d`-`date +%H%M`.html"
#Generating HTML file
echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">" >> $html
echo "<html>" >> $html
echo "<head>" >> $html
echo "<title>Bootstrap Example</title>" >> $html
echo "<meta charset="utf-8">" >> $html
echo "<meta name="viewport" content="width=device-width, initial-scale=1">" >> $html
echo "<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">" >> $html
LINUX SYSTEM CHANGE LOGGER SCRIPT
Current_os=`uname -r `
#Creating a directory if it doesn't exist to store reports first, for easy maintenance.
if [ ! -d ${HOME}/Linux_System_Monitor ]
then
mkdir ${HOME}/Linux_System_Monitor
fi
html="${HOME}/Linux_System_Monitor/Linux-System-Monitor-`hostname`-`date +%y%m
%d`-`date +%H%M`.html"
#Generating HTML file
echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">" >> $html
echo "<html>" >> $html
echo "<head>" >> $html
echo "<title>Bootstrap Example</title>" >> $html
echo "<meta charset="utf-8">" >> $html
echo "<meta name="viewport" content="width=device-width, initial-scale=1">" >> $html
echo "<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">" >> $html

12
LINUX SYSTEM CHANGE LOGGER SCRIPT
echo "<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>"
>> $html
echo "<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>" >>
$html
echo "<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></
script>" >> $html
echo "</head>" >> $html
echo "<body>" >> $html
echo "<br>" >> $html
echo "<div class="container">" >> $html
echo "<h2 style="text-align:center">My System Monitor</h2>" >> $html
echo "<br>" >> $html
echo "<!-- Nav pills -->" >> $html
echo "<ul class="nav nav-pills" role="tablist">" >> $html
echo "<li class="nav-item">" >> $html
echo "<a class="nav-link active" data-toggle="pill" href="#menu1">Current Processes</a>" >>
$html
echo "</li>" >> $html
echo "<li class="nav-item">" >> $html
echo "<a class="nav-link" data-toggle="pill" href="#menu2">Logged in Users</a>" >> $html
echo "</li>" >> $html
echo "<li class="nav-item">" >> $html
echo "<a class="nav-link" data-toggle="pill" href="#menu3">Plugged in Devices</a>" >> $html
echo "</li>" >> $html
echo "<li class="nav-item">" >> $html
LINUX SYSTEM CHANGE LOGGER SCRIPT
echo "<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>"
>> $html
echo "<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>" >>
$html
echo "<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></
script>" >> $html
echo "</head>" >> $html
echo "<body>" >> $html
echo "<br>" >> $html
echo "<div class="container">" >> $html
echo "<h2 style="text-align:center">My System Monitor</h2>" >> $html
echo "<br>" >> $html
echo "<!-- Nav pills -->" >> $html
echo "<ul class="nav nav-pills" role="tablist">" >> $html
echo "<li class="nav-item">" >> $html
echo "<a class="nav-link active" data-toggle="pill" href="#menu1">Current Processes</a>" >>
$html
echo "</li>" >> $html
echo "<li class="nav-item">" >> $html
echo "<a class="nav-link" data-toggle="pill" href="#menu2">Logged in Users</a>" >> $html
echo "</li>" >> $html
echo "<li class="nav-item">" >> $html
echo "<a class="nav-link" data-toggle="pill" href="#menu3">Plugged in Devices</a>" >> $html
echo "</li>" >> $html
echo "<li class="nav-item">" >> $html
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 26
Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.


