Skip to content

Commit

Permalink
Resolving Issue #31
Browse files Browse the repository at this point in the history
In systemctl status : CMDPHP: ERROR: A DB Exec Failed!, Error: Unknown column 'INF' in 'field list'
  • Loading branch information
cigamit committed Jan 30, 2020
1 parent aabe379 commit a6ebf4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
16 changes: 10 additions & 6 deletions flow_collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ function process_fv5($p, $peer) {
$src_rport = flowview_translate_port($data['src_port'], false, false);
$dst_rport = flowview_translate_port($data['dst_port'], false, false);

$pps = round($data['dOctets'] / $data['dPkts'], 3);
if ($data['dPkts'] > 0) {
$pps = round($data['dOctets'] / $data['dPkts'], 3);
} else {
$pps = 0;
}

$sql[] = '(' .
$listener_id . ', ' .
Expand Down Expand Up @@ -434,7 +438,7 @@ function process_fv5($p, $peer) {
$data['flags'] . ')';
}

if (sizeof($sql)) {
if (cacti_sizeof($sql)) {
debug('Flow: Writing Records: ' . sizeof($sql));
db_execute($sql_prefix . implode(' ,', $sql));
}
Expand Down Expand Up @@ -554,7 +558,7 @@ function process_fv9($p, $peer) {

// Flow Data Set
if ($fsid > 255) {
if (sizeof($templates[$peer])) {
if (cacti_sizeof($templates[$peer])) {
debug('Flow: Data Found, Processing');
} else {
debug('Flow: Data Found, Awaiting Templates');
Expand Down Expand Up @@ -641,7 +645,7 @@ function process_fv9($p, $peer) {
$j++;
}

if (sizeof($sql)) {
if (cacti_sizeof($sql)) {
debug('Flow: Writing Records: ' . sizeof($sql));
db_execute($sql_prefix . implode(', ', $sql));
}
Expand Down Expand Up @@ -761,7 +765,7 @@ function process_fv10($p, $peer) {

// Data Set
if ($fsid > 255) {
if (sizeof($templates[$peer])) {
if (cacti_sizeof($templates[$peer])) {
debug('Flow: Data Found, Processing');
} else {
debug('Flow: Data Found, Awaiting Templates');
Expand Down Expand Up @@ -828,7 +832,7 @@ function process_fv10($p, $peer) {
}
}

if (sizeof($sql)) {
if (cacti_sizeof($sql)) {
debug('Flow: Writing Records: ' . sizeof($sql));
db_execute($sql_prefix . implode(', ', $sql));
}
Expand Down
10 changes: 2 additions & 8 deletions service/flow-capture
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ $cacti_base = '/var/www/html/cacti';
include_once($cacti_base . '/include/cli_check.php');
include_once($cacti_base . '/lib/poller.php');

$tools_path = read_config_option('path_flowtools');

$shortopts = 'VvHh';
$longopts = array(
'systemd',
Expand Down Expand Up @@ -43,17 +41,14 @@ if (isset($options['systemd'])) {
}

function start() {
global $tools_path, $cacti_base, $systemd;
global $cacti_base, $systemd;

print 'NOTE: Starting Flow Collection' . PHP_EOL;

$devices = db_fetch_assoc('SELECT * FROM plugin_flowview_devices');
$legacy = db_fetch_cell('SELECT COUNT(*) FROM plugin_flowview_devices WHERE cmethod = 1');

if (!empty($devices)) {
/* removing trailing slash and anything else */
$path = rtrim($path, "/ \n\t");

foreach ($devices as $device) {
$php_binary = read_config_option('path_php_binary');
print "NOTE: Launching cacti-flow-capture as '" . $cacti_base . '/plugins/flowview/flow_collector.php --listener-id=' . $device['id'] . "'" . PHP_EOL;
Expand All @@ -70,15 +65,14 @@ function start() {
}

function stop() {
global $tools_path, $cacti_base;
global $cacti_base;

print 'NOTE: Stopping Flow Collection' . PHP_EOL;

$devices = db_fetch_assoc('SELECT * FROM plugin_flowview_devices');
$php_binary = read_config_option('path_php_binary');

if (sizeof($devices)) {
shell_exec('killall --quiet ' . $tools_path . '/flow-capture');
shell_exec('killall --quiet ' . $php_binary . ' -q ' . $cacti_base . '/plugins/flowview/flow_collector.php');
}
}
Expand Down

0 comments on commit a6ebf4a

Please sign in to comment.