예제 #1
0
def createRrdSymLink():
    try:
        if not os.path.exists(comLib.getSupportFilePath("RrdServ")):
            comLib.cmd("ln -s {}/{}/ {}".format(
                comLib.getSupportFilePath("RrdLib"), sysLib.getHostname(),
                comLib.getSupportFilePath("RrdServ")))
    except Exception as e:
        print("Error Creating rrd symlink: {}".format(e))
예제 #2
0
def setIps(ipAddrs):
    for interface in ipAddrs:
        bringInterfaceDown(interface)

    time.sleep(1)

    for interface in ipAddrs:
        setInterfaceIp(interface, ipAddrs[interface])

    time.sleep(1)

    for interface in ipAddrs:
        bringInterfaceUp(interface)

    time.sleep(1)
    comLib.cmd("sudo dhclient")
예제 #3
0
def enablePythonRrd():
    cPath = comLib.getSupportFilePath("CollectdConf")

    startIndex = -1
    stopIndex = -1
    lastBlankSpace = -1
    cLines = [x.rstrip() for x in open(cPath, 'r').readlines()]
    for x in range(len(cLines)):
        if re.match('^# ARMORE', cLines[x]) and startIndex == -1:
            startIndex = x
        elif re.match('^# ARMORE', cLines[x]) and startIndex != -1:
            stopIndex = x
        elif re.match('^$', cLines[x]) and startIndex == -1:
            lastBlankSpace = x

    newTxt = '''# ARMORE
<LoadPlugin python>
    Globals true
    Interval 900
</LoadPlugin>

<Plugin python>
    ModulePath "/var/webServer/domains/support"
    LogTraces true
    Interactive false
    import rrdDataParser
    <Module rrdDataParser>
    </Module>
</Plugin>
# ARMORE'''.split('\n')

    if startIndex == -1:
        cLines.extend(newTxt)
    else:
        cLines[startIndex:stopIndex + 1] = newTxt

    with open(cPath, 'w') as cFile:
        cFile.write("\n".join(cLines))

    comLib.cmd("/etc/init.d/collectd restart")
예제 #4
0
def setInterfaceIp(interface, ip):
    theCmd = "sudo ip addr add {0} dev {1}".format(ip, interface)
    comLib.cmd(theCmd)
예제 #5
0
def bringInterfaceUp(interface):
    theCmd = "sudo ip link set {0} up".format(interface)
    comLib.cmd(theCmd)
예제 #6
0
def bringInterfaceDown(interface):
    theCmd = "sudo ip link set {0} down".format(interface)
    comLib.cmd(theCmd)
    clearIpsOfInterface(interface)
예제 #7
0
def clearIpsOfInterface(interface):
    theCmd = "sudo ip addr flush dev {0}".format(interface)
    comLib.cmd(theCmd)
예제 #8
0
def restartBro():
    comLib.cmd('broctl restart')
예제 #9
0
def restartProxy():
    comLib.cmd('/etc/init.d/armoreconfig stop')
    comLib.cmd('/etc/init.d/armoreconfig start')
예제 #10
0
def createArmoreDb():
    try:
        comLib.cmd("sh {}".format(comLib.getSupportFilePath("ArmoreDBInit")))
    except Exception as e:
        print("Error Creating armore.db: {}".format(e))