mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Added module for disk, with function to report on disk usage
This commit is contained in:
parent
8d47be052b
commit
05891a7ba1
1 changed files with 31 additions and 0 deletions
31
salt/modules/disk.py
Normal file
31
salt/modules/disk.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
'''
|
||||
Module for gathering disk information
|
||||
'''
|
||||
import subprocess
|
||||
|
||||
def usage():
|
||||
'''
|
||||
Return usage information for volumes mounted on this minion
|
||||
|
||||
CLI Example:
|
||||
salt '*' disk.usage
|
||||
'''
|
||||
cmd = 'df -P'
|
||||
ret = {}
|
||||
out = subprocess.Popen(cmd,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE).communicate()[0].split('\n')
|
||||
for line in out:
|
||||
if not line.count(' '):
|
||||
continue
|
||||
if line.startswith('Filesystem'):
|
||||
continue
|
||||
comps = line.split()
|
||||
ret[comps[0]] = {
|
||||
'1K-blocks': comps[1],
|
||||
'used': comps[2],
|
||||
'available': comps[3],
|
||||
'capacity': comps[4],
|
||||
'mountpoint':comps[5]
|
||||
}
|
||||
return ret
|
Loading…
Add table
Reference in a new issue