Multiple Issues - Graphing and Database Issues

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
bmallett
Posts: 5
Joined: Mon Dec 14, 2020 3:19 pm

Multiple Issues - Graphing and Database Issues

Post by bmallett »

I've searched through the docs and forums trying a few of the similar issues' solutions, but none have helped thus far.

I am running:
- Cacti v1.2.16
- Ubuntu 20.04.1 LTS

One of the issues is as follows... Database connectivity.

FATAL: Connection to Cacti database failed. Please ensure:

the PHP MySQL module is installed and enabled.
the database is running.
the credentials in config.php are valid.

I have checked and everything seems to be correct. I was logged in yesterday and when I came in this morning, I get this.
User avatar
macan
Cacti Guru User
Posts: 1106
Joined: Tue Mar 18, 2008 2:30 am
Location: Czech

Re: Multiple Issues - Graphing and Database Issues

Post by macan »

1) is database running?
2) try to connect via mysql client: mysql -h database_ip -u cactiuser -p cactipassword (use credentials from config.php)
3) try to check and repair database: mysqlcheck -u root -p --auto-repair --check --all-databases
Let the Cacti grow!
bmallett
Posts: 5
Joined: Mon Dec 14, 2020 3:19 pm

Re: Multiple Issues - Graphing and Database Issues

Post by bmallett »

macan wrote: Wed Dec 16, 2020 1:41 am 1) is database running?
2) try to connect via mysql client: mysql -h database_ip -u cactiuser -p cactipassword (use credentials from config.php)
3) try to check and repair database: mysqlcheck -u root -p --auto-repair --check --all-databases
1) Database is running.
2) Connected fine
  • Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 438
    Server version: 8.0.22-0ubuntu0.20.04.3 (Ubuntu)

    Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
3) Ran your check and repair and all came back as 'OK'

:cry:
Last edited by bmallett on Wed Dec 16, 2020 12:29 pm, edited 1 time in total.
User avatar
macan
Cacti Guru User
Posts: 1106
Joined: Tue Mar 18, 2008 2:30 am
Location: Czech

Re: Multiple Issues - Graphing and Database Issues

Post by macan »

Try mysql connect from php:
<?php
$servername = "localhost";
$username = "username";
$password = "password";

try {
$conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
?>

Sorry, I posted wrong code before
<?php
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");

if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}

echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;

mysqli_close($link);
?>
Last edited by macan on Wed Dec 16, 2020 12:38 pm, edited 1 time in total.
Let the Cacti grow!
bmallett
Posts: 5
Joined: Mon Dec 14, 2020 3:19 pm

Re: Multiple Issues - Graphing and Database Issues

Post by bmallett »

Success: A proper connection to MySQL was made! The `cactidb` database is great. Host information: 127.0.0.1 via TCP/IP
bmallett
Posts: 5
Joined: Mon Dec 14, 2020 3:19 pm

Re: Multiple Issues - Graphing and Database Issues

Post by bmallett »

OK, I found the issue. I was modifying the config.php in the /opt/cacti/ folder. I still had an older password in /var/www/html/cacti/ folder.

That solved the connectivity issue. :oops:

(Sorry)

The other is the issue of all graphs showing an image with "The Cacti Poller has not run yet."

I can view live stats but nothing populates automatically when I go to view graphs.
User avatar
macan
Cacti Guru User
Posts: 1106
Joined: Tue Mar 18, 2008 2:30 am
Location: Czech

Re: Multiple Issues - Graphing and Database Issues

Post by macan »

It could be problem with paths. Where are your rra files stored?
Management -> graphs -> choose any and turn debug on. You will see something like this in debug:
DEF:a='/var/db/cacti/rra/a-grafika_-_bsd_ps_l_3444.rrd':'ps_total':AVERAGE \
DEF:b='/var/db/cacti/rra/a-grafika_-_bsd_ps_l_3444.rrd':'ps_d':AVERAGE \
Let the Cacti grow!
bmallett
Posts: 5
Joined: Mon Dec 14, 2020 3:19 pm

Re: Multiple Issues - Graphing and Database Issues

Post by bmallett »

It looks like I need to find where the path is being called for the poller cron jobs. Currently it is referencing /opt/cacti/rra/local_linux_machine_load_1min_2.rrd'

I need to change the path to /var/html/...

Where is that setting at?
User avatar
macan
Cacti Guru User
Posts: 1106
Joined: Tue Mar 18, 2008 2:30 am
Location: Czech

Re: Multiple Issues - Graphing and Database Issues

Post by macan »

more options:
1) use symlink
2) move files to the right location
3) sql command update :
UPDATE poller_item SET rrd_path=\
REPLACE(rrd_path,'/opt/cacti/rra','/var/html..../cacti/rra') \
WHERE rrd_path REGEXP '^/opt/cacti/rra';
insert wrong path in SQL query! I don't know your real /var/html.... path
Let the Cacti grow!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests