Cacti / plugin_flowview

FlowView Plugin for Cacti
GNU General Public License v2.0
18 stars 10 forks source link

There are some issues. #115

Closed cheerfultime closed 3 weeks ago

cheerfultime commented 1 month ago

Hi,

There are some issues.

AlmaLinux release 9.4 + cacti + flowview(3.3 latest develop from github on Jun 5) Ubuntu 22.04 + cacti + flowview(3.3 latest develop from github on Jun 5)

  1. After "systemctl start flow-capture", there are error messages in cacti.log. PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function flowview_db_close(), 0 passed in /usr/share/cacti/plugins/flowview/flow_collector.php on line 745 and exactly 1 expected in /usr/share/cacti/plugins/flowview/database.php:54 Stack trace:

    0 /usr/share/cacti/plugins/flowview/flow_collector.php(745): flowview_db_close()

    1 /usr/share/cacti/plugins/flowview/flow_collector.php(686): database_check_connect()

    2 {main}

    thrown in /usr/share/cacti/plugins/flowview/database.php on line 54

In flow_collector.php(745) I changed "flowview_db_close();" to "flowview_db_close($config);"(I guess so.), then started successfully.

  1. Then, there are another error messages in cacti.log.

2024-06-05 11:01:06 - CMDPHP ERROR: A DB Row Failed!, Error: Table 'cacti.plugin_flowview_dnscache' doesn't exist 2024-06-05 11:01:06 - CMDPHP SQL Backtrace: (/plugins/flowview/flow_collector.php[693]:process_fv9(), /plugins/flowview/flow_collector.php[1131]:process_v9_v10(), /plugins/flowview/flow_collector.php[1545]:flowview_get_dns_from_ip(), /plugins/flowview/functions.php[3273]:flowview_db_fetch_row_prepared(), /plugins/flowview/database.php[140]:db_fetch_row_prepared(), /lib/database.php[643]:db_execute_prepared()) 2024-06-05 11:01:06 - CMDPHP ERROR: A DB Exec Failed!, Error: Table 'cacti.plugin_flowview_dnscache' doesn't exist 2024-06-05 11:01:06 - CMDPHP SQL Backtrace: (/plugins/flowview/flow_collector.php[693]:process_fv9(), /plugins/flowview/flow_collector.php[1131]:process_v9_v10(), /plugins/flowview/flow_collector.php[1545]:flowview_get_dns_from_ip(), /plugins/flowview/functions.php[3472]:flowview_db_execute_prepared(), /plugins/flowview/database.php[82]:db_execute_prepared())

In the past few days, the newly installed cacti and flowview did not automatically generate the 'cacti.plugin_flowview_dnscache' table. I successfully created 'cacti.plugin_flowview_dnscache' by referring to 'plugins/flowview/setup.php'.

  1. Then, after "systemctl start flow-capture", there are another error messages in "/var/log/messages"(AlmaLinux) or "/var/log/syslog"(Ubuntu). Jun 5 13:59:04 cacti systemd[1]: flow-capture.service: Scheduled restart job, restart counter is at 6024. Jun 5 13:59:04 cacti systemd[1]: Stopped Flow Capture Service for Cacti. Jun 5 13:59:04 cacti systemd[1]: Starting Flow Capture Service for Cacti... Jun 5 13:59:04 cacti php[157102]: NOTE: Starting Flow Collection Jun 5 13:59:04 cacti php[157102]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=1' Jun 5 13:59:04 cacti systemd[1]: Started Flow Capture Service for Cacti. Jun 5 13:59:04 cacti systemd[1]: flow-capture.service: Main process exited, code=exited, status=255/EXCEPTION Jun 5 13:59:04 cacti systemd[1]: flow-capture.service: Failed with result 'exit-code'.

I don't know how to solve this problem.

But in AlmaLinux "php /usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=1 --debug" is OK! In Ubuntu "sudo php /var/www/html/cacti/plugins/flowview/flow_collector.php" --listener-id=1 --debug is OK!

