Started integrating external systems
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// Zabbix interface
|
||||
// $config_ext['zabbix']
|
||||
|
||||
class Zabbix {
|
||||
}
|
||||
|
||||
// $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
|
||||
$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();
|
||||
$smarty->assign('zbx_hostname', $zbx_hostname);
|
||||
$zbx = NULL; // close
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user