-
Notifications
You must be signed in to change notification settings - Fork 5
/
0001-Add-watchtower-option-to-add-custom-string-into-noti.patch
78 lines (70 loc) · 2.96 KB
/
0001-Add-watchtower-option-to-add-custom-string-into-noti.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From d127738e2d67749c3750963f9b922e2cd18b47fe Mon Sep 17 00:00:00 2001
From: Ivan Mironov <[email protected]>
Date: Tue, 26 Oct 2021 12:03:04 +0500
Subject: [PATCH] Add watchtower option to add custom string into notifications
---
watchtower/src/main.rs | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/watchtower/src/main.rs b/watchtower/src/main.rs
index 3dd06dd8aaa5..a8a7424e9c31 100644
--- a/watchtower/src/main.rs
+++ b/watchtower/src/main.rs
@@ -34,6 +34,7 @@ struct Config {
monitor_active_stake: bool,
unhealthy_threshold: usize,
validator_identity_pubkeys: Vec<Pubkey>,
+ name_suffix: String,
}
fn get_config() -> Config {
@@ -134,6 +135,13 @@ fn get_config() -> Config {
no alerting should a Bad Gateway error be a side effect of \
the real problem")
)
+ .arg(
+ Arg::with_name("name_suffix")
+ .long("name-suffix")
+ .value_name("SUFFIX")
+ .takes_value(true)
+ .help("Add this string into all notification messages after \"^solana-watchtower\"")
+ )
.get_matches();
let config = if let Some(config_file) = matches.value_of("config_file") {
@@ -159,6 +167,8 @@ fn get_config() -> Config {
let monitor_active_stake = matches.is_present("monitor_active_stake");
let ignore_http_bad_gateway = matches.is_present("ignore_http_bad_gateway");
+ let name_suffix = matches.value_of("name_suffix").unwrap_or("").to_owned();
+
let config = Config {
address_labels: config.address_labels,
ignore_http_bad_gateway,
@@ -168,6 +178,7 @@ fn get_config() -> Config {
monitor_active_stake,
unhealthy_threshold,
validator_identity_pubkeys,
+ name_suffix,
};
info!("RPC URL: {}", config.json_rpc_url);
@@ -337,8 +348,8 @@ fn main() -> Result<(), Box<dyn error::Error>> {
if let Some((failure_test_name, failure_error_message)) = &failure {
let notification_msg = format!(
- "solana-watchtower: Error: {}: {}",
- failure_test_name, failure_error_message
+ "solana-watchtower{}: Error: {}: {}",
+ config.name_suffix, failure_test_name, failure_error_message
);
num_consecutive_failures += 1;
if num_consecutive_failures > config.unhealthy_threshold {
@@ -370,7 +381,10 @@ fn main() -> Result<(), Box<dyn error::Error>> {
humantime::format_duration(alarm_duration)
);
info!("{}", all_clear_msg);
- notifier.send(&format!("solana-watchtower: {}", all_clear_msg));
+ notifier.send(&format!(
+ "solana-watchtower{}: {}",
+ config.name_suffix, all_clear_msg
+ ));
}
last_notification_msg = "".into();
last_success = Instant::now();
--
2.33.1