The report is prepared for creation of a change logger script created in ubuntu OS and management of the regular activity of the user using the system. For the development of the shell script the details of the system is extracted using different shell command and the output is stored in an HTML file that would help the administrator to monitor the status of the system. The pre-installed command line tools are used for the creation of the shell script and the output is stored in a temporary log file for the management of the changes in the logs and identify the changes in made in the current system.
Specification
The shell script is created using the nano editor and it is named as “mySysMonitor.sh”, and proper permission is added to the shell script for running it. Administrative permission is needed for running the shell script and thus “chmod +x mySysMonitor.sh” command is used for providing appropriate permission and running the shell script. “sudo ./mySysMonitor.sh”, command is used for running the shell script as root user and generate the output in a HTML file.
Design Consideration
The shell script is designed using separate command for getting each of the information necessary for the development of the change logger script. The main function of the script is to monitor the current computer system and the activity of the user for creating a log with the key information. The script is named as “mySysMonitor.sh” which automatically and regularly writes the information in log file named “mySysMonitor.log”.
The output of the shell script is stored in the html file and it uses the “mySysMonitor.log” as a temporary file for storing the result of the command executed in the shell script. Since the contents of the file is copied in a temporary file and “tail -f” command is used for comparing the changes in the log file and identification of the changes made in the current system. For constructing the shell script the the following commands are used such as:
printf “At %s: n” “$(date)” // displays the data and time of the system
ps // displays the current processes running on the system
who // finds the users logged into the system
lsusb // finds the usb devices plugged in with the system
df -h /boot|awk ‘{print $5 ” “$6}’ // used for displaying the overall disk usage
df -h /home|sed -n ‘2p’ |awk ‘{print $5 ” “$6}’ // lists the home directory of the user
df -h // lists the other key directories of the system
ip link show // displays the network interface used for connecting with the internet
ping -c 1 google.com &> /dev/null && echo -e “Internet: Connected” || echo -e “Internet: Disconnected”; // used for finding the connection is active or disconnected
(uptime | awk ‘{print $3,$4}’ | cut -f1 -d,) // used for finding the system uptime
Extensive test result and exemplary log and screen output
The shell script prepared for management of the change log is given below:
#! /bin/bash
#Author : – Student
#Date : – 29 November, 2018
#Check if the script is executed as ROOT. The script must be run from a root user for maintaining proper directory structure:
if [ $EUID != 0 ]
then
echo “Run the script as root for viewing all the details! Better run with sudo.”
exit 1
fi
#Declaring variables
#set -x
Number_of_Process=`ps -ef | wc -l`
Currently_logged_in_users=`who`
Plugged_in_Devices=`lsusb`
Root_size=`df -h /dev/sda1 | tail -1 | awk ‘{print$2}’`
Disk_usage=`df -h /boot|awk ‘{print $5 ” “$6}’`
Users_home_directory=`df -h /home|sed -n ‘2p’ |awk ‘{print $5 ” “$6}’`
ip_add=`ip link show | grep “inet addr” | head -2 | tail -1 | awk {‘print$2’} | cut -f2 -d:
ping -c 1 google.com &> /dev/null && echo -e “Internet: Connected” || echo -e “Internet: Disconnected”;`
root_fs_pc=`df -h /dev/sda1 | tail -1 | awk ‘{print$5}’`
upt=`uptime | awk {‘print$3′} | cut -f1 -d’,’`
#load_avg=`uptime | cut -f5 -d’:’`
ram_usage=`free -m | head -2 | tail -1 | awk {‘print$3’}`
ram_total=`free -m | head -2 | tail -1 | awk {‘print$2’}`
inode=`df -i / | head -2 | tail -1 | awk {‘print$5’}`
#Creating a directory if it doesn’t exist to store reports first, for easy maintenance.
if [ ! -d ${HOME}/system_reports ]
then
mkdir ${HOME}/system_reports
fi
html=”${HOME}/system_reports/System-Health-Report-`hostname`-`date +%y%m%d`-`date +%H%M`.html”
email_add=”[email protected]“
for i in `ls /home`; do sudo du -sh /home/$i/* | sort -nr | grep G; done > /tmp/mySysMonitor.log
#Generating HTML file
echo “<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “https://www.w3.org/TR/html4/loose.dtd”>” >> $html
echo “<html>” >> $html
echo “<link rel=”stylesheet” href=”https://unpkg.com/[email protected]/build/pure-min.css”>” >> $html
echo “<body>” >> $html
echo “<fieldset>” >> $html
echo “<center>” >> $html
echo “<h2>Linux System Change Logger Script” >> $html
echo “<h3><legend>Script authored by Student</legend></h3>” >> $html
echo “</center>” >> $html
echo “</fieldset>” >> $html
echo “<br>” >> $html
echo “<center>” >> $html
echo “<h2>System Details : </h2>” >> $html
echo “<table class=”pure-table”>” >> $html
echo “<thead>” >> $html
echo “<tr>” >> $html
echo “<th>Number_of_Process</th>” >> $html
echo “<th>Currently_logged_in_users</th>” >> $html
echo “<th>Plugged_in_Devices</th>” >> $html
echo “<th>Uptime</th>” >> $html
echo “</tr>” >> $html
echo “</thead>” >> $html
echo “<tbody>” >> $html
echo “<tr>” >> $html
echo “<td>$Number_of_Process</td>” >> $html
echo “<td>$Currently_logged_in_users</td>” >> $html
echo “<td>$Plugged_in_Devices</td>” >> $html
echo “<td>$upt</td>” >> $html
echo “</tr>” >> $html
echo “</tbody>” >> $html
echo “</table>” >> $html
echo “<h2>Resources Utilization : </h2>” >> $html
echo “<br>” >> $html
echo “<table class=”pure-table”>” >> $html
echo “<thead>” >> $html
echo “<tr>” >> $html
echo “<th>Overall Disk Usage</th>” >> $html
echo “<th>The user’s home directory</th>” >> $html
echo “<th>Other key directories</th>” >> $html
echo “<th>Network Interface and their states</th>” >> $html
echo “<th>Used RAM(in MB)</th>” >> $html
echo “<th>Total RAM(in MB)</th>” >> $html
echo “<th>iNode Status</th>” >> $html
echo “</tr>” >> $html
echo “</thead>” >> $html
echo “<tbody>” >> $html
echo “<tr>” >> $html
echo “<td><center>$$Root_size</center></td>” >> $html
echo “<td><center>$root_fs_pc</center></td>” >> $html
echo “<td><center>$Users_home_directory</center></td>” >> $html
echo “<td><center>$ip_add</center></td>” >> $html
echo “<td><center>$ram_usage</center></td>” >> $html
echo “<td><center>$ram_total</center></td>” >> $html
echo “<td><center>$inode</center></td>” >> $html
echo “</tr>” >> $html
echo “</tbody>” >> $html
echo “</table>” >> $html
while read size name;
do
echo “<td>$size</td>” >> $html
echo “<td>$name</td>” >> $html
echo “</tr>” >> $html
echo “</tbody>” >> $html
done < /mySysMonitor.log
echo “</table>” >> $html
echo “</body>” >> $html
echo “</html>” >> $html
echo “Report has been generated in ${HOME}/mySysMonitor with file-name = $html. Report has also been sent to $email_add.”
#Sending Email to the user
cat $html | mail -s “`hostname` – mySysMonitor” -a “MIME-Version: 1.0” -a “Content-Type: text/html” -a “From: user <[email protected]>” $email_add
Conclusion
The creation of the shell script helps in reducing the effort of the network engineer for monitoring and management of the activity of the user. The shell script can be executed for getting all the information about the current system by using a single command and the user does not need to use individual command for analysing each of the activity. Apart form the advantage it also have some disadvantage that is the speed of execution is slower when the shell script is compared with the different programming language that can eb used alternatively for monitoring the activity of the current user and management of the changes made in the current system.
Banfield, J., Germaine, N. and Gerard, M., 2016. Ubuntu Linux: Learn administration, networking, and development skills with the# 1 Linux distribution!.
Brash, R. and Naik, G., 2018. Bash Cookbook: Leverage Bash scripting to automate daily tasks and improve productivity. Packt Publishing Ltd.
Cook, J., 2017. Interactive Programming. In Docker for Data Science (pp. 49-70). Apress, Berkeley, CA.
Domínguez, A.I.D., Díaz, W.M.F. and Gordon, S.S., 2018. Enterprise file synchronization and sharing services for educational environments in case of disaster. Facultad de Ingeniería, 27(47), p.3.
Flynt, C., Lakshman, S. and Tushar, S., 2017. Linux Shell Scripting Cookbook. Packt Publishing Ltd.
Jang, M. and Orsaria, A., 2016. RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 & EX300). McGraw-Hill Education Group.
Lee, M.L., Aliagas, I., Feng, J.A., Gabriel, T., O’donnell, T.J., Sellers, B.D., Wiswedel, B. and Gobbi, A., 2017. chemalot and chemalot_knime: Command line programs as workflow tools for drug discovery. Journal of cheminformatics, 9(1), p.38.
Lin, X.V., Wang, C., Zettlemoyer, L. and Ernst, M.D., 2018. NL2Bash: A Corpus and Semantic Parser for Natural Language Interface to the Linux Operating System. arXiv preprint arXiv:1802.08979.
Mishra, D. and Khandelwal, G., 2018. Command-Line Tools in Linux for Handling Large Data Files. In Bioinformatics: Sequences, Structures, Phylogeny (pp. 375-392). Springer, Singapore.
Mysore, A. and Guo, P.J., 2017, October. Torta: Generating Mixed-Media GUI and Command-Line App Tutorials Using Operating-System-Wide Activity Tracing. In Proceedings of the 30th Annual ACM Symposium on User Interface Software and Technology (pp. 703-714). ACM.
Ponyared, P., Ponsawat, J., Tongsima, S., Seresangtakul, P., Akkasaeng, C. and Tantisuwichwong, N., 2016. ESAP plus: a web-based server for EST-SSR marker development. BMC genomics, 17(13), p.1035.
Rybczy?ski, M., Stefanek, G., Broniowski, W. and Bo?ek, P., 2014. GLISSANDO 2: GLauber Initial-State Simulation AND mOre…, ver. 2. Computer Physics Communications, 185(6), pp.1759-1772.
Shen, Z., 2015. A Gentler Introduction to Unix.
Stevens, W.R. and Rago, S.A., 2013. Advanced programming in the UNIX environment. Addison-Wesley.
Taylor, D. and Perry, B., 2016. Wicked Cool Shell Scripts: 101 Scripts for Linux, OS X, and UNIX Systems. No Starch Press.
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