Example #1
0
 /**
  * __construct() - Sets the configaration options
  *
  * @param string $identityClassname
  * @param string $identityColumn
  * @param string $credentialColumn
  * @param string $objectPath
  * @return void
  */
 public function __construct($identityClassname = null, $identityColumn = null, $credentialColumn = null, $objectPath = null)
 {
     # PF: Changed. Stopped working in Pimcore 1.4+.
     #        \Zend_Db_Table::setDefaultAdapter(Pimcore_Resource_Mysql::get());
     \Zend_Db_Table::setDefaultAdapter(\Pimcore\Resource\Mysql::get()->getResource());
     if (null !== $identityClassname) {
         $this->setIdentityClassname($identityClassname);
     }
     if (null !== $identityColumn) {
         $this->setIdentityColumn($identityColumn);
     }
     if (null !== $credentialColumn) {
         $this->setCredentialColumn($credentialColumn);
     }
     if (null !== $objectPath) {
         $this->setObjectPath($objectPath);
     }
 }
 /**
  * Gathers metrics and sends them off to librato
  */
 public function performMaintenance()
 {
     if (!file_exists(self::getConfigName())) {
         return;
     }
     $config = new \Zend_Config_Xml(self::getConfigName());
     if (!($config->librato->get('installed', '0') == '1')) {
         return;
     }
     if (!($config->librato->get('enabled', '0') == '1')) {
         return;
     }
     $db = \Pimcore\Resource\Mysql::get();
     $libratoClient = self::getClient();
     foreach ($config->librato->metrics->metric as $metric) {
         $value = 0;
         $name = $metric->name;
         $sql = $metric->sql;
         if ($sql != '') {
             $value = $db->fetchOne($sql);
         }
         $php = $metric->php;
         if ($php != '') {
             $value = call_user_func($php);
         }
         switch ($metric->type) {
             case 'addCounter':
                 $libratoClient->addCounter($name, $value);
                 break;
             case 'addGauge':
             default:
                 $libratoClient->addGauge($name, $value);
                 break;
         }
     }
     $libratoClient->flush();
 }