wrong disk used/available values on Freebsd

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

Moderators: Developers, Moderators

Post Reply
c0balT

wrong disk used/available values on Freebsd

Post by c0balT »

Hi, I use 0.8.3a and i succesfully installed cacti but, displayed values for Disk Space are wrong, I mean values are dubled (*2).
I got a 2793 mb partition and displayed value is 5.39 G.
What's wrong?
whereis the error?

Thank you,
C0balT
prwood
Posts: 5
Joined: Tue Sep 30, 2003 8:14 pm
Contact:

Me Too

Post by prwood »

I am having the same problem on my Mac OS X system (which is based on FreeBSD). All of the disk space values are doubled.

Anyone know why this might happen?

p.s. I am using Mac OS X 10.2.6 (Darwin Kernel 6.6), and Cacti 0.8.3. If I do a df, here are the values returned:

Code: Select all

[Sawtooth:~] prw% df
Filesystem              512-blocks     Used    Avail Capacity  Mounted on
/dev/disk1s9             160821344 22094424 138214912    13%    /
devfs                          196      196        0   100%    /dev
fdesc                            2        2        0   100%    /dev
<volfs>                       1024     1024        0   100%    /.vol
automount -fstab [347]           0        0        0   100%    /Network/Servers
automount -static [347]          0        0        0   100%    /automount
/dev/disk0s9              20007312  2424312 17583000    12%    /Volumes/Scratch
prwood
Posts: 5
Joined: Tue Sep 30, 2003 8:14 pm
Contact:

Post by prwood »

Ok, I think I figured it out.

The script that obtains this information is:

(cacti home)/scripts/query_unix_partition.pl

This script uses "df" to gather the info. On my system, running "df" with no arguments returns the number of 512-byte blocks. Logically, I have twice as many 512-byte blocks as I do 1024-byte blocks. So it would look like I have twice as much disk space available. So I changed the "df" command in the script to use "df -k". It now reports the correct figures, and cacti shows the correct numbers.

I should note that the graph itself did show the correct relative measurements... it's just the numbers under the graph that read the wrong number of GB.
tss
Posts: 2
Joined: Sat Aug 21, 2004 12:08 pm

Disk Space values are still doubled! Cacti 0.8.5a FreeBSD5.2

Post by tss »

It makes me crazy!! I'm trying to resolve this for over 8 hours now... All reported disk space values are doubled (x2). For example: The free space is 900MB on a partition, but it is reported as 1800MB (1.8GB). It just doesn't make sense!!

The df command IS reporting the number of 1K blocks, see:

command: perl /usr/local/share/cacti/scripts/query_unix_partitions.pl get available /dev/ad0s1d, output: 890930
command: perl /usr/local/share/cacti/scripts/query_unix_partitions.pl get used /dev/ad0s1d, output: 41008
command: perl /usr/local/share/cacti/scripts/query_unix_partitions.pl get available /dev/ad0s1e, output: 905006
command: perl /usr/local/share/cacti/scripts/query_unix_partitions.pl get used /dev/ad0s1e, output: 26932
command: perl /usr/local/share/cacti/scripts/query_unix_partitions.pl get available /dev/ad0s1f, output: 61276996
command: perl /usr/local/share/cacti/scripts/query_unix_partitions.pl get used /dev/ad0s1f, output: 4432730
command: perl /usr/local/share/cacti/scripts/query_unix_partitions.pl get available /dev/ad0s1a, output: 884958
command: perl /usr/local/share/cacti/scripts/query_unix_partitions.pl get used /dev/ad0s1a, output: 46980

And cacti IS storing the right values into the RRD database:

update /usr/local/share/cacti/rra/localhost_hdd_free_56.rrd --template hdd_free:hdd_used N:890930:41008
update /usr/local/share/cacti/rra/localhost_hdd_free_57.rrd --template hdd_free:hdd_used N:905006:26932
update /usr/local/share/cacti/rra/localhost_hdd_free_58.rrd --template hdd_free:hdd_used N:61276996:4432730
update /usr/local/share/cacti/rra/localhost_hdd_free_55.rrd --template hdd_free:hdd_used N:884958:46980

These are the right values!! But on the graph, everything is doubled!!

In the graph template used ("Unix Available Disk Space"), the Base Value is set to 1024. I even double checked it in the MySQL database, it IS set to 1024.

So I have no idea why this is happening... I spent the last 8 hours trying to figure it out to no avail...

Any suggestion would be highly appreciated!!
tss
Posts: 2
Joined: Sat Aug 21, 2004 12:08 pm

I got it solved...

Post by tss »

Damn! When I run the update command manually as root from the command prompt:

# /usr/local/bin/php /usr/local/share/cacti/cmd.php

It indeed reported the free space in 1K blocks. But the next time it ran from the cron job, 'df' reported the figures in 512 byte blocks!! Because under FreeBSD the 'df' command reports differently - depending on the "BLOCKSIZE specification from the environment"!!

So the BLOCKSIZE was set to 1024 when I was logged in as root in my environment. But for the cronjob it was either not set and defaulted to 512 or it was set to 512... So changing the line

open(DF, "/bin/df|");

to

open(DF, "/bin/df -k|");

in the file scripts/query_unix_partitions.pl indeed fixed the problem!!

I can't believe it took me this long to understand what's happening... Just because in my environment (when I was testing the scripts) the BLOCKSIZE was already set to 1024... Unfortunately this did not hold for for cronjob...
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests