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
     $options_task_server_backup = array('location' => $arguments['location'], 'filepath' => $arguments['filepath']);
     if ($arguments['snapshot']) {
         $options_task_server_backup['snapshot'] = $arguments['snapshot'];
     }
     if ($arguments['newsnapshot']) {
         $options_task_server_backup['newsnapshot'] = $arguments['newsnapshot'];
     }
     if ($arguments['delete']) {
         $options_task_server_backup['deletesnapshot'] = $arguments['delete'];
     }
     if ($arguments['location']) {
         if ($arguments['do_not_generate_tar'] && $arguments['do_not_generate_tar'] != 'false') {
             $options_task_server_backup['do_not_generate_tar'] = true;
         }
     }
     $task_server_backup = new serverBackupTask($this->dispatcher, new sfFormatter());
     return $task_server_backup->run(array('serverid' => $arguments['serverid']), $options_task_server_backup);
 }
예제 #2
0
 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] Flushing old data...' . "\n");
     $eventlog_flush = EtvaSettingPeer::retrieveByPK('eventlog_flush');
     $flush_range = $eventlog_flush->getValue();
     $con->beginTransaction();
     $affected = 0;
     try {
         $offset_date = date("c", time() - $flush_range * 24 * 60 * 60);
         /*
          * get event records that have creation date outdated
          */
         $c = new Criteria();
         $c->add(EtvaEventPeer::CREATED_AT, $offset_date, Criteria::LESS_THAN);
         $affected = EtvaEventPeer::doDelete($c, $con);
         $con->commit();
         $message = sprintf('Events Log - %d Record(s) deleted after %d day offset', $affected, $flush_range);
         $context->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message)));
         $this->log('[INFO] ' . $message);
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
     $logger = new sfFileLogger($context->getEventDispatcher(), array('file' => sfConfig::get("sf_log_dir") . '/cron_status.log'));
     // log the message!
     $logger->log("[INFO] The events flush task ran!", 6);
 }
 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] Checking VirtAgents state...' . "\n");
     $offset = sfConfig::get('app_node_keepalive_update') + sfConfig::get('app_node_keepalive_update_offset');
     $total_nodes = EtvaNodePeer::doCount(new Criteria());
     if ($total_nodes > 0) {
         $con->beginTransaction();
         $affected = 0;
         try {
             $offset_date = date("c", time() - $offset);
             /*
              * get nodes that have last_keepalive field outdated
              */
             $c1 = new Criteria();
             $c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
             $c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_ACTIVE);
             // only active
             //update statement
             $c2 = new Criteria();
             $c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_INACTIVE);
             $affected += BasePeer::doUpdate($c1, $c2, $con);
             // update maintenance and running to maintenance
             $c1 = new Criteria();
             $c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
             $c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_MAINTENANCE_UP);
             //update statement
             $c2 = new Criteria();
             $c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_MAINTENANCE);
             $affected += BasePeer::doUpdate($c1, $c2, $con);
             // update fail and running to fail
             $c1 = new Criteria();
             $c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
             $c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_FAIL_UP);
             // only active
             //update statement
             $c2 = new Criteria();
             $c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_FAIL);
             $affected += BasePeer::doUpdate($c1, $c2, $con);
             $con->commit();
             $message = sprintf('%d Node(s) NOT received update in time offset of %d seconds', $affected, $offset);
             if ($affected > 0) {
                 $context->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             }
             $this->log('[INFO]' . $message);
         } catch (PropelException $e) {
             $con->rollBack();
             throw $e;
         }
     }
     $logger = new sfFileLogger($context->getEventDispatcher(), array('file' => sfConfig::get("sf_log_dir") . '/cron_status.log'));
     // log the message!
     $logger->log("[INFO] The check virtAgents 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);
     $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);
 }
