Started integrating external systems
This commit is contained in:
@@ -141,6 +141,7 @@ $sth = $dbh->prepare($sql);
|
||||
$sth->execute($p);
|
||||
$smarty->assign("assets", $sth->fetchAll());
|
||||
|
||||
$smarty->assign("extlink", extlink_enabled());
|
||||
$smarty->display("asset.tpl");
|
||||
|
||||
elseif ($action == ACT_ADD):
|
||||
@@ -192,24 +193,45 @@ $smarty->assign("nodes", $sth->fetchAll(PDO::FETCH_ASSOC));
|
||||
// external systems
|
||||
// extlink_id
|
||||
// asset_id
|
||||
// Type: enum('cdb','zabbix','topdesk', osticket
|
||||
// Type: enum('cdb','zabbix','topdesk', osticket, loginventory
|
||||
// ID: extlink_refid int
|
||||
// extlink_uid string
|
||||
|
||||
// $smarty->assign('zabbix', print_r($config_ext['zabbix']['host'],true));
|
||||
if ($config_ext['zabbix']['enabled']) {
|
||||
$smarty->assign("zabbix", true);
|
||||
$sql = "SELECT extlink_refid FROM extlink WHERE extlink_type='zabbix' AND asset_id=?";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->execute([$id]);
|
||||
$refid = $sth->fetchColumn();
|
||||
|
||||
// TODO fetch ext data here
|
||||
//$zbx = new PDO('mysql:host='.$config_ext['zabbix']['host'].';dbname='.$config_ext['zabbix']['db'].';', $config_ext['zabbix']['user'], $config_ext['zabbix']['pass']);
|
||||
//$zbx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
//$zbx->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
$zbxconn = false;
|
||||
try {
|
||||
$zbx = new PDO('mysql:host='.$config_ext['zabbix']['host'].';dbname='.$config_ext['zabbix']['db'].';', $config_ext['zabbix']['user'], $config_ext['zabbix']['pass']);
|
||||
$zbx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$zbx->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
$zbxconn = true;
|
||||
} catch (Exception $e) {
|
||||
$refid = "not_connected:" . $e->getMessage();
|
||||
}
|
||||
|
||||
if ($zbxconn) {
|
||||
$sql = "SELECT host FROM hosts WHERE hostid=?";
|
||||
$sth = $zbx->prepare($sql);
|
||||
$sth->execute([$refid]);
|
||||
$zbx_hostname = $sth->fetchColumn();
|
||||
if ($zbx_hostname === false) {
|
||||
$zbx_hostname = 'not found';
|
||||
}
|
||||
$smarty->assign('zbx_hostname', $zbx_hostname);
|
||||
$zbx = NULL; // close
|
||||
}
|
||||
|
||||
$smarty->assign('refid', $refid);
|
||||
}
|
||||
|
||||
|
||||
$smarty->assign("extlink", extlink_enabled());
|
||||
$smarty->display("assetview.tpl");
|
||||
|
||||
elseif ($action == ACT_EDIT):
|
||||
|
||||
Reference in New Issue
Block a user