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
6 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
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
...
@@ -615,7 +615,7 @@ namespace ATxService
// throw new Exception("just a test exception from RunMainTasks");
// throw new Exception("just a test exception from RunMainTasks");
// mandatory tasks, run on every call:
// mandatory tasks, run on every call:
SendLowSpaceMail
(
SystemChecks
.
CheckFreeDiskSpace
(
_config
.
SpaceMonitoring
)
);
SendLowSpaceMail
();
UpdateServiceState
();
UpdateServiceState
();
_status
.
SerializeHeartbeat
();
_status
.
SerializeHeartbeat
();
...
...
This diff is collapsed.
Click to expand it.
ATxService/Email.cs
+
10
−
14
View file @
bc3ea120
...
@@ -102,12 +102,12 @@ namespace ATxService
...
@@ -102,12 +102,12 @@ namespace ATxService
/// <summary>
/// <summary>
/// Send a notification about low drive space to the admin if the time since the last
/// 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
/// 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>
/// </summary>
/// <param name="spaceDetails">String describing the drives being low on space.</param>
private
void
SendLowSpaceMail
()
{
private
void
SendLowSpaceMail
(
string
spaceDetails
)
{
if
(
_storage
.
AllDrivesAboveThreshold
())
{
if
(
string
.
IsNullOrWhiteSpace
(
spaceDetails
))
{
Log
.
Trace
(
"Free space on all drives above threshold."
);
Log
.
Trace
(
"SendLowSpaceMail(): spaceDetails emtpy!"
);
return
;
return
;
}
}
...
@@ -118,25 +118,21 @@ namespace ATxService
...
@@ -118,25 +118,21 @@ namespace ATxService
return
;
return
;
}
}
// reaching this point means a notification will be sent to the admin, and in that
// reaching this point means a notification will be sent, so now we can ask for the
// case it makes sense to also include details about the grace location:
// full storage status report:
var
graceReport
=
FsUtils
.
GraceLocationSummary
(
var
report
=
_storage
.
Summary
();
new
DirectoryInfo
(
_config
.
DonePath
),
_config
.
GracePeriod
);
Log
.
Warn
(
"WARNING: {0}"
,
report
);
Log
.
Warn
(
"WARNING: {0}"
,
spaceDetails
);
_status
.
LastStorageNotification
=
DateTime
.
Now
;
_status
.
LastStorageNotification
=
DateTime
.
Now
;
var
substitutions
=
new
List
<
Tuple
<
string
,
string
>>
{
var
substitutions
=
new
List
<
Tuple
<
string
,
string
>>
{
Tuple
.
Create
(
"SERVICE_NAME"
,
ServiceName
),
Tuple
.
Create
(
"SERVICE_NAME"
,
ServiceName
),
Tuple
.
Create
(
"HOST_ALIAS"
,
_config
.
HostAlias
),
Tuple
.
Create
(
"HOST_ALIAS"
,
_config
.
HostAlias
),
Tuple
.
Create
(
"HOST_NAME"
,
Environment
.
MachineName
),
Tuple
.
Create
(
"HOST_NAME"
,
Environment
.
MachineName
),
Tuple
.
Create
(
"LOW_SPACE_DRIVES"
,
spaceDetails
)
Tuple
.
Create
(
"LOW_SPACE_DRIVES"
,
report
)
};
};
try
{
try
{
var
body
=
LoadMailTemplate
(
"DiskSpace-Low.txt"
,
substitutions
);
var
body
=
LoadMailTemplate
(
"DiskSpace-Low.txt"
,
substitutions
);
if
(
graceReport
.
Length
>
0
)
body
+=
$"\n\n--\n
{
graceReport
}
"
;
SendEmail
(
_config
.
AdminEmailAdress
,
"low disk space"
,
body
);
SendEmail
(
_config
.
AdminEmailAdress
,
"low disk space"
,
body
);
}
}
catch
(
Exception
ex
)
{
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