Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
3a2c6969
Commit
3a2c6969
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add missing docstrings for the class, fields and methods.
Refers to
#36
parent
65b2b6ad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxCommon/Monitoring/Cpu.cs
+30
-2
30 additions, 2 deletions
ATxCommon/Monitoring/Cpu.cs
with
30 additions
and
2 deletions
ATxCommon/Monitoring/Cpu.cs
+
30
−
2
View file @
3a2c6969
...
...
@@ -8,12 +8,35 @@ using Timer = System.Timers.Timer;
namespace
ATxCommon.Monitoring
{
/// <summary>
/// CPU load monitoring class, constantly checking the current load at the given <see
/// cref="Interval"/> using a separate timer (thus running in its own thread).
///
/// The load is determined using a <see cref="PerformanceCounter"/>, and is compared against
/// a configurable <see cref="Limit"/>. If the load changes from below the limit to above, a
/// <see cref="LoadAboveLimit"/> event will be raised. If the load has been above the limit
/// and is then dropping below, an <see cref="OnLoadBelowLimit"/> event will be raised as soon
/// as a given number of consecutive measurements (defined via <see cref="Probation"/>) were
/// found to be below the limit.
/// </summary>
public
class
Cpu
{
private
static
readonly
Logger
Log
=
LogManager
.
GetCurrentClassLogger
();
/// <summary>
/// The generic event handler delegate for CPU events.
/// </summary>
public
delegate
void
EventHandler
(
object
sender
,
EventArgs
e
);
/// <summary>
/// Event raised when the CPU load exceeds the configured limit for any measurement.
/// </summary>
public
event
EventHandler
LoadAboveLimit
;
/// <summary>
/// Event raised when the CPU load is below the configured limit for at least four
/// consecutive measurements after having exceeded this limit before.
/// </summary>
public
event
EventHandler
LoadBelowLimit
;
private
readonly
Timer
_monitoringTimer
;
...
...
@@ -26,8 +49,9 @@ namespace ATxCommon.Monitoring
private
int
_behaving
;
private
int
_probation
;
/// <summary>
/// Current CPU load (usage percentage over all cores).
/// Current CPU load (usage percentage over all cores)
, averaged of the last four readings
.
/// </summary>
/// <returns>The average CPU load from the last four readings.</returns>
public
float
Load
()
=>
_load
;
...
...
@@ -79,6 +103,7 @@ namespace ATxCommon.Monitoring
}
/// <summary>
/// Create performance counter and initialize it.
/// </summary>
...
...
@@ -105,7 +130,10 @@ namespace ATxCommon.Monitoring
Log
.
Debug
(
"Initializing CPU monitoring completed."
);
}
/// <summary>
/// Check current CPU load, update the history of readings and trigger the corresponding
/// events if the required criteria are met.
/// </summary>
private
void
UpdateCpuLoad
(
object
sender
,
ElapsedEventArgs
e
)
{
_monitoringTimer
.
Enabled
=
false
;
try
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment