예제 #1
0
 public static function writeRouterZones(array $zones)
 {
     if (self::$init === false) {
         self::init();
     }
     NagRedis::del(md5('cdcrouterzones'));
     NagRedis::sAdd(md5('cdcrouterzones'), $zones);
 }
예제 #2
0
 /**
  * buildDiffRevisions - build the revisions of the deployment and store them for diffing
  * 
  * @param mixed $deployment    deployment we are building revisions for
  * @param mixed $subdeployment deployment we are building revisions for
  * @param mixed $fromrev       from revision we are building
  * @param mixed $torev         to revision we are building
  * @param mixed $shardposition shard position we may be using
  *
  * @static
  * @access public
  * @return void
  */
 public static function buildDiffRevisions($deployment, $subdeployment, $fromrev, $torev, $shardposition)
 {
     self::$_results = array();
     self::$_output = "";
     NagRedis::init(true);
     $lockReturn = NagTester::setDeploymentBuildLock($deployment, $subdeployment, $fromrev);
     if ($lockReturn === false) {
         self::$_output = "Unable to acquire build lock for Deployment/Revision: {$deployment}/{$fromrev}";
         return false;
     }
     NagCreate::resetLocalCache();
     /* Get Current Nagios Configs */
     NagCreate::buildDeployment($deployment, $fromrev, true, true, $shardposition);
     $fromconfs = NagCreate::returnDeploymentConfigs($deployment);
     $fromconfs['nrpe.cfg'] = self::_getNRPECfg($deployment, $fromrev);
     $fromconfs['supplemental-nrpe.cfg'] = self::_getSupNRPECfg($deployment, $fromrev);
     NagTester::deleteDeploymentBuildLock($deployment, $subdeployment, $fromrev);
     $lockReturn = NagTester::setDeploymentBuildLock($deployment, $subdeployment, $torev);
     if ($lockReturn === false) {
         self::$_output = "Unable to acquire build lock for Deployment/Revision: {$deployment}/{$torev}";
         return false;
     }
     /* Get Future Revision Configs */
     NagCreate::buildDeployment($deployment, $torev, true, true, $shardposition);
     $toconfs = NagCreate::returnDeploymentConfigs($deployment);
     $toconfs['nrpe.cfg'] = self::_getNRPECfg($deployment, $torev);
     $toconfs['supplemental-nrpe.cfg'] = self::_getSupNRPECfg($deployment, $torev);
     NagTester::deleteDeploymentBuildLock($deployment, $subdeployment, $torev);
     /* Get Plugin Information */
     $fnagplugins = RevDeploy::getDeploymentNagiosPlugins($deployment, $fromrev);
     $tnagplugins = RevDeploy::getDeploymentNagiosPlugins($deployment, $torev);
     $nagplugins = array_merge($fnagplugins, $tnagplugins);
     $fromnagiosplugins = self::_getPlugins('nagios', $deployment, $fromrev, $nagplugins);
     $tonagiosplugins = self::_getPlugins('nagios', $deployment, $torev, $nagplugins);
     $fplugins = RevDeploy::getDeploymentNRPEPlugins($deployment, $fromrev);
     $tplugins = RevDeploy::getDeploymentNRPEPlugins($deployment, $torev);
     $plugins = array_merge($fplugins, $tplugins);
     $fromnrpecoreplugins = self::_getPlugins('nrpe-core', $deployment, $fromrev, $plugins);
     $tonrpecoreplugins = self::_getPlugins('nrpe-core', $deployment, $torev, $plugins);
     $fsplugins = RevDeploy::getDeploymentSupNRPEPlugins($deployment, $fromrev);
     $tsplugins = RevDeploy::getDeploymentSupNRPEPlugins($deployment, $torev);
     $supplugins = array_merge($fsplugins, $tsplugins);
     $fromsupnrpeplugins = self::_getPlugins('nrpe-sup', $deployment, $fromrev, $supplugins);
     $tosupnrpeplugins = self::_getPlugins('nrpe-sup', $deployment, $torev, $supplugins);
     /* Ok lets diff the results and send it out */
     $results = array();
     $results['nagiosconfs']['from'] = $fromconfs;
     $results['nagiosconfs']['to'] = $toconfs;
     $results['plugins']['nagios']['from'] = $fromnagiosplugins;
     $results['plugins']['nagios']['to'] = $tonagiosplugins;
     $results['plugins']['nrpe']['core']['from'] = $fromnrpecoreplugins;
     $results['plugins']['nrpe']['core']['to'] = $tonrpecoreplugins;
     $results['plugins']['nrpe']['sup']['from'] = $fromsupnrpeplugins;
     $results['plugins']['nrpe']['sup']['to'] = $tosupnrpeplugins;
     self::$_results = $results;
     unset($fromconfs, $toconfs, $results);
     unset($fnagplugins, $tnagplugins, $nagplugins, $fromnagiosplugins, $tonagiosplugins);
     unset($fplugins, $tplugins, $plugins, $fromnrpecoreplugins, $tonrpecoreplugins);
     unset($fsplugins, $tsplugins, $supplugins, $fromsupnrpeplugins, $tosupnrpeplugins);
     return true;
 }
예제 #3
0
 public static function getDeploymentHostAuditInfo($deployment)
 {
     if (self::$init === false) {
         self::init();
     }
     return NagRedis::get(md5('deployment:' . $deployment) . ':hostaudit');
 }
예제 #4
0
 public static function deleteDeploymentNagiosPlugin($deployment, $nagiosPlugin, $revision)
 {
     if (self::$init === false) {
         self::init();
     }
     $nagiosPluginInfo = self::getDeploymentNagiosPlugin($deployment, $nagiosPlugin, $revision);
     NagRedis::sRem(md5('deployment:' . $deployment) . ':' . $revision . ':nagiosplugins', $nagiosPlugin);
     NagRedis::del(md5('deployment:' . $deployment) . ':' . $revision . ':nagiosplugin:' . $nagiosPlugin);
     $nagiosPluginData = new NagiosPluginData($deployment, $revision, $nagiosPlugin, $nagiosPluginInfo, 'delete');
     self::addAuditUserLog($deployment, $revision);
     self::$log->addToLog($nagiosPluginData);
     return;
 }
예제 #5
0
 /**
  * Bumps the last used Redis time stamp, used by consumers
  *  Internal mechanism, not a Redis based command
  *
  * @return void
  */
 public static function bumpTimeStamp()
 {
     self::$timestamp = time();
     return;
 }