Hey guys and welcome back.
So in the previous nugget we explored some solutions that we could use in order to monitor
our CPU utilization as well as our memory utilization.
Now in this nugget right here we're going to be looking at some additional tools that
we can use with respect to monitoring and we'll also focus on disk IE, disk input, output
monitoring.
Now the first command which I just wanted to touch upon is the uptime command so if
we go into the man page here we can see here this is actually going to allow us to see
how long our system has been running.
It's also going to tell us our load averages.
Now we're going to see three different values within our output with the uptime command
and these three different values are going to correlate to three different time spans.
The first one is one minute, the second one is five minutes and the last value correlates
to the system load average over the last 15 minutes.
Now when we're actually talking about the system load averages right here it says here
this is the average number of processes that are either runnable or in an uninterruptible
state.
Now ultimately what we're really talking about here is CPU usage.
So a runnable state is when the CPU is being used or a process is waiting to use a CPU.
Now with respect to an uninterruptible state this is when the process is waiting for input
output access i.e. the hard disk may be fully utilized therefore a particular process has
to wait before it can access the disk in order to execute a particular task.
Now these load averages we are seeing within this uptime command relates to this type of
information right here.
Now one thing to note about the output with respect to the uptime command and let me just
press Q to clear my screen.
Now when we're talking about our three different values of one minute, five minutes and fifteen
minutes we're actually going to see the values denoted a particular way.
Now if we happen to see the value 0.5 what this tells us is that the CPU is ultimately
half used.
Okay?
Kind of makes sense 0.5 half used.
If the CPU is at the value of one that means that it's being fully utilized whereas if
it's at 0.25 then only a quarter of the CPU is being used and again you can see this at
different time intervals.
Now a few important points to note is that you might actually see a value such as 1.5
this is going to tell you that your CPU really is being taxed because whilst it might not
make sense that how can 1.5 of the CPU being used if one is the entire CPU being used what
this is actually indicating to us is that some processes are having to wait and as such
the CPU is in effect being overloaded.
So if we get a value greater than one well we may have problems to address.
Now one thing I just want to point out here is that the values I'm giving you relates
to if you happen to have one CPU available.
If you happen to have let's say for example four CPUs on your system this actually changes
the values.
So think about this if I happen to see the value from the uptime command and the value
is at one.
So 1.0 you may automatically think that the CPU is at full utilization.
In actuality what this means in the context of having four CPUs only 25% of the CPU is
being used ultimately what you're doing is you're dividing this number here by the number
of CPUs so it's one divided by four CPUs is actually 0.25 so only 25% is being used
again if we happen to see something like say 0.5 being used over four CPUs.
The CPUs are actually not at half utilization instead it's going to be 0.5 divided by four
instead this is only going to come out as 12.5% utilization.
If we actually happen to run this command here uptime we can see these values right
here 0.09, 0.07 and 0.01 again these are values over one minute in this case here five minutes
in this case and fifteen minutes in this case.
So the uptime command really is a valuable command that we can use to assess these types
of values it really does give us insight into our system.
Now the next thing I want to talk to you about is relating to IO weight i.e. input output
weight so where am I going with this?
So what IO weight actually is is ultimately a percentage of CPU actions that are waiting
for disk access so like I happened to say when we talk about IO waiting if you had maybe
say a program perhaps it might be a browser and your system is already using 100% of the
disk then your browser which needs disk access in order to perform its actual task this process
i.e. the process being used for the browser opening this is actually going to go into
a state of IO blocked input output has been blocked in real terms what this means for
us as the user is that the system is overloaded at least in respect to the disk utilization
so when you try to open that browser you double click that icon the process might actually
hang i.e. the browser is just not going to pop up on your screen you might be waiting
a while because the process really does need to wait until the resources free and here
is the thing the actual percentage of CPU processes that have to wait that is referred
to as the IO weight percentage now one of the ways we can interrogate this type of information
comes from my favorite command we just talked about it in the previous nugget that happens
to be the top command let's try and check this out and see the information we can actually
derive so what i'll do here is i'll just clear my screen right now and i'll use that
good old command top so check this out there is a particular piece of information we can
focus in relating to our IO weight if you can spot it here it's this one right here
which is in fact let me get my drawing pen because it's not showing quite so well this
one right here w a so this number is ultimately a percentage and right now it is at 0.0 that
is good meaning that we don't have any CPU processes actually waiting so we know we actually
have a tool downloaded on our system which we can use to stress our system to simulate
this type of problem so that commands is going to be the stress command so what i will do
actually is i'll go to my options and i will open a new terminal so we have a new terminal
right here what i'm going to do is use this stress command if i happen to say man stress
we can see we have the option of dash D or dash dash HDD this is going to spawn the number
of workers spinning on right basically this is going to allow us to simulate a lot of
disk utilization so what i'll do here then is i'll press q to quit to clear the screen
and i will say stress dash dash HDD and i'll choose the number one for one hard drive process
if i hit enter in fact before i actually do this let me minimize this keep an eye on this
value here the w a value okay so if i hit enter now that is going to actually spin up
a process and you can automatically see or rather instantly see should i say the waiting
value the percentage is actually beginning to spike that is due to the fact that we're
actually stressing our hard disk so to speak we are really using that resource and as such
if i actually try to go and maybe say open a browser like here it might take a little
bit of time to actually open up it's not going to be quite so snappy that is because a lot
of my processes are actually having to wait right now they're not getting access to the
disk therefore they can't operate as they ordinarily would so right now we can see here
we're still waiting on this browser and waiting and waiting and waiting sadly our browser
is kind of at the back of the queue it can't access this resource is being hogged so if
i actually just stop stress by pressing ctrl c now straight away the browser is going to
load up because we are no longer overloading the hard disk therefore the process could access
the resource and lo and behold we could open up the browser but again think about what
we're actually seeing here in this case we had a problem whereby our browser was very
very slow to load if we just were happened to be looking at the top command we would
have seen that the i o weight value was around 80% or 90% and we could actually tell or infer
that the hard disk was being particularly taxed so straight away with our troubleshooting
mind on we would have quite a good idea of where to go to solve that problem or the type
of action we would need to take in order to solve that problem now honestly as helpful
is top is and it is very helpful with respect to input output it is a little bit limited
so what i want to do is to actually show you some additional tools that we can use if i
press q to quit i'll just close this terminal for now and i'll also close my browser for
now i'll clear the screen and what i'm going to do is install something called i o top
this is like top but for input output so i'll say sudo apt install i o i can get it i o top
hit enter type in the passwords this is going to begin installation just give it a little
minute or so if i try to run the command i o top watch what happens operation not permitted
you can probably guess where i'm going with this the way to actually use this command
requires super user privileges so clear the screen and i'll say sudo i o top and i will
hit enter so what we're seeing is top like information but we are really focusing on
this right here the i o utilization and what processes happen to be using a lot of disk
so what i can actually do here is i can go and open up a new terminal and we'll do a similar
thing to what we saw before we'll use the stress command to actually put some stress on the
disk so i'll say stress dash dash hdd and i'll just say one and now the stress command
should actually be putting some pretty hard work on the i o but look at this we're actually
getting to see the input output and getting to see what is taking up a lot of that so
we can see the stress hd one taking up quite a lot of the resources and again if we go back
here i just press ctrl c to stop this instantly that's going to come back down and the i o
top command shows us that so a really valuable tool right here as opposed to just using the
regular top command now what i will do here is i'll press q to quit this clear the screen
i'll now say sudo apt install and the package i want to install is called sys stat if i
hit enter here this is going to install the sys stat package just give it a little minute
or so so now i should have access to a command called i o stat if i go into the page here
this is going to report cpu statistics for input output so this is going to give us again
just like with i o top i o related information and statistics now this is in my opinion not
quite as good as i o top but nevertheless the examination does mention i o stat within
the exam objectives so it does actually make sense that we are actually familiar with it
so clear the screen and i'll just say i o stat and what this is ultimately doing is giving
us a snapshot so we're getting to see a lot of information about data being written to
disk and read from disk this is ultimately what is taxing the particular disk we can
see the i o weight percentage right here which in this case is 1.77 quite low but like i
say this is really just a snapshot whereas if you recall the i o top command was giving
us real time updates and much more expansive so i can clear the screen another command
we want to be able to be familiar with again not quite as good as just using i o top but
the exam does require we are familiar if we go in to the man page for the sar command
this is going to allow you to collect report or save system activity information so you
can scroll right through this man page and you will see plenty options and plenty descriptions
of what this command can actually do there is quite a lot here for now i'll press q
what i'm going to do is i'm just going to say sar 1 and then 5 so what this command
is going to do it's going to allow us to take 5 different data points 1 second apart so this
is quite good to check how things progress over a time frame in this case here 5 seconds
because we have 5 recordings every single second so it's a little bit better of a snapshot
than i o stack gives us we have more data points for example but it's not quite like
i say as good as i o top giving us that streaming information and continually updating but
nevertheless let's hit enter and see how we go we're going to get 5 pieces of information so we
start at 27 seconds we get our first data point at 28 that's number one then two three four and
five so five data points one second apart we can see the percentage so we get statistics over a
whole bunch of different types of information such as system or idle but really the one we are
focusing on right now is i o weight as it transpires we are not actually taxing the i o so the values
right here all happen to be zero but as you can expect we could like we say actually stress the
hdd once again and we can rerun this command by hitting enter we get five different values right
here and at the very bottom we get the average of those five values and again we could change
these values to be maybe two and three meaning we will get three data points two seconds apart if
we hit enter we can see here the actual times the first one on zero zero the next one on zero two
the next one on zero four and at the bottom we get the average of those three over that time period
so again another really cool command to be aware of now what i'll do here is i'll just press control
c to stop this stress test in fact let me just close this terminal right here and i'll clear the
screen now another command i want to show you is one called ls o f this is going to allow us to list
our open files this should be one you will recall from the lp1 examination no doubt and like i say
it's going to allow us to track the open files on your system being all the open files now if we
just happen to use this command on its own ls o f we're going to be bombarded with an absolute
megaton of information just far too much to actually read but we can do things such as filtering to
make this information much more palatable so what i'll do actually let me just quickly open terminal
and we'll just rerun this stress command what i can actually do here is i can run this command
okay that would just show me absolutely everything but what if i happen to grep for stress itself
now we can actually see here what files are being opened by the stress program so if we happen to
note a particular process or a particular command is causing a lot of i o issues we can actually
correlate what actual files are being opened are being used by that particular command or process
so this just gives us more granular information that we can use to interrogate what is exactly going
on now one point i should actually add and in fact again let me just stop this right here one point
i should add is that with respect to disk i o problems one of the ways of course we can stop
such a thing is by not running so many processes that are actually requiring that resource but as
you know in the world of enterprise computing it's not quite so easy just to make sure that everyone
is giving up processes that they might actually need in case we may need better solutions altogether
now one of those solutions may be that the rate in reading of the hard disk is kind of slow and
inefficient and this can actually cause things to be bogged down because the longer it takes a
particular process to write into reads the longer it's going to engage that resource i e the more
of a backlog on that resource is going to happen one of the best ways you can actually ease this
type of problem is by changing things from a hard disk to an s sd a solid state drive this has got
far far far faster and more efficient read and write operations and this will actually alleviate
a lot of the problems that you're seeing if you do happen to be encountering a lot of i o weight
on your system okay doc so that is us for our introduction and to be able to monitor our disk
i o utilization like i say we saw a handful of different commands some more useful than others
but as we know in these exams very often you still have to be able to be familiar with
perhaps some less efficient and older commands such as what we saw with respect to the i o stat
command for example so really what i'm saying is don't just skip over the commands may not be so
obviously useful definitely dig in and be familiar with them at least just for the purposes of the
examination okay doc so that is us for monitoring disk input output the next thing we have to tackle
network input output and how we can actually monitor that too and well that is what we're
going to be doing in the very next nuggets i hope this has been informative for you i'd like to thank
you for viewing