Working on PostgreSQL script.

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

Moderators: Developers, Moderators

Post Reply

I use PostgreSQL!

Yes
14
61%
No
9
39%
 
Total votes: 23

miah
Posts: 6
Joined: Wed Mar 26, 2003 6:14 pm
Location: Arvada CO
Contact:

Working on PostgreSQL script.

Post by miah »

I'm am working on a script that will be a data input source for Postgres that will work identically to the MySQL input source (scripts/sql.php).

This is the code that I have so far. It outputs the number of questions on the database server since the last restart.

Code: Select all

<?php
require_once 'DB.php';

$user = 'mylimiteduser';
$pass = 'XXXXXX';
$host = 'myhost';
$db_name = 'template1';

$dsn = "pgsql://$user:$pass@$host/$db_name";

$db = DB::connect($dsn, true);

$sql = "select sum(xact_commit) as total from pg_stat_database;";
$result = $db->query($sql);

$row = $result->fetchRow(DB_FETCHMODE_ASSOC);

print trim( $row['total']);

$db->disconnect();
?>
So far, so good. I have this being run in the cron script just fine. I also have it thrusting data into an RRD. I copied the data sources configuration verbatim from the default MySQL setup. Now for the problem.

I have a graph setup (it, oddly enough, also looks like the MySQL one) that is generating pretty pictures but not quite what I had imagined. On the MySQL graph the vertical numbers are in the form of 1.0-4.0 (I have very little running on this server yet) and the GPRINTs on the bottom of the graph are also in the x.xx floating point form.

On my Postgres graph I have numbers in the form like '240 m' and this continues with smaller numbers on the GPRINTs. I am also getting 'nan' strings on the monthly and yearly graphs.

All of the configurations are identical. What could cause the graphs to have a wild dispertion of output like this?

I hope someone enjoys the Postgres script I made as well. That SQL was tough to figure out (I'm a SQL n00b).
miah
Posts: 6
Joined: Wed Mar 26, 2003 6:14 pm
Location: Arvada CO
Contact:

Also...

Post by miah »

I also get the '100 m' phenomenon on my Load Avg graph (this is also a default graph). Is this a bug or a misconfiguration?
User avatar
bulek
Cacti Pro User
Posts: 854
Joined: Mon May 20, 2002 2:07 am
Location: Poland
Contact:

Post by bulek »

There are two most common mistakes that results with graphs presenting lower values than expected.

1. Data source type set to something else than GAUGE when measuring oscilating values. Any other type measures change rate - this means that difference between current and previous value is divided by 300 (if your have 5 min polling time).

2. Default cacti settings for data source include maximum value set to 1. If you don't change the value then only values less than 1 will be stored into rrd file.

Monthly and yearly graphs use 2-hours and 1-day samples respectively. This means they may report NaN even one day after data source creation.

- bulek
miah
Posts: 6
Joined: Wed Mar 26, 2003 6:14 pm
Location: Arvada CO
Contact:

Post by miah »

bulek wrote:1. Data source type set to something else than GAUGE when measuring oscilating values. Any other type measures change rate - this means that difference between current and previous value is divided by 300 (if your have 5 min polling time).
Well, this is supposed to be just like the mysql graph. I even made sure that I was getting cumulative totals on the queries. When mysqladmin reports the stats back it reports back questions. On my server with cacti running against it this number got to 32k very fast. And, as I would run the data collection command manually the number just went up sequentially. So, I made a script to do this with postgres. It also just had a number that is the total number of questions since the last server restart. There should be no difference and they should graph the same.
bulek wrote:2. Default cacti settings for data source include maximum value set to 1. If you don't change the value then only values less than 1 will be stored into rrd file.
Check. I caught this one on a few of the other graphs. Man, is stuff named oddly until you start to "grok" what it means. I guess these are just oddities of RRDTooll. This didn't seem to be affecting they MySQL graph which when I last checked it was getting values back in the 40,000 range when the max was still set at 5,000. Odd.
bulek wrote:Monthly and yearly graphs use 2-hours and 1-day samples respectively. This means they may report NaN even one day after data source creation.
This is the only one that makes sense. If there is not enough data for it to display then it cannot display it eh? :)

But, this still didn't answer my question of why I get an 'm' after the vertical bar numbers on my graph. I did get this fixed on my load graph by setting it to '1' instead of '3'. This trick "worked" on the postgres graph concerning that it then told me that I I was doing "0.2 m" instead of "200 m". I can post these graphs somewhere so you can see them. I don't know how else I would explain them.

Where can I find out more information about the "Unit Exponent Value" that the oh-so-detailed documentation for cacti fails the mention at all?
User avatar
bulek
Cacti Pro User
Posts: 854
Joined: Mon May 20, 2002 2:07 am
Location: Poland
Contact:

Post by bulek »

Ok, you are getting cumulative values (I assume data source is set to COUNTER). Maybe I should ask this question at first. On the graph there is value 200 m which means 0.2 requests per second means a bit more than 60 requests per 5 min. Do you expect more?

- bulek
gondo
Posts: 25
Joined: Tue Oct 19, 2004 12:05 pm
Location: Oxford, OH

Postgres support

Post by gondo »

Cast vote, realized this was an old thread.
Did anything else come of this idea?
Thanks
spirit
Posts: 4
Joined: Tue Mar 29, 2005 4:05 am

Post by spirit »

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests