Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Merge branch 'solanalabs_master' into big_mod_exp_limit
Browse files Browse the repository at this point in the history
  • Loading branch information
valiksinev committed May 30, 2023
2 parents 332a8f5 + db8f118 commit a2b73c2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions watchtower/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {
solana_clap_utils::{
hidden_unless_forced,
input_parsers::pubkeys_of,
input_validators::{is_parsable, is_pubkey_or_keypair, is_url},
input_validators::{is_parsable, is_pubkey_or_keypair, is_url, is_valid_percentage},
},
solana_cli_output::display::format_labeled_address,
solana_metrics::{datapoint_error, datapoint_info},
Expand Down Expand Up @@ -35,6 +35,7 @@ struct Config {
rpc_timeout: Duration,
minimum_validator_identity_balance: u64,
monitor_active_stake: bool,
active_stake_alert_threshold: u8,
unhealthy_threshold: usize,
validator_identity_pubkeys: Vec<Pubkey>,
name_suffix: String,
Expand Down Expand Up @@ -139,7 +140,16 @@ fn get_config() -> Config {
Arg::with_name("monitor_active_stake")
.long("monitor-active-stake")
.takes_value(false)
.help("Alert when the current stake for the cluster drops below 80%"),
.help("Alert when the current stake for the cluster drops below the amount specified by --active-stake-alert-threshold"),
)
.arg(
Arg::with_name("active_stake_alert_threshold")
.long("active-stake-alert-threshold")
.value_name("PERCENTAGE")
.takes_value(true)
.validator(is_valid_percentage)
.default_value("80")
.help("Alert when the current stake for the cluster drops below this value"),
)
.arg(
Arg::with_name("ignore_http_bad_gateway")
Expand Down Expand Up @@ -183,6 +193,8 @@ fn get_config() -> Config {
.collect();

let monitor_active_stake = matches.is_present("monitor_active_stake");
let active_stake_alert_threshold =
value_t_or_exit!(matches, "active_stake_alert_threshold", u8);
let ignore_http_bad_gateway = matches.is_present("ignore_http_bad_gateway");

let name_suffix = value_t_or_exit!(matches, "name_suffix", String);
Expand All @@ -195,6 +207,7 @@ fn get_config() -> Config {
rpc_timeout,
minimum_validator_identity_balance,
monitor_active_stake,
active_stake_alert_threshold,
unhealthy_threshold,
validator_identity_pubkeys,
name_suffix,
Expand Down Expand Up @@ -301,7 +314,9 @@ fn main() -> Result<(), Box<dyn error::Error>> {
));
}

if config.monitor_active_stake && current_stake_percent < 80. {
if config.monitor_active_stake
&& current_stake_percent < config.active_stake_alert_threshold as f64
{
failures.push((
"current-stake",
format!("Current stake is {current_stake_percent:.2}%"),
Expand Down

0 comments on commit a2b73c2

Please sign in to comment.