Thanks.

TheWitness commented 1 month ago

Okay cool. Will do a new install test and fix those other minor issues.

arno-st commented 1 month ago

I have this one: After having clone the dev code, and configure my cacti_base, the system won't start, either way via systemctl, or in CLI. The flow_capture suppose to start, but then it's not visible, or just die, no error anywhere.

[root@lslcact03 service]# php flow-capture start NOTE: Starting Flow Collection NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=2' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=5' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=8' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=11' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=14' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=17' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=20' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=23' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=26' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=29' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=32' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=35' NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugins/flowview/flow_collector.php --listener-id=38' [root@lslcact03 service]# ps -ef | grep flow root 1841284 707833 0 13:41 pts/1 00:00:00 grep --color=auto flow

And on systemctl: [root@lslcact03 service]# systemctl status flow-capture ● flow-capture.service - Flow Capture Service for Cacti Loaded: loaded (/etc/systemd/system/flow-capture.service; enabled; vendor preset: disabled) Active: activating (start) since Wed 2024-06-05 13:50:42 CEST; 2ms ago Cntrl PID: 1944279 (php) Tasks: 0 (limit: 1646297) Memory: 0B CGroup: /system.slice/flow-capture.service └─1944279 /usr/bin/php -q /usr/share/cacti/plugins/flowview/service/flow-capture --systemd

Jun 05 13:50:42 lslcact03.lausanne.ch systemd[1]: Starting Flow Capture Service for Cacti...

TheWitness commented 1 month ago

Any errors in the Cacti log?

TheWitness commented 1 month ago

Is the plugin enabled?

TheWitness commented 1 month ago

Do another pull and update, make sure the plugin is enabled.

arno-st commented 1 month ago

Pull done again nothing inside cacti log, nor cacti_stderr.log and journalctl -xe displayd that: [root@lslcact03 service]# journalctl -xe -- The start-up result is done. Jun 05 17:45:02 lslcact03.lausanne.ch systemd[1]: Started Session 131761 of user apache. -- Subject: Unit session-131761.scope has finished start-up -- Defined-By: systemd -- Support: https://access.redhat.com/support -- -- Unit session-131761.scope has finished starting up. -- -- The start-up result is done. Jun 05 17:45:02 lslcact03.lausanne.ch CROND[3054932]: (apache) CMD ( /usr/bin/php /usr/share/cacti/poller.php > /d> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Starting Flow Collection Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch php[3054919]: NOTE: Launching cacti-flow-capture as '/usr/share/cacti/plugin> Jun 05 17:45:02 lslcact03.lausanne.ch systemd[1]: Started Flow Capture Service for Cacti. -- Subject: Unit flow-capture.service has finished start-up -- Defined-By: systemd -- Support: https://access.redhat.com/support -- -- Unit flow-capture.service has finished starting up. -- -- The start-up result is done. Jun 05 17:45:02 lslcact03.lausanne.ch systemd[1]: flow-capture.service: Succeeded. -- Subject: Unit succeeded -- Defined-By: systemd -- Support: https://access.redhat.com/support -- -- The unit flow-capture.service has successfully entered the 'dead' state.

TheWitness commented 1 month ago

Run one of those commands by hand using the --debug option...

TheWitness commented 1 month ago

also run the following:

systemctl status -l flow-capture

TheWitness commented 1 month ago

Do a fresh pull.

cheerfultime commented 1 month ago

Do a fresh pull.

Thank you very much for fixing the bug. After git pull, there is no error message and it's ok now.

Thanks.

arno-st commented 1 month ago

So I did a fresh pull Now the flow-capture start and I can see all ma listener.

But (sorry) I get this error: 06/06/2024 06:34:56 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/flowview/flow_collector.php[711]:CactiErrorHandler())

06/06/2024 06:34:56 - ERROR PHP WARNING in Plugin 'flowview': Undefined array key "10.253.238.25:55791" in file: /usr/share/cacti/plugins/flowview/flow_collector.php on line: 711

