Exemplo n.º 1
0
    def xmlrpc_isAlive(self):
        """ Check if olsrd is alive by looking in the process table. """
        cmd = ["/bin/ps", "-C", "relayd"]
        rc = yield twisted_call(cmd, shell=False)

        if (rc == 0):
            defer.returnValue(True)
        else:
            defer.returnValue(False)
Exemplo n.º 2
0
    def xmlrpc_isAlive(self):
        """ Check if olsrd is alive by looking in the process table. """
        cmd = ["/bin/ps", "-C", "relayd" ]
        rc = yield twisted_call(cmd, shell=False)

        if (rc==0):
            defer.returnValue(True)
        else:
            defer.returnValue(False)
Exemplo n.º 3
0
    def stop(self):
        """This function invokes start-stop-daemon to stop routeLogger"""

        cmd = ["start-stop-daemon", "--stop", "--pidfile", self._pidfile]
        rc = yield twisted_call(cmd)
        if (rc != 0):
            error("Failed to stop rtmon!!!")
        info("stopped routelogger")
        defer.returnValue(0)
Exemplo n.º 4
0
    def xmlrpc_isAlive(self):
        """ Check if netconsole module is loaded. """
        cmd = "/sbin/lsmod | grep netconsole"
        rc = yield twisted_call(cmd, shell=True)

        if (rc==0):
            defer.returnValue(True)
        else:
            defer.returnValue(False)
Exemplo n.º 5
0
    def xmlrpc_isAlive(self):
        """Check if flowgrinddd is alive by looking in the process table."""
        cmd = ["/bin/ps", "-C", self._daemon.split('/')[-1]]
        rc = yield twisted_call(cmd, shell=False)

        if (rc == 0):
            defer.returnValue(True)
        else:
            defer.returnValue(False)
Exemplo n.º 6
0
    def xmlrpc_isAlive(self):
        """ Check if netconsole module is loaded. """
        cmd = "/sbin/lsmod | grep netconsole"
        rc = yield twisted_call(cmd, shell=True)

        if (rc == 0):
            defer.returnValue(True)
        else:
            defer.returnValue(False)
Exemplo n.º 7
0
    def stop(self):
        """This function invokes start-stop-daemon to stop routeLogger"""

        cmd = [ "start-stop-daemon", "--stop",
                "--pidfile", self._pidfile]
        rc = yield twisted_call(cmd)
        if (rc != 0):
            error("Failed to stop rtmon!!!")
        info("stopped routelogger")
        defer.returnValue(0)
Exemplo n.º 8
0
    def start(self, logdir):
        """This function invokes start-stop daemon to bring up the route logger"""

        if not os.path.exists(logdir):
            info("%s does not exist. Trying to create" % logdir)
        try:
            os.mkdir(logdir)
            os.chmod(logdir, os.stat(logdir)[0] | stat.S_IWOTH)
        except OSError:
            error("Logdir creation failed")
            defer.returnValue(1)

        cmd = [
            "start-stop-daemon", "--start", "--background", "--make-pidfile",
            "--pidfile", self._pidfile, "--chuid", "lukowski", "--exec",
            self._daemon, "--", "file", logdir + "/" + self._hostname + ".log"
        ]
        yield twisted_call(cmd, shell=False)
        info("started routelogger")
        info(cmd)
        defer.returnValue(0)
Exemplo n.º 9
0
    def start(self, logdir):
        """This function invokes start-stop daemon to bring up the route logger"""

        if not os.path.exists(logdir):
            info("%s does not exist. Trying to create" % logdir)
        try:
            os.mkdir(logdir)
            os.chmod(logdir, os.stat(logdir)[0] | stat.S_IWOTH)
        except OSError:
            error("Logdir creation failed")
            defer.returnValue(1)

        cmd = [ "start-stop-daemon", "--start", "--background",
                "--make-pidfile", "--pidfile", self._pidfile,
                "--chuid", "lukowski",
                "--exec", self._daemon,
                "--", "file", logdir + "/" + self._hostname + ".log"]
        yield twisted_call(cmd, shell=False)
        info("started routelogger")
        info(cmd)
        defer.returnValue(0)
