コード例 #1
0
ファイル: initialization.py プロジェクト: timyardley/ARMORE
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
ファイル: network.py プロジェクト: timyardley/ARMORE
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
ファイル: initialization.py プロジェクト: timyardley/ARMORE
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
ファイル: network.py プロジェクト: timyardley/ARMORE
def setInterfaceIp(interface, ip):
    theCmd = "sudo ip addr add {0} dev {1}".format(ip, interface)
    comLib.cmd(theCmd)
コード例 #5
0
ファイル: network.py プロジェクト: timyardley/ARMORE
def bringInterfaceUp(interface):
    theCmd = "sudo ip link set {0} up".format(interface)
    comLib.cmd(theCmd)
コード例 #6
0
ファイル: network.py プロジェクト: timyardley/ARMORE
def bringInterfaceDown(interface):
    theCmd = "sudo ip link set {0} down".format(interface)
    comLib.cmd(theCmd)
    clearIpsOfInterface(interface)
コード例 #7
0
ファイル: network.py プロジェクト: timyardley/ARMORE
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
ファイル: initialization.py プロジェクト: timyardley/ARMORE
def createArmoreDb():
    try:
        comLib.cmd("sh {}".format(comLib.getSupportFilePath("ArmoreDBInit")))
    except Exception as e:
        print("Error Creating armore.db: {}".format(e))