예제 #1
0
    def __init__(self, logger):
        Check.__init__(self, logger)

        self.gauge('system.proc.queue_length')
        self.gauge('system.proc.count')
        self.numprocs = WinPDHCounter('System', 'Processes', logger)
        self.pql = WinPDHCounter('System', 'Processor Queue Length', logger)
예제 #2
0
    def __init__(self, name, init_config, agentConfig, instances=None):
        AgentCheck.__init__(self, name, init_config, agentConfig, instances)
        self._countersettypes = {}
        self._counters = {}
        self._metrics = {}
        self._tags = {}

        try:
            for instance in instances:
                key = hash_mutable(instance)
                counterset = instance.get('countersetname')

                cfg_tags = instance.get('tags')
                if cfg_tags is not None:
                    tags = cfg_tags.join(",")
                    self._tags[key] = list(tags) if tags else []

                metrics = instance.get('metrics')
                # list of the metrics.  Each entry is itself an entry,
                # which is the pdh name, datadog metric name, type, and the
                # pdh counter object
                self._metrics[key] = []
                for inst_name, dd_name, mtype in metrics:
                    m = getattr(self, mtype.lower())
                    obj = WinPDHCounter(counterset, inst_name, self.log)
                    entry = [inst_name, dd_name, m, obj]
                    self.log.debug("entry: %s" % str(entry))
                    self._metrics[key].append(entry)

        except Exception as e:
            self.log.debug("Exception in PDH init: %s", str(e))
            raise
예제 #3
0
    def __init__(self, logger):
        Check.__init__(self, logger)

        self.gauge('system.io.wkb_s')
        self.gauge('system.io.w_s')
        self.gauge('system.io.rkb_s')
        self.gauge('system.io.r_s')
        self.gauge('system.io.avg_q_sz')

        self.dwbpscounter = WinPDHCounter('LogicalDisk',
                                          'Disk Write Bytes/sec', logger)
        self.dwpscounter = WinPDHCounter('LogicalDisk', 'Disk Writes/sec',
                                         logger)
        self.drbpscounter = WinPDHCounter('LogicalDisk', 'Disk Read Bytes/sec',
                                          logger)
        self.drpscounter = WinPDHCounter('LogicalDisk', 'Disk Reads/sec',
                                         logger)
        self.qszcounter = WinPDHCounter('LogicalDisk',
                                        'Current Disk Queue Length', logger)
예제 #4
0
    def __init__(self, logger):
        Check.__init__(self, logger)

        self.gauge('system.mem.free')
        self.gauge('system.mem.used')
        self.gauge('system.mem.total')
        # area of physical memory that stores recently used pages of data
        # for applications
        self.gauge('system.mem.cached')
        # Committed memory is physical memory for which space has been
        # reserved on the disk paging file in case it must be written
        # back to disk
        self.gauge('system.mem.committed')
        # physical memory used by the operating system, for objects
        # that can be written to disk when they are not being used
        self.gauge('system.mem.paged')
        # physical memory used by the operating system for objects that
        # cannot be written to disk, but must remain in physical memory
        # as long as they are allocated.
        self.gauge('system.mem.nonpaged')
        # usable = free + cached
        self.gauge('system.mem.usable')
        self.gauge('system.mem.pct_usable')
        #  details about the usage of the pagefile.
        self.gauge('system.mem.pagefile.total')
        self.gauge('system.mem.pagefile.used')
        self.gauge('system.mem.pagefile.free')
        self.gauge('system.mem.pagefile.pct_free')

        self.cache_bytes_counter = WinPDHCounter('Memory', 'Cache Bytes',
                                                 logger)
        self.committed_bytes_counter = WinPDHCounter('Memory',
                                                     'Committed Bytes', logger)
        self.pool_paged_bytes_counter = WinPDHCounter('Memory',
                                                      'Pool Paged Bytes',
                                                      logger)
        self.pool_non_paged_bytes_counter = WinPDHCounter(
            'Memory', 'Pool Nonpaged Bytes', logger)
