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
bc3ea120
Commit
bc3ea120
authored
5 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Have SendLowSpaceMail retrieve the storage report itself
Relates to
#20
parent
9fec2e55
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ATxService/AutoTx.cs
+1
-1
1 addition, 1 deletion
ATxService/AutoTx.cs
ATxService/Email.cs
+10
-14
10 additions, 14 deletions
ATxService/Email.cs
with
11 additions
and
15 deletions
ATxService/AutoTx.cs
+
1
−
1
View file @
bc3ea120
...
...
@@ -615,7 +615,7 @@ namespace ATxService
// throw new Exception("just a test exception from RunMainTasks");
// mandatory tasks, run on every call:
SendLowSpaceMail
(
SystemChecks
.
CheckFreeDiskSpace
(
_config
.
SpaceMonitoring
)
);
SendLowSpaceMail
();
UpdateServiceState
();
_status
.
SerializeHeartbeat
();
...
...
This diff is collapsed.
Click to expand it.
ATxService/Email.cs
+
10
−
14
View file @
bc3ea120
...
...
@@ -102,12 +102,12 @@ namespace ATxService
/// <summary>
/// Send a notification about low drive space to the admin if the time since the last
/// notification has elapsed the configured delta. The report will also contain a summary
/// of the grace location status.
/// of the grace location status. If none of the drives are low on space nothing will be
/// done (i.e. only a generic trace-level message will be logged).
/// </summary>
/// <param name="spaceDetails">String describing the drives being low on space.</param>
private
void
SendLowSpaceMail
(
string
spaceDetails
)
{
if
(
string
.
IsNullOrWhiteSpace
(
spaceDetails
))
{
Log
.
Trace
(
"SendLowSpaceMail(): spaceDetails emtpy!"
);
private
void
SendLowSpaceMail
()
{
if
(
_storage
.
AllDrivesAboveThreshold
())
{
Log
.
Trace
(
"Free space on all drives above threshold."
);
return
;
}
...
...
@@ -118,25 +118,21 @@ namespace ATxService
return
;
}
// reaching this point means a notification will be sent to the admin, and in that
// case it makes sense to also include details about the grace location:
var
graceReport
=
FsUtils
.
GraceLocationSummary
(
new
DirectoryInfo
(
_config
.
DonePath
),
_config
.
GracePeriod
);
// reaching this point means a notification will be sent, so now we can ask for the
// full storage status report:
var
report
=
_storage
.
Summary
();
Log
.
Warn
(
"WARNING: {0}"
,
spaceDetails
);
Log
.
Warn
(
"WARNING: {0}"
,
report
);
_status
.
LastStorageNotification
=
DateTime
.
Now
;
var
substitutions
=
new
List
<
Tuple
<
string
,
string
>>
{
Tuple
.
Create
(
"SERVICE_NAME"
,
ServiceName
),
Tuple
.
Create
(
"HOST_ALIAS"
,
_config
.
HostAlias
),
Tuple
.
Create
(
"HOST_NAME"
,
Environment
.
MachineName
),
Tuple
.
Create
(
"LOW_SPACE_DRIVES"
,
spaceDetails
)
Tuple
.
Create
(
"LOW_SPACE_DRIVES"
,
report
)
};
try
{
var
body
=
LoadMailTemplate
(
"DiskSpace-Low.txt"
,
substitutions
);
if
(
graceReport
.
Length
>
0
)
body
+=
$"\n\n--\n
{
graceReport
}
"
;
SendEmail
(
_config
.
AdminEmailAdress
,
"low disk space"
,
body
);
}
catch
(
Exception
ex
)
{
...
...
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