function get_current_slack($game_name, $pool_name, $instance_count) { global $deregistered_ips; $slack_found = false; for ($try = 1; $try < 60; $try++) { $slack_api = json_decode(calculate_slack($game_name, true), true); if (isset($slack_api[$pool_name]) and $slack_api[$pool_name]['slack'] != 'NA') { $slack_found = true; break; } sleep(1); } if ($slack_found) { // $optimal_instance_count = round($instance_count*$slack_api[$pool_name]["optimal_count_factor"]); // $pool_slack = number_format((($instance_count - $optimal_instance_count) * 100)/$instance_count, 2,'.',''); $optimal_count_factor = $slack_api[$pool_name]["optimal_count_factor"]; $pool_slack = number_format((1 - $optimal_count_factor) * 100, 2, '.', ''); // echo "Current Instance Count :- $instance_count\nOptimal Count fact :- ".$slack_api[$pool_name]['optimal_count_factor']."\nCurrent Slack : $pool_slack\n\n"; return $pool_slack; } echo "Could not fetch the current slack from the zmon!\n"; print_final_result(NULL, NULL, $deregistered_ips, false); }
function main($server_cfg) { global $current_yaml_file; if (!isset($_POST["dry_run"])) { write_to_hostgroup_yml(); return_to_admin_tab(); } else { if (isset($_POST["print_data"])) { echo calculate_slack($_POST["game"], false); } else { if (isset($_POST["dry_run"])) { $final_array = json_decode($_POST["json_final"], true); create_hostgroup_yml_backup(); write_to_hostgroup_yml(); modify_hostgroup_in_db($final_array); echo calculate_slack($_POST["game"], true); restore_hostgroup_yml(); modify_hostgroup_in_db($current_yaml_file); } } } }
function get_instance_count_slack_offset($game_name) { $slack_api = json_decode(calculate_slack($game_name, false), true); return $slack_api; }