And I don't see my inbound traffic, on the Console -> Flowview -> Listener

TheWitness commented 4 weeks ago

This should be resolved now. Please continue to test.

arno-st commented 4 weeks ago

So I don't have those error, but still 2 are coming:

07/06/2024 06:34:28 - CMDPHP SQL Backtrace: (/plugins/flowview/flow_collector.php[689]:process_fv5(), /plugins/flowview/flow_collector.php[804]:flowview_get_dns_from_ip(), /plugins/flowview/functions.php[3438]:flowview_db_execute_prepared(), /plugins/flowview/database.php[82]:db_execute_prepared())
07/06/2024 06:34:28 - CMDPHP ERROR: A DB Exec Failed!, Error: Duplicate entry '224.0.0.5' for key 'PRIMARY'
07/06/2024 06:34:27 - CMDPHP SQL Backtrace: (/plugins/flowview/flow_collector.php[689]:process_fv5(), /plugins/flowview/flow_collector.php[804]:flowview_get_dns_from_ip(), /plugins/flowview/functions.php[3438]:flowview_db_execute_prepared(), /plugins/flowview/database.php[82]:db_execute_prepared())
07/06/2024 06:34:27 - CMDPHP ERROR: A DB Exec Failed!, Error: Duplicate entry '10.35.106.144' for key 'PRIMARY' 

And the second one is a call to a 'db_fetch_assoc_prepared' instead of flowview_db_fetch_assoc_prepared

07/06/2024 06:31:39 - CMDPHP SQL Backtrace: (/plugins/flowview/flowview_devices.php[84]:edit_devices(), /plugins/flowview/flowview_devices.php[242]:db_fetch_assoc_prepared(), /lib/database.php[727]:db_execute_prepared())
07/06/2024 06:31:39 - CMDPHP ERROR: A DB Row Failed!, Error: Table 'cacti_test.plugin_flowview_device_streams' doesn't exist
07/06/2024 06:31:34 - CMDPHP SQL Backtrace: (/plugins/flowview/flowview_devices.php[84]:edit_devices(), /plugins/flowview/flowview_devices.php[242]:db_fetch_assoc_prepared(), /lib/database.php[727]:db_execute_prepared())
07/06/2024 06:31:34 - CMDPHP ERROR: A DB Row Failed!, Error: Table 'cacti_test.plugin_flowview_device_streams' doesn't exist 
arno-st commented 4 weeks ago

And one more, still a call to the wrong db_fetch_assoc_prepared:

07/06/2024  06:43:25 - CMDPHP PHP ERROR WARNING Backtrace:   (/plugins/flowview/flowview_devices.php[84]:edit_devices(),  /plugins/flowview/flowview_devices.php[321]:CactiErrorHandler())
--
07/06/2024 06:43:25 - ERROR PHP WARNING in  Plugin 'flowview':  foreach() argument must be of type array\|object, bool given in file:  /usr/share/cacti/plugins/flowview/flowview_devices.php  on line: 321
07/06/2024 06:43:25 - CMDPHP SQL Backtrace:   (/plugins/flowview/flowview_devices.php[84]:edit_devices(),  /plugins/flowview/flowview_devices.php[300]:db_fetch_assoc_prepared(),  /lib/database.php[727]:db_execute_prepared())
07/06/2024 06:43:25 - CMDPHP ERROR: A DB Row Failed!, Error: Table  'cacti_test.plugin_flowview_device_templates' doesn't exist
TheWitness commented 4 weeks ago

I keep forgetting to use the flow view database calls.

TheWitness commented 4 weeks ago

@arno-st, send your contact details to my email: thewitness at cacti dot net. Do you use slack?

arno-st commented 4 weeks ago

I saw you get my contact info No I don't use slack, but I'm gonna look into it for the free version, I hope it's enough. You will see me when it's done

TheWitness commented 4 weeks ago

