Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is Shell Scripting I need the following code modified to make is eaiser to

ID: 3818018 • Letter: T

Question

This is Shell Scripting

I need the following code modified to make is eaiser to read by adding blank lines, titiles, sections, and/or color to make the output more user friendly.

#!/bin/bash

date;

echo "uptime:"

uptime

echo "Currently connected:"

w

echo "--------------------"

echo "Last logins:"

last -a |head -3

echo "--------------------"

echo "Disk and memory usage:"

df -h | xargs | awk '{print "Free/total disk: " $11 " / " $9}'

free -m | xargs | awk '{print "Free/total memory: " $17 " / " $8 " MB"}'

echo "--------------------"

start_log=`head -1 /var/log/messages |cut -c 1-12`

oom=`grep -ci kill /var/log/messages`

echo -n "OOM errors since $start_log :" $oom

echo ""

echo "--------------------"

echo "Utilization and most expensive processes:"

top -b |head -3

echo

top -b |head -10 |tail -4

echo "--------------------"

echo "Current connections:"

ss -s

echo "--------------------"

echo "processes:"

ps auxf --width=200

echo "--------------------"

echo "vmstat:"

vmstat 1 5

Explanation / Answer

#!/bin/bash
date;
echo "uptime:"
uptime
echo "Currently connected:"
w
echo "User Details:"
echo "Last logins:"
last -a |head -3
echo "Disk Usage Details: "
echo "Disk and memory usage:"
df -h | xargs | awk '{print "Free/total disk: " $11 " / " $9}'
free -m | xargs | awk '{print "Free/total memory: " $17 " / " $8 " MB"}'
echo "Manage Out of Memory Error:"
start_log=`head -1 /var/log/messages |cut -c 1-12`
oom=`grep -ci kill /var/log/messages`
echo -n "OOM errors since $start_log :" $oom
echo ""
echo "Process Management"
echo "Utilization and most expensive processes:"
top -b |head -3
echo
top -b |head -10 |tail -4
echo "Socket Statistics"
echo "Current connections:"
ss -s
echo "Process Status"
echo "processes:"
ps auxf --width=200
echo "Virtual Memory Statistics"
echo "vmstat:"
vmstat 1 5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote