[users at i-scream] Cannot read file system stats

Jens Rehsack sno at NetBSD.org
Tue Feb 5 12:25:27 GMT 2013


On 05.02.13 12:33, Patrick Nowak wrote:
> Hello,
>
> I am currently trying to use libstatgrab to read certain system
> information. Reading CPU and RAM info worked perfectly. But when I try
> to read file system stats using sg_get_fs_stats() I don't get any
> information. The integer passed to this function returns zero, meaning
> no array was created.
>
> My code:
>
> #include <iostream>
> #include <cstlib>
>
> #include <statgrab>
>
> int main(void) {
>      int mounted_fs;
>
>      sg_fs_stats *hd_stats = sg_get_fs_stats(&mounted_fs);
>
>      std::cout << "Number of mounted file systems: " << mounted_fs <<
> std::endl << std::endl;
>
>      for (int i = 0; i < mounted_fs; i++) {
>          std::cout << "Mount point: " << hd_stats->mnt_point << std::endl;
>          std::cout << "Bytes total: " << hd_stats->size << std::endl;
>          std::cout << "Bytes used: " << hd_stats->used << std::endl;
>          std::cout << "Bytes free: " << hd_stats->avail << std::endl <<
> std::endl;
>
>          hd_stats++;
>      }
> }
>
> I am using libstatgrab6, version 0.17-0ubuntu1 on an Ubuntu 12.04.
>
> I hope somebody can point out my error.
Hi Patrick,

can you try to use the version from 
http://www.netbsd.org/~sno/smart-snmpd/libstatgrab-0.17.20120906.01.tar.gz 
(or the github repo tdb created: https://github.com/tdb/libstatgrab) and 
report whether that works or not?

Thanks in advance,
Jens
-- 
Jens Rehsack
pkgsrc, Perl5




More information about the users mailing list