예제 #1
0
 def test_02_ldmsctl(self):
     logfile = "ldmsctl.log"
     self.smp = LDMSD(port=self.SMP_PORT,
                      xprt=self.XPRT,
                      verbose="DEBUG",
                      logfile=logfile)
     self.smp.run()
     if not on_timeout(self.is_logfile_ready, filename=logfile):
         raise Exception(
             "ldmsd log file isn't created within 1 second after ldmsd is started."
         )
     name_len = self.getMaxMsgSz("ldmsctl")
     line = self.getGreetingCfgCmd(name_len)
     cfg = tempfile.NamedTemporaryFile()
     cfg.write(line)
     cfg.file.flush()
     # ldmsd_controller subprocess
     ctrl = LDMSD_Controller(port=self.SMP_PORT,
                             xprt=self.XPRT,
                             source=cfg.name,
                             ldmsctl=True)
     ctrl.run()
     msg = self.getLogMsg(name_len)
     self.assertTrue(
         on_timeout(self.is_msg_in_logfile, filename=logfile, msg=msg))
예제 #2
0
    def setUpClass(cls):
        log.info("Setting up " + cls.__name__)
        try:
            cls.ldmsd = LDMSD(port=cls.PORT,
                              xprt=cls.XPRT,
                              logfile=cls.LOG,
                              auth=cls.AUTH,
                              auth_opt=cls.AUTH_OPT)
            log.info("starting ldmsd")
            cls.ldmsd.run()
            sleep(1)

            cls.ldmsd_interface = LDMSD_Controller(port=cls.PORT,
                                                   host=cls.HOST,
                                                   xprt=cls.XPRT,
                                                   auth=cls.AUTH,
                                                   auth_opt=cls.AUTH_OPT,
                                                   ldmsctl=cls.is_ldmsctl)
            cls.ldmsd_interface.run()
            cls.ldmsd_interface.read_pty(
            )  # Read the welcome message and the prompt
        except:
            if cls.ldmsd:
                del cls.ldmsd
            if cls.ldmsd_interface:
                del cls.ldmsd_interface
            raise
        log.info(cls.__name__ + " set up done")
예제 #3
0
 def test_04_setgroup_rm(self):
     """`setgroup_rm` test"""
     ctrl = LDMSD_Controller(port=self.SMP_PORT, xprt=self.XPRT)
     ctrl.run()
     ctrl.read_pty()  # discard the welcome message and the prompt
     lines = ctrl.comm_pty("setgroup_rm name=my/grp instance=smp/set7")
     time.sleep(3 * self.INTERVAL_SEC)
     self._verify_smp()
     self._verify_agg(["smp/meminfo"])
예제 #4
0
 def test_02_empty_grp(self):
     """Empty the plugin group so that we can test the manual group"""
     ctrl = LDMSD_Controller(port=self.SMP_PORT, xprt=self.XPRT)
     ctrl.run()
     ctrl.read_pty()  # discard the welcome message and the prompt
     lines = ctrl.comm_pty("config name=grptest members=0x0")
     self._verify_smp()
     # Now, only set0 and set4 shold be updated on the agg
     self._verify_agg([])
예제 #5
0
 def test_01_plugin_mod(self):
     # Now, setup the ldmsd_controller subprocess
     ctrl = LDMSD_Controller(port=self.SMP_PORT, xprt=self.XPRT)
     ctrl.run()
     ctrl.read_pty()  # discard the welcome message and the prompt
     lines = ctrl.comm_pty("config name=grptest members=0x11")
     self._verify_smp()
     # Now, only set0 and set4 shold be updated on the agg
     self._verify_agg(['smp/set0', 'smp/set4'])
예제 #6
0
 def test_03_setgroup_add_ins(self):
     """`setgroup_add` and `setgroup_ins` commands"""
     ctrl = LDMSD_Controller(port = self.SMP_PORT, xprt = self.XPRT)
     ctrl.run()
     ctrl.read_pty() # discard the welcome message and the prompt
     cmd = "setgroup_add name=my/grp interval=%(interval)d" % {
                 "interval": self.INTERVAL_US,
             }
     lines = ctrl.comm_pty(cmd)
     lines = ctrl.comm_pty("setgroup_ins name=my/grp instance=smp/meminfo,smp/set7")
     time.sleep(3 * self.INTERVAL_SEC)
     self._verify_smp()
     self._verify_agg(["smp/meminfo", "smp/set7"])
