function handle($queue, Scalr_Messaging_Msg $message, $rawMessage, $type = 'xml') { $this->logger->info(sprintf("Received message '%s' from server '%s'", $message->getName(), $message->getServerId())); try { $this->db->Execute("INSERT INTO messages SET\n messageid = ?,\n message = ?,\n server_id = ?,\n dtadded = NOW(),\n type = ?,\n ipaddress = ?,\n message_name = ?,\n message_format = ?\n ", array($message->messageId, $rawMessage, $message->getServerId(), "in", $_SERVER['REMOTE_ADDR'], $message->getName(), $type)); } catch (Exception $e) { // Message may be already delivered. // urlopen issue on scalarizr side: // QueryEnvError: <urlopen error [Errno 4] Interrupted system call> if (strpos($e->getMessage(), 'Duplicate entry') === false) { throw $e; } } }
function handle($queue, Scalr_Messaging_Msg $message, $rawMessage) { $this->logger->info(sprintf("Received message '%s' from server '%s'", $message->getName(), $message->getServerId())); try { $this->db->Execute("INSERT INTO messages SET\n\t\t\t\tmessageid = ?,\n\t\t\t\tmessage = ?,\n\t\t\t\tserver_id = ?,\n\t\t\t\tdtlasthandleattempt = NOW(),\n\t\t\t\ttype = ?,\n\t\t\t\tisszr = ?\n\t\t\t", array($message->messageId, $rawMessage, $message->getServerId(), "in", 1)); } catch (Exception $e) { // Message may be already delivered. // urlopen issue on scalarizr side: // QueryEnvError: <urlopen error [Errno 4] Interrupted system call> if (strpos($e->getMessage(), 'Duplicate entry') === false) { throw $e; } } }
function __construct($deployTaskId, $status, $lastError = null) { parent::__construct(); $this->deployTaskId = $deployTaskId; $this->status = $status; $this->lastError = $lastError; }
function __construct($device = null, $mountPoint = null, $createFs = null) { parent::__construct(); $this->device = $device; $this->mountPoint = $mountPoint; $this->createFs = $createFs; }
function __construct($behaviour = null, $resetToDefaults = null, $restartService = null) { parent::__construct(); $this->behaviour = $behaviour; $this->resetToDefaults = $resetToDefaults; $this->restartService = $restartService; }
function __construct($bundleTaskId = null, $roleName = null, $excludes = array()) { parent::__construct(); $this->bundleTaskId = $bundleTaskId; $this->roleName = $roleName; $this->excludes = $excludes; }
function __construct($rootPassword = null, $replPassword = null, $statPassword = null, $volumeConfig = null) { parent::__construct(); $this->rootPassword = $rootPassword; $this->replPassword = $replPassword; $this->statPassword = $statPassword; $this->volumeConfig = $volumeConfig; }
function __construct($behaviour = null, $roleName = null, $localIp = null, $remoteIp = null) { parent::__construct(); $this->behaviour = $behaviour; $this->roleName = $roleName; $this->localIp = $localIp; $this->remoteIp = $remoteIp; }
function __construct($status, $lastError, $preset, $behaviour) { parent::__construct(); $this->status = $status; $this->lastError = $lastError; $this->preset = $preset; $this->behavior = $behaviour; }
function __construct($farmRoleId = null, $pmaUser = null, $pmaPassword = null, $lastError = null, $status = null) { parent::__construct(); $this->status = $status; $this->lastError = $lastError; $this->pmaUser = $pmaUser; $this->pmaPassword = $pmaPassword; $this->farmRoleId = $farmRoleId; }
function __construct($volumeId = null, $deviceName = null, $mountpoint = null, $isArray = null, $name = null) { parent::__construct(); $this->volumeId = $volumeId; $this->deviceName = $deviceName; $this->mountpoint = $mountpoint; $this->isArray = $isArray; $this->name = $name; }
function __construct($behaviour = null, $roleName = null, $localIp = null, $remoteIp = null, $volumeId = null, $deviceName = null) { parent::__construct(); $this->behaviour = $behaviour; $this->roleName = $roleName; $this->localIp = $localIp; $this->remoteIp = $remoteIp; $this->volumeId = $volumeId; $this->deviceName = $deviceName; }
function __construct($behaviour = null, $roleName = null, $localIp = null, $remoteIp = null, $cryptoKey = null, $sshPubKey = null) { parent::__construct(); $this->behaviour = $behaviour; $this->roleName = $roleName; $this->localIp = $localIp; $this->remoteIp = $remoteIp; $this->cryptoKey = $cryptoKey; $this->sshPubKey = $sshPubKey; }
/** * @param string $xmlString * @return Scalr_Messaging_Msg */ function unserialize($jsonString) { $msg = @json_decode($jsonString); $ref = new ReflectionClass(Scalr_Messaging_Msg::getClassForName($msg->name)); $retval = $ref->newInstance(); $retval->messageId = "{$msg->id}"; $retval->meta = (array) $msg->meta; $this->walkSerialize($msg->body, $retval, 'camelCase'); return $retval; }
function __construct($bundleTaskId = null, $status = null, $snapshotId = null, $lastError = null, $os = null, $software = null) { parent::__construct(); $this->bundleTaskId = $bundleTaskId; $this->status = $status; $this->snapshotId = $snapshotId; $this->lastError = $lastError; $this->os = $os; $this->software = $software; }
function __construct($eventName = null, $stdout = null, $stderr = null, $timeElapsed = null, $scriptName = null, $scriptPath = null, $returnCode = null) { parent::__construct(); $this->eventName = $eventName; $this->stdout = $stdout; $this->stderr = $stderr; $this->timeElapsed = $timeElapsed; $this->scriptName = $scriptName; $this->scriptPath = $scriptPath; $this->returnCode = $returnCode; }
function __construct($snapshotId, $logFile, $logPos, $snapshotConfig, $dataBundleSize) { parent::__construct(); /** * @deprecated */ $this->snapshotId = $snapshotId; $this->logFile = $logFile; $this->logPos = $logPos; $this->snapshotConfig = $snapshotConfig; $this->dataBundleSize = $dataBundleSize; }
public static function extendMessage(Scalr_Messaging_Msg $message, AbstractServerEvent $event, DBServer $eventServer, DBServer $targetServer) { $db = \Scalr::getDb(); $retval = array(); try { $scripts = self::getEventScriptList($event, $eventServer, $targetServer); if (count($scripts) > 0) { foreach ($scripts as $script) { $itm = new stdClass(); // Script $itm->asynchronous = $script['issync'] == 1 ? '0' : '1'; $itm->timeout = $script['timeout']; if ($script['type'] == self::ORCHESTRATION_SCRIPT_TYPE_SCALR) { $itm->name = $script['name']; $itm->body = $script['body']; } elseif ($script['type'] == self::ORCHESTRATION_SCRIPT_TYPE_LOCAL) { $itm->name = "local-" . crc32($script['path']) . mt_rand(100, 999); $itm->path = $script['path']; } elseif ($script['type'] == self::ORCHESTRATION_SCRIPT_TYPE_CHEF) { $itm->name = "chef-" . crc32($script['path']) . mt_rand(100, 999); $itm->chef = $script['chef']; } if ($script['run_as']) { $itm->runAs = $script['run_as']; } $itm->executionId = $script['execution_id']; $retval[] = $itm; $event->scriptsCount++; } } } catch (Exception $e) { $scriptingError = $e->getMessage(); } $message->scripts = $retval; $message->eventId = $event->GetEventID(); $message->debugScriptingCount = count($scripts); $message->debugScriptingError = $scriptingError; $message->setGlobalVariables($targetServer, true, $event); return $message; }
function convert(Scalr_Messaging_Msg $msg, $isEventNotice = false) { $msgName = $msg->getName(); if (!array_key_exists($msgName, $this->trapMap)) { throw new Scalr_Messaging_SnmpConverterException(sprintf("There is no SNMP trap for message class '%s'", $msgName)); } $vars = $this->extractVars($msg); if (in_array($msgName, $this->eventNoticeMessages) || $isEventNotice) { $vars = array_merge($vars, $this->extractEventNotice($msg)); } $extractMethod = "extract{$msgName}"; if (method_exists($this, $extractMethod)) { $vars = array_merge($vars, $this->{$extractMethod}($msg)); } $search = array(); $replace = array(); foreach ($this->getTrapVars($isEventNotice ? "__IntEventNotice" : $msgName) as $var => $holder) { $search[] = $holder; $replace[] = $vars[$var]; } return str_replace($search, $replace, $this->trapMap[$isEventNotice ? "__IntEventNotice" : $msgName]); }
function __construct($behaviour = null, $roleName = null, $localIp = null, $remoteIp = null, $volumeId = null, $deviceName = null, $mountpoint = null, $isArray = null, $name = null) { parent::__construct(); $this->behaviour = $behaviour; $this->roleName = $roleName; $this->localIp = $localIp; $this->remoteIp = $remoteIp; $this->volumeId = $volumeId; $this->deviceName = $deviceName; $this->mountpoint = $mountpoint; $this->isArray = $isArray; $this->name = $name; }
function __construct($deployTaskId, $remotePath, $source, $preDeployRoutines = "", $postDeployRoutines = "") { parent::__construct(); $this->deployTaskId = $deployTaskId; $this->source = $source; $this->remotePath = $remotePath; $this->preDeployRoutines = new stdClass(); $this->preDeployRoutines->body = $preDeployRoutines; $this->preDeployRoutines->execTimeout = 300; $this->postDeployRoutines = new stdClass(); $this->postDeployRoutines->body = $postDeployRoutines; $this->postDeployRoutines->execTimeout = 300; }
function handle($queue, Scalr_Messaging_Msg $message, $rawMessage) { $dbserver = DBServer::LoadByID($message->getServerId()); if ($message instanceof Scalr_Messaging_Msg_ExecScriptResult) { try { $this->db->Execute("INSERT DELAYED INTO scripting_log SET \n\t\t\t\t\tfarmid = ?,\n\t\t\t\t\tserver_id = ?, \n\t\t\t\t\tevent = ?,\n\t\t\t\t\tmessage = ?, \n\t\t\t\t\tdtadded = NOW() \n\t\t\t\t", array($dbserver->farmId, $message->getServerId(), $message->eventName, sprintf("Script '%s' execution result (Time: %s s, Exit code: %s). %s %s", $message->scriptName, round($message->timeElapsed, 2), $message->returnCode, base64_decode($message->stderr), base64_decode($message->stdout)))); if ($message->meta[Scalr_Messaging_MsgMeta::SZR_VERSION]) { DBServer::LoadByID($message->getServerId())->SetProperty(SERVER_PROPERTIES::SZR_VESION, $message->meta[Scalr_Messaging_MsgMeta::SZR_VERSION]); } } catch (Exception $e) { $this->logger->warn($e->getMessage()); } } elseif ($message instanceof Scalr_Messaging_Msg_Log) { foreach ($message->entries as $entry) { try { $this->db->Execute("INSERT DELAYED INTO logentries SET \n\t\t\t\t\t\tserverid = ?, \n\t\t\t\t\t\tmessage = ?, \n\t\t\t\t\t\tseverity = ?, \n\t\t\t\t\t\ttime = ?, \n\t\t\t\t\t\tsource = ?, \n\t\t\t\t\t\tfarmid = ?\n\t\t\t\t\t", array($message->getServerId(), $entry->msg, self::$severityCodes[$entry->level], time(), $entry->name, $dbserver->farmId)); if ($message->meta[Scalr_Messaging_MsgMeta::SZR_VERSION]) { DBServer::LoadByID($message->getServerId())->SetProperty(SERVER_PROPERTIES::SZR_VESION, $message->meta[Scalr_Messaging_MsgMeta::SZR_VERSION]); } } catch (Exception $e) { $this->logger->error($e->getMessage()); } } } elseif ($message instanceof Scalr_Messaging_Msg_RebundleLog) { try { $this->db->Execute("INSERT INTO bundle_task_log SET \n\t\t\t\t\tbundle_task_id = ?,\n\t\t\t\t\tdtadded = NOW(),\n\t\t\t\t\tmessage = ?\n\t\t\t\t", array($message->bundleTaskId, $message->message)); } catch (Exception $e) { $this->logger->error($e->getMessage()); } } elseif ($message instanceof Scalr_Messaging_Msg_DeployLog) { try { $this->db->Execute("INSERT INTO dm_deployment_task_logs SET \n\t\t\t\t\t`dm_deployment_task_id` = ?,\n\t\t\t\t\t`dtadded` = NOW(),\n\t\t\t\t\t`message` = ?\n\t\t\t\t", array($message->deployTaskId, $message->message)); } catch (Exception $e) { } } elseif ($message instanceof Scalr_Messaging_Msg_OperationDefinition) { try { if ($message->name == 'Execute scripts') { return; } $this->db->Execute("INSERT INTO server_operations SET \n\t\t\t\t\t`id` = ?,\n\t\t\t\t\t`server_id` = ?,\n\t\t\t\t\t`timestamp` = ?,\n\t\t\t\t\t`status`\t= ?,\n\t\t\t\t\t`name` = ?,\n\t\t\t\t\t`phases` = ?\n\t\t\t\t", array($message->id, $dbserver->serverId, time(), 'running', $message->name, json_encode($message->phases))); } catch (Exception $e) { } } elseif ($message instanceof Scalr_Messaging_Msg_OperationProgress) { try { if ($message->warning) { $msg = $message->warning->message; $trace = $message->warning->trace; $handler = $message->warning->handler; } $this->db->Execute("INSERT INTO server_operation_progress SET \n\t\t\t\t\t`operation_id` = ?,\n\t\t\t\t\t`timestamp` = ?,\n\t\t\t\t\t`phase` = ?,\n\t\t\t\t\t`step` = ?,\n\t\t\t\t\t`status` = ?,\n\t\t\t\t\t`message`= ?,\n\t\t\t\t\t`trace` = ?,\n\t\t\t\t\t`handler` = ?,\n\t\t\t\t\t`progress` = ?,\n\t\t\t\t\t`stepno` = ? \n\t\t\t\t\tON DUPLICATE KEY UPDATE status = ?, progress = ?, trace = ?, handler = ?, message = ?\n\t\t\t\t", array($message->id, $message->getTimestamp(), $message->phase, $message->step, $message->status, $msg, $trace, $handler, $message->progress, $message->stepno, $message->status, $message->progress, $trace, $handler, $msg)); } catch (Exception $e) { } } }
/** * @param string $xmlString * @return Scalr_Messaging_Msg */ function unserialize($xmlString) { $xml = simplexml_load_string($xmlString); if (!$xml) { throw new Exception('Cannot load XML string: ' . $xmlString); } $ref = new ReflectionClass(Scalr_Messaging_Msg::getClassForName($xml->attributes()->name)); $msg = $ref->newInstance(); $msg->messageId = "{$xml->attributes()->id}"; foreach ($xml->meta->children() as $el) { $msg->meta["{$el->getName()}"] = "{$el}"; } foreach ($xml->body->children() as $el) { $msg->{$this->camelCase("{$el->getName()}")} = $this->walkUnserialize($el); } return $msg; }
public function OnCustomEvent(CustomEvent $event) { $servers = DBFarm::LoadByID($this->FarmID)->GetServersByFilter(array('status' => array(SERVER_STATUS::INIT, SERVER_STATUS::RUNNING))); $event->messageServers = count($servers); $event->processing = array(); foreach ((array) $servers as $DBServer) { try { $startTime = microtime(true); $msg = new Scalr_Messaging_Msg(); $msg->setName($event->GetName()); $msg->setServerMetaData($event->DBServer); $msg = Scalr_Scripting_Manager::extendMessage($msg, $event, $event->DBServer, $DBServer); $extendTime = microtime(true) - $startTime; // Send message ONLY if there are scripts assigned to this event if (count($msg->scripts) > 0) { $DBServer->SendMessage($msg, false, true); } $endTime = microtime(true) - $startTime; $event->processing[] = array($extendTime, $endTime, count($msg->scripts)); if (!$msg) { throw new Exception("Empty MSG"); } } catch (Exception $e) { //TODO: Log this situation } } }
function __construct($farmCryptoKey, $serverIndex) { parent::__construct(); $this->farmCryptoKey = $farmCryptoKey; $this->serverIndex = $serverIndex; }
function __construct($eventName = null) { parent::__construct(); $this->eventName = $eventName; }
/** * Send message to instance * @param Scalr_Messaging_Msg $message * @return Scalr_Messaging_Msg */ public function SendMessage(Scalr_Messaging_Msg $message, $isEventNotice = false, $delayed = false) { $startTime = microtime(true); if ($this->farmId && $message->getName() != 'BeforeHostTerminate') { if ($this->GetFarmObject()->Status == FARM_STATUS::TERMINATED) { $this->Db->Execute("UPDATE messages SET status = ? WHERE messageid = ?", array(MESSAGE_STATUS::FAILED, $message->messageId)); return; } } // We don't need to send any messages other then it's own to the server that is not in Running state if ($message->serverId != $this->serverId && !in_array($this->status, array(SERVER_STATUS::RUNNING, SERVER_STATUS::TEMPORARY, SERVER_STATUS::IMPORTING))) { return; } // Ignore OLD messages (ami-scripts) if (!$this->IsSupported("0.5")) { return; } // Put access data and reserialize message $pl = PlatformFactory::NewPlatform($this->platform); $pl->PutAccessData($this, $message); $logger = \Scalr::getContainer()->logger('DBServer'); $serializer = Scalr_Messaging_XmlSerializer::getInstance(); $cryptoTool = \Scalr::getContainer()->srzcrypto($this->GetKey(true)); if ($this->GetProperty(\SERVER_PROPERTIES::SZR_MESSAGE_FORMAT) == 'json') { $serializer = Scalr_Messaging_JsonSerializer::getInstance(); $rawMessage = $serializer->serialize($message); $messageType = 'json'; } else { $rawMessage = $serializer->serialize($message); $messageType = 'xml'; } //$rawJsonMessage = @json_encode($message); $time = microtime(true) - $startTime; // Add message to database $this->Db->Execute("INSERT INTO messages SET\n `messageid` = ?,\n `processing_time` = ?,\n `server_id` = ?,\n `event_server_id` = ?,\n `message` = ?,\n `type` = 'out',\n `message_name` = ?,\n `handle_attempts` = ?,\n `message_version` = ?,\n `dtlasthandleattempt` = NOW(),\n `dtadded` = NOW(),\n `message_format` = ?,\n `event_id` = ?\n ON DUPLICATE KEY UPDATE handle_attempts = handle_attempts+1, dtlasthandleattempt = NOW()\n ", array($message->messageId, $time, $this->serverId, $message->serverId, $rawMessage, $message->getName(), $delayed ? '0' : '1', 2, $messageType, isset($message->eventId) ? $message->eventId : '')); if ($delayed) { return $message; } $isVPC = false; if ($this->farmId) { if (DBFarm::LoadByID($this->farmId)->GetSetting(Entity\FarmSetting::EC2_VPC_ID)) { $isVPC = true; } } if (!$this->remoteIp && !$this->localIp && !$isVPC) { return; } $cryptoTool->setCryptoKey($this->GetKey(true)); $encMessage = $cryptoTool->encrypt($rawMessage); $timestamp = date("c", time()); $signature = $cryptoTool->sign($encMessage, null, $timestamp); try { $request = new Request(); $request->setRequestMethod('POST'); $ctrlPort = $this->getPort(self::PORT_CTRL); $requestHost = $this->getSzrHost() . ":{$ctrlPort}"; if ($isVPC) { $routerFarmRoleId = $this->GetFarmRoleObject()->GetSetting(Scalr_Role_Behavior_Router::ROLE_VPC_SCALR_ROUTER_ID); if ($routerFarmRoleId) { $routerRole = DBFarmRole::LoadByID($routerFarmRoleId); } else { $routerRole = $this->GetFarmObject()->GetFarmRoleByBehavior(ROLE_BEHAVIORS::VPC_ROUTER); } if ($routerRole) { // No public IP need to use proxy if (!$this->remoteIp) { $requestHost = $routerRole->GetSetting(Scalr_Role_Behavior_Router::ROLE_VPC_IP) . ":80"; $request->addHeaders(array("X-Receiver-Host" => $this->localIp, "X-Receiver-Port" => $ctrlPort)); // There is public IP, can use it } else { $requestHost = "{$this->remoteIp}:{$ctrlPort}"; } } } //Prepare request $request->setRequestUrl("http://{$requestHost}/control"); $request->setOptions(array('timeout' => \Scalr::config('scalr.system.instances_connection_timeout'), 'connecttimeout' => \Scalr::config('scalr.system.instances_connection_timeout'))); $request->addHeaders(array("Date" => $timestamp, "X-Signature" => $signature, 'X-Server-Id' => $this->serverId)); if ($messageType == 'json') { $request->addHeaders(array('Content-type' => 'application/json')); } $request->append($encMessage); // Send request $response = \Scalr::getContainer()->srzhttp->sendRequest($request); // Process response if ($response->getResponseCode() == 201) { $logger->info(sprintf("[FarmID: %s] Sending message '%s' via REST to server '%s' (server_id: %s) completed", $this->farmId, $message->getName(), $this->remoteIp, $this->serverId)); if (in_array($message->getName(), array('ExecScript'))) { $this->Db->Execute("DELETE FROM messages WHERE messageid = ?", array($message->messageId)); } else { if ($messageType != 'json') { $this->Db->Execute("UPDATE messages SET status = ?, message = '' WHERE messageid = ?", array(MESSAGE_STATUS::HANDLED, $message->messageId)); } else { $this->Db->Execute("UPDATE messages SET status = ? WHERE messageid = ?", array(MESSAGE_STATUS::HANDLED, $message->messageId)); } if (!empty($message->eventId)) { $this->Db->Execute("UPDATE events SET msg_sent = msg_sent + 1 WHERE event_id = ?", array($message->eventId)); } } } else { $logger->warn(sprintf("[FarmID: %s] Cannot deliver message '%s' (message_id: %s) via REST" . " to server '%s' (server_id: %s). Error: %s %s", $this->farmId, $message->getName(), $message->messageId, $this->remoteIp, $this->serverId, $response->getResponseCode(), $response->getResponseStatus())); } } catch (http\Exception $e) { if (isset($e->innerException)) { $msg = $e->innerException->getMessage(); } else { $msg = $e->getMessage(); } if ($this->farmId) { $logger->warn(new FarmLogMessage($this->farmId, sprintf("Cannot deliver message '%s' (message_id: %s) via REST to server '%s' (server_id: %s). Error: %s", $message->getName(), $message->messageId, $this->remoteIp, $this->serverId, $msg), $this->serverId)); } else { $logger->fatal(sprintf("Cannot deliver message '%s' (message_id: %s) via REST" . " to server '%s' (server_id: %s). Error: %s", $message->getName(), $message->messageId, $this->remoteIp, $this->serverId, $msg)); } return false; } return $message; }
function __construct() { parent::__construct(); }
function handle($queue, Scalr_Messaging_Msg $message, $rawMessage) { $dbserver = DBServer::LoadByID($message->getServerId()); if ($message instanceof Scalr_Messaging_Msg_ExecScriptResult) { try { $storage = \Scalr::config('scalr.system.scripting.logs_storage'); if (!$message->executionId || $storage == 'scalr') { $msg = sprintf("STDERR: %s \n\n STDOUT: %s", base64_decode($message->stderr), base64_decode($message->stdout)); } if ($message->scriptPath) { $name = stristr($message->scriptPath, '/usr/local/bin/scalr-scripting') ? $message->scriptName : $message->scriptPath; } else { $name = $message->scriptName; } $this->db->Execute("INSERT DELAYED INTO scripting_log SET\n farmid = ?,\n server_id = ?,\n event = ?,\n message = ?,\n dtadded = NOW(),\n script_name = ?,\n event_server_id = ?,\n exec_time = ?,\n exec_exitcode = ?,\n event_id = ?,\n execution_id = ?,\n run_as = ?\n ", array($dbserver->farmId, $message->getServerId(), $message->eventName, $msg, $name, $message->eventServerId, round($message->timeElapsed, 2), $message->returnCode, $message->eventId, $message->executionId, $message->runAs)); if ($message->meta[Scalr_Messaging_MsgMeta::SZR_VERSION]) { DBServer::LoadByID($message->getServerId())->setScalarizrVersion($message->meta[Scalr_Messaging_MsgMeta::SZR_VERSION]); } if ($message->eventId) { $updateTotal = ''; if ($message->returnCode == 130) { $field = 'scripts_timedout'; } elseif ($message->returnCode != 0) { $field = 'scripts_failed'; } else { $field = 'scripts_completed'; } if (stristr($name, '[Scalr built-in]')) { $updateTotal = ', `scripts_total` = `scripts_total`+1'; } $this->db->Execute("UPDATE events SET `{$field}` = `{$field}`+1 {$updateTotal} WHERE event_id = ?", array($message->eventId)); } } catch (Exception $e) { $this->logger->fatal($e->getMessage()); } } elseif ($message instanceof Scalr_Messaging_Msg_Log) { try { if ($message->meta[Scalr_Messaging_MsgMeta::SZR_VERSION]) { DBServer::LoadByID($message->getServerId())->setScalarizrVersion($message->meta[Scalr_Messaging_MsgMeta::SZR_VERSION]); } } catch (Exception $e) { } foreach ($message->entries as $entry) { try { if (self::$severityCodes[$entry->level] < 3) { continue; } $tm = date('YmdH'); $hash = md5("{$message->getServerId()}:{$entry->msg}:{$dbserver->farmId}:{$entry->name}:{$tm}", true); $this->db->Execute("INSERT DELAYED INTO logentries SET\n `id` = ?,\n `serverid` = ?,\n `message` = ?,\n `severity` = ?,\n `time` = ?,\n `source` = ?,\n `farmid` = ?\n ON DUPLICATE KEY UPDATE cnt = cnt + 1, `time` = ?\n ", array($hash, $message->getServerId(), $entry->msg, self::$severityCodes[$entry->level], time(), $entry->name, $dbserver->farmId, time())); } catch (Exception $e) { $this->logger->error($e->getMessage()); } } } elseif ($message instanceof Scalr_Messaging_Msg_RebundleLog) { try { $this->db->Execute("INSERT INTO bundle_task_log SET\n bundle_task_id = ?,\n dtadded = NOW(),\n message = ?\n ", array($message->bundleTaskId, $message->message)); } catch (Exception $e) { $this->logger->error($e->getMessage()); } } elseif ($message instanceof Scalr_Messaging_Msg_DeployLog) { try { $this->db->Execute("INSERT INTO dm_deployment_task_logs SET\n `dm_deployment_task_id` = ?,\n `dtadded` = NOW(),\n `message` = ?\n ", array($message->deployTaskId, $message->message)); } catch (Exception $e) { } } }
function __construct($username = null, $password = null) { parent::__construct(); $this->username = $username; $this->password = $password; }