Skip to content

Commit

Permalink
Resolving Issue #225
Browse files Browse the repository at this point in the history
  • Loading branch information
cigamit committed Jan 20, 2017
1 parent 4545aa8 commit 9b4e1c5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cmd_realtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
);

if (function_exists('proc_open')) {
$cactiphp = proc_open(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . '/script_server.php realtime', $cactides, $pipes);
$cactiphp = proc_open(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . '/script_server.php realtime ' . $poller_id, $cactides, $pipes);
$output = fgets($pipes[1], 1024);
$using_proc_function = true;
}else {
Expand All @@ -134,7 +134,7 @@

if ($col_poller_id > 1) {
$hostname = db_fetch_cell_prepared('SELECT hostname FROM poller WHERE id = ?', array($col_poller_id));
$output = file_get_contents(get_url_type() . '://' . $hostname . $config['url_path'] . '/remote_agent.php?action=polldata&host_id=' . $host_id . '&local_data_id=' . $local_data_id);
$output = file_get_contents(get_url_type() . '://' . $hostname . $config['url_path'] . '/remote_agent.php?action=polldata&host_id=' . $host_id . '&local_data_id=' . $data_source . '&poller_id=' . $poller_id);
}else{
switch ($item['action']) {
case POLLER_ACTION_SNMP: /* snmp */
Expand Down
12 changes: 11 additions & 1 deletion remote_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,25 @@ function ping_device() {
}

function poll_for_data() {
global $config;

$local_data_id = get_filter_request_var('local_data_id');
$host_id = get_filter_request_var('host_id');
$poller_id = get_nfilter_request_var('poller_id');

$item = db_fetch_row_prepared('SELECT *
FROM poller_item
WHERE host_id = ?
AND local_data_id = ?',
array($host_id, $local_data_id));

$script_server_calls = db_fetch_cell_prepared('SELECT COUNT(*)
FROM poller_item
WHERE host_id = ?
AND local_data_id = ?
AND action = 2',
array($host_id, $local_data_id));

if (sizeof($item)) {
switch ($item['action']) {
case POLLER_ACTION_SNMP: /* snmp */
Expand Down Expand Up @@ -320,7 +330,7 @@ function poll_for_data() {
);

if (function_exists('proc_open')) {
$cactiphp = proc_open(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . '/script_server.php realtime', $cactides, $pipes);
$cactiphp = proc_open(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . '/script_server.php realtime ' . $poller_id, $cactides, $pipes);
$output = fgets($pipes[1], 1024);
$using_proc_function = true;
}else {
Expand Down
2 changes: 1 addition & 1 deletion script_server.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function sig_handler($signo) {
}

/* signal for realtime */
global $environ;
global $environ, $poller_id;

/* record the script start time */
$start = microtime(true);
Expand Down
4 changes: 2 additions & 2 deletions scripts/ss_net_snmp_disk_bytes.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}

function ss_net_snmp_disk_bytes($host_id_or_hostname) {
global $environ, $config;
global $environ, $poller_id, $config;

if (!is_numeric($host_id_or_hostname)) {
$host_id = db_fetch_cell_prepared('SELECT id FROM host WHERE hostname = ?', array($host_id_or_hostname));
Expand All @@ -40,7 +40,7 @@ function ss_net_snmp_disk_bytes($host_id_or_hostname) {
$tmpfile = $host_id . '_bytes';
}else{
$tmpdir = $tmpdir . '/cacti/net-snmp-devio';
$tmpfile = $host_id . '_bytes_rt';
$tmpfile = $host_id . '_' . $poller_id . '_bytes_rt';
}

if (!is_dir($tmpdir)) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/ss_net_snmp_disk_io.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}

function ss_net_snmp_disk_io($host_id_or_hostname) {
global $environ, $config;
global $environ, $poller_id, $config;

if (!is_numeric($host_id_or_hostname)) {
$host_id = db_fetch_cell_prepared('SELECT id FROM host WHERE hostname = ?', array($host_id_or_hostname));
Expand All @@ -40,7 +40,7 @@ function ss_net_snmp_disk_io($host_id_or_hostname) {
$tmpfile = $host_id . '_io';
}else{
$tmpdir = $tmpdir . '/cacti/net-snmp-devio';
$tmpfile = $host_id . '_io_rt';
$tmpfile = $host_id . '_' . $poller_id . '_io_rt';
}

if (!is_dir($tmpdir)) {
Expand Down

0 comments on commit 9b4e1c5

Please sign in to comment.