statvfs

K

Korthrun

I'm writing some scripts to populate RRD's, mainly for practicing python.

As such I've decided to play with statvfs in order to build disk
graphs. Here is what I have and what I get. What I'm curious about
here is the meaning of the "L" charcter, as that fubars math.

###start code###

from os import statvfs, path
from statvfs import *

mps = [ '/', '/home', '/www', '/var', '/storage/backups',
'/storage/snd' ]

for fs in mps:
data = statvfs(fs)
print data

###end code, start output###
(4096, 4096, 4883593L, 4045793L, 4045793L, 0L, 0L, 0L, 1024, 255)
(4096, 4096, 1220889L, 1114718L, 1114718L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 19267346L, 18273138L, 18273138L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 3662687L, 3492397L, 3492397L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 3417702L, 2116063L, 2116063L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 25885944L, 21799115L, 21799115L, 0L, 0L, 0L, 0, 255)
###end output###

Ideally I'll just do some blocksize * number of blocks math to get
the % of used space. I know I could just .strip() the L, but I'd
to know what it means

Thanks,

Korth
 
M

Marc 'BlackJack' Rintsch

I'm writing some scripts to populate RRD's, mainly for practicing python.

As such I've decided to play with statvfs in order to build disk
graphs. Here is what I have and what I get. What I'm curious about
here is the meaning of the "L" charcter, as that fubars math.

The L means its a `long` literal, i.e. an integer value that can be
arbitrary big. Well its limited by memory of course.

And it doesn't "fubar" math, the L just shows up in the string
representation but you don't calculate with strings but numbers.
###start code###

from os import statvfs, path
from statvfs import *

mps = [ '/', '/home', '/www', '/var', '/storage/backups',
'/storage/snd' ]

for fs in mps:
data = statvfs(fs)
print data

###end code, start output###
(4096, 4096, 4883593L, 4045793L, 4045793L, 0L, 0L, 0L, 1024, 255)
(4096, 4096, 1220889L, 1114718L, 1114718L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 19267346L, 18273138L, 18273138L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 3662687L, 3492397L, 3492397L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 3417702L, 2116063L, 2116063L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 25885944L, 21799115L, 21799115L, 0L, 0L, 0L, 0, 255)
###end output###

Ideally I'll just do some blocksize * number of blocks math to get
the % of used space.

Just go ahead and do it:

In [185]: stat = os.statvfs('/')

In [186]: stat.f_bsize
Out[186]: 4096

In [187]: stat.f_blocks
Out[187]: 2622526L

In [188]: stat.f_bsize * stat.f_blocks
Out[188]: 10741866496L

Ciao,
Marc 'BlackJack' Rintsch
 
K

Korthrun

At 2007-10-29, (e-mail address removed) expressed thier undying love for me by saying:
I'm writing some scripts to populate RRD's, mainly for practicing python.

As such I've decided to play with statvfs in order to build disk
graphs. Here is what I have and what I get. What I'm curious about
here is the meaning of the "L" charcter, as that fubars math.

The L means its a `long` literal, i.e. an integer value that can be
arbitrary big. Well its limited by memory of course.

And it doesn't "fubar" math, the L just shows up in the string
representation but you don't calculate with strings but numbers.
###start code###

from os import statvfs, path
from statvfs import *

mps = [ '/', '/home', '/www', '/var', '/storage/backups',
'/storage/snd' ]

for fs in mps:
data = statvfs(fs)
print data

###end code, start output###
(4096, 4096, 4883593L, 4045793L, 4045793L, 0L, 0L, 0L, 1024, 255)
(4096, 4096, 1220889L, 1114718L, 1114718L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 19267346L, 18273138L, 18273138L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 3662687L, 3492397L, 3492397L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 3417702L, 2116063L, 2116063L, 0L, 0L, 0L, 0, 255)
(4096, 4096, 25885944L, 21799115L, 21799115L, 0L, 0L, 0L, 0, 255)
###end output###

Ideally I'll just do some blocksize * number of blocks math to get
the % of used space.

Just go ahead and do it:

In [185]: stat = os.statvfs('/')

In [186]: stat.f_bsize
Out[186]: 4096

In [187]: stat.f_blocks
Out[187]: 2622526L

In [188]: stat.f_bsize * stat.f_blocks
Out[188]: 10741866496L

Ciao,
Marc 'BlackJack' Rintsch
Thanks for the response, I'll have to play with it more, as I'm
obviously misunderstanding the error that I'm getting.
I didn't include the part of the script that did the math, as it
wasn't important to my base question.

I was getting TypeError: "sequence index must be integer", so I
thought the L was making python see it as a string.

Thanks for the insight

Josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top