For the preparation of the report on Linux system change Logger script we have selected Ubuntu as the Linux operating system for running the bash script. The script is developed with the common pre-installed command line tools without relying on the additional program or tools or libraries. The main content of the log file is the time stamped details of the significant changes of the current processes, currently logged in users. Plugged in devices, disk usage information for the different directories, state of network and details of the interface and other relevant information that is used for monitoring the computer.
For the creation of the shell script a new file is needed to be created and the shell script should be started with #!/bin/bash and for saving the file .sh is used as the extension and permission is needed to be added to be file for allowing the user to read and write. For allowing permission “ chmod +x mySysMonitor.sh” is types in the terminal after the creation of the file. For running the shell script ./mySysMonitor.sh command is used. It executes the command and stores in the output in the mySysMonitor.log file. The log file is used for comparing the output with the previous result and finding any changes made to the system from the previous time the shell script was executed.
Echo command is used for labelling the output and identification of each of the output of the command. For the development of the shell script the nano editor is used in the terminal and firstly the current process running in the system is identified using the “ps” command. The current users logged in the system can be identified using the “who” command and for finding the devices plugged in with the system the “lsusb” command is used and it returns a list of the devices that are connected with the system using the USB ports. For the identification of the overall usage of the disk “df” command is used and for getting the details of the usage for the home directory the path is needed to be defined and the command used is “df -h /home/jay” is needed to be typed where jay is the username of the account. For listing the other key directories the “df -h” command is used and it return the usage of the disk space of the directories present in the system. The interface used for communicating with the network and their states can also be identified using the “ip link show” command and for getting any other relevant information we have selected the information of the applications currently installed in the system. For displaying the application installed the “ls /usr/share/applications | awk -F ‘.desktop’ ‘ { print $1}’ – ” command is used. It helps in identification of the new application installed in the system and maintain the changes in the system.
The shell script prepared for management of the change log is given below:
#! /bin/bash
#Author : – Jay
#Date : – 29 November, 2018
#Checking if this script is being executed as ROOT. For maintaining proper directory structure, this script must be run from a root user.
if [ $EUID != 0 ]
then
echo “Please run this script as root so as to see all details! Better run with sudo.”
exit 1
fi
#Declaring variables
#set -x
num_proc=`ps -ef | wc -l`
Users_Currently_logged_in=`who`
Devices_Plugged_in=`lsusb`
total_root_size=`df -h /dev/sda1 | tail -1 | awk ‘{print$2}’`
overall_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}’`
os_name=`uname -v | awk {‘print$1′} | cut -f2 -d’-‘`
upt=`uptime | awk {‘print$3′} | cut -f1 -d’,’`
#load_avg=`uptime | cut -f5 -d’:’`
load_avg=`cat /proc/loadavg | awk {‘print$1,$2,$3’}`
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’}`
os_version=`uname -v | cut -f2 -d’~’ | awk {‘print$1′} | cut -f1 -d’-‘ | cut -c 1-5`
#Creating a directory if it doesn’t exist to store reports first, for easy maintenance.
if [ ! -d ${HOME}/health_reports ]
then
mkdir ${HOME}/health_reports
fi
html=”${HOME}/health_reports/Server-Health-Report-`hostname`-`date +%y%m%d`-`date +%H%M`.html”
email_add=”change this to yours”
for i in `ls /home`; do sudo du -sh /home/$i/* | sort -nr | grep G; done > /tmp/dir.txt
#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 Server Report” >> $html
echo “<h3><legend>Script authored by Jay</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>num_proc</th>” >> $html
echo “<th>Users_Currently_logged_in</th>” >> $html
echo “<th>Devices_Plugged_in</th>” >> $html
echo “<th>Uptime</th>” >> $html
echo “</tr>” >> $html
echo “</thead>” >> $html
echo “<tbody>” >> $html
echo “<tr>” >> $html
echo “<td>$num_proc</td>” >> $html
echo “<td>$Users_Currently_logged_in</td>” >> $html
echo “<td>$Devices_Plugged_in</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>$$total_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}/health_reports 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: Jay <[email protected]>” $email_add
The shell script runs and the output is stored in the mySysMonitor.log file temporarily and server health report.html file for displaying it on the web browser and the screenshot is given in the following screenshot.
The changes in the file is analysed using the tail -f command the changes identified in the log file is given in the following screenshot.
The tail -f command helps in identification of the significant changes that are made in the log file for the management of the computer system and increase the network security.
Conclusion
The report is prepared for the development of a shell script for monitoring the changes in the computer system that have been made from the previous time. The shell script is created for the Linux ubuntu environment and might generate some error if it is executed in another Linux environment. For testing the compatibility of the shell script Ubuntu operating system is used. The main advantage of the change logger script is that it can be used for monitoring the current activity of the user and help in securing the network from any unwanted malware or application that is installed in the client machine. The management of the permission for running the shell script is needed to be managed and the user should be restricted to modify the shell script for eliminating the risk of manipulation of the result of the script and is the main disadvantage of bash shell scripting.
Banfield, J., Germaine, N. and Gerard, M., 2016. Ubuntu Linux: Learn administration, networking, and development skills with the# 1 Linux distribution!.
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.
Jang, M. and Orsaria, A., 2016. RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 & EX300). McGraw-Hill Education Group.
Naik, G., 2018. Learning Linux Shell Scripting: Leverage the power of shell scripts to solve real-world problems.
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