Sign In
Not register? Register Now!
Pages:
2 pages/≈550 words
Sources:
No Sources
Style:
Other
Subject:
IT & Computer Science
Type:
Coursework
Language:
English (U.S.)
Document:
MS Word
Date:
Total cost:
$ 14.58
Topic:

Building GNU/Linux Bash Script that Monitors a Computer System and user Activity

Coursework Instructions:

Please find the requirement in the attachment.

Coursework Sample Content Preview:
Building GNU/Linux bash script that monitors a computer system and user activity
Linux is one of the operating systems that are an open source; one can edit it for it to suit what they want. In monitoring services, Linux is the most preferred due to its portability. Building this script that monitors the computer services using Linux is not very difficult since the Linux is based on commands. The bash script will be able to control the computer system and write to the log file what is supposed to write according to the users need. In our case, the bash file should be able to monitor the current process being executed. The memory space and time it takes to execute, the time the process was completed, and which user ran the process using the credential used. Having this all covered by the bash file, it will be easy for the supervisor to view the log and see what the system have been doing.
The bash file will also monitor the network interfaces and its state; it will be able to record how the system was changing. Sometimes the network will be fast and may fluctuate at times; this will be recorded to the log file, and the supervisor will be able to determine the time the network has been changing and find a solution if there exist a problem.
Below is a bash script that will be used to monitor the system
#!/bin/bash# mySysMonitor.sh# System monitorclearecho -e "\033[1m `username -or` Monitor script\033[0m"items="
1.Date 2.Current Users 3.Disk Statistics 4.Memory Statistics 5.Top 10 Memory consuming process 6.Top 10 CPU consuming process 7.Exit"exit_function(){ clear exit}#function press enter to go back to the main screenenter(){ ans= echo "" echo -e "Want to continue?(y/n):\c" stty -icanon min 0 time 0while [ -z "$ans" ]do read ansdoneif [ "$ans" = "y" -o "$ans" = "Y" ]then stty sane # Resetting terminal settings clearelse stty sane exit_functionfi}choice=h10="head -10"while truedo echo -e "\n\t PROGRAM MENU \n" echo -e "$items \n" echo -n "Enter the number of your choice :"read choicecase $choice in 1) clear;
echo -e "\n\n\t\t Current Date \n" date +" %d-%h-%Y Time %T"; enter;; 2) clear;
Echo -e "\n\n\t\t The Logged In Users\n" who; enter;; 3) clear;
Echo -e "\n\n\t\t Memory Disk usage Statistics\n" df -h | grep "%" press enter; 4) clear;
echo -e "\n\n\t\t Memory Usage Statistics\n " free -m | awk 'BEGIN
{printf "\t\tSum\tUsed\tFree\n\n"; OFS="\t" }\
#Displaying the chioices/Mem/||/Swap/{printf "\t"; print $1,$2,$3,$4}' enter;; 5) clear;
#sorting the gotten data k3sort="sort -nr -k 3"
#Displaying the the sorted data echo -e "\033[1m PID PPID MEM CPU COMMAND \033[0m "
#Returning to the menu of the sorted data ps -Ao pid= -o ppid= -o pmem= -o pcpu= -o comm=|$k3sort|$h10 enter;;
6) clear;;
#sorting the gotten data k4sort="sort -nr -k 4"
#Displaying the the sorted data echo -e "\033[1m PID PPID MEM CPU COMMAND \033[0m"
#Returning to the menu of the sorted data ps -Ao pid= -o ppid= -o pmem= -o pcpu= -o comm=|$k4sort|$h10 enter;;
#Exiting after sorting 7)exit_function ;;
*)echo -e "Wrong choice \n Please try 1,2,3,4,5,6 or 7\n" echo " Press enter ...
Updated on
Get the Whole Paper!
Not exactly what you need?
Do you need a custom essay? Order right now:

👀 Other Visitors are Viewing These Other Coursework Samples:

HIRE A WRITER FROM $11.95 / PAGE
ORDER WITH 15% DISCOUNT!