This commit is contained in:
laf
2016-01-04 12:09:32 +00:00
316 changed files with 36603 additions and 11399 deletions
+18 -8
View File
@@ -3,14 +3,22 @@
if ($device['os_group'] == 'unix') {
echo $config['project_name'].' UNIX Agent: ';
// FIXME - this should be in config and overridable in database
$agent_port = '6556';
$agent_port = get_dev_attrib($device,'override_Unixagent_port');
if (empty($agent_port)) {
$agent_port = $config['unix-agent']['port'];
}
if (empty($config['unix-agent']['connection-timeout'])) {
$config['unix-agent']['connection-timeout'] = $config['unix-agent-connection-time-out'];
}
if (empty($config['unix-agent']['read-timeout'])) {
$config['unix-agent']['read-timeout'] = $config['unix-agent-read-time-out'];
}
$agent_start = utime();
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent-connection-time-out']);
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent']['connection-timeout']);
// Set stream timeout (for timeouts during agent fetch
stream_set_timeout($agent, $config['unix-agent-read-time-out']);
stream_set_timeout($agent, $config['unix-agent']['read-timeout']);
$agentinfo = stream_get_meta_data($agent);
if (!$agent) {
@@ -55,9 +63,11 @@ if ($device['os_group'] == 'unix') {
$agentapps = array(
"apache",
"ceph",
"mysql",
"nginx",
"bind",
"powerdns",
"proxmox",
"tinydns");
@@ -108,10 +118,10 @@ if ($device['os_group'] == 'unix') {
if (file_exists("includes/polling/applications/$key.inc.php")) {
d_echo("Enabling $key for ".$device['hostname']." if not yet enabled\n");
if (in_array($key, array('apache', 'mysql', 'nginx', 'proxmox'))) {
if (in_array($key, array('apache', 'mysql', 'nginx', 'proxmox', 'ceph', 'powerdns'))) {
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $key)) == '0') {
echo "Found new application '$key'\n";
dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key), 'applications');
dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key, 'app_status' => '', 'app_instance' => ''), 'applications');
}
}
}
@@ -123,7 +133,7 @@ if ($device['os_group'] == 'unix') {
foreach ($agent_data['app']['memcached'] as $memcached_host => $memcached_data) {
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'memcached', $memcached_host)) == '0') {
echo "Found new application 'Memcached' $memcached_host\n";
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_instance' => $memcached_host), 'applications');
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_status' => '', 'app_instance' => $memcached_host), 'applications');
}
}
}
@@ -137,7 +147,7 @@ if ($device['os_group'] == 'unix') {
$agent_data['app']['drbd'][$drbd_dev] = $drbd_data;
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'drbd', $drbd_dev)) == '0') {
echo "Found new application 'DRBd' $drbd_dev\n";
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_instance' => $drbd_dev), 'applications');
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_status' => '', 'app_instance' => $drbd_dev), 'applications');
}
}
}