[Autogenerated] Welcome back in this final module.
We'll delve into server monitoring.
We'll cover performance counters,
event logs and even get into a troubleshooting session all using PowerShell.
So let's dig in by leveraging PowerShell,
you can collect and analyze key server performance
metrics to identify bottlenecks.
PowerShell also makes it easy to query event logs whether on demand
or on schedule with metrics and logs combined.
You can then build real time health monitoring to be
notified of issues immediately.
Overall PowerShell gives you increased visibility into your server environment.
Your team has been asked to investigate occasional
performance issues with a critical internal web
application used across your organization.
Users have reported sluggish response times and
timeouts during peak usage periods.
You need to monitor the web server CPU utilization over time to identify
any CPU spikes that could be contributing to the problem.
I'm on my Sr V one server via PowerShell remoting.
This is the server, the web app is running on,
let's investigate and see what's going on.
So first up,
let's start by checking the current CP utilization on the
server just to get a baseline to do that.
I'll use, get counter,
get counter allows you to query any performance
counter by providing a counter Nate.
In this instance,
I'm querying the total process of utilization time across all processors.
Now, if you don't know the counter name offhand,
you can also use the list set parameter and use a wild
card on the list set parameters value.
So I was able to find all of the different counters sets by running git
counter providing that asterisk on list set parameter.
And then I'm popping that to select object and only showing the
counters set name and all path associated with that counter since it
does return a whole lot of information by default.
Anyway, let's get back to our CPU usage issue.
Run this again to get this back on the screen looks like it
is in the process of high CP utilization.
You see one processor is 53% the other one is 33 and the other one is 43.
So it looks like it is experiencing GP U load right now.
Run this again.
There we go 98 96 97.
So right now it's happening but it happens sporadically.
Let me run this consistently.
So I don't have to keep running it manually using the continuous parameter.
And there we go.
Now it's back to normal.
It's about about 0%.
Whenever we are looking at it, we saw the high CP utilization happen,
but now it's back to 0%.
Right now.
I have a real time.
Look at that CPU percentage metric based on what the users report I'd wager.
It's probably a scheduled task because it,
it's at a certain interval or maybe it's some
service _______ off too frequently.
Let's check on the scheduled tasks that are on the server.
I'm using, get scheduled task to do that.
I'm going to check in the route because that's where the
user created tasks are always created.
Hm.
There's an oddly suspicious looking scheduled task in there,
but I'm not quite sure that's the one just yet.
Let's see how often that one runs.
I can use, get scheduled task info to see more information about that.
And it looks like it was last run around the time
we saw that increased CPU usage.
The next runtime is also a minute after that.
It's by the minute, that's exactly what the users have been saying.
I think we found the scheduled task that runs every minute.
So let's disable that task and see what happens.
I can do that by just piping the scheduled task directly to the disabled
scheduled task command and that should disable it.
So right now it's running.
Let's check it again.
I believe it only runs for about 30 seconds.
There we go.
Yep.
As soon as it got done running, it's automatically disabled.
Now it won't even run again.
Now that the scheduled task is disabled,
I can run,
get counter again with the continuous parameter and now i'll monitor this for
like a minute and a half or something to see what happens.
And if this CPU does a spike, I think we found the issue.
Well over a minute has went by and no CPU spike.
I think we found the culprit.
So in this demo,
we covered how to monitor processor performance counters live to
pinpoint issues G counter and streaming it with the continuous parameter
are invaluable tools in your monitoring arsenal.