Question: Overview In this assignment you will use BASH and various system utilities to construct a system monitor that periodically reports and alerts on system activities

Overview
In this assignment you will use BASH and various system utilities to construct a system
monitor that periodically reports and alerts on system activities such as Network Usage
(number of connections, data sent, data received), Disc I.O., Running Processes (including
their CPU, and Memory consumption), System CPU and Memory consumption, the system
temperature, and system load.
To be successful you will need to create several bash functions, utilize and parse the output of
multiple commands (this may require using parsing commands). A helpful list of commands
to research:
top
vmstat
iostat
netstat
ifstat
uptime
ps
df
wc
grep
sed
cut
awk
date
cat
sort
head
If you need to find a way to get data and dont know the command apropos can help. For
some items you may need to get information from the /sys system
(i.e./sys/class/thermal/thermal zone0). You can explore the various classes there for if
there are ones of use.
2
System Monitor [80 Points]
Your system monitor will be involved with the following command format:
./system_monitor.sh 1060./sys_monitor.log "cpu>80 mem>90 disk>75" eno0\
sda /sys/class/thermal/thermal_zone0/temp
(line break for clarity) where the arguments are as follows:
Interval (e.g.10 seconds how often to check all parameters)
Duration (e.g.60 seconds how long to run for)
Logfile (e.g.60./sys monitor.log where to log the data)
Alerts (e.g.cpu80 mem90 disk75 What tests should trigger an alert)
Network Interface (e.g. eno0 what network interface to monitor)
Drive (e.g. sda what disc to monitor)
Temperature Node (e.g./sys/class/thermal/thermal zone0/temp what tempera-
ture node to monitor)
You should always monitor the following parameters:
cpu Current Total CPU usage, unit: %
mem Current Total MEM usage, unit: %
net tx Current Total Network Transmit, unit: packets
net rx Current Total Network Receive, unit: packets
net con Current Total Network Connections, unit: none
disk Current Total Disk usage, unit: kB
disk W Current Total Disk write, unit: kB
disk R Current Total Disk read, unit: kB
proc Current Total Number of Processes (all users), unit: none
proc cpu Current Process (name) with highest cpu usage, unit: none
proc mem Current Process (name) with highest memory usage, unit: none
temp Current system temperature, unit: C
load Current system 1 minute load average, unit: none
3
Logging
Your monitor should output these parameters to a log file at each interval on a single line
with no units separated by a space preceeded by a timestamp in the format YYYYMMDD-HHMM:
20240707-1435 cpu=50 mem=75, net_tx=750 net_rx=500 net_con=500 disk=500532\
disk_W=44001039 disc_R=5181087 proc=896 proc_cpu=tmux proc_mem=systemd \
temp=76 load=0.01
Your log should follow exactly this format (line breaks in this document for clarity
should not be in your output)
Alerts
Your monitor should detect if a parameter matches an alert condition and report this to
both the logfile and stderr. The alert should report the timesamp and the condition broken.
If multiple conditions are broken report them on separate lines. i.e:
20240707-1435 ALERT: cpu>80
Your alerts should follow exactly this format
Bonus [5 Points]
Make your monitor run indefinitely when the duration is given as 0. The command must be
terminated with a ctrl-C and print a message that it is stopping to receive this bonus, a
simple infinite loop will not qualify. Hint: man trap
Testing [20 Points]
Testing system events can be difficult, but not impossible. First write a test plan of the
general proceedure for how you would test monitoring and alerting. (i.e. test cpu usage
by increasing cpu usage and checking for evidence in the log) For now keep this high level
without considering exactly how you will accomplish these tasks. Document as many of
these tests as you think you need, you should try to cover all of the different monitors, but
dont have to test only one at a time (in somecases that might be very difficult or impossible)
Call this file testplan-initial.txt.
Now, for each test use man pages, apropos, and any other resources to develop an idea of
how to create the test condition. For each test case document a command that can create the
conditions you want (i.e. for increasing cpu usage you might run a cpu intensive program).
These commands should be usable on the lab machines. Add these to your test plan in a
new file testplan-completed.txt
4
Lastly execute your test plan, and document the results. Include snippets of the log or
command output which show your monitor passed the test.
5
Files to hand in

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!