Exemplo n.º 10
0
 def callback(rc):
     if rc != 0:
         return
     cmd = ["gzip", dfile]
     twisted_call(cmd, shell=False)
Exemplo n.º 11
0
def test_flowgrind(mrs, log_file, src, dst, src_ctrl=None, dst_ctrl=None,
                   timeout=10, duration=15, warmup=0, cc=None, dump=None,
                   bport=5999, opts=[], fg_bin="flowgrind", gzip_dumps=True,
                   **kwargs):
    """This test performs a simple flowgrind (new, aka dd version) test with
    one tcp flow from src to dst.

       required arguments:
            mrs     : reference to parent measurement class
            log_file: file descriptor where the results are written to
            src     : sender of the flow
            dst     : receiver of the flow

       optional arguments:
            src_ctrl : control connection to the sender
            dst_ctrl : control connection to the receiver
            duration : duration of the flow in seconds
            cc       : congestion control method to use
            warmup   : warmup time for flow in seconds
            dump     : turn tcpdump on src and dst on iface 'dump' on
            bport    : flowgrind base port
            opts     : additional command line arguments
            fg_bin   : flowgrind binary
            gzip_pcap: gzip dumps to save space
    """

    # path of executable
    cmd = [ fg_bin ]

    # add -p for numerical output
    cmd.extend(["-p"])

    # test duration
    cmd.extend(["-T", "s=%.2f" % duration])

    # inital delay
    if warmup:
        cmd.extend(["-Y", "s=%.2f" % warmup])

    # which tcp congestion control module
    if cc:
        cmd.extend(["-O", "s=TCP_CONG_MODULE=%s" % cc])

    # control connections in place?
    if not src_ctrl:
        src_ctrl = src
    if not dst_ctrl:
        dst_ctrl = dst

    # build host specifiers
    cmd.extend(["-H", "s=%s/%s,d=%s/%s" %(src, src_ctrl, dst, dst_ctrl)])

    # just add additional parameters
    if opts:
        cmd.extend(opts)

    # start tcpdump
    if dump:
        raise NotImplementedError, "bport must be re-added to new flowgrind first"

        dumpfile_src = None
        dumpfile_dst = None
        results = yield mrs.xmlrpc_many([src_ctrl, dst_ctrl], "tcpdump.start",
            dump, "port %u" %bport )
        debug(results)

        # shortcuts
        sres = results[0]
        dres = results[1]
        if sres[0]:
            dumpfile_src = sres[1]
        else:
            warn("Failed to start tcpdump on %s: %s" %(src_ctrl,
                sres[1].getErrorMessage()))
        if dres[0]:
            dumpfile_dst = dres[1]
        else:
            warn("Failed to start tcpdump on %s: %s" %(dst_ctrl,
                dres[1].getErrorMessage()))

    # run flowgrind
    rc = yield mrs.local_execute(" ".join(cmd), log_file, timeout=(duration +
        warmup + timeout))
    defer.returnValue(rc)

    # stop tcpdump
    if dump:
        yield mrs.xmlrpc_many([src_ctrl, dst_ctrl], "tcpdump.stop")

        # just schedule moving and compressing for later execution
        if dumpfile_src:
            # just append .hostname.pcap to logfilename
            sfile = "%s.%s.pcap" %(log_file.name, src_ctrl)
            cmd = ["mv", dumpfile_src, sfile]
            d = twisted_call(cmd, shell=False)
            if gzip_pcap:
                def callback(rc):
                    if rc != 0:
                        return
                    cmd = ["gzip", sfile]
                    twisted_call(cmd, shell=False)

                d.addCallback(callback)
        if dumpfile_dst:
            # just append .hostname.pcap to logfilename
            dfile = "%s.%s.pcap" %(log_file.name, dst_ctrl)
            cmd = ["mv", dumpfile_dst, dfile]
            d=twisted_call(cmd, shell=False)
            if gzip_dumps:
                def callback(rc):
                    if rc != 0:
                        return
                    cmd = ["gzip", dfile]
                    twisted_call(cmd, shell=False)

                d.addCallback(callback)