예제 #5
0
    def __init__(self, name, init_config, agentConfig, instances,
                 counter_list):
        AgentCheck.__init__(self, name, init_config, agentConfig, instances)
        self._countersettypes = {}
        self._counters = {}
        self._metrics = {}
        self._tags = {}

        try:
            for instance in instances:
                key = hash_mutable(instance)

                cfg_tags = instance.get('tags')
                if cfg_tags is not None:
                    if not isinstance(cfg_tags, list):
                        self.log.error("Tags must be configured as a list")
                        raise ValueError("Tags must be type list, not %s" %
                                         str(type(cfg_tags)))
                    self._tags[key] = list(cfg_tags)

                remote_machine = None
                host = instance.get('host')
                self._metrics[key] = []
                if host is not None and host != ".":
                    try:
                        remote_machine = host

                        username = instance.get('username')
                        password = instance.get('password')
                        nr = win32wnet.NETRESOURCE()
                        nr.lpRemoteName = r"\\%s\c$" % remote_machine
                        nr.dwType = 0
                        nr.lpLocalName = None
                        win32wnet.WNetAddConnection2(nr, password, username, 0)

                    except Exception as e:
                        self.log.error("Failed to make remote connection %s" %
                                       str(e))
                        return

                # list of the metrics.  Each entry is itself an entry,
                # which is the pdh name, datadog metric name, type, and the
                # pdh counter object

                for counterset, inst_name, counter_name, dd_name, mtype in counter_list:
                    m = getattr(self, mtype.lower())
                    obj = WinPDHCounter(counterset,
                                        counter_name,
                                        self.log,
                                        inst_name,
                                        machine_name=remote_machine)
                    entry = [inst_name, dd_name, m, obj]
                    self.log.debug("entry: %s" % str(entry))
                    self._metrics[key].append(entry)

                # get any additional metrics in the instance
                addl_metrics = instance.get('additional_metrics')
                if addl_metrics is not None:
                    for counterset, inst_name, counter_name, dd_name, mtype in addl_metrics:
                        if inst_name.lower() == "none" or len(
                                inst_name
                        ) == 0 or inst_name == "*" or inst_name.lower(
                        ) == "all":
                            inst_name = None
                        m = getattr(self, mtype.lower())
                        obj = WinPDHCounter(counterset,
                                            counter_name,
                                            self.log,
                                            inst_name,
                                            machine_name=remote_machine)
                        entry = [inst_name, dd_name, m, obj]
                        self.log.debug("additional metric entry: %s" %
                                       str(entry))
                        self._metrics[key].append(entry)

        except Exception as e:
            self.log.debug("Exception in PDH init: %s", str(e))
            raise
예제 #6
0
    def __init__(self, name, init_config, agentConfig, instances,
                 counter_list):
        AgentCheck.__init__(self, name, init_config, agentConfig, instances)
        self._countersettypes = {}
        self._counters = {}
        self._metrics = {}
        self._tags = {}

        try:
            for instance in instances:
                key = hash_mutable(instance)

                cfg_tags = instance.get('tags')
                if cfg_tags is not None:
                    if not isinstance(cfg_tags, list):
                        self.log.error("Tags must be configured as a list")
                        raise ValueError("Tags must be type list, not %s" %
                                         str(type(cfg_tags)))
                    self._tags[key] = list(cfg_tags)

                remote_machine = None
                host = instance.get('host')
                self._metrics[key] = []
                if host is not None and host != ".":
                    try:
                        remote_machine = host

                        username = instance.get('username')
                        password = instance.get('password')
                        nr = win32wnet.NETRESOURCE()
                        nr.lpRemoteName = r"\\%s\c$" % remote_machine
                        nr.dwType = 0
                        nr.lpLocalName = None
                        win32wnet.WNetAddConnection2(nr, password, username, 0)

                    except Exception as e:
                        self.log.error("Failed to make remote connection %s" %
                                       str(e))
                        return

                ## counter_data_types allows the precision with which counters are queried
                ## to be configured on a per-metric basis. In the metric instance, precision
                ## should be specified as
                ## counter_data_types:
                ## - iis.httpd_request_method.get,int
                ## - iis.net.bytes_rcvd,float
                ##
                ## the above would query the counter associated with iis.httpd_request_method.get
                ## as an integer (LONG) and iis.net.bytes_rcvd as a double
                datatypes = {}
                precisions = instance.get('counter_data_types')
                if precisions is not None:
                    if not isinstance(precisions, list):
                        self.log.warning(
                            "incorrect type for counter_data_type %s" %
                            str(precisions))
                    else:
                        for p in precisions:
                            k, v = p.split(",")
                            v = v.lower().strip()
                            if v in int_types:
                                self.log.info(
                                    "Setting datatype for %s to integer" % k)
                                datatypes[k] = DATA_TYPE_INT
                            elif v in double_types:
                                self.log.info(
                                    "Setting datatype for %s to double" % k)
                                datatypes[k] = DATA_TYPE_DOUBLE
                            else:
                                self.log.warning("Unknown data type %s" %
                                                 str(v))

                # list of the metrics.  Each entry is itself an entry,
                # which is the pdh name, datadog metric name, type, and the
                # pdh counter object

                for counterset, inst_name, counter_name, dd_name, mtype in counter_list:
                    m = getattr(self, mtype.lower())

                    precision = datatypes.get(dd_name)

                    obj = WinPDHCounter(counterset,
                                        counter_name,
                                        self.log,
                                        inst_name,
                                        machine_name=remote_machine,
                                        precision=precision)
                    entry = [inst_name, dd_name, m, obj]
                    self.log.debug("entry: %s" % str(entry))
                    self._metrics[key].append(entry)

                # get any additional metrics in the instance
                addl_metrics = instance.get('additional_metrics')
                if addl_metrics is not None:
                    for counterset, inst_name, counter_name, dd_name, mtype in addl_metrics:
                        if inst_name.lower() == "none" or len(
                                inst_name
                        ) == 0 or inst_name == "*" or inst_name.lower(
                        ) == "all":
                            inst_name = None
                        m = getattr(self, mtype.lower())

                        precision = datatypes.get(dd_name)

                        obj = WinPDHCounter(counterset,
                                            counter_name,
                                            self.log,
                                            inst_name,
                                            machine_name=remote_machine,
                                            precision=precision)
                        entry = [inst_name, dd_name, m, obj]
                        self.log.debug("additional metric entry: %s" %
                                       str(entry))
                        self._metrics[key].append(entry)

        except Exception as e:
            self.log.debug("Exception in PDH init: %s", str(e))
            raise