Question
Write a complete bash script that monitors the number of processes per user on the current CSE Linux machine (e.g., cse01, cse02, etc.) where the
Write a complete bash script that monitors the number of processes per user on the current CSE Linux machine (e.g., cse01, cse02, etc.) where the script is running. In particular, you will count all processes and total them per user every 5 seconds and report each user ID with the number of processes running during that time frame. Note this will include system processes. If the user enters a list of user IDs as arguments to the program it should only report processes for those users. In addition, you will install a custom signal handler to trap the SIGINT (i.e., ^C). This signal handler should prompt the user if they really want to exit. If they enter Y or y, your program should exit. If anything else is entered, the program should continue to run.
You will also print out the current date and time, a heading before listing the users and process count followed by a line containing the total number of users and total number of processes running. The users column and the counts should line up to look nice. Add a blank line between each output to make it easier to see each report. The output of each line
Please see the SAMPLE OUTPUT for several examples, including the different scenarios that might occur.
$ ./minor2.sh root uuidd WDJ0017
Sun 16 Feb 2020 11:19:06 PM CST
User ID Count
root 92
wdj0017 8
uuidd 1
3 USERS, TOTAL PROCESSES 101
Sun 16 Feb 2020 11:19:11 PM CST
User ID Count
root 92
wdj0017 8
uuidd 1
3 USERS, TOTAL PROCESSES 101
^C (SIGINT) received
Terminate Program? (Y/N) n
Continuing Execution
Sun 16 Feb 2020 11:19:16 PM CST
User ID Count
root 90
wdj0017 8
uuidd 1
3 USERS, TOTAL PROCESSES 99
Sun 16 Feb 2020 11:19:21 PM CST
User ID Count
root 90
wdj0017 8
uuidd 1
3 USERS, TOTAL PROCESSES 99
^C (SIGINT) received
Terminate Program? (Y/N) Y
Terminating program
$ ./minor2.sh
Sun 16 Feb 2020 11:21:34 PM CST
User ID Count
lightdm 14
cth0124 2
pcp0019 4
root 104
cjh0372 2
colord 1
rtkit 1
hhh0028 10
vsb0030 6
gst0031 2
fbg0007 5
eee0086 2
statd 1
shd0033 3
ga0221 6
sd0683 2
mel0220 6
aas0376 4
an0548 7
rk0423 12
jl0844 12
gj0099 14
systemd-resolve 1
systemd-timesync 1
pam0196 4
nmp0081 1
dmg0151 6
kas0499 3
aaa0694 1
rjp0109 4
mba0096 2
vg0254 7
nkn0021 7
tn0188 7
sn0508 2
bb0472 2
wdj0017 8
ima0041 3
ajs0403 4
pk0316 6
uuidd 1
rte0023 1
at0733 2
sshd 2
lam0518 2
fk0071 5
at0747 2
rwa0048 2
ksg0102 4
ao0291 2
50 USERS, TOTAL PROCESSES 312
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started