Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are two (2) problems with this script. The first involves an error in the output about a missing command. The second is the fact

There are two (2) problems with this script. The first involves an error in the output about a missing command. The second is the fact that the vmstat command should include a timestamp for each line of output. To address the second problem you will need to read the documentation for vmstat. .

#!/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/syslog |cut -c 1-12) oom=$(grep -ci kill /var/log/syslog) 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 "Open TCP ports:" nmap -p- -T4 127.0.0.1 echo "--------------------" echo "Current connections:" ss -s echo "--------------------" echo "processes:" ps auxf --width=200 echo "--------------------" echo "vmstat:" vmstat 1 5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions