static function getWithServers() { /*$criteria = new Criteria(); $criteria->addJoin(self::ID, EtvaServerPeer::NODE_ID, Criteria::LEFT_JOIN); //$criteria->addJoin(EtvaServerPeer::SF_GUARD_GROUP_ID, sfContext::getInstance()->getUser()->getGroupsId(), Criteria::IN); $criteria->setDistinct(); return self::doSelect($criteria);*/ $list = EtvaNodeQuery::create()->useEtvaServerAssignQuery('ServerAssign', Criteria::LEFT_JOIN)->endUse()->distinct()->find(); return $list; }
protected function execute($arguments = array(), $options = array()) { $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true)); parent::execute($arguments, $options); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $con = $databaseManager->getDatabase($options['connection'])->getConnection(); // add your code here $this->log('[INFO]Checking node(s) virtual machines state...' . "\n"); // get nodes active $updated_vm_state = array(); $nodes = EtvaNodeQuery::create()->filterByState(EtvaNode::NODE_ACTIVE)->find(); $affected = 0; foreach ($nodes as $node) { $response = $node->soapSend('domains_stats'); $success = $response['success']; if ($success) { $returned_data = $response['response']; foreach ($returned_data as $i => $server) { $server_data = (array) $server; $etva_server = $node->retrieveServerByName($server_data['name']); if ($etva_server) { $server_id = $etva_server->getId(); // get server id if ($etva_server->getVmState() !== EtvaServer::STATE_MIGRATING) { // only if not in migrating mode $etva_server->setVmState($server_data['state']); $etva_server->save(); } $updated_vm_state[$server_id] = $etva_server->getVmState(); // mark as updated } } } else { $affected++; $errors[] = $response['error']; } } // change state as STOP for servers that are not in array EtvaServerQuery::create()->filterById(array_keys($updated_vm_state), Criteria::NOT_IN)->update(array('VmState' => EtvaServer::STATE_STOP)); if ($nodes) { $message = sprintf('%d Node(s) could not be checked for virtual machines state', $affected); if ($affected > 0) { $context->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); } } if (!empty($errors)) { $this->log('[INFO]' . $message); } $logger = new sfFileLogger($context->getEventDispatcher(), array('file' => sfConfig::get("sf_log_dir") . '/cron_status.log')); // log the message! $logger->log("The check virtual machines state task ran!", 6); }
protected function execute($arguments = array(), $options = array()) { $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true)); parent::execute($arguments, $options); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); // add your code here $this->log('Refreshing Guest Agents Info...' . "\n"); $nodes = EtvaNodeQuery::create()->filterByState(EtvaNode::NODE_ACTIVE)->find(); foreach ($nodes as $node) { $node_va = new EtvaNode_VA($node); $this->log('Collecting info for node: ' . $node->getName() . "\n"); $bulk_response_gas = $node_va->send_get_gas_info(); //$this->log('The following servers info were updated: '.implode('; ', $bulk_response_gas)); $message = 'The following servers info were updated: ' . implode('; ', $bulk_response_gas); $this->log($message); $context->getEventDispatcher()->notify(new sfEvent($node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::INFO))); } }
public function getAdmissionGate(EtvaServer $server) { if ($this->getHasNodeHA()) { if ($this->getAdmissionGateType() == self::CLUSTER_ADMISSION_GATE_TYPE_N_HOSTS_TOLERATE || $this->getAdmissionGateType() == self::CLUSTER_ADMISSION_GATE_TYPE_PER_RESOURCES) { $nodes = EtvaNodeQuery::create()->leftJoin('EtvaNode.EtvaServerAssign')->leftJoin('EtvaServerAssign.EtvaServer')->addJoinCondition('EtvaServer', 'EtvaServer.VmState = ?', EtvaServer::RUNNING)->withColumn('SUM(EtvaServer.Mem)', 'sum_mem')->withColumn('SUM(EtvaServer.Vcpu)', 'sum_vcpu')->groupBy('EtvaNode.Id')->orderBy('EtvaNode.Memtotal', 'desc')->filterByClusterId($this->getId())->filterByState(EtvaNode::NODE_ACTIVE)->filterByInitialize(EtvaNode::INITIALIZE_OK)->find(); $n_hosts_tolerate = 0; if ($this->getAdmissionGateType() == self::CLUSTER_ADMISSION_GATE_TYPE_N_HOSTS_TOLERATE) { $n_hosts_tolerate = $this->getAdmissionGateValue(); } $n_hosts_tolerate_value = $n_hosts_tolerate; $sum_all_Nodes_memtotal = 0; $sum_n_biggest_Nodes_memtotal = 0; $sum_all_running_Servers_mem = 0; $sum_all_Nodes_memfree = 0; $max_cpu_Nodes = 0; $server_mem_bytes = $server->getMem() * 1024 * 1024; foreach ($nodes as $node) { if ($n_hosts_tolerate) { $sum_n_biggest_Nodes_memtotal = +$node->getMemtotal(); $n_hosts_tolerate--; // decrease } $sum_all_Nodes_memtotal += $node->getMemtotal(); $sum_all_Nodes_memfree += $node->getMemfree(); $sum_all_running_Servers_mem += $node->getSum_mem(); if (!$max_cpu_Nodes || $node->getCputotal() < $max_cpu_Nodes) { $max_cpu_Nodes = $node->getCputotal(); } } $sum_all_running_Servers_mem_bytes = $sum_all_running_Servers_mem * 1024 * 1024; error_log("getAdmissionGate getAdmissionGateType=" . $this->getAdmissionGateType() . " getAdmissionGateValue=" . $this->getAdmissionGateValue() . " sum_all_Nodes_memtotal={$sum_all_Nodes_memtotal} sum_n_biggest_Nodes_memtotal={$sum_n_biggest_Nodes_memtotal} sum_all_running_Servers_mem_bytes={$sum_all_running_Servers_mem_bytes} sum_all_Nodes_memfree={$sum_all_Nodes_memfree} max_cpu_Nodes={$max_cpu_Nodes} vcpu=" . $server->getVcpu() . " mem=" . $server->getMem() . " name=" . $server->getName()); if ($this->getAdmissionGateType() == self::CLUSTER_ADMISSION_GATE_TYPE_N_HOSTS_TOLERATE) { $sum_all_running_Servers_memfree_bytes_after = $sum_all_Nodes_memtotal - $sum_all_running_Servers_mem_bytes - $server_mem_bytes; $sum_all_Nodes_memfree_after = $sum_all_Nodes_memfree - $server_mem_bytes; error_log("getAdmissionGate TYPE_N_HOSTS_TOLERATE n_hosts_tolerate_value={$n_hosts_tolerate_value} sum_all_running_Servers_memfree_bytes_after={$sum_all_running_Servers_memfree_bytes_after} sum_all_Nodes_memfree_after={$sum_all_Nodes_memfree_after} sum_n_biggest_Nodes_memtotal={$sum_n_biggest_Nodes_memtotal} max_cpu_Nodes={$max_cpu_Nodes} vcpu=" . $server->getVcpu() . " mem=" . $server->getMem() . " name=" . $server->getName()); # the all free memory get from running server should not be less then total of sum of memory of biggest nodes if ($sum_all_running_Servers_memfree_bytes_after < $sum_n_biggest_Nodes_memtotal) { return array('success' => false, 'info' => sfContext::getInstance()->getI18N()->__('Unfulfilled policy for (%n_hosts_tolerate_value%) host(s) failures tolerate. The calc of free memory from running servers say that has %free_mem% to garantee %total_mem%.', array('%n_hosts_tolerate_value%' => $n_hosts_tolerate_value, '%free_mem%' => $sum_all_running_Servers_memfree_bytes_after, '%total_mem%' => $sum_n_biggest_Nodes_memtotal))); } # the all free memory verified on nodes should not be less then total of sum of memory of biggest nodes if ($sum_all_Nodes_memfree_after < $sum_n_biggest_Nodes_memtotal) { return array('success' => false, 'info' => sfContext::getInstance()->getI18N()->__('Unfulfilled policy for (%n_hosts_tolerate_value%) host(s) failures tolerate. The node info says that has %free_mem% free memory to garantee %total_mem%.', array('%n_hosts_tolerate_value%' => $n_hosts_tolerate_value, '%free_mem%' => $sum_all_Nodes_memfree_after, '%total_mem%' => $sum_n_biggest_Nodes_memtotal))); } if ($server->getVcpu() > $max_cpu_Nodes) { return array('success' => false, 'info' => sfContext::getInstance()->getI18N()->__('Number max. of cpus (%max_cpu_Nodes%) exceeded.', array('%max_cpu_Nodes%' => $max_cpu_Nodes))); } } if ($this->getAdmissionGateType() == self::CLUSTER_ADMISSION_GATE_TYPE_PER_RESOURCES) { $per_resources_value = $this->getAdmissionGateValue(); $per_resources = $per_resources_value / 100; $sum_all_running_Servers_memfree_bytes_after = $sum_all_Nodes_memtotal - $sum_all_running_Servers_mem_bytes - $server_mem_bytes; $sum_all_Nodes_memfree_after = $sum_all_Nodes_memfree - $server_mem_bytes; $all_Node_memtotal_threshold = $sum_all_Nodes_memtotal * $per_resources; error_log("getAdmissionGate TYPE_PER_RESOURCES sum_all_running_Servers_memfree_bytes_after={$sum_all_running_Servers_memfree_bytes_after} sum_all_Nodes_memfree_after={$sum_all_Nodes_memfree_after} all_Node_memtotal_threshold={$all_Node_memtotal_threshold} max_cpu_Nodes={$max_cpu_Nodes} vcpu=" . $server->getVcpu() . " mem=" . $server->getMem() . " name=" . $server->getName()); # the all free memory get from running server should not be less then percentage of memory of nodes if ($sum_all_running_Servers_memfree_bytes_after < $all_Node_memtotal_threshold) { return array('success' => false, 'info' => sfContext::getInstance()->getI18N()->__('Unfulfilled policy for (%per_resources_value%) percentage of resources reserved to failover. The calc of free memory from running servers say that has %free_mem% to garantee %total_mem%.', array('%per_resources_value%' => $per_resources_value, '%free_mem%' => $sum_all_running_Servers_memfree_bytes_after, '%total_mem%' => $all_Node_memtotal_threshold))); } # the all free memory verified on nodes should not be less then percentage of memory of nodes if ($sum_all_Nodes_memfree_after < $all_Node_memtotal_threshold) { return array('success' => false, 'info' => sfContext::getInstance()->getI18N()->__('Unfulfilled policy for (%per_resources_value%) percentage of resources reserved to failover. The node info says that has %free_mem% free memory to garantee %total_mem%.', array('%per_resources_value%' => $per_resources_value, '%free_mem%' => $sum_all_Nodes_memfree_after, '%total_mem%.' => $all_Node_memtotal_threshold))); } if ($server->getVcpu() > $max_cpu_Nodes) { return array('success' => false, 'info' => sfContext::getInstance()->getI18N()->__('Number max. of cpus (%max_cpu_Nodes%) exceeded.', array('%max_cpu_Nodes%' => $max_cpu_Nodes))); } } } } return array('success' => true); }
/** * * @return */ public function executeJsonListFreeDevices(sfWebRequest $request) { $server_id = $request->getParameter('sid'); $dev_type = $request->getParameter('type'); # get server's node $etva_node = EtvaNodeQuery::create()->useEtvaServerAssignQuery()->filterByServerId($server_id)->endUse()->findOne(); if ($etva_node && $etva_node->getState() != 0) { $node_va = new EtvaNode_VA($etva_node); $response = $node_va->send_get_devs($dev_type); if ($response['success']) { $devs = $response['data']; $rsp_devs = array(); $devs_in_use = EtvaNodePeer::getDevicesInUse($etva_node); foreach ($devs as $k => $dev) { $dev->id = $dev->idvendor . $dev->idproduct; // check if device is already attached $testid = $dev->id . $dev->type; foreach ($devs_in_use as $du) { if ($du == $testid) { unset($response['data'][$k]); } } } # reindexing array $response['data'] = array_values($response['data']); $return = json_encode($response); // if the request is made throught soap request... if (sfConfig::get('sf_environment') == 'soap') { return $return; } // if is browser request return text renderer $this->getResponse()->setHttpHeader('Content-type', 'application/json'); return $this->renderText($return); } else { if (sfConfig::get('sf_environment') == 'soap') { return json_encode($response); } $return = $this->setJsonError($response); return $this->renderText($return); } } else { if ($etva_node && $etva_node->getState() == 0) { # report that node is down # EtvaNodePeer::_STATE_DOWN_ } } return $response; }
protected function execute($arguments = array(), $options = array()) { $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true)); parent::execute($arguments, $options); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); // add your code here // Update nodes logical volumes $this->log('[INFO] Update nodes logical volumes info...' . "\n"); $list_nodes = EtvaNodeQuery::create()->find(); foreach ($list_nodes as $node) { $lv_va = new EtvaLogicalvolume_VA(); $lv_errors = $lv_va->send_update($node, false, false); } // Check servers with snapshots $this->log('[INFO] Checking Servers with snapshots...' . "\n"); $errors_arr = array(); $list_servers = EtvaServerQuery::create()->find(); foreach ($list_servers as $server) { $server_lvs = $server->getEtvaLogicalvolumes(); foreach ($server_lvs as $lv) { if ($lv->getPerUsageSnapshots() >= EtvaLogicalvolume::PER_USAGESNAPSHOTS_CRITICAL) { $this->log('[ERROR] Logical volume \'' . $lv->getLvdevice() . '\' of server \'' . $server->getName() . '\' is in CRITICAL with ' . sprintf('%g%%', round($lv->getPerUsageSnapshots() * 100)) . ' of usage by snapshots '); array_push($errors_arr, array('server_name' => $server->getName(), 'lvdevice' => $lv->getLvdevice(), 'per_usage_snapshots' => $lv->getPerUsageSnapshots(), 'status_id' => EtvaServer::USAGESNAPSHOTS_STATUS_CRITICAL, 'status_str' => EtvaServer::USAGESNAPSHOTS_STATUS_CRITICAL_STR)); } else { if ($lv->getPerUsageSnapshots() >= EtvaLogicalvolume::PER_USAGESNAPSHOTS_WARNING) { $this->log('[ERROR] Logical volume \'' . $lv->getLvdevice() . '\' of server \'' . $server->getName() . '\' is in WARNING with ' . sprintf('%g%%', round($lv->getPerUsageSnapshots() * 100)) . ' of usage by snapshots '); array_push($errors_arr, array('server_name' => $server->getName(), 'lvdevice' => $lv->getLvdevice(), 'per_usage_snapshots' => $lv->getPerUsageSnapshots(), 'status_id' => EtvaServer::USAGESNAPSHOTS_STATUS_WARNING, 'status_str' => EtvaServer::USAGESNAPSHOTS_STATUS_WARNING_STR)); } else { $this->log('[INFO] Logical volume \'' . $lv->getLvdevice() . '\' of server \'' . $server->getName() . '\' is in NORMAL with ' . sprintf('%g%%', round($lv->getPerUsageSnapshots() * 100)) . ' of usage by snapshots '); #array_push($errors_arr, array('server_name'=>$server->getName(),'lvdevice'=>$lv->getLvdevice(),'per_usage_snapshots'=>$lv->getPerUsageSnapshots(),'status_id'=>EtvaServer::USAGESNAPSHOTS_STATUS_CRITICAL,'status_str'=>EtvaServer::USAGESNAPSHOTS_STATUS_CRITICAL_STR)); } } } } if (!empty($errors_arr)) { $message = ""; foreach ($errors_arr as $err) { if ($server_name != $err['server_name']) { $server_name = $err['server_name']; $message = $message . "Server '{$server_name}':\r\n"; } $message = $message . " Logical volume '" . $err['lvdevice'] . "' in state '" . $err['status_str'] . "' with " . sprintf('%g%%', round($err['per_usage_snapshots'] * 100)) . " usage of snapshots.\r\n"; } $from = EtvaSettingPeer::retrieveByPK(EtvaSettingPeer::_ALERT_EMAIL_FROM_)->getValue(); if (!$from) { $from = '*****@*****.**'; } $to = EtvaSettingPeer::retrieveByPK(EtvaSettingPeer::_ALERT_EMAIL_)->getValue(); if (!$to) { $to = '*****@*****.**'; } $subject_prefix = EtvaSettingPeer::retrieveByPK(EtvaSettingPeer::_ALERT_SUBJECT_PREFIX_)->getValue(); if (!$subject_prefix) { $subject_prefix = 'Nuxis -'; } #$to = "*****@*****.**"; $subject = $subject_prefix . " " . "Servers snapshots usage report"; $headers = "From: {$from}\r\n"; mail($to, $subject, $message, $headers); $this->log("[INFO] Email with report sent to {$to}"); } else { $this->log("[INFO] No errors to report"); } }
public function executeJsonUpdate(sfWebRequest $request) { // create cluster entry $id = $request->getParameter('id'); $cluster = EtvaClusterPeer::retrieveByPK($id); if (!$cluster) { $error_msg = sprintf('Object etva_cluster does not exist (%s).', $request->getParameter('id')); $info = array('success' => false, 'error' => $error_msg); $error = $this->setJsonError($info); return $this->renderText($error); } /*if(!$cluster) $form = new EtvaClusterForm(); else $form = new EtvaClusterForm($cluster); $result = $this->processJsonForm($request, $form); if(!$result['success']){ $error = $this->setJsonError($result); return $this->renderText($error); } //get cluster object $etva_cluster = $result['object'];*/ $form_data = (array) json_decode($request->getParameter('etva_cluster')); $clustername = $form_data['name']; if (!preg_match('/^[a-zA-Z][a-zA-Z0-9\\-\\_]+$/', $clustername)) { $msg = "Invalid name format"; error_log("CLUSTER[ERROR]" . $msg); $msg_i18n = $this->getContext()->getI18N()->__($msg); $error_msg = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n); //notify system log $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => Etva::getLogMessage(array('name' => $clustername, 'info' => $msg), EtvaClusterPeer::_ERR_CREATE_), 'priority' => EtvaEventLogger::ERR))); $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'info' => $msg_i18n, 'error' => array($error_msg)); // if is a CLI soap request return json encoded data if (sfConfig::get('sf_environment') == 'soap') { return json_encode($error); } // if is browser request return text renderer $error = $this->setJsonError($error); return $this->renderText($error); } $cluster->setName($clustername); $cluster->setIsDefaultCluster(0); if ($form_data['isDefaultCluster']) { $updatecluster = array('Isdefaultcluster' => 0); EtvaClusterQuery::create()->update($updatecluster); $cluster->setIsDefaultCluster(1); } $cluster->setHasNodeHA($form_data['hasNodeHA'] ? 1 : 0); $cluster->setAdmissionGateType($form_data['admissionGate_type']); $cluster->setAdmissionGateValue($form_data['admissionGate_value']); $cluster->save(); $etva_cluster = $cluster; $updateNodes = array('Issparenode' => 0); if ($request->getParameter('fencingconf')) { $fencingconf = $request->getParameter('fencingconf'); $updateNodes['Fencingconf'] = $fencingconf; } //clear spare node EtvaNodeQuery::create()->filterByClusterId($etva_cluster->getId())->update($updateNodes); if ($sparenode_id = $request->getParameter('sparenode')) { if ($etva_sparenode = EtvaNodePeer::retrieveByPK($sparenode_id)) { // and mark the spare node $etva_sparenode->setIsSpareNode(1); $etva_sparenode->save(); } } $name = $etva_cluster->getName(); $i18n_msg = $msg_i18n = $this->getContext()->getI18N()->__(EtvaClusterPeer::_OK_UPDATE_, array('%name%' => $name)); //notify system log $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => Etva::getLogMessage(array('name' => $name), EtvaClusterPeer::_OK_UPDATE_)))); $return = array('success' => true, 'agent' => sfConfig::get('config_acronym'), 'response' => $i18n_msg, 'cluster_id' => $etva_cluster->getId()); $return = json_encode($return); $this->getResponse()->setHttpHeader('Content-type', 'application/json'); return $this->renderText($return); }
public function listNodesAssignTo($migrate = false) { $nodes_assign = array(); $actual_node = $this->getEtvaNode(); if (!$migrate && $actual_node) { array_push($nodes_assign, $actual_node); } else { $nodes = EtvaNodeQuery::create()->leftJoin('EtvaNode.EtvaServerAssign')->leftJoin('EtvaServerAssign.EtvaServer')->addJoinCondition('EtvaServer', 'EtvaServer.VmState = ?', EtvaServer::RUNNING)->withColumn('sum(EtvaServer.Vcpu)', 'sum_vcpu')->withColumn('sum(EtvaServer.Vcpu)/EtvaNode.Cputotal', 'per_cpu')->withColumn('((sum(EtvaServer.Vcpu)/EtvaNode.Cputotal)+(1-(EtvaNode.Memfree/EtvaNode.Memtotal)))/2', 'per_res')->withColumn('1-(EtvaNode.Memfree/EtvaNode.Memtotal)', 'per_mem')->groupBy('EtvaNode.Id')->orderBy('per_res', 'asc')->orderBy('per_mem', 'asc')->orderBy('per_cpu', 'asc')->filterByClusterId($this->getClusterId())->filterByState(EtvaNode::NODE_ACTIVE)->filterByInitialize(EtvaNode::INITIALIZE_OK)->find(); if (count($nodes) == 1 || count($nodes) > 1 && $this->isAllSharedLogicalvolumes()) { # TODO calc assign gate foreach ($nodes as $i => $node) { if (!$actual_node || $actual_node->getId() != $node->getId()) { if ($node->canAssignServer($this)) { array_push($nodes_assign, $node); } } } } else { $nodes_withdisks = EtvaNodeQuery::create()->leftJoin('EtvaNode.EtvaServerAssign')->leftJoin('EtvaServerAssign.EtvaServer')->addJoinCondition('EtvaServer', 'EtvaServer.VmState = ?', EtvaServer::RUNNING)->withColumn('sum(EtvaServer.Vcpu)', 'sum_vcpu')->withColumn('sum(EtvaServer.Vcpu)/EtvaNode.Cputotal', 'per_cpu')->withColumn('((sum(EtvaServer.Vcpu)/EtvaNode.Cputotal)+(1-(EtvaNode.Memfree/EtvaNode.Memtotal)))/2', 'per_res')->withColumn('1-(EtvaNode.Memfree/EtvaNode.Memtotal)', 'per_mem')->groupBy('EtvaNode.Id')->orderBy('per_res', 'asc')->orderBy('per_mem', 'asc')->orderBy('per_cpu', 'asc')->filterByClusterId($this->getClusterId())->filterByState(EtvaNode::NODE_ACTIVE)->filterByInitialize(EtvaNode::INITIALIZE_OK)->useEtvaNodeLogicalvolumeQuery('NodeLogicalvolume', 'INNER JOIN')->useEtvaLogicalvolumeQuery('Logicalvolume', 'INNER JOIN')->useEtvaServerLogicalQuery('ServerLogical', 'INNER JOIN')->filterByServerId($this->getId())->endUse()->endUse()->endUse()->find(); foreach ($nodes_withdisks as $i => $node) { if (!$actual_node || $actual_node->getId() != $node->getId()) { if ($node->canAssignServer($this)) { array_push($nodes_assign, $node); } } } } } //usort($nodes_assign,'cmp_nodes_by_resources'); return $nodes_assign; }
protected function execute($arguments = array(), $options = array()) { $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true)); parent::execute($arguments, $options); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $con = $databaseManager->getDatabase($options['connection'])->getConnection(); // add your code here $this->log('[INFO] Send explicit check to VirtAgents...' . "\n"); $inactive_nodes = EtvaNodeQuery::create()->filterByState(EtvaNode::NODE_INACTIVE)->find(); if (count($inactive_nodes) > 0) { $queue = new processCheckQueuing($this); foreach ($inactive_nodes as $node) { $cluster = $node->getEtvaCluster(); // only if cluster has HA if ($cluster->getHasNodeHA()) { $message = sprintf('Node %s is inactive and the cluster %s has Node HA configured.', $node->getName(), $cluster->getName()); $this->log($message); Etva::makeNotifyLogMessage($this->name, $message); // if fail mark as coma $etva_node_va = new EtvaNode_VA($node); $response = $etva_node_va->checkState(EtvaNode::NODE_COMA); if (!$response['success']) { $msg_fail = sprintf(' agent %s getstate fail ', $node->getName()); $this->log($msg_fail); Etva::makeNotifyLogMessage($this->name, $msg_fail); $queue->enqueueProcess($node, 180); } else { $msg_ok = sprintf(' agent %s getstate with success ', $node->getName()); $this->log($msg_ok); Etva::makeNotifyLogMessage($this->name, $msg_ok, array(), null, array(), EtvaEventLogger::INFO); } } else { $msg_noha = sprintf('Node %s is inactive but the cluster %s doesn\'t have Node HA configured.', $node->getName(), $cluster->getName()); $this->log($msg_noha); } } $queue->loop(); } else { $this->log('No inactive nodes found!'); } }