Changes

Jump to: navigation, search

OPS245 Lab 5

714 bytes added, 9 March
no edit summary
{{Admon/caution|DO NOT USE THIS VERSION OF THE COURSE. This page will no longer be updated.|'''Debian version here:''' https://seneca-ictoer.github.io/OPS245
<br>'''CentOS version here:''' https://seneca-ictoer.github.io/OPS245-C7<br>'''Andrew's version here:''' http://wiki.littlesvr.ca/wiki/OPS245_Lab_5}}
=LAB PREPARATION=
{| width="40%" align="right" cellpadding="10"
#Perform this section in your '''c7host''' machine
#Use <b><code><span style="cursor:default;color:#3366CC;font-size:1.2em;">sudo -i</span></code></b> to get temporary '''root''' permissions.#Change to the your '''/root/bin''' directory.#Download the following shell script by issuing the following command: <br><b><code><span style="cursor:default;color:#3366CC;font-size:1.2em;">wget https://ictraw.senecacollegegithubusercontent.cacom/~ops235OPS245/labs/main/monitor-disk-space.bashpy</span></code></b>#Try to understand what this Bash Shell script does (refer to man pages for the '''awk''' command), and then run the script as rootwith elevated permissions.
#Give execute permissions and run this shell script. This script is supposed to notify the root user by email if there are any potential partition size issues.
#Issue the follow command: <b><code><span style="color:#3366CC;font-size:1.2em;">sudo mail-u root</span></code></b> (if you get an error, install email by issuing the command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">yum install mailx</span></code></b><br>Check to see if there are any mail messages. If there are mail messages, they do not relate to this shell script execution. Remove all mail messages by typing d immediately followed by a mail message number range (eg. to remove all messages. For example, if there are 5 messages, type '''d1-5''' and then press '''ENTER''' and enter '''q''' to exit the mail application).#Edit the '''monitor-disk-space.bashpy''' shell script, and set the <b><code><span style="color:#3366CC;font-size:1.2em;">ALERT=90</span></code></b> value to <b><code><span style="color:#3366CC;font-size:1.2em;">ALERT=10</span></code></b>. Then save your editing session, and re-run this shell script.
#Run the '''mail''' command. Do you have a mail message? Enter the mail message number to view the message. If there is a message, what is the purpose of this message?
# Exit from the mail command.
<li value="11">Quickly view the tutorial about the <b>[http://code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800 Using crontab]</b> file to understand the purpose of this
file and how to basically set up a schedule to run a shell script.</li>
<li>Issue the following command to setup a crontab entry for root:<br><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">crontab -e</span></code></b></li><li>Enter the following line in order to run at 6:00 on the first day of every month:<br><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">0 6 1 * * /roothome/&lt;YOURUSERNAME&gt;/bin/monitor-disk-space.bash py #Runs first day of each month (6:00 am)</span></code></b><br />Note: Make sure you put your own username in that entry.</li><li>'''Save''' the crontab entry.</li><li>Confirm that the entry was properly saved by issuing the following command:<br><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">crontab -l</span></code></b></li></ol>
=INVESTIGATION 2: MANAGING HARD DISK SPACE USING LVM=
 
{{Admon/caution|DO NOT USE THIS VERSION OF THE COURSE. This page will no longer be updated.|'''Debian version here:''' https://seneca-ictoer.github.io/OPS245
<br>'''CentOS version here:''' https://seneca-ictoer.github.io/OPS245-C7}}
An application called '''LVM''' is a very useful tool for Linux system administrators to easily manage file systems, in some cases, even when the computer system is running!
<ol><li value="13">You <u>'''must'''</u> '''restart''' your centos2 VM to allow changes to take effect.</li>
<li>Verify that you created this partition by issuing the following command: <b><code><span style="color:#3366CC;font-size:1.2em;">sudo fdisk -l /dev/vda</span></code></b></li>
<li>Re-issue the '''ssmlist''' command. Do you see a new /dev/vda3 partition under Physical Volumes?</li>
<li>To add the newly created partition, you need to add it into LVM to be used. Issue the following command to add the partition into LVM: <br><b><code><span style="color:#3366CC;font-size:1.2em;">sudo pvcreate /dev/vda3</span></code></b> (or ''pvcreate /dev/sda3'' ) (enter '''y''' to proceed - ignore warning)</li>
</ol>
{{Admon/important|Check your VG name|Run <b>vgs</b> to determine your Volume Group name. If it is just <b>centos</b> or <b>cl</b>, replace <b>centos_centos2</b> with <b>centos</b> or <b>cl</b> for the rest of the following commands in this lab.<br /> Do '''NOT''' try to rename your volume group.}}
<ol>
<li value="17">Issue the following command to add your new-created and formatted partition called /dev/vda3 to your volume group:<br><b><code><span style="color:#3366CC;font-size:1.2em;">sudo vgextend centos_centos2 /dev/vda3</span></code></b></li>
<ol>
<li>Make a copy of of "monitor-disk-space.bashpy" called '''disk-monitor.bashpy''' and place it in your user's bin directory.</li>
<li>Keep the original preamble comments in the script, but add a line indicating that you modified it (and when you did so). Make sure you indicate the change in script name too.</li>
<li>Modify the script so that it will use '''getoptsargparse''' to accept command line input from the user for their preferred values for who to send the email to, and what percentage of use is worth sending an email over.
::You may choose the letters for each of these options, just document your choice in the comments in the script.
::Make sure your script keeps the original values as defaults, in case the user doesn't specify one of them (i.e. if they don't use the option to set who to send the email to, just continue to use root).</li>
# Switch to your '''c7host''' machine.
# Open a shell terminal, change to your user's '''bin''' directory.
# Issue the Linux command: <b><code><span style="color:#3366CC;font-size:1.2em;">wget https://ictraw.senecacollegegithubusercontent.cacom/OPS245/labs/main//lab5-check.bash</span></code></b><!--<br />For Andrew's sections use this script instead:<b><code><span style="color:#3366CC;font-size:1.2em;">wget http://~peterlittlesvr.callaghanca/ops245/labs/lab5-check-andrew.bash</span></code></b>-->
# Give the '''lab5-check.bash''' file execute permissions (for the file owner).
# Run the shell script (with elevated permissions) and if there are any warnings, make fixes and re-run shell script until you receive "congratulations" message.
#Arrange proof of the following on the screen:<br><blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''centos2''' VM:<blockquote><ul><li>Output from '''sudo ssm list''' command.</li><li>Proof that '''/archive''' has been mounted</li></ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''c7host''' Machine:<blockquote><ul><li>Proof of creation of the shell script: '''monitor-disk-space.bashpy'''</li><li>Crontab entry for '''root''' account</li><li>Run the '''lab5-check.bash''' script in front of your instructor (must have all <b><code><span style="color:#66cc00;border:thin solid black;font-size:1.2em;">&nbsp;OK&nbsp;</span></code></b> messages)</li></ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''Lab5''' log-book filled out.#Upload a screen of the proof from the previous step, along with the file generated by '''lab5-check.bash''', your log book, and your disk-monitior.bash py script to blackboard.
= Practice For Quizzes, Tests, Midterm &amp; Final Exam =

Navigation menu