--- func/minion/modules/disk.py | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-) create mode 100644 func/minion/modules/disk.py diff --git a/func/minion/modules/disk.py b/func/minion/modules/disk.py new file mode 100644 index 0000000..f9a2c55 --- /dev/null +++ b/func/minion/modules/disk.py @@ -0,0 +1,60 @@ +# +# Copyright 2009 +# Greg Swift <gregswift@xxxxxxxxx> +# +# This software may be freely redistributed under the terms of the GNU +# general public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import func_module +from func.minion import sub_process + +class DiskModule(func_module.FuncModule): + version = "0.0.1" + api_version = "0.0.1" + description = "Gathering disk related information" + + def usage(self, partition=None): + """ + Returns the results of df -P + """ + results = {} + # splitting the command variable out into a list does not seem to function + # in the tests I have run + command = '/bin/df -P' + if (partition): + command += ' %s' % (partition) + cmdref = sub_process.Popen(command, stdout=sub_process.PIPE, + stderr=sub_process.PIPE, shell=True, + close_fds=True) + (stdout, stderr) = cmdref.communicate() + for disk in stdout.split('\n'): + if (disk.startswith('Filesystem') or not disk): + continue + (device, total, used, available, percentage, mount) = disk.split() + results[mount] = {'device':device, + 'total':int(total), + 'used':int(used), + 'available':int(available), + 'percentage':int(percentage[:-1])} + return results + + def register_method_args(self): + """ + The argument export method + """ + return { + 'usage':{ + 'args':{ + 'partition': { + 'type':'string', + 'optional':True, + 'description':'A specific partition to get usage data for', + } + }, + 'description':'Gather disk usage information' + } + } -- 1.6.6.1 _______________________________________________ Func-list mailing list Func-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/func-list