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
9d701b7f
Commit
9d701b7f
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Use CPU monitoring from ATxCommon.Monitoring.
parent
21e0aeea
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxDiagnostics/ATxDiagnostics.cs
+10
-16
10 additions, 16 deletions
ATxDiagnostics/ATxDiagnostics.cs
with
10 additions
and
16 deletions
ATxDiagnostics/ATxDiagnostics.cs
+
10
−
16
View file @
9d701b7f
...
...
@@ -2,6 +2,7 @@
using
System.Diagnostics
;
using
System.Management
;
using
ATxCommon
;
using
ATxCommon.Monitoring
;
using
NLog
;
using
NLog.Config
;
using
NLog.Targets
;
...
...
@@ -28,10 +29,16 @@ namespace ATxDiagnostics
logConfig
.
LoggingRules
.
Add
(
logRuleConsole
);
LogManager
.
Configuration
=
logConfig
;
GetCpuCounter
();
Log
.
Debug
(
SystemChecks
.
GetCpuUsage
());
Log
.
Debug
(
QueryCpuLoad
());
Log
.
Debug
(
"Free space on drive [C:]: "
+
Conv
.
BytesToString
(
SystemChecks
.
GetFreeDriveSpace
(
"C:"
)));
var
cpu
=
new
Cpu
{
Interval
=
250
,
Limit
=
25
,
Probation
=
16
,
Enabled
=
true
};
while
(
true
)
{
System
.
Threading
.
Thread
.
Sleep
(
1000
);
}
}
private
static
int
QueryCpuLoad
()
{
...
...
@@ -74,18 +81,5 @@ namespace ATxDiagnostics
return
usageInt32
;
}
private
static
void
GetCpuCounter
()
{
var
counter
=
new
PerformanceCounter
(
"Processor"
,
"% Processor Time"
,
"_Total"
);
var
i
=
0
;
while
(
true
)
{
i
++;
//Log.Debug("PerformanceCounter reading {1}: {0}", counter.NextValue(), i);
var
watch
=
Stopwatch
.
StartNew
();
var
reading
=
counter
.
NextValue
();
watch
.
Stop
();
Console
.
WriteLine
(
"reading {1} (took {2} ms): {0}"
,
reading
,
i
,
watch
.
ElapsedMilliseconds
);
System
.
Threading
.
Thread
.
Sleep
(
250
);
}
}
}
}
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