Exemplo n.º 1
0
def mounts() : 
    out = cfge.instance().check_output(["mount"])
    mnt = {}
    mnt['by_device'] = {}
    mnt['by_mount'] = {}
    for line in out.splitlines(True) : 
        s = line.split()
        mnt['by_device'][s[0].decode()] = s[2].decode()
        mnt['by_mount'][s[2].decode()] = s[0].decode()
    return mnt;
Exemplo n.º 2
0
def get_procs() :
    ps = {}
    pso = cfge.instance().check_output(["ps", "-elfy"]).splitlines(True)    
    headers = pso[0].split()
    for line in pso[1:] :
        row = line.split()
        pid = row[2].decode()
        ps[pid] = {}
        num = 0
        for num in range(0, 14, 1) :
            ps[pid][headers[num].decode()] = row[num].decode();
    return ps
Exemplo n.º 3
0
def readtab(cmd, idcol=0, headers=None, sep=None) :
    r = {}
    out = cfge.instance().check_output(cmd).splitlines(True)

    if headers == None:
        headers = out[0].decode().split(sep=sep)

    for line in out[1:] :
        data = line.decode().split(sep=sep, maxsplit=len(headers)-1)
        key = data[idcol].lower().strip()
        r[key] = {}
        for index, item in enumerate(data) :
            r[key][headers[index].lower().strip()] = item.strip()

    return r
Exemplo n.º 4
0
#! /usr/bin/python3 

import os
import re
import cfge
import cfge.commands 

engine = cfge.instance()

if engine.geteuid() != 0 :
    print ("You must run this as root!")
    exit (1)

lvm = cfge.commands.lvmstat()
mounts = cfge.commands.mounts()

#lvs = lvscan()
#vgs = vgscan()
#mnts = getmounts()

# look for snapshot 
snapvolume = ""
for uuid, lv in lvm['lvs'].items() :
    if lv['origin'] != '' :
        snapvolume = uuid
        break

if snapvolume == "" :
    print ("No snapshot found!")
    exit (1)