예제 #7
0
 def test_06_setgroup_del(self):
     ctrl = LDMSD_Controller(port=self.SMP_PORT, xprt=self.XPRT)
     ctrl.run()
     ctrl.read_pty()  # discard the welcome message and the prompt
     cmd = "setgroup_del name=my/grp"
     lines = ctrl.comm_pty(cmd)
     time.sleep(3 * self.INTERVAL_SEC)
     x = LdmsWrap(self.AGG_PORT)
     s = x.get("my/grp")
     self.assertEqual(s, None)
예제 #8
0
 def test_05_setgroup_mod(self):
     """`setgroup_mod` test"""
     ctrl = LDMSD_Controller(port=self.SMP_PORT, xprt=self.XPRT)
     ctrl.run()
     ctrl.read_pty()  # discard the welcome message and the prompt
     cmd = "setgroup_mod name=my/grp interval=%d" % (60 * self.INTERVAL_US)
     lines = ctrl.comm_pty(cmd)
     time.sleep(3 * self.INTERVAL_SEC)
     self._verify_smp()
     self._verify_agg([])
예제 #9
0
파일: ldmsctl.py 프로젝트: oceandlr/ovis
    def setUpClass(cls):
        # 1 sampler, 1 aggregator
        log.info("Setting up " + cls.__name__)
        try:
            # samplers (producers)
            smp_cfg = """
                load name=meminfo
                config name=meminfo producer=smp \
                       instance=smp/meminfo schema=meminfo
                start name=meminfo interval=1000000 offset=0
            """
            log.debug("smp_cfg: %s" % smp_cfg)
            cls.smp = LDMSD(port=cls.SMP_PORT,
                            xprt=cls.XPRT,
                            auth=cls.AUTH,
                            auth_opt=cls.LDMSD_AUTH_OPT,
                            cfg=smp_cfg,
                            logfile=cls.SMP_LOG)
            log.info("starting sampler")
            cls.smp.run()

            # aggregator
            cls.agg = LDMSD(port=cls.AGG_PORT,
                            xprt=cls.XPRT,
                            auth=cls.AUTH,
                            auth_opt=cls.LDMSD_AUTH_OPT,
                            logfile=cls.AGG_LOG)
            log.info("starting aggregator")
            cls.agg.run()
            time.sleep(1)

            # Now, setup the ldmsd_controller subprocess
            cls.ctrl = LDMSD_Controller(port=cls.AGG_PORT,
                                        xprt=cls.XPRT,
                                        auth=cls.AUTH,
                                        auth_opt=cls.LDMSD_AUTH_OPT,
                                        ldmsctl=True)
            cls.ctrl.run()
            cls.ctrl.read_pty()  # discard the welcome message and the prompt
        except:
            del cls.agg
            del cls.smp
            del cls.ctrl
            raise
        log.info(cls.__name__ + " set up done")
예제 #10
0
    def test_01_req_noexp(self):
        """Request over xprt shall not be command-expanded"""
        ctrl = LDMSD_Controller(port=self.SMP_PORT, xprt=self.XPRT)
        ctrl.run()
        ctrl.read_pty()
        ctrl.write_pty("env X=$(hostname)\n")
        ctrl.write_pty("load name=vmstat\n")
        ctrl.write_pty("config name=vmstat producer=${X} \
                               instance=${X}/vmstat\
                               schema=vmstat\n")
        ctrl.write_pty("start name=vmstat interval=1000000 offset=0\n")
        time.sleep(0.2)

        host = socket.gethostname()
        xprt = ldms.LDMS_xprt_new(self.XPRT)
        rc = ldms.LDMS_xprt_connect_by_name(xprt, "localhost", "10001")
        self.assertEqual(rc, 0)
        dir_resp = ldms.LDMS_xprt_dir(xprt)
        dir_resp.sort()
        expected = [host + "/$(whoami)/meminfo", "$(hostname)/vmstat"]
        expected.sort()
        self.assertEqual(dir_resp, expected)