Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
Corrected typo, indentation and removed trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Naveira committed May 25, 2015
1 parent b820b80 commit b9fb3df
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions grains/osdisk.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
#!/usr/bin/env python
import os
import os

def get_osdisk_stats():
"""
Calculates and resturns the disk used, available and total capacity
in gigabytes. Calculations code from:
http://www.stealthcopter.com/blog/2009/09/python-diskspace/
"""
grains = {}
grains['osdisk'] = {}
disk = os.statvfs("/")
capacity = disk.f_bsize * disk.f_blocks
available = disk.f_bsize * disk.f_bavail
used = disk.f_bsize * (disk.f_blocks - disk.f_bavail)
# print information in bytes
#print used, available, capacity
# print information in Kilobytes
#print used/1024, available/1024, capacity/1024
# print information in Megabytes
#print used/1.048576e6, available/1.048576e6, capacity/1.048576e6
# print information in Gigabytes
#print used/1.073741824e9, available/1.073741824e9, capacity/1.073741824e9
'''
Calculates and returns the disk used, available and total capacity
in gigabytes. Calculations code from:
http://www.stealthcopter.com/blog/2009/09/python-diskspace/
'''
grains = {}
grains['osdisk'] = {}
disk = os.statvfs("/")

capacity = disk.f_bsize * disk.f_blocks
available = disk.f_bsize * disk.f_bavail
used = disk.f_bsize * (disk.f_blocks - disk.f_bavail)

# print information in bytes
#print used, available, capacity
# print information in Kilobytes
#print used/1024, available/1024, capacity/1024
# print information in Megabytes
#print used/1.048576e6, available/1.048576e6, capacity/1.048576e6
# print information in Gigabytes
#print used/1.073741824e9, available/1.073741824e9, capacity/1.073741824e9

grains['osdisk']['used'] = int(round(used/1.073741824e9))
grains['osdisk']['available'] = int(round(available/1.073741824e9))
grains['osdisk']['capacity'] = int(round(capacity/1.073741824e9))
grains['osdisk']['used'] = int(round(used/1.073741824e9))
grains['osdisk']['available'] = int(round(available/1.073741824e9))
grains['osdisk']['capacity'] = int(round(capacity/1.073741824e9))

return grains
return grains

0 comments on commit b9fb3df

Please sign in to comment.