With all the flexibilities provided by the Linux systems, there are numerous issues that arouses due to the open source nature of the operating system. Even though most of the distributions of Linux are bundled with lots of performance monitoring tools. All these command line and GUI based tools offers different metrics that can be utilized to collect information about system and user activities.
System administrators can utilize all these tools in order to find out the possible reasons of any kind of performance issues for any kind of Linux distributions. The following report contributes the development of a shell script that uses the most fundamental commands to system performance analysis and other debugging issues.
Specification
The shell script for this project is developed using the Vim Text editor and Bash shell on the Ubuntu distribution of Linux. All the commands that are compatible with different distributions of the Linux operating system is included and managed in the script. Being the best practice the terminal in the Ubuntu is used for development and testing of the script.
Using the terminal, we changed the permission of the script to be a executable using the chmod +x mySysMonitor.sh is used. Apart from this the terminal is used checking devices, status and usage, files permission as well as folders of the file systems. As it is important to generate a log file in html format thus using the ./mySysMonitor.sh to execute the script and store the file in the directories.
Design consideration
Following are the code to of the developed script that generates the HTML report of the Linux System monitoring activities.
usbdev_name=`lsusb`
upt=`ip link show`
ip_add=`ifconfig | grep “inet addr” | head -2 | tail -1 | awk {‘print$2’} | cut -f2 -d:`
num_proc=`ps -ef | wc -l`
total_root_size=`df -h /dev/sda1 | tail -1 | awk ‘{print$2}’`
load_avg=`cat /proc/loadavg | awk {‘print$1,$2,$3’}`
disk_usage=`df -h /boot| awk {‘print $5,$6’}`
ram_total=`free -m | head -2 | tail -1 | awk {‘print$2’}`
prcs=`ps`
user=`who`
if [ ! -d ${HOME}/mySysMonitorlog ]
then
mkdir ${HOME}/mySysMonitorlog
fi
html=”${HOME}/health_reports/mySysMmonitor.log-“.html”
for i in `ls /home`; do sudo du -sh /home/$i/* | sort -nr | grep G; done > /tmp/dir.txt
echo “<html>” >> $html
echo “<body>” >> $html
echo “<fieldset>” >> $html
echo “<center>” >> $html
echo “<h2>Linux system monitoring Report” >> $html
echo “</center>” >> $html
echo “</fieldset>” >> $html
echo “<br>” >> $html
echo “<center>” >> $html
echo “<h2>Report Details : </h2>” >> $html
echo “<table class=”pure-table”>” >> $html
echo “<thead>” >> $html
echo “<tr>” >> $html
echo “<th>usb devices</th>” >> $html
echo “<th>user</th>” >> $html
echo “<th>IP Address of the system</th>” >> $html
echo “<th>network interfaces</th>” >> $html
echo “</tr>” >> $html
echo “</thead>” >> $html
echo “<tbody>” >> $html
echo “<tr>” >> $html
echo “<td>$usbdev_name</td>” >> $html
echo “<td>$user</td>” >> $html
echo “<td>$ip_add</td>” >> $html
echo “<td>$upt</td>” >> $html
echo “</tr>” >> $html
echo “</tbody>” >> $html
echo “</table>” >> $html
echo “<h2>Resources: </h2>” >> $html
echo “<br>” >> $html
echo “<table class=”pure-table”>” >> $html
echo “<thead>” >> $html
echo “<tr>” >> $html
echo “<th># of Processes</th>” >> $html
echo “<th>Total Size of Root FS</th>” >> $html
echo “<th>Load Average</th>” >> $html
echo “<th>Disk usgae</th>” >> $html
echo “<th> RAM</th>” >> $html
echo “<th>Current Processes</th>” >> $html
echo “</tr>” >> $html
echo “</thead>” >> $html
echo “<tbody>” >> $html
echo “<tr>” >> $html
echo “<td><center>$num_proc</center></td>” >> $html
echo “<td><center>$load_avg</center></td>” >> $html
echo “<td><center>$disk_usage</center></td>” >> $html
echo “<td><center>$ram_total</center></td>” >> $html
echo “<td><center>$prcs</center></td>” >> $html
echo “</tr>” >> $html
echo “</tbody>” >> $html
echo “</table>” >> $html
echo “<h2>other Directories </h2>” >> $html
echo “<br>” >> $html
echo “<table class=”pure-table”>” >> $html
echo “<thead>” >> $html
echo “<tr>” >> $html
echo “<th>Size</th>” >> $html
echo “<th>Name</th>” >> $html
echo “</tr>” >> $html
echo “</thead>” >> $html
echo “<tr>” >> $html
while read size name;
do
echo “<td>$size</td>” >> $html
echo “<td>$name</td>” >> $html
echo “</tr>” >> $html
echo “</tbody>” >> $html
done < /tmp/dir.txt
echo “</table>” >> $html
echo “</body>” >> $html
echo “</html>” >> $html
echo “Report has been generated in ${HOME}/health_reports with file-name = $html.”
Extensive test result and screenshot
The following is the screenshot, which depicts the use and installation of the mySysMonitor.sh script which asks the user to enter the sudo user password in order to generate and store the report.
The above screen shot shows the html report browsed in the Mozilla browser which is available in the Ubuntu distributions of Linux.
Conclusion
It is important to monitor the use of the resources by the different users and processes in order to maintain the consistent performance level of the system that is using the Linux distributions while addressing the issues of the system in an efficient way. The script is developed in such a way that, it will ask for “sudo” password before running and installing it on any system on bash script. So that only the system administrators will be able to access she results and control the system resource utilization. Even though the use of the sell script is time and memory consuming as for the execution of the script every time a new process is started from the Linux kernel.
Ebrahim, M. and Mallett, A., 2018. Mastering Linux Shell Scripting: A practical guide to Linux command-line, Bash scripting, and Shell programming.
Gantala, A., Vijaykumar, G., Telagam, N. and Anjaneyulu, P., 2017. Design of Smart Sensor Using Linux-2.6. 29 Kernel. International Journal of Applied Engineering Research, 12(18), pp.7891-7896.
Gantala, A., Vijaykumar, G., Telagam, N. and Anjaneyulu, P., 2017. Design of Smart Sensor Using Linux-2.6. 29 Kernel. International Journal of Applied Engineering Research, 12(18), pp.7891-7896.
Kraemer, J.A., CARBON BLACK Inc, 2017. System and Method for Reverse Command Shell Detection. U.S. Patent Application 15/457,719.
Wang, B., Lu, K. and Chang, P., 2016, August. Design and implementation of Linux firewall based on the frame of Netfilter/IPtable. In Computer Science & Education (ICCSE), 2016 11th International Conference on (pp. 949-953). IEEE.
Essay Writing Service Features
Our Experience
No matter how complex your assignment is, we can find the right professional for your specific task. Contact Essay is an essay writing company that hires only the smartest minds to help you with your projects. Our expertise allows us to provide students with high-quality academic writing, editing & proofreading services.Free Features
Free revision policy
$10Free bibliography & reference
$8Free title page
$8Free formatting
$8How Our Essay Writing Service Works
First, you will need to complete an order form. It's not difficult but, in case there is anything you find not to be clear, you may always call us so that we can guide you through it. On the order form, you will need to include some basic information concerning your order: subject, topic, number of pages, etc. We also encourage our clients to upload any relevant information or sources that will help.
Complete the order formOnce we have all the information and instructions that we need, we select the most suitable writer for your assignment. While everything seems to be clear, the writer, who has complete knowledge of the subject, may need clarification from you. It is at that point that you would receive a call or email from us.
Writer’s assignmentAs soon as the writer has finished, it will be delivered both to the website and to your email address so that you will not miss it. If your deadline is close at hand, we will place a call to you to make sure that you receive the paper on time.
Completing the order and download