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
810c5188
Commit
810c5188
authored
6 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add SystemChecks.HealthReport() and use it in AutoTx.StartupSummary()
Refers to
#20
parent
db61f557
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ATxCommon/SystemChecks.cs
+18
-0
18 additions, 0 deletions
ATxCommon/SystemChecks.cs
ATxService/AutoTx.cs
+3
-21
3 additions, 21 deletions
ATxService/AutoTx.cs
with
21 additions
and
21 deletions
ATxCommon/SystemChecks.cs
+
18
−
0
View file @
810c5188
...
...
@@ -151,6 +151,24 @@ namespace ATxCommon
}
}
/// <summary>
/// Generate an overall system health report with free space, grace location status, etc.
/// </summary>
/// <param name="storage">StorageStatus object used for space and grace reports.</param>
/// <returns>A multi-line string containing the details assembled in the report. These
/// comprise system uptime, free RAM, free storage space and current grace location status.
/// </returns>
public
static
string
HealthReport
(
StorageStatus
storage
)
{
var
report
=
"------ System health report ------\n\n"
+
$" - hostname:
{
Environment
.
MachineName
}
\n"
+
$" - uptime:
{
TimeUtils
.
SecondsToHuman
(
Uptime
(),
false
)}
\n"
+
$" - free system memory:
{
GetFreeMemory
()}
MB"
+
"\n\n"
;
report
+=
storage
.
Summary
();
return
report
;
}
/// <summary>
/// Get the current system uptime in seconds. Note that this will miss all times where the
/// system had been suspended / hibernated, as it is based on the OS's ticks counter.
...
...
This diff is collapsed.
Click to expand it.
ATxService/AutoTx.cs
+
3
−
21
View file @
810c5188
...
...
@@ -395,28 +395,10 @@ namespace ATxService
"\n------ Loaded configuration settings ------\n"
+
_config
.
Summary
();
msg
+=
"\n------ Current system parameters ------\n"
+
"Hostname: "
+
Environment
.
MachineName
+
"\n"
+
"Free system memory: "
+
SystemChecks
.
GetFreeMemory
()
+
" MB"
+
"\n"
;
foreach
(
var
driveToCheck
in
_config
.
SpaceMonitoring
)
{
msg
+=
"Free space on drive '"
+
driveToCheck
.
DriveName
+
"': "
+
Conv
.
BytesToString
(
SystemChecks
.
GetFreeDriveSpace
(
driveToCheck
.
DriveName
))
+
"\n"
;
}
var
health
=
SystemChecks
.
HealthReport
(
_storage
);
msg
+=
"\n"
+
health
;
msg
+=
"\n------ Grace location status, threshold: "
+
_config
.
GracePeriod
+
" days "
+
"("
+
TimeUtils
.
DaysToHuman
(
_config
.
GracePeriod
)
+
") ------\n"
;
try
{
var
tmp
=
SendGraceLocationSummary
(
_config
.
GracePeriod
);
if
(
string
.
IsNullOrEmpty
(
tmp
))
{
msg
+=
" -- NO EXPIRED folders in grace location! --\n"
;
}
else
{
msg
+=
tmp
;
}
}
catch
(
Exception
ex
)
{
Log
.
Error
(
"GraceLocationSummary() failed: {0}"
,
ex
.
Message
);
}
// TODO: send health report!
Log
.
Debug
(
msg
);
...
...
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