function tool_main_add_restart_notification($sequence_id, $service_su, $service_egs, $shard_id, $sorbot_message_type, $sql_connection, $shard_lang = 'en') { nt_common_add_debug('tool_main_add_restart_notification()'); if ($sql_connection != '') { $csdb = new sql_db_string($sql_connection); if (is_object($csdb)) { $sequence_info = tool_main_get_restart_sequence_by_id($sequence_id); $shard_info = tool_main_get_domain_shard_data($sequence_info['restart_sequence_domain_id'], $sequence_info['restart_sequence_shard_id']); if ($sorbot_message_type == 4102) { //$open_timer = 60*25; // 25 minutes before a shard opens itself // new timer $open_timer = 60 * 10; // 10 minutes before a shard opens itself } else { $open_timer = 0; } if ($sequence_info && $shard_info) { // lets find the shard id used by the ticket system $sql = "SELECT * FROM ForumCS_tickets_shards WHERE shard_ca='" . $shard_info['domain_application'] . "' AND shard_id='" . $shard_id . "'"; if ($result = $csdb->sql_query($sql)) { if ($csdb->sql_numrows($result)) { $ticketsystem_shard_info = $csdb->sql_fetchrow($result); nt_common_add_debug($ticketsystem_shard_info); $ticketsystem_shard_id = $ticketsystem_shard_info['id']; // now we have the shard id, lets see which klients servers wants events for it $sql = "SELECT * FROM Sorbot_botconfig WHERE config_name='shardRestart' AND config_value LIKE '%:" . $ticketsystem_shard_id . ":%'"; if ($result2 = $csdb->sql_query($sql)) { if ($csdb->sql_numrows($result2)) { //$klients_servers = array(); //while ($row = $csdb->sql_fetchrow($result2)) //{ // $klients_servers[] = $row['server_name']; //} // NOTE: live but not in CVS yet ! $local_timer = $open_timer; $klients_servers = array(); while ($row = $csdb->sql_fetchrow($result2)) { $klients_servers[] = $row['server_name']; // lets find if there is any specific opening timer, and keep the lowest one $sql = "SELECT * FROM Sorbot_botconfig WHERE server_name='" . $row['server_name'] . "' AND config_name='shardRestartOpenTimer'"; if ($result3 = $csdb->sql_query($sql)) { if ($csdb->sql_numrows($result3)) { $timer_row = $csdb->sql_fetchrow($result3); if ($timer_row['config_value'] < $local_timer) { $local_timer = $timer_row['config_value']; } } } } $open_timer = $local_timer; // END NOTE: live but not in CVS yet ! // ok now we the list of servers that want this event, lets give it to them // lets build some messages $klients_countdown = ''; tool_main_get_elapsed_time_string($sequence_info['restart_sequence_timer'] - $sequence_info['restart_sequence_date_end'], $klients_countdown); $klients_countdown = trim($klients_countdown); $klients_open_countdown = ''; tool_main_get_elapsed_time_string($open_timer, $klients_open_countdown); $klients_open_countdown = trim($klients_open_countdown); $opening_message = tool_admin_restart_messages_get_list_from_name('opening', $shard_lang); $opening_message = $opening_message[0]['restart_message_value']; $opened_message = tool_admin_restart_messages_get_list_from_name('opened', $shard_lang); $opened_message = $opening_message[0]['restart_message_value']; $klients_messages = array('before' => array(".topic Shard Maintenance in progress for '" . $ticketsystem_shard_info['shard_name'] . "' - Shard LOCKED - (" . date("r", $sequence_info['restart_sequence_date_start']) . " - Countdown set to " . $klients_countdown . ")", "[Shard Maintenance] A Shard Restart has been triggered for shard '" . $ticketsystem_shard_info['shard_name'] . "' on " . date("r", $sequence_info['restart_sequence_date_start']), "[Shard Maintenance] Shard is LOCKED and should go down in " . $klients_countdown), 'at' => array(".topic Shard Maintenance in progress for '" . $ticketsystem_shard_info['shard_name'] . "' - Shard DOWN - (" . date("r", $sequence_info['restart_sequence_date_start']) . ")", "[Shard Maintenance] A Shard Restart has been triggered for shard '" . $ticketsystem_shard_info['shard_name'] . "' on " . date("r", $sequence_info['restart_sequence_date_start']), "[Shard Maintenance] Shard is DOWN after a countdown of " . $klients_countdown), 'over' => array(".topic Shard Maintenance in finished for '" . $ticketsystem_shard_info['shard_name'] . "' - Shard LOCKED - Ready for CSRs ! ETA : |EventETA| - To Open : .sorOpenShard |EventID| 0", "[Shard Maintenance] The Shard Restart that has been triggered for shard '" . $ticketsystem_shard_info['shard_name'] . "' on " . date("r", $sequence_info['restart_sequence_date_start']) . " is now finished !", "[Shard Maintenance] Shard is LOCKED and Ready for CSRs, it will OPEN automatically in |EventTIME| !", "[Shard Maintenance] To change the OPEN countdown, you need to send me the command : .sorOpenShard |EventID| <seconds>", "[Shard Maintenance] Example to OPEN the Shard now, you need to send me the command : .sorOpenShard |EventID| 0"), 'open' => array(".topic Shard Maintenance over for '" . $ticketsystem_shard_info['shard_name'] . "' - Shard OPEN ", "[Shard Maintenance] The shard '" . $ticketsystem_shard_info['shard_name'] . "' should now be OPEN to all !"), 'cancel' => array(".topic Shard Maintenance has been cancelled for '" . $ticketsystem_shard_info['shard_name'] . "' - Shard OPEN", "[Shard Maintenance] The shard restart has been CANCELLED for '" . $ticketsystem_shard_info['shard_name'] . "', the shard is OPEN again !"), 'giveup' => array(".topic Shard Maintenance for '" . $ticketsystem_shard_info['shard_name'] . "' is on hold for technical issues - Shard DOWN", "[Shard Maintenance] The shard restart has been set ON HOLD for technical issues !"), 'opening' => $opening_message, 'opened' => $opened_message); $notification_info = array('sequence' => $sequence_info, 'ts' => $ticketsystem_shard_info, 'messages' => $klients_messages, 'shard' => $shard_info, 'opentimer' => $open_timer, 'shardid' => $shard_id, 'shardsu' => $service_su, 'shardegs' => $service_egs); $notification_data = base64_encode(serialize($notification_info)); $event_insert_ids = array(); $sql = "LOCK TABLES Sorbot_events WRITE"; $csdb->sql_query($sql); reset($klients_servers); foreach ($klients_servers as $klient_server) { $sql = "INSERT INTO Sorbot_events (`server_name`,`event_action`,`event_time`,`event_lap`,`event_params`) "; $sql .= " VALUES ('" . $klient_server . "'," . $sorbot_message_type . "," . time() . "," . $open_timer . ",'" . $notification_data . "')"; $csdb->sql_query($sql); $event_insert_ids[] = $csdb->sql_nextid(); } // we have a list of all the events, lets save them somewhere // lets inform each events of all other events for the same sequence if (sizeof($event_insert_ids)) { $notification_info['eventlist'] = array_values($event_insert_ids); $notification_data = base64_encode(serialize($notification_info)); $sql = "UPDATE Sorbot_events SET event_params='" . $notification_data . "' WHERE event_id IN (" . implode(',', array_values($event_insert_ids)) . ")"; $csdb->sql_query($sql); // save the events locally too tool_main_set_restart_sequence_events($sequence_id, implode(',', array_values($event_insert_ids))); } $sql = "UNLOCK TABLES"; $csdb->sql_query($sql); } else { nt_common_add_debug('no klients server found wanting to hear about this event'); } } } else { nt_common_add_debug('no shard found in TS matching the application and shard id'); } } else { nt_common_add_debug('query failed ?!'); } } else { nt_common_add_debug('missing some information about the sequence ?!'); } $csdb->sql_close(); } else { nt_common_add_debug('failed to init db!'); } } else { nt_common_add_debug('no db string to work with'); } }
$graph->SetMargin(35, 10, 5, 25); // left - right - top - bottom $graph->SetScale("intlin"); $graph->xgrid->Show(true, true); $graph->ygrid->Show(true, true); $graph->xaxis->SetLabelFormatCallback('tool_graphs_xaxis_callback'); $line = new LinePlot($mean_values['val'], $mean_values['ref']); $line->SetColor('blue'); $line->SetFillColor('lightblue'); $graph->Add($line); $high_sys_name = NELTOOL_RRDSYSBASE . $graph_item['rd_file'] . "-" . $view_time_highframe . '_0.png'; $high_web_name = NELTOOL_RRDWEBBASE . $graph_item['rd_file'] . "-" . $view_time_highframe . '_0.png'; $graph->Stroke($high_sys_name); $file_description = str_replace(array('.rrd', '.hrd', '.'), array('', '', ' - '), $graph_item['rd_file']); $time_string = ''; tool_main_get_elapsed_time_string($view_time_highframe / 1000, $time_string); $rrd_webs[] = array('desc' => $file_description . ' over ' . $time_string . ' - (' . sizeof($mean_values['val']) . ' values)', 'img' => $high_web_name); } else { $rrd_webs[] = array('desc' => 'Not enough values to render plot for ' . $graph_item['rd_file'] . ' over ' . $view_time_highframe / 1000 . 's.', 'img' => ''); } } } } $tpl->assign('tool_rrd_high_output', $rrd_webs); break; case 'old': /* * ################################################################################################### * Old Page * ################################################################################################### */