mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Add disk.inodeusage and fix disk.usage logic
Previously, disk.usage was returning a dictionary where the key was in the "Filesystem" column. It seemed proper to return every filesystem, even the virtual ones so the dict key was changed to the mountpoint. $ df -P Filesystem 1024-blocks Used Available Capacity Mounted on /dev/sda8 177822980 12504764 156285272 8% / none 6154104 312 6153792 1% /dev none 6161372 3736 6157636 1% /dev/shm none 6161372 336 6161036 1% /var/run none 6161372 0 6161372 0% /var/lock /dev/sda1 101086 85423 15663 85% /boot /dev/sda5 240308484 219822840 20485644 92% /home /dev/sda7 54791132 1104204 50903672 3% /var This can be changed to skip anything that has a Filesystem of none down the road, but I don't have any non-Linux hosts to test on.
This commit is contained in:
parent
98148b33e4
commit
5e6f23fbef
@ -20,11 +20,42 @@ def usage():
|
|||||||
if line.startswith('Filesystem'):
|
if line.startswith('Filesystem'):
|
||||||
continue
|
continue
|
||||||
comps = line.split()
|
comps = line.split()
|
||||||
ret[comps[0]] = {
|
ret[comps[5]] = {
|
||||||
'1K-blocks': comps[1],
|
'filesystem': comps[0],
|
||||||
'available': comps[3],
|
'1K-blocks': comps[1],
|
||||||
'capacity': comps[4],
|
'used': comps[2],
|
||||||
'mountpoint': comps[5],
|
'available': comps[3],
|
||||||
'used': comps[2]
|
'capacity': comps[4],
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def inodeusage():
|
||||||
|
'''
|
||||||
|
Return inode usage information for volumes mounted on this minion
|
||||||
|
|
||||||
|
CLI Example::
|
||||||
|
|
||||||
|
salt '*' disk.inodeusage
|
||||||
|
'''
|
||||||
|
cmd = 'df -i'
|
||||||
|
ret = {}
|
||||||
|
out = __salt__['cmd.run'](cmd).split('\n')
|
||||||
|
for line in out:
|
||||||
|
if line.startswith('Filesystem'):
|
||||||
|
continue
|
||||||
|
comps = line.split()
|
||||||
|
# Don't choke on empty lines
|
||||||
|
if not comps:
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
ret[comps[5]] = {
|
||||||
|
'inodes': comps[1],
|
||||||
|
'used': comps[2],
|
||||||
|
'free': comps[3],
|
||||||
|
'use': comps[4],
|
||||||
|
'filesystem': comps[0],
|
||||||
|
}
|
||||||
|
except IndexError:
|
||||||
|
print "DEBUG: comps='%s'" % comps
|
||||||
|
return ret
|
||||||
|
Loading…
Reference in New Issue
Block a user