public function collect() { foreach ($this->keysConfig as $instance => $server) { $command_option_host = $server['conf']['host']; $command_option_url_status = $server['conf']['status_url']; $lines = $this->execCommandAndReturnOutputLines("curl --silent http://" . $command_option_host . "/" . $command_option_url_status . "?auto | grep ':' | sed 's/:/ /g' | awk '{print \$1\" \"\$2}'"); $variables = $this->getVariablesFromOutputLines($lines); if ($this->debug) { self::log(Helper::dump($variables)); } $vars2store = $server['vars']; foreach ($vars2store as $var_name => $enabled) { if (isset($variables[$var_name])) { if ($enabled == 1) { $this->collected[] = (new Serie(NULL, $this->hostname, $this->name, $instance, $var_name, trim($variables[$var_name])))->getArray(); } } } } }
public function storeData($values) { if ($this->debugLevel > 2) { $this->debugMemory("SAVE " . __LINE__); } while (count($values) > 0) { $value = array_shift($values); if ($this->debugLevel > 2) { $this->monolog->addDebug("NEW DATA => " . Helper::dumpInLine($value)); } $serie = new \Models\SerieValue(); $serie->fromArray($value); if ($serie->isValid()) { try { $serie->save(); if ($this->debugLevel > 2) { $this->debugMemory("SAVE " . __LINE__); } } catch (\PDOException $e) { $this->monolog->addError("DB : " . $e->getCode() . " - " . $e->getMessage()); } } unset($serie); gc_collect_cycles(); if ($this->debugLevel > 2) { $this->debugMemory("SAVE " . __LINE__); } } unset($values); gc_collect_cycles(); }