Answered step by step
Verified Expert Solution
Question
1 Approved Answer
SCRIPT DESCRIPTION: Write a complete bash script that monitors the number of processes per user on the current CSE Linux machine (e.g., cse01, cse02, etc.)
SCRIPT DESCRIPTION: 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 (.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. REQUIREMENTS: Your script should be well documented in terms of comments. For example, good comments in general consist of a header (with your name, course section, date, and brief description), comments for each variable, and commented blocks of code. Your bash script should be named minor2.sh", without the quotes. Note that this must be done as a bash script, not a C program. Your script will be graded based largely on whether it works correctly on the CSE machines (e.g., cse01, cse02, ..., cse06), so you should make sure that your script runs on a CSE machine. Please pay attention to the SAMPLE OUTPUT for how this script is expected to work. If you have any questions about this, please contact your instructor or TAS assigned to this course to ensure you understand these directions. SAMPLE OUTPUT (user input shown in bold): $ ./minor2.sh root uuidd WDJ0017 92 Sun 16 Feb 2020 11:19:06 PM CST User ID Count root wdj 0017 uuidd 3 USERS, TOTAL PROCESSES 101 CON Sun 16 Feb 2020 11:19:11 PM CST User ID Count root wdj 0017 uuidd 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 wdj 0017 uuidd 3 USERS, TOTAL PROCESSES 99 O 000 90 Sun 16 Feb 2020 11:19:21 PM CST User ID Count root wdj 0017 uuidd 3 USERS, TOTAL PROCESSES ^C (SIGINT) received Terminate Program? (Y/N) Y Terminating program 99 $ ./minor2.sh Sun 16 Feb 2020 11:21:34 PM CST User ID Count lightdm cth0124 pcp0019 root cjh0372 colord rtkit hhh0028 vsb0030 gst0031 fbg0007 eee0086 NUN OPENAN statd shd0033 ga0221 sd0683 me10220 aas0376 an0548 rk0423 j10844 gj0099 systemd-resolve systemd-timesync pam0196 nmp 0081 dmg0151 kas0499 aaa0694 rip0109 mba 0096 vg0254 nkn0021 tn0188 sn0508 bb0472 wdj 0017 ima 0041 ajs0403 pk0316 uuidd rte 0023 at0733 sshd lam0518 fk0071 at0747 rwa0048 ksg0102 ao0291 50 USERS, TOTAL PROCESSES NNNNNNNPPOWOONNNPWPPANNONOW 14 Sun 16 Feb 2020 11:21:39 PM CST User ID Count light dm cth0124 pcp0019 root cjh0372 colord rtkit hhh0028 vsb0030 gst0031 fbg0007 eee 0086 NUN statd shd0033 ga0221 sd0683 me10220 aas0376 an0548 rk0423 j10844 gj0099 systemd-resolve systemd-timesync pam0196 nmp0081 dmg0151 kas0499 aaa0694 rjp0109 mba 0096 vg0254 nkn0021 tn0188 sn0508 bb0472 wdj 0017 ima0041 aj s0403 pk0316 uuidd rte0023 at0733 sshd lam0518 fk0071 at0747 rwa0048 ksg0102 a00291 50 USERS, TOTAL PROCESSES ^C (SIGINT) received Terminate Program? (Y/N) Y Terminating program 31
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