mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge branch 'master' of github.com:thatch45/salt
This commit is contained in:
commit
386d763d04
2 changed files with 85 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
|
54
salt/modules/sysctl.py
Normal file
54
salt/modules/sysctl.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
'''
|
||||
Module for viewing and modifying sysctl paramters
|
||||
'''
|
||||
import subprocess
|
||||
|
||||
def list():
|
||||
'''
|
||||
Return a list of sysctl parameters for this minion
|
||||
|
||||
CLI Example:
|
||||
salt '*' sysctl.list
|
||||
'''
|
||||
cmd = 'sysctl -a'
|
||||
ret = {}
|
||||
out = subprocess.Popen(cmd,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE).communicate()[0].split('\n')
|
||||
for line in out:
|
||||
if not line.count(' '):
|
||||
continue
|
||||
comps = line.split(' = ')
|
||||
ret[comps[0]] = comps[1]
|
||||
return ret
|
||||
|
||||
def get( name ):
|
||||
'''
|
||||
Return a single sysctl parameter for this minion
|
||||
|
||||
CLI Example:
|
||||
salt '*' sysctl.get net.ipv4.ip_forward
|
||||
'''
|
||||
cmd = 'sysctl -n %s' % name
|
||||
ret = {}
|
||||
out = subprocess.Popen(cmd,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE).communicate()[0]
|
||||
ret[name] = out[0]
|
||||
return out[0]
|
||||
|
||||
def set( name, value ):
|
||||
'''
|
||||
Set a single sysctl parameter for this minion
|
||||
|
||||
CLI Example:
|
||||
salt '*' sysctl.set net.ipv4.ip_forward 1
|
||||
'''
|
||||
cmd = 'sysctl -w %s=%s' % ( name, value )
|
||||
ret = {}
|
||||
out = subprocess.Popen(cmd,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE).communicate()[0].strip()
|
||||
comps = out.split(' = ')
|
||||
ret[comps[0]] = comps[1]
|
||||
return ret
|
Loading…
Add table
Reference in a new issue