Private GIT

Skip to content
Snippets Groups Projects
Commit 20de58c4 authored by Jeremy Delpierre's avatar Jeremy Delpierre
Browse files

feat(api): Add new core data broker and engine versions

parent 103e7efd
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ require_once dirname(__FILE__) . "/webService.class.php"; ...@@ -37,6 +37,7 @@ require_once dirname(__FILE__) . "/webService.class.php";
require_once _CENTREON_PATH_ . "/www/class/centreonUUID.class.php"; require_once _CENTREON_PATH_ . "/www/class/centreonUUID.class.php";
require_once _CENTREON_PATH_ . "/www/class/centreonGMT.class.php"; require_once _CENTREON_PATH_ . "/www/class/centreonGMT.class.php";
require_once _CENTREON_PATH_ . "/www/class/centreonVersion.class.php"; require_once _CENTREON_PATH_ . "/www/class/centreonVersion.class.php";
require_once _CENTREON_PATH_ . "/www/class/centreonDB.class.php";
class CentreonStatistics extends CentreonWebService class CentreonStatistics extends CentreonWebService
{ {
...@@ -78,11 +79,10 @@ class CentreonStatistics extends CentreonWebService ...@@ -78,11 +79,10 @@ class CentreonStatistics extends CentreonWebService
*/ */
public function getVersion() public function getVersion()
{ {
$centreonVersion = new CentreonVersion($this->pearDB); $dbStorage = new CentreonDB("centstorage");
$centreonVersion = new CentreonVersion($this->pearDB, $dbStorage);
return array( return array(
'core' => array( 'core' => $centreonVersion->getCore(),
'centreon-web' => $centreonVersion->getVersion()
),
'modules' => $centreonVersion->getModules(), 'modules' => $centreonVersion->getModules(),
'widgets' => $centreonVersion->getWidgets(), 'widgets' => $centreonVersion->getWidgets(),
'system' => $centreonVersion->getSystem(), 'system' => $centreonVersion->getSystem(),
......
...@@ -37,34 +37,58 @@ class CentreonVersion ...@@ -37,34 +37,58 @@ class CentreonVersion
{ {
/** /**
* @var CentreonDB * @var CentreonDB
* @var CentreonDBStorage
*/ */
private $db; private $db;
private $dbStorage;
/** /**
* Constructor * Constructor
* *
* @param CentreonDB $db * @param CentreonDB $db
* @param CentreonDBStorage $dbStorage
*/ */
public function __construct($db) public function __construct($db, $dbStorage = null)
{ {
$this->db = $db; $this->db = $db;
if (!is_null($dbStorage)) {
$this->dbStorage = $dbStorage;
}
} }
/** /**
* Get Centreon web version * Get Centreon core version
* *
* @return string * @return array
*/ */
public function getVersion() public function getCore()
{ {
$data = ''; $data = array();
// Get version of the centreon-web
$query = 'SELECT i.value FROM informations i ' . $query = 'SELECT i.value FROM informations i ' .
'WHERE i.key = "version"'; 'WHERE i.key = "version"';
$result = $this->db->query($query); $result = $this->db->query($query);
if ($row = $result->fetchRow()) { if ($row = $result->fetchRow()) {
$data = $row['value']; $data['centreon-web'] = $row['value'];
} }
// Get version of the centreon-broker
$cmd = shell_exec("cbd -v");
if (preg_match('/^.*(\d+\.\d+\.\d+)$/', $cmd, $matches)) {
$data['centreon-broker'] = $matches[1];
}
// Get version of the centreon-engine
$queryProgram = "SELECT DISTINCT instance_id, version AS program_version, engine AS program_name, name AS instance_name FROM instances WHERE deleted = 0 ";
$result = $this->dbStorage->query($queryProgram);
while ($info = $result->fetchRow()) {
$data['centreon-engine'] = $info["program_version"];
}
return $data; return $data;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment