Ejemplo n.º 1
0
    def strgp_metric_del(self, name, metric_name):
        """
        Remove a metric name from the storage policy. The storage policy
        must be STOPPED.

        Parameters:
        - The storage policy name
        - The metric name to remove

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        req = LDMSD_Request(
                command_id=LDMSD_Request.STRGP_METRIC_DEL,
                attrs=[
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.METRIC, value=metric_name)
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 2
0
    def listen(self, xprt, port, host=None, auth=None):
        """
        Add a listening endpoint

        Parameters:
        xprt - Transport name [sock, rdma, ugni]
        port - Port number
        [host] - Hostname
        [auth] - Authentication domain - If none, the default
                 authentication given the command line
                 (-a and -A) will be used

        """
        attr_list = [ LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.XPRT, value=xprt),
                      LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.PORT, value=port)
        ]
        req = LDMSD_Request(
                command='listen',
                attrs=attr_list
              )
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception as e:
            return errno.ENOTCONN, None
Ejemplo n.º 3
0
    def updtr_prdcr_del(self, name, regex):
        """
        Remove matching producers from an updater policy. The
        updater must be STOPPED.
        
        Parameters:
        - The updater name
        - A regular expression matching zero or more producers

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        req = LDMSD_Request(
                command_id=LDMSD_Request.UPDTR_PRDCR_DEL,
                attrs=[
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.REGEX, value=regex)
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 4
0
    def strgp_prdcr_add(self, name, regex):
        """
        Add matching producers to an storage policy. The
        storage policy must be STOPPED.
        
        Parameters:
        - The storage policy name
        - A regular expression matching zero or more producers

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        req = LDMSD_Request(
                command_id=LDMSD_Request.STRGP_PRDCR_ADD,
                attrs=[
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.REGEX, value=regex)
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 5
0
    def strgp_metric_add(self, name, metric_name):
        """
        Add a metric name that will be stored. By default all metrics
        in the schema specified in strgp_add will be stored.

        Parameters::
        - The update policy name
        - The name of the metric to store

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        req = LDMSD_Request(
                command_id=LDMSD_Request.STRGP_METRIC_ADD,
                attrs=[
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.METRIC, value=metric_name)
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 6
0
    def updtr_match_del(self, name, regex, match='schema'):
        """
        Remove a match condition from an updater. The updater
        must be STOPPED.

        Parameters::
        name  - The update policy name
        regex - The regular expression string
        match - The value with which to compare; if match='inst' (default),
                the expression will match the set's instance name, if
                match='schema', the expression will match the set's
                schema name.

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        req = LDMSD_Request(
                command_id=LDMSD_Request.UPDTR_MATCH_DEL,
                attrs=[
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.REGEX, value=regex),
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.MATCH, value=match)
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 7
0
    def prdcr_subscribe(self, regex, stream):
        """
        Subscribe to stream data from matching producers

        Parameters:
        - A regular expression matching producer names
        - The name of the stream

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        req = LDMSD_Request(command_id = LDMSD_Request.PRDCR_STREAM_SUBSCRIBE,
                attrs = [
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.REGEX, value=regex),
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.STREAM, value=stream)
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 8
0
    def strgp_add(self, name, plugin, container, schema, perm=0o600):
        """
        Add a Storage Policy that will store metric set data when
        updates complete on a metric set.

        Parameters:
        name        The unique storage policy name.
        plugin      The name of the storage backend.
        container   The storage backend container name.
        schema      The schema name of the metric set to store.

        Keyword Parameters:
        perm        The permission required to modify the storage policy,
                    default perm=0o600

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        attrs = [
            LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
            LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.PLUGIN, value=plugin),
            LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.CONTAINER, value=container),
            LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.SCHEMA, value=schema),
            LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.PERM, value=str(perm))
        ]
        req = LDMSD_Request(command_id=LDMSD_Request.STRGP_ADD, attrs=attrs)
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 9
0
    def plugn_config(self, name, **args):
        """
        Configure an LDMSD plugin

        Parameters:
        - The plugin name

        Keyword Parameters:
        - dictionary of plugin specific key/value pairs
        """
        cfg_str = ''
        for key in args:
            if len(cfg_str):
                cfg_str += ' '
            cfg_str += key + '=' + args[key]
        req = LDMSD_Request(
                command_id=LDMSD_Request.PLUGN_CONFIG,
                attrs=[ LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
                        LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.STRING, value=cfg_str)
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 10
0
    def prdcr_status(self, name = None):
        """
        Query the LDMSD for the status of one or more producers.

        Keyword Parameters:
        name - If not None (default), the name of the producer to query.
      
        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or
          the object containing the producer status
        """
        if name:
            attrs = [ attrs.append(LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name)) ]
        else:
            attrs = None
        req = LDMSD_Request(command_id=LDMSD_Request.PRDCR_STATUS, attrs=attrs)
        try:
            req.send(self)
            resp = req.receive(self)
            err = resp['errcode']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
        if err == 0:
            status = json.loads(resp['msg'])
        else:
            status = None
        return err, status
Ejemplo n.º 11
0
 def daemon_status(self):
     """Query the daemon's status"""
     req = LDMSD_Request(command_id=LDMSD_Request.DAEMON_STATUS)
     try:
         req.send(self)
         resp = req.receive(self)
         return resp['errcode'], resp['msg']
     except Exception:
         self.close()
         return errno.ENOTCONN, None
Ejemplo n.º 12
0
    def prdcr_add(self, name, ptype, xprt, host, port, reconnect, auth=None, perm=None):
        """
        Add a producer. A producer is a peer to the LDMSD being configured.
        Once started, the LDSMD will attempt to connect to this peer
        periodically until the connection succeeds.

        A producer starts in the STOPPED state. Use the prdcr_start() function
        to start the producer.

        Parameters:
        - The name to give the producer. This name must be unique on the producer.
        - The type of the producer, one of 'passive', or 'active'
        - The transport type, one of 'sock', 'ugni', 'rdma', or 'fabric'
        - The hostname
        - The port number
        - The reconnect interval in microseconds

        Keyword Parameters:
        perm - The configuration client permission required to
               modify the producer configuration. Default is None.

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        attrs = [
            LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.NAME, value=name),
            LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.TYPE, value=ptype),
            LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.XPRT, value=xprt),
            LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.HOST, value=host),
            LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.PORT, value=str(port)),
            LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.INTERVAL, value=str(reconnect))
        ]
        if auth:
            attrs.append(LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.AUTH, value=auth))
        if perm:
            attrs.append(LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.PERM, value=str(perm)))

        req = LDMSD_Request(
                command_id=LDMSD_Request.PRDCR_ADD,
                attrs=attrs)
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 13
0
 def test_comm_1_level_agg(self):
     ctrl = ldmsdInbandConfig(host = self.AGG1_HOST, port = self.AGG1_PORT,
                                  xprt = self.AGG1_XPRT, auth = self.AUTH,
                                  auth_opt = self.AUTH_OPT)
     attr = LDMSD_Req_Attr(value = None, attr_id = LDMSD_Req_Attr.PATH)
     attr_term = LDMSD_Req_Attr()
     req = LDMSD_Request(command_id = LDMSD_Request.GREETING, attrs = [attr, attr_term])
     req.send(ctrl)
     resp = req.receive(ctrl)
     ctrl.close()
     self.assertEqual(len(resp['attr_list']), 1)
     self.assertEqual(resp['attr_list'][0].attr_value,
                     "{0}:{1}".format(self.SMP_NAME, self.AGG1_NAME))
     self.assertTrue(self.smp.is_running())
     self.assertTrue(self.agg1.is_running())
Ejemplo n.º 14
0
 def thread_stats(self, reset=False):
     """Query the daemon's I/O thread utilization data"""
     req = LDMSD_Request(
             command_id=LDMSD_Request.THREAD_STATS,
             attrs=[
                 LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.RESET,
                             value=str(reset)),
             ])
     try:
         req.send(self)
         resp = req.receive(self)
         return resp['errcode'], resp['msg']
     except Exception:
         self.close()
         return errno.ENOTCONN, None
Ejemplo n.º 15
0
 def setUpClass(cls):
     log.info("Setting up TestLDMSAuthNaive")
     ldms.ldms_init(512 * 1024 * 1024)  # 512MB should suffice
     cls.ldmsd = LDMSD(port=cls.PORT, auth=cls.AUTH, auth_opt=cls.AUTH_OPT)
     log.info("starting ldmsd")
     cls.ldmsd.run()
     cls.cfg = ldmsdInbandConfig(host="localhost",
                                 port=cls.PORT,
                                 xprt=cls.XPRT,
                                 auth=cls.AUTH,
                                 auth_opt=cls.AUTH_OPT)
     # NOTE: cls.cfg automatically create an LDMS xprt and connect to the
     #       target ldmsd.
     cmds = []
     for _set, _perm in zip(cls.SETS, cls.PERMS):
         cmds.append("load name=%s" % _set)
         cmds.append("config name=%(set)s producer=test1 instance=%(set)s \
                      schema=%(set)s component_id=1 \
                      uid=%(uid)s gid=%(gid)s perm=%(perm)s" % {
             "set": _set,
             "uid": cls.UID,
             "gid": cls.GID,
             "perm": _perm,
         })
         cmds.append("start name=%s interval=1000000" % _set)
     log.info("configuring ldmsd over LDMS xprt")
     for cmd in cmds:
         req = LDMSD_Request.from_str(cmd)
         req.send(cls.cfg)
         resp = req.receive(cls.cfg)
         errcode = resp["errcode"] if "errcode" in resp else 0
         if errcode:
             raise RuntimeError("LDMSD request errcode: %d" % errcode)
     time.sleep(1)
     log.info("TestLDMSAuthNaive setup complete")
Ejemplo n.º 16
0
    def updtr_start(self, name, interval=None, auto=None):
        """
        Start a STOPPED updater.

        Parameters:
        - The name of the updater to start.

        Keyword Parameters:
        interval  - The update data collection interval. This is required
                    if auto is False.
        auto      - [True|False] If True, the updater will schedule
                    set updates according to the update hint. The sets
                    with no hints will not be updated. If False, the
                    updater will schedule the set updates according to
                    the given sample interval. The default is False.

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        attrs = [
            LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
        ]
        if interval:
            intrvl_us, offset_us = cvt_sample_intrvl_str_to_us(interval)
            if auto:
                return errno.EINVAL, "'auto' is incompatible with 'interval'"
            attrs += [
                LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.INTERVAL, value=str(intrvl_us)),
                LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.OFFSET, value=str(offset_us))
            ]
        elif auto:
            attrs += [
                LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.AUTO_INTERVAL, value=str(auto))
            ]

        req = LDMSD_Request(command_id=LDMSD_Request.UPDTR_START, attrs=attrs)
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 17
0
    def prdcr_start(self, name, regex=True, reconnect=None):
        """
        Start one or more STOPPED producers

        Parameters:
        - The name of the producer to start. If regex=True (default),
          this is a regular expression.

        Keyword Parameters:
        regex     - True, the 'name' parameter is a regular expression.
                    Default is False.
        reconnect - The reconnect interval in microseconds. If not None, this
                    will override the interval specified when the producer
                    was created. Default is None.

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        if regex:
            cmd_id = LDMSD_Request.PRDCR_START_REGEX
            name_id = LDMSD_Req_Attr.REGEX
        else:
            cmd_id = LDMSD_Request.PRDCR_START
            name_id = LDMSD_Req_Attr.NAME

        attrs = [
            LDMSD_Req_Attr(attr_id = name_id, value=name),
        ]
        if reconnect:
            attrs.append(LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.INTERVAL,
                                        value = str(reconnect)))

        req = LDMSD_Request(command_id = cmd_id, attrs = attrs)
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 18
0
 def smplr_start(self, name, interval_str):
     intrvl_us, offset_us = cvt_sample_intrvl_str_to_us(interval_str)
     req = LDMSD_Request(
             command_id = LDMSD_Request.PLUGN_START,
             attrs=[
                 LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
                 LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.INTERVAL, value=str(intrvl_us)),
                 LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.OFFSET, value=str(offset_us))
             ])
     try:
         req.send(self)
         resp = req.receive(self)
         err = resp['errcode']
     except Exception:
         self.close()
         return errno.ENOTCONN, None
     if err == 0 and resp['msg'] is not None:
         status = json.loads(resp['msg'])
     else:
         status = None
     return err, status
Ejemplo n.º 19
0
 def _ldmsd_ctrl(self, cmd, uid=LDMSD_UID, gid=LDMSD_GID):
     cfg = ldmsdInbandConfig(host="localhost",
                             port=self.AGG_PORT,
                             xprt=self.XPRT,
                             auth=self.AUTH,
                             auth_opt={
                                 "uid": str(uid),
                                 "gid": str(gid)
                             })
     req = LDMSD_Request.from_str(cmd)
     req.send(cfg)
     resp = req.receive(cfg)
     cfg.close()
     return resp
Ejemplo n.º 20
0
    def plugn_load(self, name):
        """
        Load an LDMSD plugin.

        Parameters::
        name  - The plugin name

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        req = LDMSD_Request(
                command_id=LDMSD_Request.PLUGN_LOAD,
                attrs=[
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            return errno.ENOTCONN, None
Ejemplo n.º 21
0
    def strgp_start(self, name):
        """
        Start a STOPPED storage policy.

        Parameters:
        - The name of the storage policy to start.

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        attrs = [
            LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
        ]
        req = LDMSD_Request(command_id=LDMSD_Request.STRGP_START, attrs=attrs)
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 22
0
    def plugn_stop(self, name):
        """
        Stop a LDMSD Plugin

        Parameters:
        - The plugin name
        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        req = LDMSD_Request(
                command_id=LDMSD_Request.PLUGN_STOP,
                attrs=[
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name)
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception as e:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 23
0
    def req(self, cmd_line):
        """Form LDMSD_Request according to `cmd_line` and send.

        Returns the response received from the daemon.
        """
        if not self._conn:
            raise RuntimeError("Error: no LDMS connection")
        verb, args = ( cmd_line.split(" ", 1) + [None] )[:2]
        attr_list = []
        if args:
            attr_s = []
            attr_str_list = args.split()
            for attr_str in attr_str_list:
                name = None
                value = None
                [name, value] = (attr_str.split("=", 1) + [None])[:2]
                if (verb == "config" and name != "name") or (verb == "env"):
                    attr_s.append(attr_str)
                elif (verb == "auth_add" and name not in ["name", "plugin"]):
                    attr_s.append(attr_str)
                else:
                    try:
                        attr = LDMSD_Req_Attr(value = value, attr_name = name)
                    except KeyError:
                        attr_s.append(attr_str)
                    except Exception:
                        raise
                    else:
                        attr_list.append(attr)
            if len(attr_s) > 0:
                attr_str = " ".join(attr_s)
                attr = LDMSD_Req_Attr(value = attr_str, attr_id = LDMSD_Req_Attr.STRING)
                attr_list.append(attr)
        request = LDMSD_Request(command = verb, attrs = attr_list)
        request.send(self)
        resp = request.receive(self)
        return resp
Ejemplo n.º 24
0
    def prdcrset_status(self, name = None, instance = None, schema = None):
        """
        Query the LDMSD for one or all producer's set status

        Keyword Parameters:
        name     - If not None (default), the producer to query
        instance - If not None (default), the set's instance name
        schema   - If not None (default), the set's schema name

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or
          the object containing the producer sets status
        """
        attrs = []
        if name:
            attrs.append(attrs.append(LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name)))
        if instance:
            attrs.append(attrs.append(LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.INSTANCE, value=instance)))
        if schema:
            attrs.append(attrs.append(LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.SCHEMA, value=schema)))
        if len(attrs) == 0:
            attrs = None    
        req = LDMSD_Request(command_id=LDMSD_Request.PRDCR_SET_STATUS, attrs=attrs)
        try:
            req.send(self)
            resp = req.receive(self)
        except Exception:
            self.close()
            return errno.ENOTCONN, None
        err = resp['errcode']
        if err == 0:
            status = json.loads(resp['msg'])
        else:
            status = None
        return err, status
Ejemplo n.º 25
0
    def strgp_del(self, name):
        """
        Delete a storage policy. The storage policy cannot be RUNNING.

        Parameters:
        name - The policy name

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        req = LDMSD_Request(
                command_id=LDMSD_Request.STRGP_DEL,
                attrs = [
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name)
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 26
0
 def plugn_start(self, name, interval_us, offset_us=None):
     # If offset unspecified, start in non-synchronous mode
     req_attrs = [ LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name),
                   LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.INTERVAL, value=str(interval_us))
                 ]
     if offset_us != None:
         offset_us = check_offset(interval_us, offset_us)
         req_attrs.append(LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.OFFSET, value=str(offset_us)))
     req = LDMSD_Request(
             command_id = LDMSD_Request.PLUGN_START,
             attrs=req_attrs
             )
     try:
         req.send(self)
         resp = req.receive(self)
         err = resp['errcode']
     except Exception:
         self.close()
         return errno.ENOTCONN, None
     if err == 0 and resp['msg'] is not None:
         status = json.loads(resp['msg'])
     else:
         status = None
     return err, status
Ejemplo n.º 27
0
    def prdcr_stop(self, name, regex=True):
        """
        Stop one or more RUNNING producers

        Parameters:
        - The name of the producer to start. If regex=True (default),
          this is a regular expression.

        Keyword Parameters:
        regex     - True, the 'name' parameter is a regular expression.
                    Default is False.

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        if regex:
            cmd_id = LDMSD_Request.PRDCR_STOP_REGEX
            name_id = LDMSD_Req_Attr.REGEX
        else:
            cmd_id = LDMSD_Request.PRDCR_STOP
            name_id = LDMSD_Req_Attr.NAME

        attrs = [
            LDMSD_Req_Attr(attr_id = name_id, value=name),
        ]

        req = LDMSD_Request(command_id = cmd_id, attrs = attrs)
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 28
0
    def updtr_stop(self, name):
        """
        Stop a RUNNING updater.

        Parameters:
        - The name of the updater

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or None
        """
        req = LDMSD_Request(
                command_id=LDMSD_Request.UPDTR_STOP,
                attrs=[
                    LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name)
                ])
        try:
            req.send(self)
            resp = req.receive(self)
            return resp['errcode'], resp['msg']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
Ejemplo n.º 29
0
    def smplrset_status(self, name=None):
        """
        Return the metric sets provided by a sampler plugin.

        Keyword Parameters:
        name  - The name of the sampler to query. If None (default), all
                samplers are queried.

        Returns:
        A tuple of status, data
        - status is an errno from the errno module
        - data is an error message if status != 0 or
          the object containing the sampler set status
        """
        if name:
            attrs = [
                LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name)
            ]
        else:
            attrs = None
        req = LDMSD_Request(
                command_id=LDMSD_Request.PLUGN_SETS,
                attrs=attrs
        )
        try:
            req.send(self)
            resp = req.receive(self)
            err = resp['errcode']
        except Exception:
            self.close()
            return errno.ENOTCONN, None
        if err == 0:
            status = json.loads(resp['msg'])
        else:
            status = None
        return err, status
Ejemplo n.º 30
0
 def auth_add(self, name, auth_opt=None):
     """
     Add an authentication domain
     Parameters:
     name - The authentication domain name
     <plugin-specific attribute> e.g. conf=ldmsauth.conf
     """
     attrs=[ LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.NAME, value=name) ]
     if auth_opt:
         if len(auth_opt.split('=')) > 1:
             attrs.append(LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.STRING, value=auth_opt))
         else:
             auth_opt = 'conf='+auth_opt
             attrs.append(LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.STRING, value=auth_opt))
     req = LDMSD_Request(
             command_id=LDMSD_Request.AUTH_ADD,
             attrs=attrs
             )
     try:
         req.send(self)
         resp = req.receive(self)
         return resp['errcode'], resp['msg']
     except Exception:
         return errno.ENOTCONN, None