IMAT5122 Coursework Report: Linux System Change Logger Script Analysis

Verified

Added on  2022/10/04

|16
|2229
|46
Report
AI Summary
This report presents an analysis of a Linux system monitoring script, mySysMonitor.sh, designed to log system and network information. The report begins with an introduction to the importance of shell commands in monitoring and administration, followed by a detailed explanation of the script's requirements. The core of the report focuses on the script's functionality, which involves using various UNIX terminal commands to gather data on active processes, resource-intensive processes, connected devices, disk space usage, network interfaces, and other system details. The report justifies the use of each command and then provides screenshots of the script and log files to verify the output. The report concludes by highlighting the utility of shell scripts in providing comprehensive system and network monitoring capabilities. This report is a coursework assignment submitted by a student and available on Desklib, a platform providing AI-powered study tools.
Document Page
Running head: NETWORK AND SYSTEM MONITORING
Network and System Monitoring
Name of the Student
Name of the University
Author Note
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1NETWORK AND SYSTEM MONITORING
Abstract
A wide range of researches have proved the importance of UNIX or Linux shell commands
for the purpose of checking various system or even network specific information. Despite
these details also being available through GUI interfaces, shell scripts are found to provide
the complete details and aid in generating logs which automatically show output of shell
commands specified by the script and can be opened by admins any time. The report
concerns a script file mySysMonitor.sh which prints the output of different system based and
networking specific data in the mySysMonitor.log file. In performing this, the report uses
various UNIX based terminal commands and their respective extensions for printing the
desired results. The report then explains the use of these commands. After this different
screenshots are provided by the report showing contents of the script and log files. Thus the
report verifies the log output and ends with concluding notes.
Document Page
2NETWORK AND SYSTEM MONITORING
Table of Contents
Introduction................................................................................................................................3
Requirements..............................................................................................................................4
Solution......................................................................................................................................4
Shell script commands and justification................................................................................7
Currently active processes..................................................................................................7
Five most CPU and RAM hungry processes......................................................................7
All connected devices and USBs.......................................................................................8
Usage of disk space – overall.............................................................................................8
Usage of disk space – Home Directory..............................................................................8
Usage of disk space – Other Directories............................................................................8
Network interfaces and their states....................................................................................8
Other key directories..........................................................................................................8
Screenshots.............................................................................................................................9
mySysMonitor.sh in text editor..........................................................................................9
mySysMonitor.sh through terminal.................................................................................10
mySysMonitor.log in text editor......................................................................................10
mySysMonitor.log through the terminal..........................................................................11
Conclusion................................................................................................................................11
Bibliography.............................................................................................................................13
Document Page
3NETWORK AND SYSTEM MONITORING
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4NETWORK AND SYSTEM MONITORING
Introduction
This report below tries to highlight the importance of UNIX or Linux shell commands
for the purpose of checking various system or even network specific information. The report
begins by specifying the requirements of monitoring and administration of the system and the
network. Here the report concerns a script file mySysMonitor.sh which prints the output of
different system based and networking specific data in the mySysMonitor.log file. In
performing this, the report uses various UNIX based terminal commands and their respective
extensions for printing the desired results. The report then explains the use of these
commands. After this different screenshots are provided by the report showing contents of the
script and log files. Thus the report verifies the log output and ends with concluding notes.
Document Page
5NETWORK AND SYSTEM MONITORING
Requirements
The shell script file mySysMonitor.sh must be created such that the file periodically
writes system and network information into a log file named mySysMonitor.log in automatic
ways.
The mySysMonitor.log file is supposed to contain in depth information as also time
related details as per the changes occurring to the processes running currently in background,
five top CPU intensive and RAM heavy applications, all the devices that are currently
plugged to the system, overall disk usage percentage of the system including that of home
directory in particular as also all the other directories. The file is also to include information
based on the network interfaces as also other information that are relevant for monitoring of
the system and network.
This file containing the shell script commands must be built with GNU nano which is
the text editor for UNIX or Linux based operating systems with appropriate headings
specified on top.
The file thus created should be such that the network administrators are able to open
this program by means of simple cat commands in CLI terminals of UNIX or Linux (Ubuntu)
based operating systems.
Solution
The concerned solution involves a file containing shell script commands for printing
various details owing to administration of the system, the as also monitoring of performance
of both system components and network interfaces in the file called mySysMonitor.log. The
aim behind this is to aid in determining if these systems are operating as expected and
whether or not there are presence of suspicious activities running on the existing network
Document Page
6NETWORK AND SYSTEM MONITORING
interfaces and to find their current state. This monitoring data can consist of the below listed
details about the network and the system:
o Processes currently active on the system
o Five most resource hungry processes (CPU and RAM)
o All devices and USBs connected to the system
o Disk space Usage: The overall disk usage of the system
o Disk space Usage: Home directory usage of disk space
o Disk space Usage: Usage of disk by other key directories
o State of network interfaces and their availability
o Other information relevant to monitoring and administration of the system and
the network
The above details are next then printed into the log file called mySysMonitor.log. Network
administrators can view the contents of the log file as also the shell script file through the
terminals and even the text editors. The file containing the shell script commands -
mySysMonitor.sh contains the following script.
#!/bin/bash
# My System Information
#redirect stdout/stderr to a file
exec &> mySysMonitor.log
echo "Currently active processes - ";
ps
echo " 5 most CPU intensive and RAM hungry processes - ";
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
7NETWORK AND SYSTEM MONITORING
ps aux | sort -rk 3,3 | head -n 6
echo "All connected devices and USBs - ";
lsusb
echo "Usage of disk space - ";
echo "Overall usage of the disk - ";
df -h /dev/sda1
echo "Disk usage of home directory - ";
df -hT /home
echo " Disk usage of other key directories - ";
df -h
echo "Available network interfaces and their present state - ";
ip link show
echo "Other information relevant to the system";
uname –a
As can be found from the above shell script, it addresses all the five criteria out of which the
criteria for disk usage contains a set of three sub criteria which are overall usage of system
disk space, disk space usage of home directory and disk usage of other important directories.
The file mySysMonitor.log according to the shell script file shows the echo message followed
by the corresponding results
Document Page
8NETWORK AND SYSTEM MONITORING
The above file needs to be run using the command - ./mySysMonitor.sh
This creates the mySysMonitor.log file which is generated by the shell script file
Shell script commands and justification
Currently active processes
‘ps’ – To show the processes which are active currently, the UNIX command ‘ps’ can serve a
very useful purpose in Linux based operating systems where ps stands for ‘process status’.
This ps command makes it possible to view details of those processes which are active or
running in the system background. This command lists every process that is currently active
while also showing their PIDs.
Five most CPU and RAM hungry processes
‘ps aux | sort -rk 3,3 | head -n 6’ – The aux part in ‘ps aux | sort -rk 3,3 | head -n 6’ serve to
perform various types of tasks. They can include showing all processes for all users by means
of ‘a’, display of users or owners of numerous processes by means of ‘u’ and showing of
processes that are absent from the terminal by means of ‘x’. After this multiple filters can get
applied through the use of separators denoted by the ‘|’s. The filters can perform sort
Document Page
9NETWORK AND SYSTEM MONITORING
operations by specifying ‘r’ and ‘k’ values. Another filter can be applied by using another
separator.
All connected devices and USBs
lsusb - lsusb makes it possible to display details regarding the USB bus slots which exists in
the system and shows details of all devices connected to them.
Usage of disk space – overall
df - h /dev/sda1 – The command df-h makes it possible for showing total system disk usage.
Here, the ‘/dev/sda1’ extension shows the combined disk space usage of that particular user
directory of the system which usually contain the operating system.
Usage of disk space – Home Directory
df - hT /home – The hT /home extension used shows the output containing usage of disk
space of particularly the home directory.
Usage of disk space – Other Directories
df - h – The command has been used in different forms for the above purposes of finding disk
usages of different directories from the system. Here, no specific directories are mentioned
and hence no specific results are shown that is disk usage of all other directories are
displayed.
States of Network interfaces
ip link show – This shell command is used to display output regarding details of network
interfaces along with the current state of network interfaces.
Other important directories
uname - a – This UNIX command can be used in the terminal for displaying details about
which operating system is installed in the system currently.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
10NETWORK AND SYSTEM MONITORING
Screenshots
The screenshots provided below verify that the file mySysMonitor.sh thus created and
the log file generated by this script file mySysMonitor.log meets the requirements for the
network administrators. Screenshots of mySysMonitor.log present the outputs of shell
commands listed in script file mySysMonitor.sh.
mySysMonitor.sh in text editor
Document Page
11NETWORK AND SYSTEM MONITORING
mySysMonitor.sh through terminal
mySysMonitor.log in text editor
chevron_up_icon
1 out of 16
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]