@arno-st, I've done another update. Please keep testing.

arno-st commented 3 weeks ago

So access is ok, but I have some weird stuff going on.

I have 3 listeners, each with 1 host sending data. flowview listener

I can see the data inside the DB.

on 1 of them I can see the Inbound Streams and Status is active, flowview listener detail UP

On the 2 other inbound stream are down (but data are coming). flowview listener detail

As for template, even if the Inbound streams display 2 templates, I have nothing. flowview template

TheWitness commented 3 weeks ago

Is everything v9 or IPFIX?

arno-st commented 3 weeks ago

Actually it's v5, I can switch V9 to test it

arno-st commented 3 weeks ago

Hmm ok so V9 I have some template, I'm gona push it to all my 3 devices to see how it's going on

arno-st commented 3 weeks ago

Isn't the listener suppose to accept the flow from multiple device on 1 listener, or is still in development ? I try to have 2 devices to use the same listener. but only one is showing up

TheWitness commented 3 weeks ago

Yes, but there could be bugs...

I'll have more dev time starting on Wednesday. @xmacan is on vacation, so we are short a dev right now too.

I've already a few things queued up around listeners that I'll be rolling out this week.

It's going to be a few more weeks before this release is ready to go.

TheWitness commented 3 weeks ago

Good to know they are V5. This is currently a gap that I'll close in the next point release.

arno-st commented 3 weeks ago

Ok For now on I switch my 3 devices to V9, I have other I can add to V5, but I will see later.

One other thing, I change a config on the fly of one of my device. The source ip of the flow, was it's default interface, so I change to make it from a administrative Loopback. And on the same time I switch to a listener just for him.

No that much luck. now the listener B35, is updated on a regular basis OK flowview listener B35

but the IP I can see is wrong, and that's why is down, so far so good, but no trace of the new IP flowview listener detail B35

But I do have a template with the new IP address: flowview template B35

TheWitness commented 3 weeks ago

I have to trim off the port numbers in the database. So, I added a script called flowview_upgrade.php over the weekend. You will need to run it by hand. It has a --forcever option like Cacti. You will need to run it using 3.3 with my next commit.

arno-st commented 3 weeks ago

Ok process is running, it's gona take a long long time ! My table are quit large.

And one mistake: 12/06/2024 08:31:51 - FLOWVIEW Upgrading from v3.3 to 3.4 PHP Warning: Undefined variable $flowviewdb_default in /usr/share/cacti/plugins/flowview/flowview_upgrade.php on line 142

You can remove the $flowviewdb_default on this command, using flowview_db_execute take care of the right database.

TheWitness commented 3 weeks ago

Oh, it was not declared global.

TheWitness commented 3 weeks ago

I have not really started the next update. I was just doing unit testing of the install process and noted the tables were not being created.

On a separate note, I was going to tinker with MariaDB ColumnStore, and found it does not support varbin() columns. 😫

Back to Parallel Union Query designs.

arno-st commented 3 weeks ago

Hmm the script toke me something like 2hours to finish! And during this time Nothing else was working on cacti !!

arno-st commented 3 weeks ago

Hmm another one 12/06/2024 16:49:34 - CMDPHP PHP ERROR Backtrace: (/plugins/flowview/flow_collector.php[693]:process_fv9(), /plugins/flowview/flow_collector.php[1131]:process_v9_v10(), /plugins/flowview/flow_collector.php[1548]:flowview_get_dns_from_ip(), /plugins/flowview/functions.php[3723]:str_replace(), CactiErrorHandler()) 12/06/2024 16:49:34 - ERROR PHP DEPRECATED in Plugin 'flowview': str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in file: /usr/share/cacti/plugins/flowview/functions.php on line: 3723

I think it's the place where you declare the $host (line 3564), that is outside the view at line 3723. Just my 2 cents

TheWitness commented 3 weeks ago

Yea this will be fixed shortly. Going to close this one as it's turning into a catch all for bugs.