예제 #5
0
 protected function execute($arguments = array(), $options = array())
 {
     $this->log("[INFO] loadModelConf");
     // Instance variables
     $this->loadModelConf();
     parent::execute($arguments, $options);
     $this->log("[INFO] cheking db version");
     $i = $this->getCurrentVersion();
     $required_version = $this->getRequiredVersion();
     if ($required_version == $i) {
         $this->log("[INFO] Database is up to date. Nothing to do!");
         return 5;
     }
     $i++;
     $dbfile = $arguments['datafile'];
     for ($i; $i <= $required_version; $i++) {
         switch ($i) {
             case 10:
                 // version 1.0
                 $this->upgradeToV10($dbfile);
                 break;
             case 11:
                 // version 1.1
                 $this->upgradeToV11($dbfile);
                 break;
             case 12:
                 // version 1.2
                 $this->upgradeToV12($dbfile);
                 break;
             case 13:
                 // version 1.3
                 $this->upgradeToV13($dbfile);
                 break;
             case 20:
                 // version 2.0
             // version 2.0
             case 21:
                 // version 2.1
                 $this->upgradeToV20($dbfile, $i);
                 break;
         }
     }
     return 0;
 }
 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)));
     }
 }
 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('Checking shared storage cluster consistency...' . "\n");
     $ok = 1;
     $affected = 0;
     $errors = array();
     $clusters = EtvaClusterPeer::doSelect(new Criteria());
     foreach ($clusters as $cluster) {
         $bulk_response_lvs = $cluster->soapSend('getlvs_arr', array('force' => 1));
         $bulk_response_dtable = $cluster->soapSend('device_table');
         $lv_va = new EtvaLogicalvolume_VA();
         foreach ($bulk_response_lvs as $node_id => $node_response) {
             if ($node_response['success']) {
                 //response received ok
                 $lvs = (array) $node_response['response'];
                 $node = EtvaNodePeer::retrieveByPK($node_id);
                 //$consist = $lv_va->check_shared_consistency($node,$lvs);
                 $response_dtable = (array) $bulk_response_dtable[$node_id];
                 $dtable = array();
                 if ($response_dtable['success']) {
                     $dtable = (array) $response_dtable['response'];
                     //$consist_dtable = $lv_va->check_shared_devicetable_consistency($node,$dtable,$bulk_response_dtable);
                 }
                 $check_res = $lv_va->check_consistency($node, $lvs, $dtable, $bulk_response_dtable);
                 if (!$check_res['success']) {
                     $err = $check_res['errors'];
                     $msg = sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_INCONSISTENT_, array('%info%' => ''));
                     $err_msg = sprintf(" node with id=%s is not consistent: %s \n", $node_id, $msg);
                     $errors[] = array('message' => $err_msg, 'debug' => $err);
                     $affected++;
                     $node->setErrorMessage(EtvaLogicalvolume_VA::LVINIT);
                 } else {
                     $node->clearErrorMessage(EtvaLogicalvolume_VA::LVINIT);
                 }
                 /*if( !$consist || !$consist_dtable ){
                                     $errors = $lv_va->get_missing_lv_devices();
                                     $msg = $errors ? $errors['message'] :
                                                     sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_INCONSISTENT_,array('%info%'=>''));
                 
                                     $err_msg = sprintf( " node with id=%s is not consistent: %s \n", $node_id, $msg );
                                     $errors[] = array( 'message'=> $err_msg, 'debug'=>array( 'consist_lvs'=>$consist, 'consist_dtable'=>$consist_dtable ) );
                                     $affected++;
                                     $node->setErrorMessage(EtvaLogicalvolume_VA::LVINIT);
                                 } else {
                                     $node->clearErrorMessage(EtvaLogicalvolume_VA::LVINIT);
                                 }*/
             } else {
                 $errors[] = $node_response;
                 $affected++;
             }
         }
         $bulk_response_pvs = $cluster->soapSend('hash_phydisks', array('force' => 1));
         $pv_va = new EtvaPhysicalvolume_VA();
         foreach ($bulk_response_pvs as $node_id => $node_response) {
             if ($node_response['success']) {
                 //response received ok
                 $pvs = (array) $node_response['response'];
                 $node = EtvaNodePeer::retrieveByPK($node_id);
                 $check_res = $pv_va->check_consistency($node, $pvs);
                 if (!$check_res['success']) {
                     $err = $check_res['errors'];
                     $msg = sfContext::getInstance()->getI18N()->__(EtvaPhysicalvolumePeer::_ERR_INCONSISTENT_, array('%info%' => ''));
                     $err_msg = sprintf(" node with id=%s is not consistent: %s \n", $node_id, $msg);
                     $errors[] = array('message' => $err_msg, 'debug' => $err);
                     $affected++;
                     $node->setErrorMessage(EtvaPhysicalvolume_VA::PVINIT);
                 } else {
                     $node->clearErrorMessage(EtvaPhysicalvolume_VA::PVINIT);
                 }
             } else {
                 $errors[] = $node_response;
                 $affected++;
             }
         }
         $bulk_responses_vgs = $cluster->soapSend('getvgpvs', array('force' => 1));
         $vg_va = new EtvaVolumegroup_VA();
         foreach ($bulk_response_vgs as $node_id => $node_response) {
             if ($node_response['success']) {
                 //response received ok
                 $vgs = (array) $node_response['response'];
                 $node = EtvaNodePeer::retrieveByPK($node_id);
                 $check_res = $vg_va->check_consistency($node, $vgs);
                 if (!$check_res['success']) {
                     $err = $check_res['errors'];
                     $msg = sfContext::getInstance()->getI18N()->__(EtvaVolumegroupPeer::_ERR_INCONSISTENT_, array('%info%' => ''));
                     $err_msg = sprintf(" node with id=%s is not consistent: %s \n", $node_id, $msg);
                     $errors[] = array('message' => $err_msg, 'debug' => $err);
                     $affected++;
                     $node->setErrorMessage(EtvaVolumegroup_VA::VGINIT);
                 } else {
                     $node->clearErrorMessage(EtvaVolumegroup_VA::VGINIT);
                 }
             } else {
                 $errors[] = $node_response;
                 $affected++;
             }
         }
     }
     if (!empty($errors)) {
         $this->log($message);
     } else {
         // log the message!
         $this->log("The check shared storage cluster consistency 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);
     $con = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $this->log('[INFO] Checking Servers heartbeat...' . "\n");
     $servers_timeout = EtvaServerQuery::create()->filterByVmState(EtvaServer::RUNNING)->filterByGaState(EtvaServerPeer::_GA_RUNNING_)->filterByHasha(1)->where('hbtimeout>0 AND UNIX_TIMESTAMP(heartbeat) < (UNIX_TIMESTAMP(now()) - hbtimeout)')->useEtvaServerAssignQuery('ServerAssign', 'RIGHT JOIN')->useEtvaNodeQuery()->filterByState(EtvaNode::NODE_ACTIVE)->endUse()->endUse()->find();
     if (count($servers_timeout) > 0) {
         foreach ($servers_timeout as $etva_server) {
             $message = sprintf(' The server %s with id %s get heartbeat timed out (last heartbeat at %s and heartbeat timeout %s secods)', $etva_server->getName(), $etva_server->getId(), $etva_server->getHeartbeat(), $etva_server->getHbtimeout());
             $this->log($message);
             // add log message
             Etva::makeNotifyLogMessage($this->name, $message);
             $etva_node = $etva_server->getEtvaNode();
             $server_va = new EtvaServer_VA($etva_server);
             $response_ga = $etva_server->getGAInfo($etva_node);
             if (!$response_ga['success']) {
                 $msg = sprintf(' Something wrong with node %s agent, can\'t get GA state of the server %s with id %s run.', $etva_node->getName(), $etva_server->getName(), $etva_server->getId());
                 $this->log($msg);
                 // add log message
                 Etva::makeNotifyLogMessage($this->name, $msg);
                 $etva_server->setGaState(EtvaServerPeer::_GA_STOPPED_);
                 // mark GA as stopped
                 $etva_server->save();
             } else {
                 if ($reponse_ga['ga_state'] == EtvaServerPeer::_GA_RUNNING_) {
                     $message_ga = sprintf(' But the explicit check GA state of the server %s with id %s run with success.', $etva_server->getName(), $etva_server->getId());
                     $this->log($message_ga);
                     // add log message
                     Etva::makeNotifyLogMessage($this->name, $message_ga, array(), null, array(), EtvaEventLogger::INFO);
                 } else {
                     // go restart
                     $starttime = sfConfig::get('app_server_heartbeat_starttime');
                     $starttime_date = date("c", time() - $starttime);
                     if ($etva_server->getHblaststart() && $etva_server->getHblaststart() > $starttime_date) {
                         $msg = sprintf(' the server %s with id %s is in starttime.', $etva_server->getName(), $etva_server->getId());
                         $this->log($msg);
                         // add log message
                         Etva::makeNotifyLogMessage($this->name, $msg, array(), null, array(), EtvaEventLogger::INFO);
                     } else {
                         $last_nrestarts = $etva_server->getHbnrestarts();
                         if ($last_nrestarts >= sfConfig::get('app_server_heartbeat_number_of_restart')) {
                             $msg = sprintf(' the server %s with id %s exceed number of restart.', $etva_server->getName(), $etva_server->getId());
                             $this->log($msg);
                             // add log message
                             Etva::makeNotifyLogMessage($this->name, $msg);
                         } else {
                             $msg = sprintf(' the server %s with id %s is heartbeat out of date and will be restart.', $etva_server->getName(), $etva_server->getId());
                             $this->log($msg);
                             // add log message
                             Etva::makeNotifyLogMessage($this->name, $msg, array(), null, array(), EtvaEventLogger::INFO);
                             // force to stop
                             $response_stop = $server_va->send_stop($etva_node, array('force' => 1, 'destroy' => 1));
                             sleep(5);
                             // wait a few seconds
                             $response_start = $server_va->send_start($etva_node);
                             if (!$response_start['success']) {
                                 // start fail...
                                 sleep(10);
                                 // wait a few seconds
                                 $response_start = $server_va->send_start($etva_node);
                                 // start again
                             }
                             $etva_server->resetHeartbeat(EtvaServerPeer::_GA_STOPPED_);
                             // reset heartbeat and mark GA as stopped
                             $etva_server->setHbnrestarts($last_nrestarts + 1);
                             // inc number of restart
                             $etva_server->save();
                         }
                     }
                 }
             }
         }
     } else {
         $this->log("[INFO] No servers with heartbeat timed out.");
     }
     // log the message!
     $this->log("[INFO] The check servers heartbeat task ran!");
 }
 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");
     }
 }
 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!');
     }
 }