Exemplo n.º 1
0
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $nid = $arguments['id'];
     $this->log("[INFO] node check id={$nid}");
     if (!($etva_node = EtvaNodePeer::retrieveByPK($nid))) {
         $msg_i18n = $context->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     } else {
         $etva_node_va = new EtvaNode_VA($etva_node);
         $response = $etva_node_va->checkState();
         if (!$response['success']) {
             $this->log("[ERROR] " . $response['error']);
         } else {
             $this->log("[INFO] " . $response['response']);
         }
         return $response;
     }
 }
Exemplo n.º 2
0
 public function checkState($etva_node)
 {
     $etva_node_va = new EtvaNode_VA($etva_node);
     return $etva_node_va->checkState();
 }
 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!');
     }
 }