Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement gldf, gldu #32

Open
NuxRo opened this issue Apr 26, 2017 · 2 comments
Open

Implement gldf, gldu #32

NuxRo opened this issue Apr 26, 2017 · 2 comments

Comments

@NuxRo
Copy link

NuxRo commented Apr 26, 2017

Hello,

Currently there is no way of knowing how big a volume is, one needs to mount and run "du" on it.
Please implement a gldu, gldf so admins can easily see disk usage of the volumes.

Thanks!

@prashanthpai
Copy link

Here's a quick python script:

#!/usr/bin/env python
import sys
from gluster import gfapi

SERVER = '127.0.0.1'
MB = (1024 * 1024)
GB = MB * 1024

def get_volume_usage(volume):
    v = gfapi.Volume(SERVER, volume)
    try:
        v.mount()
        s = v.statvfs("/")
    except:
        print("Mount()/Statvfs() failed for volume %s\n" % volume)
    else:
        total = (s.f_blocks * s.f_frsize) / MB
        free = (s.f_bavail * s.f_bsize) / MB
        used = total - free
        print("volume=%s: total=%d, used=%d, free=%d" % (volume, total, used, free))
    finally:
        if v.mounted:
            v.umount()

if __name__ == '__main__':
    for i in range(1, len(sys.argv)):
        get_volume_usage(sys.argv[i])

Usage:

$ ./pyscript.py test test2
volume=test: total=950, used=534, free=416
volume=test2: total=950, used=34, free=916

Make sure you have libgfapi-python installed:

$ sudo dnf install python2-glusterfs-api

or

$ sudo dnf install python-pip
$ sudo pip install gfapi

@NuxRo
Copy link
Author

NuxRo commented Apr 26, 2017

Thank you, for now I have found out this great tool:
https://github.com/aravindavk/glusterfs-tools

Looking forward to seeing this functionality in glusterfs-coreutils, though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants