Example #1
0
File: query.py Project: zer0n1/salt
    def _get_disk_size(self, device):
        '''
        Get a size of a disk.
        '''
        out = __salt__['cmd.run_all']("df {0}".format(device))
        if out['retcode']:
            msg = "Disk size info error: {0}".format(out['stderr'])
            log.error(msg)
            raise SIException(msg)

        devpath, blocks, used, available, used_p, mountpoint = [elm for elm in
                                                                out['stdout'].split(os.linesep)[-1].split(" ") if elm]
        return {
            'device': devpath, 'blocks': blocks, 'used': used,
            'available': available, 'used (%)': used_p, 'mounted': mountpoint,
        }
Example #2
0
    def _get_mem(self):
        '''
        Get memory.
        '''
        out = __salt__['cmd.run_all']("vmstat -s")
        if out['retcode']:
            raise SIException("Memory info error: {0}".format(out['stderr']))

        ret = dict()
        for line in out['stdout'].split(os.linesep):
            line = line.strip()
            if not line:
                continue
            size, descr = line.split(" ", 1)
            if descr.startswith("K "):
                descr = descr[2:]
                size = size + "K"
            ret[descr] = size
        return ret
Example #3
0
    def _get_mem(self):
        """
        Get memory.
        """
        out = __salt__["cmd.run_all"]("vmstat -s")
        if out["retcode"]:
            raise SIException("Memory info error: {}".format(out["stderr"]))

        ret = dict()
        for line in out["stdout"].split(os.linesep):
            line = line.strip()
            if not line:
                continue
            size, descr = line.split(" ", 1)
            if descr.startswith("K "):
                descr = descr[2:]
                size = size + "K"
            ret[descr] = size
        return ret
Example #4
0
    def _get_disk_size(self, device):
        """
        Get a size of a disk.
        """
        out = __salt__["cmd.run_all"]("df {0}".format(device))
        if out["retcode"]:
            msg = "Disk size info error: {0}".format(out["stderr"])
            log.error(msg)
            raise SIException(msg)

        devpath, blocks, used, available, used_p, mountpoint = [
            elm for elm in out["stdout"].split(os.linesep)[-1].split(" ") if elm
        ]
        return {
            "device": devpath,
            "blocks": blocks,
            "used": used,
            "available": available,
            "used (%)": used_p,
            "mounted": mountpoint,
        }
Example #5
0
 def __init__(self, systype):
     if systype.lower() == "solaris":
         raise SIException(
             "Platform {0} not (yet) supported.".format(systype))