From bc20b8d61ecb70960a56dd9702d3435043811b61 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Sun, 17 Mar 2024 13:29:41 -0400 Subject: [PATCH] Fixing issue #34 - poller_graphs.php returns no data * Multiple HMIB errors with Graphing function returning no data. * This is a second attempt to catch the second instance of errors. --- poller_graphs.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/poller_graphs.php b/poller_graphs.php index 8473351..6a48cc2 100644 --- a/poller_graphs.php +++ b/poller_graphs.php @@ -364,7 +364,25 @@ function add_summary_graphs($host_id, $host_template) { ' --graph-type=cg' . ' --host-id=' . $host_id; - print str_replace("\n", ' ', passthru($command)) . "\n"; + $output = array(); + $return_code = 0; + $timeout = 20; + + exec_with_timeout($command, $output, $return_code, $timeout); + + if ($return_code == 0) { + if (cacti_sizeof($output)) { + print implode(PHP_EOL, $output); + } else { + print 'Graph command completed sucessfully without returning any data.' . PHP_EOL; + } + } else { + print 'Graph command completed with errors.' . PHP_EOL; + + if (cacti_sizeof($output)) { + print implode(PHP_EOL, $output); + } + } } } }