Skip to content

Commit

Permalink
added support for including hostname in apprise message
Browse files Browse the repository at this point in the history
  • Loading branch information
toutas committed Aug 28, 2023
1 parent a96deec commit 76b59a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Models/NotificationConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class NotificationConfig
[YamlDotNet.Serialization.YamlMember(Alias = "errors_only")]
public bool AppriseNotificationsErrorsOnly { get; set; } = true;
[YamlDotNet.Serialization.YamlMember(Alias = "apprise")]
public List<string> AppriseServices { get; set; } = new List<string>();
public List<string> AppriseServices { get; set; } = new List<string>();
[YamlDotNet.Serialization.YamlMember(Alias = "include_hostname")]
public bool AppriseNotificationsIncludeHostname { get; set; } = false;
}
}
4 changes: 3 additions & 1 deletion SARotate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ private async Task SendAppriseNotification(SARotateConfig yamlConfigContent, str
{
string appriseCommand = $"apprise -vv ";
string escapedLogMessage = logMessage.Replace("'", "´").Replace("\"", "´");
appriseCommand += $"-b '{escapedLogMessage}' ";
string hostName = yamlConfigContent.NotificationConfig.AppriseNotificationsIncludeHostname ? $" on { System.Net.Dns.GetHostName()}" : "";

appriseCommand += $"-b '{escapedLogMessage}{hostName}' ";

foreach (var appriseService in yamlConfigContent.NotificationConfig.AppriseServices.Where(svc => !string.IsNullOrWhiteSpace(svc)))
{
Expand Down

0 comments on commit 76b59a7

Please sign in to comment.