Exemplo n.º 1
0
 def _configDevBytes(self, namestr, titlestr, devlist):
     """Generate configuration for I/O Throughput stats.
     
     @param namestr:  Field name component indicating device type.
     @param titlestr: Title component indicating device type.
     @param devlist:  List of devices.
     
     """
     name = 'diskio_%s_bytes' % namestr
     if self.graphEnabled(name):
         graph = MuninGraph('Disk I/O - %s - Throughput' % titlestr, self._category,
             info='Disk I/O - %s Throughput, bytes read / written per second.'
                  % titlestr,
             args='--base 1000 --lower-limit 0', printf='%6.1lf',
             vlabel='bytes/sec read (-) / write (+)',
             autoFixNames = True)
         for dev in devlist:
             graph.addField(dev + '_read', 
                            fixLabel(dev, maxLabelLenGraphDual, 
                                     repl = '..', truncend=False,
                                     delim = self._labelDelim.get(namestr)),
                            draw='LINE2', type='DERIVE', min=0, graph=False)
             graph.addField(dev + '_write', 
                            fixLabel(dev, maxLabelLenGraphDual, 
                                     repl = '..', truncend=False,
                                     delim = self._labelDelim.get(namestr)),
                            draw='LINE2', type='DERIVE', min=0, 
                            negative=(dev + '_read'), info=dev)
         self.appendGraph(name, graph)
Exemplo n.º 2
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """      
        MuninPlugin.__init__(self, argv, env, debug)

        if self.graphEnabled('ntp_peer_stratum'):
            graph = MuninGraph('NTP Stratum for System Peer', 'Time',
                info='Stratum of the NTP Server the system is in sync with.',
                args='--base 1000 --lower-limit 0')
            graph.addField('stratum', 'stratum', type='GAUGE', draw='LINE2')
            self.appendGraph('ntp_peer_stratum', graph)

        if self.graphEnabled('ntp_peer_stats'):
            graph = MuninGraph('NTP Timing Stats for System Peer', 'Time',
                info='Timing Stats for the NTP Server the system is in sync with.',
                args='--base 1000 --lower-limit 0',
                vlabel='seconds'
                )
            graph.addField('offset', 'offset', type='GAUGE', draw='LINE2')
            graph.addField('delay', 'delay', type='GAUGE', draw='LINE2')
            graph.addField('jitter', 'jitter', type='GAUGE', draw='LINE2')
            self.appendGraph('ntp_peer_stats', graph)
Exemplo n.º 3
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        if self.graphEnabled("ntp_peer_stratum"):
            graph = MuninGraph(
                "NTP Stratum for System Peer",
                "Time",
                info="Stratum of the NTP Server the system is in sync with.",
                args="--base 1000 --lower-limit 0",
            )
            graph.addField("stratum", "stratum", type="GAUGE", draw="LINE2")
            self.appendGraph("ntp_peer_stratum", graph)

        if self.graphEnabled("ntp_peer_stats"):
            graph = MuninGraph(
                "NTP Timing Stats for System Peer",
                "Time",
                info="Timing Stats for the NTP Server the system is in sync with.",
                args="--base 1000 --lower-limit 0",
                vlabel="seconds",
            )
            graph.addField("offset", "offset", type="GAUGE", draw="LINE2")
            graph.addField("delay", "delay", type="GAUGE", draw="LINE2")
            graph.addField("jitter", "jitter", type="GAUGE", draw="LINE2")
            self.appendGraph("ntp_peer_stats", graph)
Exemplo n.º 4
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        if self.arg0 is None:
            raise Exception("Remote host name cannot be determined.")
        else:
            self._remoteHost = self.arg0

        if self.graphEnabled('ntp_host_stratum'):
            graphName = 'ntp_host_stratum_%s' % self._remoteHost
            graph = MuninGraph('NTP Stratum of Host %s' % self._remoteHost, 
                'Time',
                info='NTP Stratum of Host %s.' % self._remoteHost,
                args='--base 1000 --lower-limit 0')
            graph.addField('stratum', 'stratum', type='GAUGE', draw='LINE2')
            self.appendGraph(graphName, graph)

        if self.graphEnabled('ntp_host_offset'):
            graphName = 'ntp_host_offset_%s' % self._remoteHost
            graph = MuninGraph('NTP Offset of Host %s' % self._remoteHost, 'Time',
                info=('NTP Offset of Host %s relative to current node.' 
                      % self._remoteHost),
                args='--base 1000 --lower-limit 0',
                vlabel='seconds'
                )
            graph.addField('offset', 'offset', type='GAUGE', draw='LINE2')
            graph.addField('delay', 'delay', type='GAUGE', draw='LINE2')
            self.appendGraph(graphName, graph)
Exemplo n.º 5
0
 def __init__(self, argv=(), env={}, debug=False):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self._host = self.envGet('host')
     self._port = self.envGet('port', None, int)
     self._user = self.envGet('user')
     self._monpath = self.envGet('monpath')
     self._password = self.envGet('password')
     self._ssl = self.envCheckFlag('ssl', False) 
     
     if self.graphEnabled('php_fpm_connections'):
         graph = MuninGraph('PHP FPM - Connections per second', 'PHP',
             info='PHP Fast Process Manager (FPM) - Connections per second.',
             args='--base 1000 --lower-limit 0')
         graph.addField('conn', 'conn', draw='LINE2', type='DERIVE', min=0)
         self.appendGraph('php_fpm_connections', graph)
     
     if self.graphEnabled('php_fpm_processes'):
         graph = MuninGraph('PHP FPM - Processes', 'PHP',
             info='PHP Fast Process Manager (FPM) - Active / Idle Processes.',
             args='--base 1000 --lower-limit 0')
         graph.addField('active', 'active', draw='AREASTACK', type='GAUGE')
         graph.addField('idle', 'idle', draw='AREASTACK', type='GAUGE')
         graph.addField('total', 'total', draw='LINE2', type='GAUGE',
                        colour='000000')
         self.appendGraph('php_fpm_processes', graph)
Exemplo n.º 6
0
 def _configDevActive(self, namestr, titlestr, devlist):
     """Generate configuration for I/O Queue Length.
     
     @param namestr:  Field name component indicating device type.
     @param titlestr: Title component indicating device type.
     @param devlist:  List of devices.
     
     """
     name = 'diskio_%s_active' % namestr
     if self.graphEnabled(name):
         graph = MuninGraph(
             'Disk I/O - %s - Queue Length' % titlestr,
             'Disk I/O',
             info=
             'Disk I/O - Number  of I/O Operations in Progress for every %s.'
             % titlestr,
             args='--base 1000 --lower-limit 0',
             printf='%6.1lf',
             autoFixNames=True)
         for dev in devlist:
             graph.addField(dev,
                            fixLabel(dev,
                                     maxLabelLenGraphSimple,
                                     repl='..',
                                     truncend=False,
                                     delim=self._labelDelim.get(namestr)),
                            draw='AREASTACK',
                            type='GAUGE',
                            info=dev)
         self.appendGraph(name, graph)
Exemplo n.º 7
0
    def __init__(self, argv=(), env=None, debug=False):
        MuninPlugin.__init__(self, argv, env, debug)

        graphs = [
            ('stats_active_users', 'Active Users', 'Active Users',
             'Active Users', 'LINE2', 'GAUGE', '--lower-limit 0'),
            ('stats_authorized_requests', 'Authorized Requests',
             'Authorized Requests', 'Authorized Requests', 'LINE2', 'GAUGE',
             '--lower-limit 0'),
            ('stats_https_connects', 'HTTPS Connects', 'HTTPS Connects',
             'HTTPS Connects', 'LINE2', 'GAUGE', '--lower-limit 0'),
            ('stats_request_errors', 'Request Errors', 'Request Errors',
             'Request Errors', 'LINE2', 'GAUGE', '--lower-limit 0'),
            ('stats_request_intercepted', 'Intercepted Requests',
             'Intercepted Requests', 'Intercepted Requests', 'LINE2', 'GAUGE',
             '--lower-limit 0'),
            ('stats_non_activated_users', 'Non-activated users',
             'Non-activated users', 'Non-activated users', 'LINE2', 'GAUGE',
             '--lower-limit 0'),
            ('stats_not_authorized_requests', 'Not Authorized Requests',
             'Not Authorized Requests', 'Not Authorized Requests', 'LINE2',
             'GAUGE', '--lower-limit 0'),
            ('stats_proxy_sessions', 'Proxy Sessions', 'Proxy Sessions',
             'Proxy Sessions', 'LINE2', 'GAUGE', '--lower-limit 0'),
            ('stats_ratelimited_requests', 'Rate limited requests',
             'Proxy Sessions', 'Proxy Sessions', 'LINE2', 'GAUGE',
             '--lower-limit 0'),
            ('stats_requests', 'Requests', 'Requests', 'Requests', 'LINE2',
             'GAUGE', '--lower-limit 0'),
            ('stats_responses', 'Responses', 'Responses', 'Responses', 'LINE2',
             'GAUGE', '--lower-limit 0'),
            ('stats_saved_requests', 'Saved Requests', 'Saved Requests',
             'Saved Requests', 'LINE2', 'GAUGE', '--lower-limit 0'),
            ('stats_worker_queue', 'Worker Queue', 'Worker Queue',
             'Worker Queue', 'LINE2', 'GAUGE', '--lower-limit 0'),
        ]

        self._category = 'debugproxy'
        self.identity = 'debugproxy'
        self._stats = defaultdict(dict)

        for (graph_name, graph_title, graph_info, graph_vlabel, graph_draw,
             graph_type, graph_args) in graphs:
            if self.graphEnabled(graph_name):
                graph = MuninGraph('debugProxy - {0}'.format(graph_title),
                                   self._category,
                                   info=graph_info,
                                   vlabel=graph_vlabel,
                                   args=graph_args)

                graph.addField("count",
                               "count",
                               draw=graph_draw,
                               type=graph_type,
                               info=graph_info,
                               min=0)

                self.appendGraph(graph_name, graph)
    def __init__(self, argv=(), env=None, debug=False):
        MuninPlugin.__init__(self, argv, env, debug)

        graphs = [
            ('supervisord_processes_memory_usage', 'Memory usage',
             'Memory usage', 'Memory usage (MiB)', 'LINE2', 'GAUGE', None),
            ('supervisord_processes_cpu_percent',
             'CPU utilization as a percentage',
             'CPU utilization as a percentage', 'CPU percentage', 'LINE2',
             'GAUGE', None),
            ('supervisord_processes_num_fds', 'File descriptors used',
             'File descriptors used', None, 'LINE2', 'GAUGE',
             '--lower-limit 0'),
            ('supervisord_processes_num_threads', 'Threads currently used',
             'Threads currently used', None, 'LINE2', 'GAUGE',
             '--lower-limit 0'),
            ('supervisord_processes_num_connections',
             'Socket connections opened', 'Socket connections opened', None,
             'LINE2', 'GAUGE', '--lower-limit 0')
        ]

        self._category = 'supervisord'
        transport = supervisor.xmlrpc.SupervisorTransport(
            None, None, serverurl=self.envGet('url'))
        proxy = xmlrpclib.ServerProxy('http://127.0.0.1', transport=transport)
        # print proxy.supervisor.getState()
        self.identity = '{0}_{1}'.format(proxy.supervisor.getIdentification(),
                                         proxy.supervisor.getPID())
        self.entries = proxy.supervisor.getAllProcessInfo()
        self._stats = defaultdict(dict)

        for (graph_name, graph_title, graph_info, graph_vlabel, graph_draw,
             graph_type, graph_args) in graphs:
            if self.graphEnabled(graph_name):
                graph = MuninGraph('Supervisord - {0}'.format(graph_title),
                                   self._category,
                                   info=graph_info,
                                   vlabel=graph_vlabel,
                                   args=graph_args)

                for entry in self.entries:
                    if entry['statename'] not in ('RUNNING', ):
                        continue

                    label_fmt = entry['group'] == entry[
                        'name'] and '{name}.{pid}' or '{group}:{name}'
                    graph.addField(
                        entry['name'],
                        label_fmt.format(**entry),
                        draw=graph_draw,
                        type=graph_type,
                        info=graph_info,
                        min=graph_name.startswith('supervisord_processes_num_')
                        and 0 or None)

                if graph.getFieldCount() > 0:
                    self.appendGraph(graph_name, graph)
Exemplo n.º 9
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        if self.arg0 is None:
            raise Exception("Remote host name cannot be determined.")
        else:
            self._remoteHost = self.arg0

        if self.graphEnabled('ntp_host_stratum'):
            graphName = 'ntp_host_stratum_%s' % self._remoteHost
            graph = MuninGraph('NTP Stratum of Host %s' % self._remoteHost, 
                'Time',
                info='NTP Stratum of Host %s.' % self._remoteHost,
                args='--base 1000 --lower-limit 0')
            graph.addField('stratum', 'stratum', type='GAUGE', draw='LINE2')
            self.appendGraph(graphName, graph)

        if self.graphEnabled('ntp_host_stat'):
            graphName = 'ntp_host_stat_%s' % self._remoteHost
            graph = MuninGraph('NTP Offset of Host %s' % self._remoteHost, 'Time',
                info=('NTP Offset of Host %s relative to current node.' 
                      % self._remoteHost),
                args='--base 1000 --lower-limit 0',
                vlabel='seconds'
                )
            graph.addField('offset', 'offset', type='GAUGE', draw='LINE2')
            graph.addField('delay', 'delay', type='GAUGE', draw='LINE2')
            self.appendGraph(graphName, graph)
Exemplo n.º 10
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._fshost = self.envGet('fshost')
        self._fsport = self.envGet('fsport')
        self._fspass = self.envGet('fspass')

        if self.graphEnabled('fs_calls'):
            graph = MuninGraph('FreeSWITCH - Active Calls',
                               'FreeSwitch',
                               info='FreeSWITCH - Number of Active Calls.',
                               args='--base 1000 --lower-limit 0')
            graph.addField('calls',
                           'calls',
                           type='GAUGE',
                           draw='LINE2',
                           info='Active Calls')
            self.appendGraph('fs_calls', graph)

        if self.graphEnabled('fs_channels'):
            graph = MuninGraph('FreeSWITCH - Active Channels',
                               'FreeSWITCH',
                               info='FreeSWITCH - Number of Active Channels.',
                               args='--base 1000 --lower-limit 0')
            graph.addField('channels', 'channels', type='GAUGE', draw='LINE2')
            self.appendGraph('fs_channels', graph)
Exemplo n.º 11
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        if self.envHasKey("ntphosts"):
            hosts_str = re.sub("[^\d\.,]", "", self.envGet("ntphosts"))
            self._remoteHosts = hosts_str.split(",")
        else:
            raise AttributeError("Remote host list must be passed in the " "'ntphosts' environment variable.")

        if self.graphEnabled("ntp_host_stratums"):
            graph = MuninGraph(
                "NTP Stratums of Multiple Hosts",
                "Time",
                info="NTP Stratum of Multiple Remote Hosts.",
                args="--base 1000 --lower-limit 0",
            )
            for host in self._remoteHosts:
                hostkey = re.sub("\.", "_", host)
                graph.addField(hostkey, host, type="GAUGE", draw="LINE2")
            self.appendGraph("ntp_host_stratums", graph)

        if self.graphEnabled("ntp_host_offsets"):
            graph = MuninGraph(
                "NTP Offsets of Multiple Hosts",
                "Time",
                info="NTP Delays of Multiple Hosts relative to current node.",
                args="--base 1000 --lower-limit 0",
                vlabel="seconds",
            )
            for host in self._remoteHosts:
                hostkey = re.sub("\.", "_", host)
                graph.addField(hostkey, host, type="GAUGE", draw="LINE2")
            self.appendGraph("ntp_host_offsets", graph)

        if self.graphEnabled("ntp_host_delays"):
            graph = MuninGraph(
                "NTP Delays of Multiple Hosts",
                "Time",
                info="NTP Delays of Multiple Hosts relative to current node.",
                args="--base 1000 --lower-limit 0",
                vlabel="seconds",
            )
            for host in self._remoteHosts:
                hostkey = re.sub("\.", "_", host)
                graph.addField(hostkey, host, type="GAUGE", draw="LINE2")
            self.appendGraph("ntp_host_delays", graph)
Exemplo n.º 12
0
    def __init__(self, argv=(), env=None, debug=False):
        """
        Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('container', '^\w+$')
        self._username = self.envGet('username')
        self._api_key = self.envGet('api_key')
        self._region = self.envGet('region')
        self._servicenet = self.envCheckFlag('servicenet', False)
        self._category = 'Rackspace'

        self._fileInfo = CloudFilesInfo(username=self._username,
                                        api_key=self._api_key,
                                        region=self._region,
                                        servicenet=self._servicenet)
        self._fileContList = [
            name for name in self._fileInfo.getContainerList()
            if self.containerIncluded(name)
        ]

        if self.graphEnabled('rackspace_cloudfiles_container_size'):
            graph = MuninGraph(
                'Rackspace Cloud Files - Container Size (bytes)',
                self._category,
                info=
                'The total size of files for each Rackspace Cloud Files container.',
                args='--base 1024 --lower-limit 0',
                autoFixNames=True)
            for contname in self._fileContList:
                graph.addField(contname,
                               contname,
                               draw='AREASTACK',
                               type='GAUGE')
            self.appendGraph('rackspace_cloudfiles_container_size', graph)

        if self.graphEnabled('rackspace_cloudfiles_container_count'):
            graph = MuninGraph(
                'Rackspace Cloud Files - Container Object Count',
                self._category,
                info=
                'The total number of files for each Rackspace Cloud Files container.',
                args='--base 1024 --lower-limit 0',
                autoFixNames=True)
            for contname in self._fileContList:
                graph.addField(contname,
                               contname,
                               draw='AREASTACK',
                               type='GAUGE')
            self.appendGraph('rackspace_cloudfiles_container_count', graph)
Exemplo n.º 13
0
 def _configDevActive(self, namestr, titlestr, devlist):
     """Generate configuration for I/O Queue Length.
     
     @param namestr:  Field name component indicating device type.
     @param titlestr: Title component indicating device type.
     @param devlist:  List of devices.
     
     """
     name = 'diskio_%s_active' % namestr
     if self.graphEnabled(name):
         graph = MuninGraph('Disk I/O - %s - Queue Length' % titlestr, 
             'Disk I/O',
             info='Disk I/O - Number  of I/O Operations in Progress for every %s.'
                  % titlestr,
             args='--base 1000 --lower-limit 0')
         for dev in devlist:
             graph.addField(dev, dev, draw='AREASTACK', type='GAUGE')
         self.appendGraph(name, graph)
Exemplo n.º 14
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)
        self._category = 'Time'

        if self.envHasKey('ntphosts'):
            hosts_str = re.sub('[^\d\.,]', '', self.envGet('ntphosts'))
            self._remoteHosts = hosts_str.split(',')
        else:
            raise AttributeError("Remote host list must be passed in the "
                                 "'ntphosts' environment variable.")

        if self.graphEnabled('ntp_host_stratums'):
            graph = MuninGraph('NTP Stratums of Multiple Hosts', self._category,
                info='NTP Stratum of Multiple Remote Hosts.',
                args='--base 1000 --lower-limit 0')
            for host in self._remoteHosts:
                hostkey = re.sub('\.', '_', host)
                graph.addField(hostkey, host, type='GAUGE', draw='LINE2')
            self.appendGraph('ntp_host_stratums', graph)

        if self.graphEnabled('ntp_host_offsets'):
            graph = MuninGraph('NTP Offsets of Multiple Hosts', self._category,
                info='NTP Delays of Multiple Hosts relative to current node.',
                args ='--base 1000 --lower-limit 0',
                vlabel='seconds'
                )
            for host in self._remoteHosts:
                hostkey = re.sub('\.', '_', host)
                graph.addField(hostkey, host, type='GAUGE', draw='LINE2')
            self.appendGraph('ntp_host_offsets', graph)
    
        if self.graphEnabled('ntp_host_delays'):
            graph = MuninGraph('NTP Delays of Multiple Hosts', self._category,
                info='NTP Delays of Multiple Hosts relative to current node.',
                args='--base 1000 --lower-limit 0',
                vlabel='seconds'
                )
            for host in self._remoteHosts:
                hostkey = re.sub('\.', '_', host)
                graph.addField(hostkey, host, type='GAUGE', draw='LINE2')
            self.appendGraph('ntp_host_delays', graph)
Exemplo n.º 15
0
 def _configDevBytes(self, namestr, titlestr, devlist):
     """Generate configuration for I/O Throughput stats.
     
     @param namestr:  Field name component indicating device type.
     @param titlestr: Title component indicating device type.
     @param devlist:  List of devices.
     
     """
     name = 'diskio_%s_bytes' % namestr
     if self.graphEnabled(name):
         graph = MuninGraph('Disk I/O - %s - Throughput' % titlestr, 'Disk I/O',
             info='Disk I/O - %s Throughput, bytes read / written per second.'
                  % titlestr,
             args='--base 1000 --lower-limit 0',
             vlabel='bytes/sec read (-) / write (+)')
         for dev in devlist:
             graph.addField(dev + '_read', dev, draw='LINE2', type='DERIVE',
                 min=0, graph=False)
             graph.addField(dev + '_write', dev, draw='LINE2', type='DERIVE',
                 min=0, negative=(dev + '_read'))
         self.appendGraph(name, graph)
Exemplo n.º 16
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._fshost = self.envGet("fshost")
        self._fsport = self.envGet("fsport")
        self._fspass = self.envGet("fspass")

        if self.graphEnabled("fs_calls"):
            graph = MuninGraph(
                "FreeSWITCH - Active Calls",
                "FreeSwitch",
                info="FreeSWITCH - Number of Active Calls.",
                args="--base 1000 --lower-limit 0",
            )
            graph.addField("calls", "calls", type="GAUGE", draw="LINE2", info="Active Calls")
            self.appendGraph("fs_calls", graph)

        if self.graphEnabled("fs_channels"):
            graph = MuninGraph(
                "FreeSWITCH - Active Channels",
                "FreeSWITCH",
                info="FreeSWITCH - Number of Active Channels.",
                args="--base 1000 --lower-limit 0",
            )
            graph.addField("channels", "channels", type="GAUGE", draw="LINE2")
            self.appendGraph("fs_channels", graph)
Exemplo n.º 17
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._fshost = self.envGet('fshost')
        self._fsport = self.envGet('fsport', None, int)
        self._fspass = self.envGet('fspass')

        if self.graphEnabled('fs_calls'):
            graph = MuninGraph('FreeSWITCH - Active Calls', 'FreeSwitch',
                info = 'FreeSWITCH - Number of Active Calls.',
                args = '--base 1000 --lower-limit 0')
            graph.addField('calls', 'calls', type='GAUGE',
                draw='LINE2',info='Active Calls')
            self.appendGraph('fs_calls', graph)

        if self.graphEnabled('fs_channels'):
            graph = MuninGraph('FreeSWITCH - Active Channels', 'FreeSWITCH',
                info = 'FreeSWITCH - Number of Active Channels.',
                args = '--base 1000 --lower-limit 0')
            graph.addField('channels', 'channels', type='GAUGE',
                           draw='LINE2')
            self.appendGraph('fs_channels', graph)
Exemplo n.º 18
0
 def __init__(self, argv=(), env={}, debug=False):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self.envRegisterFilter('ports', '^\d+$')
     
     self._host = self.envGet('hostname')
     self._community = self.envGet('community')
     self._name_full = []
     self._data_full = []
     self._protocol_name = []
     self._variable_name = []
     self._variable_type = []
     self._variable_data = []
     
     self._names_dic = self.dict_snmpbulkwalk('1.3.6.1.4.1.8384.1001.1.1.205',self._community,self._host)
     self._types_dic = self.dict_snmpbulkwalk('1.3.6.1.4.1.8384.1001.1.1.206',self._community,self._host)
     self._values_dic = self.dict_snmpbulkwalk('1.3.6.1.4.1.8384.1001.1.1.207',self._community,self._host)
     
         
     #Start of voyager graphing   
     if self.graphEnabled('vserverTable'):
         
         for name in self._names_dic['variable_data']:
             
             graph = MuninGraph('Voyager stats for %s' %(name), 'Voyager',
             info='%s'%(name),
             args='--base 1000 --lower-limit 0')
             
             
             graph.addField(name, name, draw='LINESTACK1', type='GAUGE',
                         info="Counts the %s field"%(name))
             
             self.appendGraph('%s'%(name), graph)
Exemplo n.º 19
0
 def __init__(self, argv=(), env={}, debug=False):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """     
     MuninPlugin.__init__(self, argv, env, debug)
      
     if self.graphEnabled('netstat_conn_status'):
         graph = MuninGraph('Network - Connection Status', 'Network', 
                            info='TCP connection status stats.',
                            args='--base 1000 --lower-limit 0')
         for (fname, fdesc) in (
             ('listen', 'Socket listening for incoming connections.'),
             ('established', 'Socket with established connection.'),
             ('syn_sent', 'Socket actively attempting connection.'),
             ('syn_recv', 'Socket that has received a connection request'
                          ' from network.'),
             ('fin_wait1', 'Connection closed, and connection shutting down.'),
             ('fin_wait2', 'Connection is closed, and the socket is waiting'
                           ' for  a  shutdown from the remote end.'),
             ('time_wait', 'Socket is waiting after close '
                           'to handle packets still in the network.'),
             ('close', 'Socket is not being used.'),
             ('close_wait', 'The remote end has shut down, '
                            'waiting for the socket to close.'),
             ('last_ack', 'The remote end has shut down, and the socket'
                          ' is closed.  Waiting for acknowledgement.'),
             ('closing', 'Both  sockets are shut down'
                         ' but not all data is sent yet.'),
             ('unknown', 'Sockets with unknown state.'),
             ): 
             graph.addField(fname, fname, type='GAUGE', draw='AREA',
                            info=fdesc)
         self.appendGraph('netstat_conn_status', graph)
         
     if self.graphEnabled('netstat_server_conn'):
         self._srv_dict = {}
         self._srv_list = []
         self._port_list = []
         for srv_str in self.envGetList('server_ports', '(\w+)(:\d+)+$'):
             elems = srv_str.split(':')
             if len(elems) > 1:
                 srv = elems[0]
                 ports = elems[1:]
                 self._srv_list.append(srv)
                 self._srv_dict[srv] = ports
                 self._port_list.extend(ports)      
         self._srv_list.sort()
         if len(self._srv_list) > 0:
             graph = MuninGraph('Network - Server Connections', 'Network', 
                                info='Number of TCP connections to server ports.',
                                args='--base 1000 --lower-limit 0')
             for srv in self._srv_list:
                 graph.addField(srv, srv, type='GAUGE', draw='AREA', 
                     info=('Number of connections for service %s on ports: %s' 
                           % (srv, ','.join(self._srv_dict[srv]))))
             self.appendGraph('netstat_conn_server', graph)
Exemplo n.º 20
0
    def __init__(self, argv=(), env=None, debug=False):
        MuninPlugin.__init__(self, argv, env, debug)

        graphs = [
            ('supervisord_processes_memory_usage', 'Memory usage', 'Memory usage', 'Memory usage (MiB)', 'LINE2', 'GAUGE', None),
            ('supervisord_processes_cpu_percent_avg', 'CPU utilization as a percentage (avg)', 'CPU utilization as a percentage (avg)', 'Avg CPU percentage', 'LINE2', 'GAUGE', None),
            ('supervisord_processes_cpu_percent_max', 'CPU utilization as a percentage (max)', 'CPU utilization as a percentage (max)', 'Max CPU percentage', 'LINE2', 'GAUGE', None),
            ('supervisord_processes_num_context_switches_involuntary', 'Context switches (involuntary)', 'Context switches (involuntary)', 'Involuntary context switches', 'LINE2', 'GAUGE', None),
            ('supervisord_processes_num_context_switches_voluntary', 'Context switches (voluntary)', 'Context switches (voluntary)', 'Voluntary context switches', 'LINE2', 'GAUGE', None),
            ('supervisord_processes_num_fds', 'File descriptors used', 'File descriptors used', None, 'LINE2', 'GAUGE', '--lower-limit 0'),
            ('supervisord_processes_num_threads', 'Threads currently used', 'Threads currently used', None, 'LINE2', 'GAUGE', '--lower-limit 0'),
            ('supervisord_processes_num_connections', 'Socket connections opened', 'Socket connections opened', None, 'LINE2', 'GAUGE', '--lower-limit 0')
        ]

        self._category = 'supervisord'
        transport = supervisor.xmlrpc.SupervisorTransport(None, None, serverurl=self.envGet('url'))
        proxy = xmlrpclib.ServerProxy('http://127.0.0.1', transport=transport)
        # print proxy.supervisor.getState()
        self.identity = '{0}_{1}'.format(proxy.supervisor.getIdentification(), proxy.supervisor.getPID())
        self.entries = proxy.supervisor.getAllProcessInfo()
        self._stats = defaultdict(dict)

        for (graph_name, graph_title, graph_info, graph_vlabel, graph_draw, graph_type, graph_args) in graphs:
            if self.graphEnabled(graph_name):
                graph = MuninGraph('Supervisord - {0}'.format(graph_title),
                                   self._category, info=graph_info, vlabel=graph_vlabel, args=graph_args)

                for entry in self.entries:
                    if entry['statename'] not in ('RUNNING',):
                        continue

                    label_fmt = entry['group'] == entry['name'] and '{name}.{pid}' or '{group}:{name}'
                    graph.addField(entry['name'],
                                   label_fmt.format(**entry), draw=graph_draw,
                                   type=graph_type, info=graph_info,
                                   min=graph_name.startswith('supervisord_processes_num_') and 0 or None)

                if graph.getFieldCount() > 0:
                    self.appendGraph(graph_name, graph)
Exemplo n.º 21
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """     
        MuninPlugin.__init__(self, argv, env, debug)
        
        self._category = 'Processes'

        for (prefix, title, desc) in (('proc', self._category, 'Number of processes'),
                                      ('thread', 'Threads', 'Number of threads')):
            graph_name = '%s_status' % prefix
            graph_title = '%s - Status' % title
            graph_desc = '%s discriminated by status.' % desc 
            if self.graphEnabled(graph_name):
                graph = MuninGraph(graph_title, self._category, info=graph_desc,
                    args='--base 1000 --lower-limit 0')
                for (fname, fdesc) in (
                    ('unint_sleep', 'Uninterruptable sleep. (Usually I/O)'),
                    ('stopped', 'Stopped, either by job control signal '
                     'or because it is being traced.'),
                    ('defunct', 'Defunct (zombie) process. '
                                'Terminated but not reaped by parent.'),
                    ('running', 'Running or runnable (on run queue).'),
                    ('sleep', 'Interruptable sleep. '
                              'Waiting for an event to complete.')): 
                    graph.addField(fname, fname, type='GAUGE', draw='AREA',
                                   info=fdesc)
                self.appendGraph(graph_name, graph)
                
            graph_name = '%s_prio' % prefix
            graph_title = '%s - Priority' % title
            graph_desc = '%s discriminated by priority.' % desc 
            if self.graphEnabled(graph_name):
                graph = MuninGraph(graph_title, self._category, info=graph_desc,
                    args='--base 1000 --lower-limit 0')
                for (fname, fdesc) in (
                    ('high', 'High priority.'),
                    ('low', 'Low priority.'),
                    ('norm', 'Normal priority.')):
                    graph.addField(fname, fname, type='GAUGE', draw='AREA',
                                   info=fdesc) 
                graph.addField('locked', 'locked', type='GAUGE', draw='LINE2',
                               info='Has pages locked into memory.')
                self.appendGraph(graph_name, graph)
Exemplo n.º 22
0
 def _configDevActive(self, namestr, titlestr, devlist):
     """Generate configuration for I/O Queue Length.
     
     @param namestr:  Field name component indicating device type.
     @param titlestr: Title component indicating device type.
     @param devlist:  List of devices.
     
     """
     name = 'diskio_%s_active' % namestr
     if self.graphEnabled(name):
         graph = MuninGraph('Disk I/O - %s - Queue Length' % titlestr, 
             self._category,
             info='Disk I/O - Number  of I/O Operations in Progress for every %s.'
                  % titlestr,
             args='--base 1000 --lower-limit 0', printf='%6.1lf',
             autoFixNames = True)
         for dev in devlist:
             graph.addField(dev, 
                            fixLabel(dev, maxLabelLenGraphSimple, 
                                     repl = '..', truncend=False,
                                     delim = self._labelDelim.get(namestr)), 
                            draw='AREASTACK', type='GAUGE', info=dev)
         self.appendGraph(name, graph)
Exemplo n.º 23
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._category = "Processes"

        for (prefix, title, desc) in (
            ("proc", self._category, "Number of processes"),
            ("thread", "Threads", "Number of threads"),
        ):
            graph_name = "%s_status" % prefix
            graph_title = "%s - Status" % title
            graph_desc = "%s discriminated by status." % desc
            if self.graphEnabled(graph_name):
                graph = MuninGraph(graph_title, self._category, info=graph_desc, args="--base 1000 --lower-limit 0")
                for (fname, fdesc) in (
                    ("unint_sleep", "Uninterruptable sleep. (Usually I/O)"),
                    ("stopped", "Stopped, either by job control signal " "or because it is being traced."),
                    ("defunct", "Defunct (zombie) process. " "Terminated but not reaped by parent."),
                    ("running", "Running or runnable (on run queue)."),
                    ("sleep", "Interruptable sleep. " "Waiting for an event to complete."),
                ):
                    graph.addField(fname, fname, type="GAUGE", draw="AREA", info=fdesc)
                self.appendGraph(graph_name, graph)

            graph_name = "%s_prio" % prefix
            graph_title = "%s - Priority" % title
            graph_desc = "%s discriminated by priority." % desc
            if self.graphEnabled(graph_name):
                graph = MuninGraph(graph_title, self._category, info=graph_desc, args="--base 1000 --lower-limit 0")
                for (fname, fdesc) in (
                    ("high", "High priority."),
                    ("low", "Low priority."),
                    ("norm", "Normal priority."),
                ):
                    graph.addField(fname, fname, type="GAUGE", draw="AREA", info=fdesc)
                graph.addField("locked", "locked", type="GAUGE", draw="LINE2", info="Has pages locked into memory.")
                self.appendGraph(graph_name, graph)
Exemplo n.º 24
0
 def __init__(self, argv=(), env=None, debug=False):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self.envRegisterFilter('fspaths', '^[\w\-\/]+$')
     self.envRegisterFilter('fstypes', '^\w+$')
     self._category = 'Disk Usage'
     
     self._statsSpace = None
     self._statsInode = None
     self._info = FilesystemInfo()
     
     self._fslist = [fs for fs in self._info.getFSlist()
                     if (self.fsPathEnabled(fs) 
                         and self.fsTypeEnabled(self._info.getFStype(fs)))]
     self._fslist.sort()
     
     name = 'diskspace'
     if self.graphEnabled(name):
         self._statsSpace = self._info.getSpaceUse()
         graph = MuninGraph('Disk Space Usage (%)', self._category,
             info='Disk space usage of filesystems.',
             args='--base 1000 --lower-limit 0', printf='%6.1lf',
             autoFixNames=True)
         for fspath in self._fslist:
             if self._statsSpace.has_key(fspath):
                 graph.addField(fspath, 
                     fixLabel(fspath, maxLabelLenGraphSimple, 
                              delim='/', repl='..', truncend=False), 
                     draw='LINE2', type='GAUGE',
                     info="Disk space usage for: %s" % fspath)
         self.appendGraph(name, graph)
     
     name = 'diskinode'
     if self.graphEnabled(name):
         self._statsInode = self._info.getInodeUse()
         graph = MuninGraph('Inode Usage (%)', self._category,
             info='Inode usage of filesystems.',
             args='--base 1000 --lower-limit 0', printf='%6.1lf',
             autoFixNames=True)
         for fspath in self._fslist:
             if self._statsInode.has_key(fspath):
                 graph.addField(fspath,
                     fixLabel(fspath, maxLabelLenGraphSimple, 
                              delim='/', repl='..', truncend=False), 
                     draw='LINE2', type='GAUGE',
                     info="Inode usage for: %s" % fspath)
         self.appendGraph(name, graph)
Exemplo n.º 25
0
 def __init__(self, argv=(), env={}, debug=False):
     """
     Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self._container = self.envGet('container')
     self._username = self.envGet('username')
     self._api_key = self.envGet('api_key')
     
     self._stats = None
     self._prev_stats = self.restoreState()
     if self._prev_stats is None:
         cdnInfo = RackspaceContainerInfo(
             self._container,
             self._username, 
             self._api_key
         )
         self._stats = cdnInfo.getStats()
         stats = self._stats
     else:
         stats = self._prev_stats
     if stats is None:
         raise Exception("Undetermined error accessing stats.")
     
     if stats.has_key('rackspace_containersize'):
         graph = MuninGraph('Rackspace - Container Size', 'Rackspace',
             info='The total size of files contained in a Rackspace CDN container',
             vlabel='bytes', args='--base 1024 --lower-limit 0')
         graph.addField('size', 'size', draw='AREASTACK', type='GAUGE')
         self.appendGraph('rackspace_containersize', graph)
     
     if stats.has_key('rackspace_containercount'):
         graph = MuninGraph('Rackspace - Container Count', 'Rackspace',
             info='The total number of files contained in a Rackspace CDN container',
             vlabel='objects', args='--base 1000 --lower-limit 0')
         graph.addField('count', 'count', draw='AREASTACK', type='GAUGE')
         self.appendGraph('rackspace_containercount', graph)
Exemplo n.º 26
0
    def __init__(self, argv=(), env={}, debug=False):
        """
        Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._container = self.envGet("container")
        self._username = self.envGet("username")
        self._api_key = self.envGet("api_key")

        self._stats = None
        self._prev_stats = self.restoreState()
        if self._prev_stats is None:
            cdnInfo = RackspaceContainerInfo(self._container, self._username, self._api_key)
            self._stats = cdnInfo.getStats()
            stats = self._stats
        else:
            stats = self._prev_stats
        if stats is None:
            raise Exception("Undetermined error accessing stats.")

        if stats.has_key("rackspace_containersize"):
            graph = MuninGraph(
                "Rackspace - Container Size",
                "Rackspace",
                info="The total size of files contained in a Rackspace CDN container",
                vlabel="bytes",
                args="--base 1024 --lower-limit 0",
            )
            graph.addField("size", "size", draw="AREASTACK", type="GAUGE")
            self.appendGraph("rackspace_containersize", graph)

        if stats.has_key("rackspace_containercount"):
            graph = MuninGraph(
                "Rackspace - Container Count",
                "Rackspace",
                info="The total number of files contained in a Rackspace CDN container",
                vlabel="objects",
                args="--base 1000 --lower-limit 0",
            )
            graph.addField("count", "count", draw="AREASTACK", type="GAUGE")
            self.appendGraph("rackspace_containercount", graph)
Exemplo n.º 27
0
 def __init__(self, argv=(), env=None, debug=False):
     """
     Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self.envRegisterFilter('container', '^\w+$')
     self._username = self.envGet('username')
     self._api_key = self.envGet('api_key')
     self._region = self.envGet('region')
     self._servicenet = self.envCheckFlag('servicenet', False)
     self._category = 'Rackspace'
     
     self._fileInfo = CloudFilesInfo(username=self._username,
                                     api_key=self._api_key,
                                     region=self._region,
                                     servicenet=self._servicenet)
     self._fileContList = [name for name in self._fileInfo.getContainerList()
                                if self.containerIncluded(name)]
     
     if self.graphEnabled('rackspace_cloudfiles_container_size'):
         graph = MuninGraph('Rackspace Cloud Files - Container Size (bytes)', 
                            self._category,
             info='The total size of files for each Rackspace Cloud Files container.',
             args='--base 1024 --lower-limit 0', autoFixNames=True)
         for contname in self._fileContList:
                 graph.addField(contname, contname, draw='AREASTACK', 
                                type='GAUGE')
         self.appendGraph('rackspace_cloudfiles_container_size', graph)
     
     if self.graphEnabled('rackspace_cloudfiles_container_count'):
         graph = MuninGraph('Rackspace Cloud Files - Container Object Count', 
                            self._category,
             info='The total number of files for each Rackspace Cloud Files container.',
             args='--base 1024 --lower-limit 0', autoFixNames=True)
         for contname in self._fileContList:
                 graph.addField(contname, contname, draw='AREASTACK', 
                                type='GAUGE')
         self.appendGraph('rackspace_cloudfiles_container_count', graph)
Exemplo n.º 28
0
 def _configDevBytes(self, namestr, titlestr, devlist):
     """Generate configuration for I/O Throughput stats.
     
     @param namestr:  Field name component indicating device type.
     @param titlestr: Title component indicating device type.
     @param devlist:  List of devices.
     
     """
     name = 'diskio_%s_bytes' % namestr
     if self.graphEnabled(name):
         graph = MuninGraph(
             'Disk I/O - %s - Throughput' % titlestr,
             'Disk I/O',
             info=
             'Disk I/O - %s Throughput, bytes read / written per second.' %
             titlestr,
             args='--base 1000 --lower-limit 0',
             printf='%6.1lf',
             vlabel='bytes/sec read (-) / write (+)',
             autoFixNames=True)
         for dev in devlist:
             graph.addField(dev + '_read',
                            fixLabel(dev,
                                     maxLabelLenGraphDual,
                                     repl='..',
                                     truncend=False,
                                     delim=self._labelDelim.get(namestr)),
                            draw='LINE2',
                            type='DERIVE',
                            min=0,
                            graph=False)
             graph.addField(dev + '_write',
                            fixLabel(dev,
                                     maxLabelLenGraphDual,
                                     repl='..',
                                     truncend=False,
                                     delim=self._labelDelim.get(namestr)),
                            draw='LINE2',
                            type='DERIVE',
                            min=0,
                            negative=(dev + '_read'),
                            info=dev)
         self.appendGraph(name, graph)
Exemplo n.º 29
0
 def __init__(self, argv = (), env = {}):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv: List of command line arguments.
     @param env:  Dictionary of environment variables.
     
     """
     MuninPlugin.__init__(self, argv, env)
     
     self.envRegisterFilter('fspaths', '^[\w\-\/]+$')
     self.envRegisterFilter('fstypes', '^\w+$')
     
     self._statsSpace = None
     self._statsInode = None
     self._info = FilesystemInfo()
     
     name = 'diskspace'
     if self.graphEnabled(name):
         self._statsSpace = self._info.getSpaceUse()
         graph = MuninGraph('Disk Space Usage (%)', 'Disk Usage',
             info='Disk space usage of filesystems.',
             args='--base 1000 --lower-limit 0',
             autoFixNames=True)
         for (fspath, stats) in self._statsSpace.iteritems():
             if self.fsPathEnabled(fspath) and self.fsTypeEnabled(stats['type']):
                 graph.addField(fspath, fspath, draw='LINE2', type='GAUGE',
                     info="Disk space usage for filesystem: %s" % fspath)
         self.appendGraph(name, graph)
     
     name = 'diskinode'
     if self.graphEnabled(name):
         self._statsInode = self._info.getInodeUse()
         graph = MuninGraph('Inode Usage (%)', 'Disk Usage',
             info='Inode usage of filesystems.',
             args='--base 1000 --lower-limit 0',
             autoFixNames=True)
         for (fspath, stats) in self._statsInode.iteritems():
             if self.fsPathEnabled(fspath) and self.fsTypeEnabled(stats['type']):
                 graph.addField(fspath, fspath, draw='LINE2', type='GAUGE',
                     info="Inode usage for filesystem: %s" % fspath)
         self.appendGraph(name, graph)
Exemplo n.º 30
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.

        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)

        """
        MuninPlugin.__init__(self, argv, env, debug)
        self._category = "network"
        self.ip_addr = self.envGet("ip")
        self.pihole_url = "http://" + str(self.ip_addr) \
                          + "/admin/api.php?overTimeData10mins"

        graph = MuninGraph("PiHole Domains Over Time",
                           self._category,
                           info="Number of requests.",
                           vlabel="DNS requests",
                           args="--lower-limit 0")
        graph.addField("blocked", "blocked", type="GAUGE", draw="LINE2")
        graph.addField("total", "total", type="GAUGE", draw="LINE2")
        self.appendGraph("domains_graph", graph)
Exemplo n.º 31
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.

        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)

        """
        MuninPlugin.__init__(self, argv, env, debug)
        self._category = "network"
        self.ip_addr = self.envGet("ip")

        # Create the URL for the requests. Normally contains the current
        # timestamp, but that's probably to ignore any browser cache.
        self.xml_url = "http://" + str(self.ip_addr) \
                       + "/common_page/status_info_lua.lua"

        # Create graph
        graph = MuninGraph("Downstream/Upstream", self._category,
                           info="Current downstream & upstream speed in kbps.",
                           args="--lower-limit 0", vlabel="Speed (kbps)")
        graph.addField("upstream", "upstream", type="GAUGE", draw="LINE2")
        graph.addField("downstream", "downstream", type="GAUGE", draw="LINE2")
        self.appendGraph("down_up_graph", graph)
Exemplo n.º 32
0
 def __init__(self, argv=(), env=None, debug=False):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self._host = self.envGet('host')
     self._port = self.envGet('port', None, int)
     self._user = self.envGet('user')
     self._monpath = self.envGet('monpath')
     self._password = self.envGet('password')
     self._ssl = self.envCheckFlag('ssl', False)
     
     if self.graphEnabled('php_apc_memory'):
         graph = MuninGraph('PHP APC Cache - Memory Utilization (bytes)', 'PHP',
             info='Memory Utilization of PHP APC Cache in bytes.',
             args='--base 1000 --lower-limit 0')
         graph.addField('filecache', 'File Cache', draw='AREASTACK', 
                        type='GAUGE')
         graph.addField('usercache', 'User Cache', draw='AREASTACK', 
                        type='GAUGE')
         graph.addField('other', 'Other', draw='AREASTACK', 
                        type='GAUGE')
         graph.addField('free', 'Free', draw='AREASTACK', type='GAUGE')
         self.appendGraph('php_apc_memory', graph)
     
     if self.graphEnabled('php_apc_items'):
         graph = MuninGraph('PHP APC Cache - Cached Items', 'PHP',
             info='Number of items (files, user data) in PHP APC Cache.',
             args='--base 1000 --lower-limit 0')
         graph.addField('filecache', 'File Cache', draw='AREASTACK', 
                        type='GAUGE')
         graph.addField('usercache', 'User Cache', draw='AREASTACK', 
                        type='GAUGE')
         self.appendGraph('php_apc_items', graph)
     
     if self.graphEnabled('php_apc_reqs_filecache'):
         graph = MuninGraph('PHP APC - File Cache Requests per second', 'PHP',
             info='PHP APC File Cache Requests (Hits and Misses) per second.',
             args='--base 1000 --lower-limit 0')
         graph.addField('hits', 'hits', draw='AREASTACK', 
                        type='DERIVE', min=0)
         graph.addField('misses', 'misses', draw='AREASTACK',
                        type='DERIVE', min=0)
         graph.addField('inserts', 'inserts', draw='LINE2',
                        type='DERIVE', min=0)
         self.appendGraph('php_apc_reqs_filecache', graph)
     
     if self.graphEnabled('php_apc_reqs_usercache'):
         graph = MuninGraph('PHP APC - User Cache Requests per second', 'PHP',
             info='PHP APC User Cache Requests (Hits and Misses) per second.',
             args='--base 1000 --lower-limit 0')
         graph.addField('hits', 'hits', draw='AREASTACK', 
                        type='DERIVE', min=0)
         graph.addField('misses', 'misses', draw='AREASTACK',
                        type='DERIVE', min=0)
         graph.addField('inserts', 'inserts', draw='LINE2',
                        type='DERIVE', min=0)
         self.appendGraph('php_apc_reqs_usercache', graph)
         
     if self.graphEnabled('php_apc_expunge'):
         graph = MuninGraph('PHP APC - Cache Expunge Runs per second', 'PHP',
             info='PHP APC File and User Cache Expunge Runs per second.',
             args='--base 1000 --lower-limit 0')
         graph.addField('filecache', 'File Cache', draw='LINE2', 
                        type='DERIVE', min=0)
         graph.addField('usercache', 'User Cache', draw='LINE2', 
                        type='DERIVE', min=0)
         self.appendGraph('php_apc_expunge', graph)
Exemplo n.º 33
0
 def __init__(self, argv=(), env={}, debug=False):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self._instance = self.envGet('instance')
     varnish_info = VarnishInfo(self._instance)
     self._stats = varnish_info.getStats()
     self._desc = varnish_info.getDescDict()
     
     graph_name = 'varnish_client_conn'
     if self.graphEnabled(graph_name):
         graph = MuninGraph('Varnish - Client Connections / sec', 
             'Varnish',
             info='Client connections per second for Varnish Cache.',
             args='--base 1000 --lower-limit 0')
         graph.addField('client_conn', 'conn', draw='LINE2', type='DERIVE', 
                        min=0, info=self._desc.get('client_conn'))
         graph.addField('client_drop', 'drop', draw='LINE2', type='DERIVE', 
                        min=0, info=self._desc.get('client_drop'))
         self.appendGraph(graph_name, graph)
     
     graph_name = 'varnish_client_requests'
     if self.graphEnabled(graph_name):
         graph = MuninGraph('Varnish - Client Requests / sec', 
             'Varnish',
             info='Requests per second to Varnish Cache.',
             args='--base 1000 --lower-limit 0')
         graph.addField('client_req', 'reqs', draw='LINE2', type='DERIVE', 
                        min=0, info=self._desc.get('client_req'))
         self.appendGraph(graph_name, graph)
     
     graph_name = 'varnish_backend_conn'
     if self.graphEnabled(graph_name):
         graph = MuninGraph('Varnish - Backend Connections / sec', 
             'Varnish',
             info='Connections per second from Varnish Cache to backends.',
             args='--base 1000 --lower-limit 0')
         graph.addField('backend_conn', 'conn', draw='LINE2', type='DERIVE', 
                        min=0, info=self._desc.get('backend_conn'))
         self.appendGraph(graph_name, graph)
     
     graph_name = 'varnish_backend_requests'
     if self.graphEnabled(graph_name):
         graph = MuninGraph('Varnish - Backend Requests / sec', 
             'Varnish',
             info='Requests per second from Varnish Cache to backends.',
             args='--base 1000 --lower-limit 0')
         graph.addField('backend_req', 'reqs', draw='LINE2', type='DERIVE', 
                        min=0, info=self._desc.get('backend_req'))
         self.appendGraph(graph_name, graph)
         
     graph_name = 'varnish_traffic'
     if self.graphEnabled(graph_name):
         graph = MuninGraph('Varnish - Traffic (bytes/sec)', 
             'Varnish',
             info='HTTP Header and Body traffic. '
                  '(TCP/IP overhead not included.)',
             args='--base 1000 --lower-limit 0')
         graph.addField('s_hdrbytes', 'header', draw='AREASTACK', type='DERIVE', 
                        min=0, info=self._desc.get('s_hdrbytes'))
         graph.addField('s_bodybytes', 'body', draw='AREASTACK', type='DERIVE', 
                        min=0, info=self._desc.get('s_bodybytes'))
         self.appendGraph(graph_name, graph)
         
     graph_name = 'varnish_workers'
     if self.graphEnabled(graph_name):
         graph = MuninGraph('Varnish - Worker Threads', 
             'Varnish',
             info='Number of worker threads.',
             args='--base 1000 --lower-limit 0')
         graph.addField('cache_hit', 'hit', draw='AREASTACK', type='DERIVE', 
                        min=0, info=self._desc.get('cache_hit'))
         graph.addField('cache_hitpass', 'pass', draw='AREASTACK', type='DERIVE', 
                        min=0, info=self._desc.get('cache_hitpass'))
         graph.addField('cache_miss', 'miss', draw='AREASTACK', type='DERIVE', 
                        min=0, info=self._desc.get('cache_miss'))
         self.appendGraph(graph_name, graph)
         
     graph_name = 'varnish_hits'
     if self.graphEnabled(graph_name):
         graph = MuninGraph('Varnish - Cache Hits vs. Misses', 
             'Varnish',
             info='Number of Cache Hits and Misses por second.',
             args='--base 1000 --lower-limit 0')
         graph.addField('n_wrk', 'req', draw='AREASTACK', type='DERIVE', 
                        min=0, info=self._desc.get('n_wrk'))
         self.appendGraph(graph_name, graph)
Exemplo n.º 34
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('ifaces', '^[\w\d:]+$')

        self._ifaceInfo = NetIfaceInfo()
        self._ifaceStats = self._ifaceInfo.getIfStats()
        self._ifaceList = []
        for iface in list(self._ifaceStats):
            if iface not in [
                    'lo',
            ] and self.ifaceIncluded(iface):
                if max(self._ifaceStats[iface].values()) > 0:
                    self._ifaceList.append(iface)
        self._ifaceList.sort()

        for iface in self._ifaceList:
            if self.graphEnabled('netiface_traffic'):
                graph = MuninGraph(
                    'Network Interface - Traffic - %s' % iface,
                    'Network',
                    info='Traffic Stats for Network Interface %s in bps.' %
                    iface,
                    args='--base 1000 --lower-limit 0',
                    vlabel='bps in (-) / out (+) per second')
                graph.addField('rx',
                               'bps',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               graph=False)
                graph.addField('tx',
                               'bps',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               negative='rx')
                self.appendGraph('netiface_traffic_%s' % iface, graph)

            if self.graphEnabled('netiface_errors'):
                graph = MuninGraph(
                    'Network Interface - Errors - %s' % iface,
                    'Network',
                    info='Error Stats for Network Interface %s in errors/sec.'
                    % iface,
                    args='--base 1000 --lower-limit 0',
                    vlabel='errors in (-) / out (+) per second')
                graph.addField('rxerrs',
                               'errors',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               graph=False)
                graph.addField('txerrs',
                               'errors',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               negative='rxerrs',
                               info='Rx(-)/Tx(+) Errors per second.')
                graph.addField('rxframe',
                               'frm/crr',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               graph=False)
                graph.addField('txcarrier',
                               'frm/crr',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               negative='rxframe',
                               info='Frame(-)/Carrier(+) Errors per second.')
                graph.addField('rxdrop',
                               'drop',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               graph=False)
                graph.addField('txdrop',
                               'drop',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               negative='rxdrop',
                               info='Rx(-)/Tx(+) Dropped Packets per second.')
                graph.addField('rxfifo',
                               'fifo',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               graph=False)
                graph.addField('txfifo',
                               'fifo',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               negative='rxfifo',
                               info='Rx(-)/Tx(+) FIFO Errors per second.')
                self.appendGraph('netiface_errors_%s' % iface, graph)
Exemplo n.º 35
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('db', '^\w+$')
        self._host = self.envGet('host')
        self._port = self.envGet('port', None, int)
        self._database = self.envGet('database')
        self._user = self.envGet('user')
        self._password = self.envGet('password')
        self._detailGraphs = self.envCheckFlag('detail_graphs', False)
        self._replGraphs = self.envCheckFlag('repl_graphs', False)
        self._category_sys = 'PostgreSQL Sys'
        self._category_db = 'PostgreSQL DB'

        self._dbconn = PgInfo(self._host, self._port, self._database,
                              self._user, self._password)
        dblist = [
            db for db in self._dbconn.getDatabases() if self.dbIncluded(db)
        ]
        dblist.sort()

        if self.graphEnabled('pg_connections'):
            graph = MuninGraph(
                'PostgreSQL - Active Connections',
                self._category_sys,
                info='Active connections for PostgreSQL Database Server.',
                args='--base 1000 --lower-limit 0',
                autoFixNames=True)
            for db in dblist:
                graph.addField(db,
                               db,
                               draw='AREASTACK',
                               type='GAUGE',
                               info="Active connections to database %s." % db)
            graph.addField('total',
                           'total',
                           draw='LINE2',
                           type='GAUGE',
                           colour='000000',
                           info="Total number of active connections.")
            graph.addField(
                'max_conn',
                'max_conn',
                draw='LINE2',
                type='GAUGE',
                colour='FF0000',
                info="Global server level concurrent connections limit.")
            self.appendGraph('pg_connections', graph)

        if self.graphEnabled('pg_diskspace'):
            graph = MuninGraph(
                'PostgreSQL - Database Disk Usage',
                self._category_sys,
                info='Disk usage of databases on PostgreSQL Server in bytes.',
                args='--base 1024 --lower-limit 0',
                autoFixNames=True)
            for db in dblist:
                graph.addField(db,
                               db,
                               draw='AREASTACK',
                               type='GAUGE',
                               info="Disk usage of database %s." % db)
            graph.addField('total',
                           'total',
                           draw='LINE2',
                           type='GAUGE',
                           colour='000000',
                           info="Total disk usage of all databases.")
            self.appendGraph('pg_diskspace', graph)

        if self.graphEnabled('pg_blockreads'):
            graph = MuninGraph('PostgreSQL - Block Read Stats',
                               self._category_sys,
                               info='Block read stats for PostgreSQL Server.',
                               args='--base 1000 --lower-limit 0')
            graph.addField(
                'blk_hit',
                'cache hits',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info="Blocks read from PostgreSQL Cache per second.")
            graph.addField(
                'blk_read',
                'disk reads',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info="Blocks read directly from disk or operating system "
                "disk cache per second.")
            self.appendGraph('pg_blockreads', graph)

        if self.graphEnabled('pg_xact'):
            graph = MuninGraph(
                'PostgreSQL - Transactions',
                self._category_sys,
                info=
                'Transaction commit / rollback Stats for PostgreSQL Server.',
                args='--base 1000 --lower-limit 0')
            graph.addField('commits',
                           'commits',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           info="Transactions per second.")
            graph.addField('rollbacks',
                           'rollbacks',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           info="Rollbacks per second.")
            self.appendGraph('pg_xact', graph)

        if self._dbconn.checkVersion('8.3'):
            if self.graphEnabled('pg_checkpoints'):
                graph = MuninGraph(
                    'PostgreSQL - Checkpoints per minute',
                    self._category_sys,
                    info=
                    'Number of Checkpoints per Minute for PostgreSQL Server.',
                    args='--base 1000 --lower-limit 0',
                    period='minute')
                graph.addField('req',
                               'req',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               info="Requested checkpoints..")
                graph.addField('timed',
                               'timed',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               info="Check points started by timeout.")
                self.appendGraph('pg_checkpoints', graph)
            if self.graphEnabled('pg_bgwriter'):
                graph = MuninGraph(
                    'PostgreSQL - BgWriter Stats (blocks / second)',
                    self._category_sys,
                    info=
                    'PostgreSQL Server - Bgwriter - Blocks written per second.',
                    args='--base 1000 --lower-limit 0',
                    period='minute')
                graph.addField(
                    'backend',
                    'backend',
                    draw='LINE2',
                    type='DERIVE',
                    min=0,
                    info="Buffers written by backend and not bgwriter.")
                graph.addField('clean',
                               'clean',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               info="Buffers cleaned by bgwriter runs.")
                graph.addField('chkpoint',
                               'chkpoint',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               info="Buffers written performing checkpoints.")
                self.appendGraph('pg_bgwriter', graph)

        if self.graphEnabled('pg_tup_read'):
            graph = MuninGraph(
                'PostgreSQL - Tuple Reads',
                self._category_sys,
                info='Tuple return and fetch Stats for PostgreSQL Server.',
                args='--base 1000 --lower-limit 0')
            graph.addField(
                'fetch',
                'fetch',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info="Tuples returned per second by table or index scans.")
            graph.addField(
                'return',
                'return',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info="Tuples fetched per second from tables using indices "
                "or bitmap scans.")
            self.appendGraph('pg_tup_read', graph)

        if self.graphEnabled('pg_tup_write'):
            graph = MuninGraph(
                'PostgreSQL - Tuple Writes',
                self._category_sys,
                info=
                'Tuple insert, update and delete Stats for PostgreSQL Server.',
                args='--base 1000 --lower-limit 0')
            graph.addField('delete',
                           'delete',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info="Tuples deleted per second.")
            graph.addField('update',
                           'update',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info="Tuples updated per second.")
            graph.addField('insert',
                           'insert',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info="Tuples inserted per second.")
            self.appendGraph('pg_tup_write', graph)

        for lock_state, desc in (
            ('all', 'Total number of locks grouped by lock mode.'),
            ('wait', 'Number of locks in wait state grouped by lock mode.'),
        ):
            graph_name = "pg_lock_%s" % lock_state
            if self.graphEnabled(graph_name):
                mode_iter = iter(PgInfo.lockModes)
                graph = MuninGraph("PostgreSQL - Locks (%s)" % lock_state,
                                   self._category_sys,
                                   info=desc,
                                   args='--base 1000 --lower-limit 0')
                for mode in (
                        'AccessExcl',
                        'Excl',
                        'ShrRwExcl',
                        'Shr',
                        'ShrUpdExcl',
                        'RwExcl',
                        'RwShr',
                        'AccessShr',
                ):
                    graph.addField(mode,
                                   mode,
                                   draw='AREASTACK',
                                   type='GAUGE',
                                   min=0,
                                   info="Number of locks of mode: %s" %
                                   mode_iter.next())
                self.appendGraph(graph_name, graph)

        if self._detailGraphs:
            if self.graphEnabled('pg_blockread_detail'):
                graph = MuninGraph(
                    'PostgreSQL - Block Read Stats Detail',
                    self._category_db,
                    info=
                    'Block read stats for each database in PostgreSQL Server.',
                    args='--base 1000 --lower-limit 0',
                    autoFixNames=True)
                for db in dblist:
                    graph.addField(
                        db,
                        db,
                        draw='AREASTACK',
                        type='DERIVE',
                        min=0,
                        info="Blocks read per second for database %s." % db)
                self.appendGraph('pg_blockread_detail', graph)
            if self.graphEnabled('pg_xact_commit_detail'):
                graph = MuninGraph(
                    'PostgreSQL - Transaction Commits Detail',
                    self._category_db,
                    info=
                    'Transaction commits for each database in PostgreSQL Server.',
                    args='--base 1000 --lower-limit 0',
                    autoFixNames=True)
                for db in dblist:
                    graph.addField(
                        db,
                        db,
                        draw='AREASTACK',
                        type='DERIVE',
                        min=0,
                        info="Transaction commits per second for database %s."
                        % db)
                self.appendGraph('pg_xact_commit_detail', graph)
            if self.graphEnabled('pg_xact_rollback_detail'):
                graph = MuninGraph(
                    'PostgreSQL - Transaction Rollbacks Detail',
                    self._category_db,
                    info=
                    'Transaction rollbacks for each database in PostgreSQL Server.',
                    args='--base 1000 --lower-limit 0',
                    autoFixNames=True)
                for db in dblist:
                    graph.addField(
                        db,
                        db,
                        draw='AREASTACK',
                        type='DERIVE',
                        min=0,
                        info="Transaction rollbacks per second for database %s."
                        % db)
                self.appendGraph('pg_xact_rollback_detail', graph)
            if self.graphEnabled('pg_tup_return_detail'):
                graph = MuninGraph(
                    'PostgreSQL - Tuple Scan Detail',
                    self._category_db,
                    info='Tuple scans for each database in PostgreSQL Server.',
                    args='--base 1000 --lower-limit 0',
                    autoFixNames=True)
                for db in dblist:
                    graph.addField(
                        db,
                        db,
                        draw='AREASTACK',
                        type='DERIVE',
                        min=0,
                        info="Tuples scanned per second from database %s." %
                        db)
                self.appendGraph('pg_tup_return_detail', graph)
            if self.graphEnabled('pg_tup_fetch_detail'):
                graph = MuninGraph(
                    'PostgreSQL - Tuple Fetch Detail',
                    self._category_db,
                    info=
                    'Tuple fetches for each database in PostgreSQL Server.',
                    args='--base 1000 --lower-limit 0',
                    autoFixNames=True)
                for db in dblist:
                    graph.addField(
                        db,
                        db,
                        draw='AREASTACK',
                        type='DERIVE',
                        min=0,
                        info="Tuples fetched per second from database %s." %
                        db)
                self.appendGraph('pg_tup_fetch_detail', graph)
            if self.graphEnabled('pg_tup_delete_detail'):
                graph = MuninGraph(
                    'PostgreSQL - Tuple Delete Detail',
                    self._category_db,
                    info=
                    'Tuple deletes for each database in PostgreSQL Server.',
                    args='--base 1000 --lower-limit 0',
                    autoFixNames=True)
                for db in dblist:
                    graph.addField(
                        db,
                        db,
                        draw='AREASTACK',
                        type='DERIVE',
                        min=0,
                        info="Tuples deleted per second from database %s." %
                        db)
                self.appendGraph('pg_tup_delete_detail', graph)
            if self.graphEnabled('pg_tup_update_detail'):
                graph = MuninGraph(
                    'PostgreSQL - Tuple Updates Detail',
                    self._category_db,
                    info=
                    'Tuple updates for each database in PostgreSQL Server.',
                    args='--base 1000 --lower-limit 0',
                    autoFixNames=True)
                for db in dblist:
                    graph.addField(
                        db,
                        db,
                        draw='AREASTACK',
                        type='DERIVE',
                        min=0,
                        info="Tuples updated per second in database %s." % db)
                self.appendGraph('pg_tup_update_detail', graph)
            if self.graphEnabled('pg_tup_insert_detail'):
                graph = MuninGraph(
                    'PostgreSQL - Tuple Inserts Detail',
                    self._category_db,
                    info=
                    'Tuple insertes for each database in PostgreSQL Server.',
                    args='--base 1000 --lower-limit 0',
                    autoFixNames=True)
                for db in dblist:
                    graph.addField(
                        db,
                        db,
                        draw='AREASTACK',
                        type='DERIVE',
                        min=0,
                        info="Tuples inserted per second into database %s." %
                        db)
                self.appendGraph('pg_tup_insert_detail', graph)
            for lock_state, desc in (
                ('all', 'Total number of locks grouped by database.'),
                ('wait', 'Number of locks in wait state grouped by database.'),
            ):
                graph_name = "pg_lock_%s_detail" % lock_state
                if self.graphEnabled(graph_name):
                    graph = MuninGraph("PostgreSQL - Locks (%s) Detail" %
                                       lock_state,
                                       self._category_sys,
                                       info=desc,
                                       args='--base 1000 --lower-limit 0',
                                       autoFixNames=True)
                    for db in dblist:
                        graph.addField(
                            db,
                            db,
                            draw='AREASTACK',
                            type='GAUGE',
                            min=0,
                            info="Number of locks for database: %s" % db)
                    self.appendGraph(graph_name, graph)

        if self._replGraphs and self._dbconn.checkVersion('9.1'):
            if self.graphEnabled('pg_repl_conflicts'):
                graph = MuninGraph(
                    'PostgreSQL - Replication Conflicts',
                    'Postgresql Repl.',
                    info='Number of queries cancelled due to conflict with '
                    'recovery on standby servers.',
                    args='--base 1000 --lower-limit 0')
                for field, desc in (
                    ('lock',
                     'Queries that have been canceled due to lock timeouts.'),
                    ('snapshot',
                     'Queries that have been canceled due to old snapshots.'),
                    ('bufferpin',
                     'Queries that have been canceled due to pinned buffers.'),
                    ('deadlock',
                     'Queries that have been canceled due to deadlocks.'),
                ):
                    graph.addField(field,
                                   field,
                                   draw='AREASTACK',
                                   type='DERIVE',
                                   min=0,
                                   info=desc)
                self.appendGraph('pg_repl_conflicts', graph)
            if self._detailGraphs and self.graphEnabled(
                    'pg_repl_conflicts_detail'):
                graph = MuninGraph(
                    'PostgreSQL - Replication Conflicts Detail',
                    'Number of queries cancelled due to conflict with recovery '
                    'on standby servers per database.',
                    info='Replication ',
                    args='--base 1000 --lower-limit 0',
                    autoFixNames=True)
                for db in dblist:
                    graph.addField(
                        db,
                        db,
                        draw='AREASTACK',
                        type='DERIVE',
                        min=0,
                        info="Queries on database %s cancelled due to conflict "
                        "with recovery on standby." % db)
                self.appendGraph('pg_repl_conflicts_detail', graph)
Exemplo n.º 36
0
    def __init__(self, argv=(), env=None, debug=False):
        """
        Populate Munin Plugin with MuninGraph instances.

        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        """
        MuninPlugin.__init__(self, argv, env, debug)

        # Get CPID from environment
        if self.cpid is None and self.envHasKey("cpid"):
            self.cpid = self.envGet("cpid")

        # Create stats URL
        self.stats_url = self.url_base + self.cpid

        # Set Munin graphs category
        self._category = "htc"

        # Total credit graph
        graph = MuninGraph("BOINC Total Credit", self._category,
                           vlabel="Cobblestones",
                           info="Total credit across all projects.",
                           args="--base 1000 --logarithmic")
        graph.addField("credit", "credit", type="GAUGE", draw="LINE2")
        self.appendGraph("total_credit", graph)

        # World Position graph
        graph = MuninGraph("World Position (Total Credit)", self._category,
                           info="Position in BOINC combined World stats based "
                                "on total credit.",
                           args="--lower-limit 0")
        graph.addField("position", "position", type="GAUGE", draw="LINE2")
        self.appendGraph("world_position", graph)

        # RAC graph
        graph = MuninGraph("BOINC Recent Average Credit", self._category,
                           info="Recent Average Credit across all projects.",
                           vlabel="Cobblestones",
                           args="--lower-limit 0")
        graph.addField("rac", "R.A.C.", type="GAUGE", draw="LINE2")
        self.appendGraph("rac", graph)

        # Credit per project graph
        graph = MuninGraph("BOINC Total Credit per project", self._category,
                           info="BOINC credit for each project.",
                           vlabel="Cobblestones",
                           args="--base 1000")
        # Maybe the type could be COUNTER here... Credit shouldn't decrease

        # Only add to the graph the projects that are active for this user
        for project in self.get_stats()["projects"]:
            project_name = project[0]

            # Find color for this project, if it exists
            if project_name in self.project_colors:
                color = self.project_colors[project_name]
            else:
                color = None

            graph.addField(proj_name_to_id(project_name), project_name.lower(),
                           type="GAUGE", draw="AREASTACK", colour=color,
                           info="Total Credit for project " + project_name)
        self.appendGraph("credits_per_proj", graph)
Exemplo n.º 37
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._host = self.envGet('host')
        self._port = self.envGet('port')
        self._db = self.envGet('db')
        self._password = self.envGet('password')
        self._socket_timeout = self.envGet('socket_timeout', None, float)
        self._unix_socket_path = self.envGet('unix_socket_path')
        self._category = 'Redis'

        self._serverInfo = RedisInfo(self._host, self._port, self._db,
                                     self._password, self._socket_timeout,
                                     self._unix_socket_path)
        self._stats = self._serverInfo.getStats()
        self._stats['rtt'] = self._serverInfo.ping()

        cmd_list = []
        db_list = []
        for k in self._stats.keys():
            if k.startswith('cmdstat_'):
                cmd_list.append(k[len('cmdstat_'):])
            elif k.startswith('db'):
                db_list.append(k)
        db_list.sort()
        cmd_list.sort()
        graphs = [
            ('redis_ping', 'Ping Latency (secs)',
             'Round Trip Time in seconds for Redis Ping.',
             (('rtt', 'rtt', 'LINE2', 'GAUGE', 'Round trip time.'), )),
            ('redis_conn_client', 'Active Client Connections',
             'Number of connections to Redis Server.', (
                 ('connected_clients', 'clients', 'AREA', 'GAUGE',
                  'Number of clients connected to server.'),
                 ('blocked_clients', 'blocked', 'LINE2', 'GAUGE',
                  'Number of clients pending on a blocking call.'),
             )),
            ('redis_conn_rate', 'Client Connections per Sec',
             'Connections accepted / rejected per second by the Redis Server.',
             (
                 ('rejected_connections', 'reject', 'AREASTACK', 'DERIVE',
                  'Number of connections rejected by the server.'),
                 ('total_connections_received', 'accept', 'AREASTACK',
                  'DERIVE', 'Number of connections accepted by the server.'),
             )),
            ('redis_cmd_rate', 'Commands Processed per Sec',
             'Number of commands processed per second by the Redis Server.',
             (('total_commands_processed', 'cmds', 'LINE2', 'DERIVE',
               'Number of commands processed by the Redis Server.'), )),
            ('redis_memory', 'Memory Usage (bytes)',
             'Memory usage of Redis Server.', (
                 ('used_memory_rss', 'rss', 'AREASTACK', 'GAUGE',
                  'Resident Memory space (bytes) allocated to Redis by the OS for '
                  'storing data.'),
                 ('used_memory_lua', 'lua', 'AREASTACK', 'GAUGE',
                  'Memory space (bytes) used by the Lua Engine.'),
                 ('used_memory', 'mem', 'LINE2', 'GAUGE',
                  'Memory space (bytes) allocated by Redis Allocator for storing data.'
                  ),
             )),
            ('redis_memory_fragmentation', 'Memory Fragmentation Ratio',
             'Ratio between RSS and virtual memory use for Redis Server. '
             'Values much higher than 1 imply fragmentation. Values less '
             'than 1 imply that memory has been swapped out by OS.',
             (('mem_fragmentation_ratio', 'ratio', 'LINE2', 'GAUGE',
               'Ratio between RSS and virtual memory use.'), )),
            ('redis_cpu_util', 'CPU Utilization',
             'Processor time utilized by Redis Server.', (
                 ('used_cpu_sys', 'srv_sys', 'AREASTACK', 'DERIVE',
                  'System CPU Time consumed by the server.'),
                 ('used_cpu_user', 'srv_user', 'AREASTACK', 'DERIVE',
                  'User CPU Time consumed by the server.'),
                 ('used_cpu_sys_children', 'child_sys', 'AREASTACK', 'DERIVE',
                  'System CPU Time consumed by the background processes.'),
                 ('used_cpu_user_children', 'child_user', 'AREASTACK',
                  'DERIVE',
                  'User CPU Time consumed by the background processes.'),
             )),
            ('redis_hits_misses', 'Hits/Misses per Sec',
             'Hits vs. misses in main dictionary lookup by Redis Server.', (
                 ('keyspace_hits', 'hit', 'AREASTACK', 'DERIVE',
                  'Number of hits in main dictionary lookup.'),
                 ('keyspace_misses', 'miss', 'AREASTACK', 'DERIVE',
                  'Number of misses in main dictionary lookup.'),
             )),
            ('redis_keys_expired', 'Expired Keys per Sec',
             'Number of keys expired by the Redis Server.',
             (('expired_keys', 'keys', 'LINE2', 'DERIVE',
               'Number of keys expired.'), )),
            ('redis_keys_evicted', 'Evicted Keys per Sec',
             'Number of keys evicted by the Redis Server due to memory limits.',
             (('evicted_keys', 'keys', 'LINE2', 'DERIVE',
               'Number of keys evicted.'), )),
            ('redis_subscriptions', 'Subscriptions',
             'Channels or patterns with subscribed clients.', (
                 ('pubsub_patterns', 'patterns', 'AREASTACK', 'GAUGE',
                  'Global number of pub/sub patterns with client subscriptions.'
                  ),
                 ('pubsub_channels', 'channels', 'AREASTACK', 'GAUGE',
                  'Global number of pub/sub channels with client subscriptions.'
                  ),
             )),
            ('redis_rdb_changes', 'RDB Pending Changes',
             'Number of pending changes since last RDB Dump of Redis Server.',
             (('rdb_changes_since_last_save', 'changes', 'LINE2', 'GAUGE',
               'Number of changes since last RDB Dump.'), )),
            ('redis_rdb_dumptime', 'RDB Dump Duration (sec)',
             'Duration of the last RDB Dump of Redis Server in seconds.',
             (('rdb_last_bgsave_time_sec', 'duration', 'LINE2', 'GAUGE',
               'Duration of the last RDB Dump in seconds.'), )),
        ]

        if self._stats.get('aof_enabled', 0) > 0:
            graphs.extend((
                ('redis_aof_filesize', 'AOF File Size (bytes)',
                 'Redis Server AOF File Size in bytes.',
                 (('aof_current_size', 'size', 'LINE2', 'GAUGE',
                   'AOF File Size in bytes.'), )),
                ('redis_aof_bufflen', 'AOF Buffer Length (bytes)',
                 'Redis Server AOF Buffer Length in bytes.',
                 (('aof_buffer_length', 'len', 'LINE2', 'GAUGE',
                   'AOF Buffer Length in bytes.'), )),
                ('redis_aof_rewrite_bufflen',
                 'AOF Rewrite Buffer Length (bytes)',
                 'Redis Server AOF Rewrite Buffer Length in bytes.',
                 (('aof_rewrite_buffer_length', 'len', 'LINE2', 'GAUGE',
                   'AOF Rewrite Buffer Length in bytes.'), )),
                ('redis_aof_rewritetime', 'AOF Rewrite Duration (sec)',
                 'Duration of the last AOF Rewrite of Redis Server in seconds.',
                 (('aof_last_rewrite_time_sec', 'duration', 'AREA', 'GAUGE',
                   'Duration of the last AOF Rewrite in seconds.'), )),
            ))

        for graph_name, graph_title, graph_info, graph_fields in graphs:
            if self.graphEnabled(graph_name):
                graph = MuninGraph("Redis - %s" % graph_title,
                                   self._category,
                                   info=graph_info,
                                   args='--base 1000 --lower-limit 0')
                for fname, flabel, fdraw, ftype, finfo in graph_fields:
                    if self._stats.has_key(fname):
                        graph.addField(fname,
                                       flabel,
                                       draw=fdraw,
                                       type=ftype,
                                       min=0,
                                       info=finfo)
                if graph.getFieldCount() > 0:
                    self.appendGraph(graph_name, graph)

        self._stats['db_total_keys'] = 0
        self._stats['db_total_expires'] = 0
        if self.graphEnabled('redis_db_totals'):
            for db in db_list:
                fname_keys = "%s_keys" % db
                fname_expires = "%s_expires" % db
                num_keys = self._stats[db].get('keys', 0)
                num_expires = self._stats[db].get('expires', 0)
                self._stats[fname_keys] = num_keys
                self._stats[fname_expires] = num_expires
                self._stats['db_total_keys'] += num_keys
                self._stats['db_total_expires'] += num_expires
            self._stats['db_total_persists'] = (
                self._stats['db_total_keys'] - self._stats['db_total_expires'])

        graph_name = 'redis_db_totals'
        if self.graphEnabled(graph_name) and len(db_list) > 0:
            graph = MuninGraph("Redis - Number of Keys",
                               self._category,
                               info="Number of keys stored by Redis Server",
                               args='--base 1000 --lower-limit 0')
            graph.addField('db_total_expires',
                           'expire',
                           'GAUGE',
                           'AREASTACK',
                           min=0,
                           info="Total number of keys with expiration.")
            graph.addField('db_total_persists',
                           'persist',
                           'GAUGE',
                           'AREASTACK',
                           min=0,
                           info="Total number of keys without expiration.")
            graph.addField('db_total_keys',
                           'total',
                           'GAUGE',
                           'LINE2',
                           min=0,
                           info="Total number of keys.",
                           colour='000000')
            self.appendGraph(graph_name, graph)

        graph_name = 'redis_db_keys'
        if self.graphEnabled(graph_name) and len(db_list) > 0:
            graph = MuninGraph(
                "Redis - Number of Keys per DB",
                self._category,
                info="Number of keys stored in each DB by Redis Server",
                args='--base 1000 --lower-limit 0')
            for db in db_list:
                fname = "%s_keys" % db
                graph.addField(fname,
                               db,
                               'GAUGE',
                               'AREASTACK',
                               min=0,
                               info="Number of keys stored in %s." % db)
            self.appendGraph(graph_name, graph)

        graph_name = 'redis_db_expires'
        if self.graphEnabled(graph_name) and len(db_list) > 0:
            graph = MuninGraph(
                "Redis - Number of Keys with Expiration per DB",
                self._category,
                info="Number of keys stored in each DB by Redis Server",
                args='--base 1000 --lower-limit 0')
            for db in db_list:
                fname = "%s_expires" % db
                graph.addField(
                    fname,
                    db,
                    'GAUGE',
                    'AREASTACK',
                    min=0,
                    info="Number of keys with expiration stored in %s." % db)
            self.appendGraph(graph_name, graph)
Exemplo n.º 38
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._host = self.envGet('host')
        self._port = self.envGet('port')
        self._user = self.envGet('user')
        self._password = self.envGet('password')
        self._statuspath = self.envGet('statuspath')
        self._ssl = self.envCheckFlag('ssl', False)

        if self.graphEnabled('apache_access'):
            graph = MuninGraph(
                'Apache Web Server - Throughput (Requests / sec)',
                'Apache',
                info='Throughput in Requests per second for Apache Web Server.',
                args='--base 1000 --lower-limit 0')
            graph.addField('reqs',
                           'reqs',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           info="Requests per second.")
            self.appendGraph('apache_access', graph)

        if self.graphEnabled('apache_bytes'):
            graph = MuninGraph(
                'Apache Web Server - Througput (bytes/sec)',
                'Apache',
                info='Throughput in bytes per second for Apache Web Server.',
                args='--base 1024 --lower-limit 0')
            graph.addField('bytes',
                           'bytes',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            self.appendGraph('apache_bytes', graph)

        if self.graphEnabled('apache_workers'):
            graph = MuninGraph(
                'Apache Web Server - Workers',
                'Apache',
                info='Worker utilization stats for Apache Web server.',
                args='--base 1000 --lower-limit 0')
            graph.addField('busy',
                           'busy',
                           draw='AREASTACK',
                           type='GAUGE',
                           info="Number of busy workers.")
            graph.addField('idle',
                           'idle',
                           draw='AREASTACK',
                           type='GAUGE',
                           info="Number of idle workers.")
            graph.addField('max',
                           'max',
                           draw='LINE2',
                           type='GAUGE',
                           info="Maximum number of workers permitted.",
                           colour='FF0000')
            self.appendGraph('apache_workers', graph)
Exemplo n.º 39
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._host = self.envGet('host')
        self._port = self.envGet('port', None, int)
        self._user = self.envGet('user')
        self._monpath = self.envGet('monpath')
        self._password = self.envGet('password')
        self._ssl = self.envCheckFlag('ssl', False)
        self._category = 'PHP'
        self._extras = False

        graph_name = 'php_apc_memory'
        if self.graphEnabled(graph_name):
            graph = MuninGraph('PHP APC Cache - Memory Usage (bytes)',
                               self._category,
                               info='Memory usage of PHP APC Cache in bytes.',
                               args='--base 1024 --lower-limit 0')
            graph.addField('filecache',
                           'File Cache',
                           draw='AREASTACK',
                           type='GAUGE')
            graph.addField('usercache',
                           'User Cache',
                           draw='AREASTACK',
                           type='GAUGE')
            graph.addField('other', 'Other', draw='AREASTACK', type='GAUGE')
            graph.addField('free', 'Free', draw='AREASTACK', type='GAUGE')
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_items'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP APC Cache - Cached Items',
                self._category,
                info='Number of items (files, user data) in PHP APC Cache.',
                args='--base 1000 --lower-limit 0')
            graph.addField('filecache',
                           'File Items',
                           draw='AREASTACK',
                           type='GAUGE')
            graph.addField('usercache',
                           'User Items',
                           draw='AREASTACK',
                           type='GAUGE')
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_reqs_filecache'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP APC - File Cache Requests per second',
                self._category,
                info=
                'PHP APC File Cache Requests (Hits and Misses) per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField('hits',
                           'hits',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0)
            graph.addField('misses',
                           'misses',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0)
            graph.addField('inserts',
                           'inserts',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_reqs_usercache'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP APC - User Cache Requests per second',
                self._category,
                info=
                'PHP APC User Cache Requests (Hits and Misses) per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField('hits',
                           'hits',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0)
            graph.addField('misses',
                           'misses',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0)
            graph.addField('inserts',
                           'inserts',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_expunge'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP APC - Cache Expunge Runs per second',
                self._category,
                info='PHP APC File and User Cache Expunge Runs per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField('filecache',
                           'File Cache',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            graph.addField('usercache',
                           'User Cache',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_mem_util_frag'
        if self.graphEnabled(graph_name):
            self._extras = True
            graph = MuninGraph(
                'PHP APC Cache - Memory Util. vs. Fragmentation (%)',
                self._category,
                info='PHP APC Cache Memory utilization and fragmentation.',
                args='--base 1000 --lower-limit 0',
                scale=False,
            )
            graph.addField('util',
                           'util',
                           draw='LINE2',
                           type='GAUGE',
                           min=0,
                           max=100)
            graph.addField('frag',
                           'frag',
                           draw='LINE2',
                           type='GAUGE',
                           min=0,
                           max=100)
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_mem_frag_count'
        if self.graphEnabled(graph_name):
            self._extras = True
            graph = MuninGraph(
                'PHP APC Cache - Fragment Count',
                self._category,
                info='Number of memory fragments for PHP APC Cache.',
                args='--base 1000 --lower-limit 0')
            graph.addField('num', 'num', draw='LINE2', type='GAUGE')
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_mem_frag_avgsize'
        if self.graphEnabled(graph_name):
            self._extras = True
            graph = MuninGraph(
                'PHP APC Cache - Avg. Fragment Size (bytes)',
                self._category,
                info='Average memory fragment size in bytes for PHP APC Cache.',
                args='--base 1000 --lower-limit 0')
            graph.addField('size', 'size', draw='LINE2', type='GAUGE')
            self.appendGraph(graph_name, graph)
Exemplo n.º 40
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('engine', '^\w+$')

        self._host = self.envGet('host')
        self._port = self.envGet('port')
        self._database = self.envGet('database')
        self._user = self.envGet('user')
        self._password = self.envGet('password')

        self._dbconn = MySQLinfo(self._host, self._port, self._database,
                                 self._user, self._password)

        if self.graphEnabled('mysql_connections'):
            graph = MuninGraph(
                'MySQL - Connections per second',
                'MySQL',
                info=
                'MySQL Database Server new and aborted connections per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField(
                'conn',
                'conn',
                draw='LINE2',
                type='DERIVE',
                min=0,
                info='The number of connection attempts to the MySQL server.')
            graph.addField(
                'abort_conn',
                'abort_conn',
                draw='LINE2',
                type='DERIVE',
                min=0,
                info=
                'The number of failed attempts to connect to the MySQL server.'
            )
            graph.addField(
                'abort_client',
                'abort_client',
                draw='LINE2',
                type='DERIVE',
                min=0,
                info='The number of connections that were aborted, because '
                'the client died without closing the connection properly.')
            self.appendGraph('mysql_connections', graph)

        if self.graphEnabled('mysql_traffic'):
            graph = MuninGraph(
                'MySQL - Network Traffic (bytes/sec)',
                'MySQL',
                info=
                'MySQL Database Server Network Traffic in bytes per second.',
                args='--base 1000 --lower-limit 0',
                vlabel='bytes in (-) / out (+) per second')
            graph.addField('rx',
                           'bytes',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           graph=False)
            graph.addField('tx',
                           'bytes',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           negative='rx',
                           info="Bytes In (-) / Out (+) per second.")
            self.appendGraph('mysql_traffic', graph)

        if self.graphEnabled('mysql_slowqueries'):
            graph = MuninGraph(
                'MySQL - Slow Queries per second',
                'MySQL',
                info='The number of queries that have taken more than '
                'long_query_time seconds.',
                args='--base 1000 --lower-limit 0')
            graph.addField('queries',
                           'queries',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            self.appendGraph('mysql_slowqueries', graph)

        if self.graphEnabled('mysql_rowmodifications'):
            graph = MuninGraph(
                'MySQL - Row Insert, Delete, Updates per second',
                'MySQL',
                info='MySQL Inserted, Deleted, Updated Rows per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField(
                'insert',
                'insert',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info='The number of requests to insert a rows into tables.')
            graph.addField(
                'update',
                'update',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info='The number of requests to update a rows in a tables.')
            graph.addField(
                'delete',
                'delete',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info='The number of requests to delete rows from tables.')
            self.appendGraph('mysql_rowmodifications', graph)

        if self.graphEnabled('mysql_tablelocks'):
            graph = MuninGraph('MySQL - Table Locks per second',
                               'MySQL',
                               info='MySQL Table Locks per second.',
                               args='--base 1000 --lower-limit 0')
            graph.addField(
                'waited',
                'waited',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info='The number of times that a request for a table lock '
                'could not be granted immediately and a wait was needed.')
            graph.addField(
                'immediate',
                'immediate',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info='The number of times that a request for a table lock '
                'could be granted immediately.')
            self.appendGraph('mysql_tablelocks', graph)

        if self.graphEnabled('mysql_threads'):
            graph = MuninGraph('MySQL - Threads',
                               'MySQL',
                               info='MySQL Database Server threads status.',
                               args='--base 1000 --lower-limit 0')
            graph.addField('running',
                           'running',
                           draw='AREASTACK',
                           type='GAUGE',
                           info="Number of threads executing queries.")
            graph.addField(
                'idle',
                'idle',
                draw='AREASTACK',
                type='GAUGE',
                info="Number of idle threads with connected clients.")
            graph.addField(
                'cached',
                'cached',
                draw='AREASTACK',
                type='GAUGE',
                info="Number of cached threads without connected clients.")
            graph.addField('total',
                           'total',
                           draw='LINE2',
                           type='GAUGE',
                           colour='000000',
                           info="Total number of threads.")
            self.appendGraph('mysql_threads', graph)
Exemplo n.º 41
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._category = 'Processes'

        for (prefix, title,
             desc) in (('proc', self._category, 'Number of processes'),
                       ('thread', 'Threads', 'Number of threads')):
            graph_name = '%s_status' % prefix
            graph_title = '%s - Status' % title
            graph_desc = '%s discriminated by status.' % desc
            if self.graphEnabled(graph_name):
                graph = MuninGraph(graph_title,
                                   self._category,
                                   info=graph_desc,
                                   args='--base 1000 --lower-limit 0')
                for (fname,
                     fdesc) in (('unint_sleep',
                                 'Uninterruptable sleep. (Usually I/O)'),
                                ('stopped',
                                 'Stopped, either by job control signal '
                                 'or because it is being traced.'),
                                ('defunct', 'Defunct (zombie) process. '
                                 'Terminated but not reaped by parent.'),
                                ('running',
                                 'Running or runnable (on run queue).'),
                                ('sleep', 'Interruptable sleep. '
                                 'Waiting for an event to complete.')):
                    graph.addField(fname,
                                   fname,
                                   type='GAUGE',
                                   draw='AREA',
                                   info=fdesc)
                self.appendGraph(graph_name, graph)

            graph_name = '%s_prio' % prefix
            graph_title = '%s - Priority' % title
            graph_desc = '%s discriminated by priority.' % desc
            if self.graphEnabled(graph_name):
                graph = MuninGraph(graph_title,
                                   self._category,
                                   info=graph_desc,
                                   args='--base 1000 --lower-limit 0')
                for (fname, fdesc) in (('high', 'High priority.'),
                                       ('low', 'Low priority.'),
                                       ('norm', 'Normal priority.')):
                    graph.addField(fname,
                                   fname,
                                   type='GAUGE',
                                   draw='AREA',
                                   info=fdesc)
                graph.addField('locked',
                               'locked',
                               type='GAUGE',
                               draw='LINE2',
                               info='Has pages locked into memory.')
                self.appendGraph(graph_name, graph)
Exemplo n.º 42
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._category = 'System'
        self._sysinfo = SystemInfo()
        self._loadstats = None
        self._cpustats = None
        self._memstats = None
        self._procstats = None
        self._vmstats = None

        if self.graphEnabled('sys_loadavg'):
            graph = MuninGraph('Load Average',
                               self._category,
                               info='Load Average (15 min, 5 min, 1 min).',
                               args='--base 1000 --lower-limit 0')
            graph.addField('load15min', '15 min', type='GAUGE', draw='AREA')
            graph.addField('load5min', '5 min', type='GAUGE', draw='LINE1')
            graph.addField('load1min', '1 min', type='GAUGE', draw='LINE1')
            self.appendGraph('sys_loadavg', graph)

        if self.graphEnabled('sys_cpu_util'):
            self._cpustats = self._sysinfo.getCPUuse()
            graph = MuninGraph('CPU Utilization (%)',
                               self._category,
                               info='System CPU Utilization.',
                               args='--base 1000 --lower-limit 0')
            for field in [
                    'system', 'user', 'nice', 'idle', 'iowait', 'irq',
                    'softirq', 'steal', 'guest'
            ]:
                if self._cpustats.has_key(field):
                    graph.addField(field,
                                   field,
                                   type='DERIVE',
                                   min=0,
                                   cdef='%s,10,/' % field,
                                   draw='AREASTACK')
            self.appendGraph('sys_cpu_util', graph)

        if self.graphEnabled('sys_mem_util'):
            if self._memstats is None:
                self._memstats = self._sysinfo.getMemoryUse()
            self._memstats['MemUsed'] = self._memstats['MemTotal']
            for field in ['MemFree', 'SwapCached', 'Buffers', 'Cached']:
                if self._memstats.has_key(field):
                    self._memstats['MemUsed'] -= self._memstats[field]
            self._memstats['SwapUsed'] = (self._memstats['SwapTotal'] -
                                          self._memstats['SwapFree'])
            graph = MuninGraph('Memory Utilization (bytes)',
                               self._category,
                               info='System Memory Utilization in bytes.',
                               args='--base 1024 --lower-limit 0')
            for field in [
                    'MemUsed', 'SwapCached', 'Buffers', 'Cached', 'MemFree',
                    'SwapUsed'
            ]:
                if self._memstats.has_key(field):
                    graph.addField(field,
                                   field,
                                   type='GAUGE',
                                   draw='AREASTACK')
            self.appendGraph('sys_mem_util', graph)

        if self.graphEnabled('sys_mem_avail'):
            if self._memstats is None:
                self._memstats = self._sysinfo.getMemoryUse()
            if self._memstats.has_key('Hugepagesize'):
                self._memstats['MemHugePages'] = (
                    self._memstats['HugePages_Total'] *
                    self._memstats['Hugepagesize'])
            self._memstats['MemKernel'] = self._memstats['MemTotal']
            for field in ['MemHugePages', 'Active', 'Inactive', 'MemFree']:
                if self._memstats.has_key(field):
                    self._memstats['MemKernel'] -= self._memstats[field]
            graph = MuninGraph(
                'Memory Utilization - Active/Inactive (bytes)',
                self._category,
                info='System Memory Utilization (Active/Inactive) in bytes.',
                args='--base 1024 --lower-limit 0')
            for field in [
                    'MemKernel', 'MemHugePages', 'Active', 'Inactive',
                    'MemFree'
            ]:
                if self._memstats.has_key(field):
                    graph.addField(field,
                                   field,
                                   type='GAUGE',
                                   draw='AREASTACK')
            self.appendGraph('sys_mem_avail', graph)

        if self.graphEnabled('sys_mem_huge'):
            if self._memstats is None:
                self._memstats = self._sysinfo.getMemoryUse()
            if (self._memstats.has_key('Hugepagesize')
                    and self._memstats['HugePages_Total'] > 0):
                graph = MuninGraph(
                    'Memory Utilization - Huge Pages (bytes)',
                    self._category,
                    info='System Memory Huge Pages Utilization in bytes.',
                    args='--base 1024 --lower-limit 0')
                for field in ['Rsvd', 'Surp', 'Free']:
                    fkey = 'HugePages_' + field
                    if self._memstats.has_key(fkey):
                        graph.addField(field,
                                       field,
                                       type='GAUGE',
                                       draw='AREASTACK')
                self.appendGraph('sys_mem_huge', graph)

        if self.graphEnabled('sys_processes'):
            graph = MuninGraph(
                'Processes',
                self._category,
                info='Number of processes in running and blocked state.',
                args='--base 1000 --lower-limit 0')
            graph.addField('running',
                           'running',
                           type='GAUGE',
                           draw='AREASTACK')
            graph.addField('blocked',
                           'blocked',
                           type='GAUGE',
                           draw='AREASTACK')
            self.appendGraph('sys_processes', graph)

        if self.graphEnabled('sys_forks'):
            graph = MuninGraph('Process Forks per Second',
                               self._category,
                               info='Process Forks per Second.',
                               args='--base 1000 --lower-limit 0')
            graph.addField('forks',
                           'forks',
                           type='DERIVE',
                           min=0,
                           draw='LINE2')
            self.appendGraph('sys_forks', graph)

        if self.graphEnabled('sys_intr_ctxt'):
            if self._procstats is None:
                self._procstats = self._sysinfo.getProcessStats()
            graph = MuninGraph(
                'Interrupts and Context Switches per Second',
                self._category,
                info='Interrupts and Context Switches per Second',
                args='--base 1000 --lower-limit 0')
            labels = ['irq', 'softirq', 'ctxt']
            infos = [
                'Hardware Interrupts per second',
                'Software Interrupts per second.',
                'Context Switches per second.'
            ]
            idx = 0
            for field in ['intr', 'softirq', 'ctxt']:
                if self._procstats.has_key(field):
                    graph.addField(field,
                                   labels[idx],
                                   type='DERIVE',
                                   min=0,
                                   draw='LINE2',
                                   info=infos[idx])
                    idx += 1
            self.appendGraph('sys_intr_ctxt', graph)

        if self.graphEnabled('sys_vm_paging'):
            graph = MuninGraph(
                'VM - Paging',
                self._category,
                info=
                'Virtual Memory Paging: Pages In (-) / Out (+) per Second.',
                args='--base 1000 --lower-limit 0',
                vlabel='pages in (-) / out (+) per second')
            graph.addField('in',
                           'pages',
                           type='DERIVE',
                           min=0,
                           draw='LINE2',
                           graph=False)
            graph.addField('out',
                           'pages',
                           type='DERIVE',
                           min=0,
                           draw='LINE2',
                           negative='in')
            self.appendGraph('sys_vm_paging', graph)

        if self.graphEnabled('sys_vm_swapping'):
            graph = MuninGraph(
                'VM - Swapping',
                self._category,
                info=
                'Virtual Memory Swapping: Pages In (-) / Out (+) per Second.',
                args='--base 1000 --lower-limit 0',
                vlabel='pages in (-) / out (+) per second')
            graph.addField('in',
                           'pages',
                           type='DERIVE',
                           min=0,
                           draw='LINE2',
                           graph=False)
            graph.addField('out',
                           'pages',
                           type='DERIVE',
                           min=0,
                           draw='LINE2',
                           negative='in')
            self.appendGraph('sys_vm_swapping', graph)
Exemplo n.º 43
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._host = self.envGet('host')
        self._port = self.envGet('port')
        self._user = self.envGet('user')
        self._monpath = self.envGet('monpath')
        self._password = self.envGet('password')
        self._ssl = self.envCheckFlag('ssl', False)

        if self.graphEnabled('php_apc_memory'):
            graph = MuninGraph(
                'PHP APC Cache - Memory Utilization (bytes)',
                'PHP',
                info='Memory Utilization of PHP APC Cache in bytes.',
                args='--base 1000 --lower-limit 0')
            graph.addField('filecache',
                           'File Cache',
                           draw='AREASTACK',
                           type='GAUGE')
            graph.addField('usercache',
                           'User Cache',
                           draw='AREASTACK',
                           type='GAUGE')
            graph.addField('other', 'Other', draw='AREASTACK', type='GAUGE')
            graph.addField('free', 'Free', draw='AREASTACK', type='GAUGE')
            self.appendGraph('php_apc_memory', graph)

        if self.graphEnabled('php_apc_items'):
            graph = MuninGraph(
                'PHP APC Cache - Cached Items',
                'PHP',
                info='Number of items (files, user data) in PHP APC Cache.',
                args='--base 1000 --lower-limit 0')
            graph.addField('filecache',
                           'File Cache',
                           draw='AREASTACK',
                           type='GAUGE')
            graph.addField('usercache',
                           'User Cache',
                           draw='AREASTACK',
                           type='GAUGE')
            self.appendGraph('php_apc_items', graph)

        if self.graphEnabled('php_apc_reqs_filecache'):
            graph = MuninGraph(
                'PHP APC - File Cache Requests per second',
                'PHP',
                info=
                'PHP APC File Cache Requests (Hits and Misses) per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField('hits',
                           'hits',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0)
            graph.addField('misses',
                           'misses',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0)
            graph.addField('inserts',
                           'inserts',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            self.appendGraph('php_apc_reqs_filecache', graph)

        if self.graphEnabled('php_apc_reqs_usercache'):
            graph = MuninGraph(
                'PHP APC - User Cache Requests per second',
                'PHP',
                info=
                'PHP APC User Cache Requests (Hits and Misses) per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField('hits',
                           'hits',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0)
            graph.addField('misses',
                           'misses',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0)
            graph.addField('inserts',
                           'inserts',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            self.appendGraph('php_apc_reqs_usercache', graph)

        if self.graphEnabled('php_apc_expunge'):
            graph = MuninGraph(
                'PHP APC - Cache Expunge Runs per second',
                'PHP',
                info='PHP APC File and User Cache Expunge Runs per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField('filecache',
                           'File Cache',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            graph.addField('usercache',
                           'User Cache',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            self.appendGraph('php_apc_expunge', graph)
Exemplo n.º 44
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._host = self.envGet('host')
        self._port = self.envGet('port', None, int)
        self._socket_file = self.envGet('socket_file', None)
        self._category = 'Memcached'

        self._stats = None
        self._prev_stats = self.restoreState()
        if self._prev_stats is None:
            serverInfo = MemcachedInfo(self._host, self._port,
                                       self._socket_file)
            self._stats = serverInfo.getStats()
            stats = self._stats
        else:
            stats = self._prev_stats
        if stats is None:
            raise Exception("Undetermined error accesing stats.")

        if (self.graphEnabled('memcached_connections')
                and stats.has_key('curr_connections')):
            graph = MuninGraph('Memcached - Active Connections',
                               self._category,
                               info='Active connections for Memcached Server.',
                               vlabel='connections',
                               args='--base 1000 --lower-limit 0')
            graph.addField('conn', 'conn', draw='LINE2', type='GAUGE')
            self.appendGraph('memcached_connections', graph)

        if (self.graphEnabled('memcached_items')
                and stats.has_key('curr_items')):
            graph = MuninGraph(
                'Memcached - Items',
                self._category,
                info='Current number of items stored on Memcached Server.',
                vlabel='items',
                args='--base 1000 --lower-limit 0')
            graph.addField('items', 'items', draw='LINE2', type='GAUGE')
            self.appendGraph('memcached_items', graph)

        if (self.graphEnabled('memcached_memory') and stats.has_key('bytes')):
            graph = MuninGraph(
                'Memcached - Memory Usage',
                self._category,
                info='Memory used to store items on Memcached Server in bytes.',
                vlabel='bytes',
                args='--base 1024 --lower-limit 0')
            graph.addField('bytes', 'bytes', draw='LINE2', type='GAUGE')
            self.appendGraph('memcached_memory', graph)

        if (self.graphEnabled('memcached_connrate')
                and stats.has_key('total_connections')):
            graph = MuninGraph('Memcached - Throughput - Connections',
                               self._category,
                               info='Connections per second.',
                               vlabel='conn / sec',
                               args='--base 1000 --lower-limit 0')
            graph.addField('conn', 'conn', draw='LINE2', type='DERIVE', min=0)
            self.appendGraph('memcached_connrate', graph)

        if (self.graphEnabled('memcached_traffic')
                and stats.has_key('bytes_read')
                and stats.has_key('bytes_written')):
            graph = MuninGraph(
                'Memcached - Throughput - Network',
                self._category,
                info='Bytes sent (+) / received (-)  by Memcached per second.',
                vlabel='bytes in (-) / out (+) per second',
                args='--base 1024 --lower-limit 0')
            graph.addField('rxbytes',
                           'bytes',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           graph=False)
            graph.addField('txbytes',
                           'bytes',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           negative='rxbytes')
            self.appendGraph('memcached_traffic', graph)

        if (self.graphEnabled('memcached_reqrate') and stats.has_key('cmd_set')
                and stats.has_key('cmd_get')):
            graph = MuninGraph('Memcached - Throughput - Request Rate',
                               self._category,
                               info='Requests per second.',
                               vlabel='reqs / sec',
                               args='--base 1000 --lower-limit 0')
            for (fname, fstat,
                 fstr) in (('set', 'cmd_set',
                            'Set'), ('get', 'cmd_get',
                                     'Get'), ('del', 'delete_hits', 'Delete'),
                           ('cas', 'cas_hits', 'CAS'), ('incr', 'incr_hits',
                                                        'Increment'),
                           ('decr', 'decr_hits', 'Decrement')):
                if stats.has_key(fstat):
                    graph.addField(fname,
                                   fname,
                                   draw='AREASTACK',
                                   type='DERIVE',
                                   min=0,
                                   info='%s requests per second.' % fstr)
            self.appendGraph('memcached_reqrate', graph)

        if (self.graphEnabled('memcached_statget')
                and stats.has_key('cmd_get')):
            graph = MuninGraph('Memcached - Stats - Get',
                               self._category,
                               info='Get requests per second.',
                               vlabel='reqs / sec',
                               args='--base 1000 --lower-limit 0')
            graph.addField('hit',
                           'hit',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Get request hits per second.')
            graph.addField('miss',
                           'miss',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Get request misses per second.')
            graph.addField('total',
                           'total',
                           draw='LINE1',
                           type='DERIVE',
                           min=0,
                           colour='000000',
                           info='Total get requests per second.')
            self.appendGraph('memcached_statget', graph)

        if (self.graphEnabled('memcached_statset')
                and stats.has_key('cmd_set')):
            graph = MuninGraph('Memcached - Stats - Set',
                               self._category,
                               info='Set requests per second.',
                               vlabel='reqs / sec',
                               args='--base 1000 --lower-limit 0')
            graph.addField('hit',
                           'hit',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Set request hits per second.')
            graph.addField('miss',
                           'miss',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Set request misses per second.')
            graph.addField('total',
                           'total',
                           draw='LINE1',
                           type='DERIVE',
                           min=0,
                           colour='000000',
                           info='Total set requests per second.')
            self.appendGraph('memcached_statset', graph)

        if (self.graphEnabled('memcached_statdel')
                and stats.has_key('delete_hits')):
            graph = MuninGraph('Memcached - Stats - Delete',
                               self._category,
                               info='Delete requests per second.',
                               vlabel='reqs / sec',
                               args='--base 1000 --lower-limit 0')
            graph.addField('hit',
                           'hit',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Delete request hits per second.')
            graph.addField('miss',
                           'miss',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Delete request misses per second.')
            graph.addField('total',
                           'total',
                           draw='LINE1',
                           type='DERIVE',
                           min=0,
                           colour='000000',
                           info='Total delete requests per second.')
            self.appendGraph('memcached_statdel', graph)

        if (self.graphEnabled('memcached_statcas')
                and stats.has_key('cas_hits')):
            graph = MuninGraph('Memcached - Stats - CAS',
                               self._category,
                               info='CAS requests per second.',
                               vlabel='reqs / sec',
                               args='--base 1000 --lower-limit 0')
            graph.addField('hit',
                           'hit',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='CAS request hits per second.')
            graph.addField('miss',
                           'miss',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='CAS request misses per second.')
            graph.addField('badval',
                           'badval',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='CAS requests hits with bad value per second.')
            graph.addField('total',
                           'total',
                           draw='LINE1',
                           type='DERIVE',
                           min=0,
                           colour='000000',
                           info='Total CAS requests per second.')
            self.appendGraph('memcached_statcas', graph)

        if (self.graphEnabled('memcached_statincrdecr')
                and stats.has_key('incr_hits') and stats.has_key('decr_hits')):
            graph = MuninGraph(
                'Memcached - Stats - Incr / Decr',
                self._category,
                info='Increment / decrement requests per second.',
                vlabel='reqs / sec',
                args='--base 1000 --lower-limit 0')
            graph.addField('incr_hit',
                           'incr_hit',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Increment hits per second.')
            graph.addField('decr_hit',
                           'decr_hit',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Decrement hits per second.')
            graph.addField('incr_miss',
                           'incr_miss',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Increment misses per second.')
            graph.addField('decr_miss',
                           'decr_miss',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Decrement misses per second.')
            graph.addField(
                'total',
                'total',
                draw='LINE1',
                type='DERIVE',
                min=0,
                colour='000000',
                info='Total Increment / decrement requests per second.')
            self.appendGraph('memcached_statincrdecr', graph)

        if (self.graphEnabled('memcached_statevict')
                and stats.has_key('evictions')):
            graph = MuninGraph('Memcached - Stats - Evictions',
                               self._category,
                               info='Cache evictions and reclaims per second.',
                               vlabel='per second',
                               args='--base 1000 --lower-limit 0')
            graph.addField('evict',
                           'evict',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           info='Items evicted from cache per second.')
            if stats.has_key('reclaimed'):
                graph.addField(
                    'reclaim',
                    'reclaim',
                    draw='LINE2',
                    type='DERIVE',
                    min=0,
                    info='Items stored over expired entries per second.')
            self.appendGraph('memcached_statevict', graph)

        if (self.graphEnabled('memcached_statauth')
                and stats.has_key('auth_cmds')):
            graph = MuninGraph('Memcached - Stats - Autentication',
                               self._category,
                               info='Autentication requests per second.',
                               vlabel='reqs / sec',
                               args='--base 1000 --lower-limit 0')
            graph.addField('reqs',
                           'reqs',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           info='Authentication requests per second.')
            graph.addField('errors',
                           'errors',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           info='Authentication errors per second.')
            self.appendGraph('memcached_statauth', graph)

        if (self.graphEnabled('memcached_hitpct') and stats.has_key('cmd_set')
                and stats.has_key('cmd_get')):
            graph = MuninGraph('Memcached - Hit Percent',
                               self._category,
                               info='Hit percent for memcached requests.',
                               vlabel='%',
                               args='--base 1000 --lower-limit 0')
            graph.addField('set',
                           'set',
                           draw='LINE2',
                           type='GAUGE',
                           info='Stored items vs. total set requests.')
            for (fname, fstat,
                 fstr) in (('get', 'cmd_get',
                            'Get'), ('del', 'delete_hits',
                                     'Delete'), ('cas', 'cas_hits', 'CAS'),
                           ('incr', 'incr_hits',
                            'Increment'), ('decr', 'decr_hits', 'Decrement')):
                if stats.has_key(fstat):
                    graph.addField(fname,
                                   fname,
                                   draw='LINE2',
                                   type='GAUGE',
                                   info='%s requests - hits vs total.' % fstr)
            self.appendGraph('memcached_hitpct', graph)
Exemplo n.º 45
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('ifaces', '^[\w\d]+$')

        self._wanpipeInfo = WanpipeInfo()
        self._ifaceStats = self._wanpipeInfo.getIfaceStats()
        self._ifaceList = []
        for iface in list(self._ifaceStats):
            if self.ifaceIncluded(iface):
                self._ifaceList.append(iface)
        self._ifaceList.sort()

        for iface in self._ifaceList:
            if self._reqIfaceList is None or iface in self._reqIfaceList:
                if self.graphEnabled('wanpipe_traffic'):
                    graph = MuninGraph(
                        'Wanpipe - Traffic - %s' % iface,
                        'Asterisk',
                        info='Traffic Stats for Wanpipe Interface %s '
                        'in packets/sec.' % iface,
                        args='--base 1000 --lower-limit 0',
                        vlabel='packets in (-) / out (+) per second')
                    graph.addField('rxpackets',
                                   'packets',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   graph=False)
                    graph.addField('txpackets',
                                   'packets',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   negative='rxpackets')
                    self.appendGraph('wanpipe_traffic_%s' % iface, graph)

                if self.graphEnabled('wanpipe_errors'):
                    graph = MuninGraph(
                        'Wanpipe - Errors - %s' % iface,
                        'Asterisk',
                        info='Error Stats for Wanpipe Interface %s'
                        ' in errors/sec.' % iface,
                        args='--base 1000 --lower-limit 0',
                        vlabel='errors in (-) / out (+) per second')
                    graph.addField('rxerrs',
                                   'errors',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   graph=False)
                    graph.addField('txerrs',
                                   'errors',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   negative='txerrs',
                                   info='Rx(-)/Tx(+) Errors per second.')
                    graph.addField('rxframe',
                                   'frm/crr',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   graph=False)
                    graph.addField(
                        'txcarrier',
                        'frm/crr',
                        draw='LINE2',
                        type='DERIVE',
                        min=0,
                        negative='rxframe',
                        info='Frame(-)/Carrier(+) Errors per second.')
                    graph.addField('rxdrop',
                                   'drop',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   graph=False)
                    graph.addField(
                        'txdrop',
                        'drop',
                        draw='LINE2',
                        type='DERIVE',
                        min=0,
                        negative='rxdrop',
                        info='Rx(-)/Tx(+) Dropped Packets per second.')
                    graph.addField('rxfifo',
                                   'fifo',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   graph=False)
                    graph.addField('txfifo',
                                   'fifo',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   negative='rxfifo',
                                   info='Rx(-)/Tx(+) FIFO Errors per second.')
                    self.appendGraph('wanpipe_errors_%s' % iface, graph)

                if self.graphEnabled('wanpipe_pri_errors'):
                    graph = MuninGraph(
                        'Wanpipe - ISDN PRI Stats - %s' % iface,
                        'Asterisk',
                        info='ISDN PRI Error Stats for Wanpipe Interface %s'
                        ' in errors/sec.' % iface,
                        args='--base 1000 --lower-limit 0',
                        vlabel='errors in (-) / out (+) per second')
                    graph.addField(
                        'linecodeviolation',
                        'Line Code Violation',
                        draw='LINE2',
                        type='DERIVE',
                        min=0,
                        info='Line Code Violation errors per second.')
                    graph.addField('farendblockerrors',
                                   'Far End Block Errors',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   info='Far End Block errors per second.')
                    graph.addField('crc4errors',
                                   'CRC4 Errors',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   info='CRC4 errors per second.')
                    graph.addField('faserrors',
                                   'FAS Errors',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   info='FAS errors per second.')
                    self.appendGraph('wanpipe_pri_errors_%s' % iface, graph)

        if self.graphEnabled('wanpipe_pri_rxlevel'):
            graph = MuninGraph('Wanpipe - ISDN PRI Signal Level',
                               'Asterisk',
                               info='ISDN PRI received signal level in DB.',
                               args='--base 1000 --lower-limit 0',
                               vlabel='db')
            for iface in self._ifaceList:
                if self._reqIfaceList is None or iface in self._reqIfaceList:
                    graph.addField(iface, iface, draw='LINE2')
            self.appendGraph('wanpipe_pri_rxlevel', graph)
Exemplo n.º 46
0
 def __init__(self, argv=(), env={}, debug=False):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self.envRegisterFilter('db', '^\w+$')
     self._host = self.envGet('host')
     self._port = self.envGet('port', None, int)
     self._database = self.envGet('database')
     self._user = self.envGet('user')
     self._password = self.envGet('password')
     self._detailGraphs = self.envCheckFlag('detail_graphs', False)
     
     self._dbconn = PgInfo(self._host, self._port, self._database, 
                           self._user, self._password)
     dblist = [db for db in self._dbconn.getDatabases()
               if self.dbIncluded(db)]
     dblist.sort()
     
     if self.graphEnabled('pg_connections'):
         graph = MuninGraph('PostgreSQL - Active Connections', 
             'PostgreSQL Sys',
             info='Active connections for PostgreSQL Database Server.',
             args='--base 1000 --lower-limit 0',
             autoFixNames = True)
         for db in dblist:
             graph.addField(db, db, draw='AREASTACK', type='GAUGE',
                 info="Active connections to database %s." % db)
         graph.addField('total', 'total', draw='LINE2', type='GAUGE', 
                        colour='000000',
             info="Total number of active connections.")
         graph.addField('max_conn', 'max_conn', draw='LINE2', type='GAUGE', 
                        colour='FF0000',
             info="Global server level concurrent connections limit.")
         self.appendGraph('pg_connections', graph)
     
     if self.graphEnabled('pg_diskspace'):
         graph = MuninGraph('PostgreSQL - Database Disk Usage', 
             'PostgreSQL Sys',
             info='Disk usage of databases on PostgreSQL Server in bytes.',
             args='--base 1024 --lower-limit 0',
             autoFixNames = True)
         for db in dblist:
             graph.addField(db, db, draw='AREASTACK', type='GAUGE',
                 info="Disk usage of database %s." % db)
         graph.addField('total', 'total', draw='LINE2', type='GAUGE', 
             colour='000000', info="Total disk usage of all databases.")
         self.appendGraph('pg_diskspace', graph)
     
     if self.graphEnabled('pg_blockreads'):
         graph = MuninGraph('PostgreSQL - Block Read Stats', 'PostgreSQL Sys',
             info='Block read stats for PostgreSQL Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('blk_hit', 'cache hits', draw='AREASTACK', 
             type='DERIVE', min=0, 
             info="Blocks read from PostgreSQL Cache per second.")
         graph.addField('blk_read', 'disk reads', draw='AREASTACK', 
             type='DERIVE', min=0,
             info="Blocks read directly from disk or operating system "
                  "disk cache per second.")
         self.appendGraph('pg_blockreads', graph)
     
     if self.graphEnabled('pg_xact'):
         graph = MuninGraph('PostgreSQL - Transactions', 'PostgreSQL Sys',
             info='Transaction commit / rollback Stats for PostgreSQL Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('commits', 'commits', draw='LINE2', type='DERIVE', 
                        min=0, info="Transactions per second.")
         graph.addField('rollbacks', 'rollbacks', draw='LINE2', type='DERIVE', 
                        min=0, info="Rollbacks per second.")
         self.appendGraph('pg_xact', graph)
     
     if self._dbconn.checkVersion('8.3'):
         if self.graphEnabled('pg_checkpoints'):
             graph = MuninGraph('PostgreSQL - Checkpoints per minute', 
                 'PostgreSQL Sys',
                 info='Number of Checkpoints per Minute for PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0', period='minute')
             graph.addField('req', 'req', draw='LINE2', type='DERIVE', 
                            min=0, info="Requested checkpoints..")
             graph.addField('timed', 'timed', draw='LINE2', type='DERIVE', 
                            min=0, info="Check points started by timeout.")
             self.appendGraph('pg_checkpoints', graph)
         if self.graphEnabled('pg_bgwriter'):
             graph = MuninGraph('PostgreSQL - BgWriter Stats (blocks / second)', 
                 'PostgreSQL Sys',
                 info='PostgreSQL Server - Bgwriter - Blocks written per second.',
                 args='--base 1000 --lower-limit 0', period='minute')
             graph.addField('backend', 'backend', draw='LINE2', 
                            type='DERIVE', min=0, 
                            info="Buffers written by backend and not bgwriter.")
             graph.addField('clean', 'clean', draw='LINE2', 
                            type='DERIVE', min=0, 
                            info="Buffers cleaned by bgwriter runs.")
             graph.addField('chkpoint', 'chkpoint', draw='LINE2', type='DERIVE', 
                            min=0, info="Buffers written performing checkpoints.")
             self.appendGraph('pg_bgwriter', graph)
     
     if self.graphEnabled('pg_tup_read'):
         graph = MuninGraph('PostgreSQL - Tuple Reads', 'PostgreSQL Sys',
             info='Tuple return and fetch Stats for PostgreSQL Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('fetch', 'fetch', draw='AREASTACK', 
             type='DERIVE', min=0, 
             info="Tuples returned per second by table or index scans.")
         graph.addField('return', 'return', draw='AREASTACK', 
             type='DERIVE', min=0,
             info="Tuples fetched per second from tables using indices "
                  "or bitmap scans.")
         self.appendGraph('pg_tup_read', graph)
         
     if self.graphEnabled('pg_tup_write'):
         graph = MuninGraph('PostgreSQL - Tuple Writes', 'PostgreSQL Sys',
             info='Tuple insert, update and delete Stats for PostgreSQL Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('delete', 'delete', draw='AREASTACK', type='DERIVE', 
                        min=0, info="Tuples deleted per second.")
         graph.addField('update', 'update', draw='AREASTACK', type='DERIVE', 
                        min=0, info="Tuples updated per second.")
         graph.addField('insert', 'insert', draw='AREASTACK', type='DERIVE', 
                        min=0, info="Tuples inserted per second.")
         self.appendGraph('pg_tup_write', graph)
     
     for lock_state, desc in (('all', 
                               'Total number of locks grouped by lock mode.'),
                              ('wait',
                               'Number of locks in wait state grouped by lock mode.'),):
         graph_name = "pg_lock_%s" % lock_state
         if self.graphEnabled(graph_name):
             mode_iter = iter(PgInfo.lockModes)
             graph = MuninGraph("PostgreSQL - Locks (%s)" % lock_state, 
                 'PostgreSQL Sys',
                 info=desc,
                 args='--base 1000 --lower-limit 0')
             for mode in ('AccessExcl', 'Excl', 'ShrRwExcl', 'Shr', 
                          'ShrUpdExcl', 'RwExcl', 'RwShr', 'AccessShr',):
                 graph.addField(mode, mode, draw='AREASTACK', type='GAUGE', 
                                min=0, 
                                info="Number of locks of mode: %s" % mode_iter.next())
             self.appendGraph(graph_name, graph)
     
     if self._detailGraphs:        
         if self.graphEnabled('pg_blockread_detail'):
             graph = MuninGraph('PostgreSQL - Block Read Stats Detail', 
                 'PostgreSQL DB',
                 info='Block read stats for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Blocks read per second for database %s." % db)
             self.appendGraph('pg_blockread_detail', graph)
         if self.graphEnabled('pg_xact_commit_detail'):
             graph = MuninGraph('PostgreSQL - Transaction Commits Detail', 
                 'PostgreSQL DB',
                 info='Transaction commits for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Transaction commits per second for database %s." % db)
             self.appendGraph('pg_xact_commit_detail', graph)
         if self.graphEnabled('pg_xact_rollback_detail'):
             graph = MuninGraph('PostgreSQL - Transaction Rollbacks Detail', 
                 'PostgreSQL DB',
                 info='Transaction rollbacks for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Transaction rollbacks per second for database %s." % db)
             self.appendGraph('pg_xact_rollback_detail', graph)
         if self.graphEnabled('pg_tup_return_detail'):
             graph = MuninGraph('PostgreSQL - Tuple Scan Detail', 
                 'PostgreSQL DB',
                 info='Tuple scans for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Tuples scanned per second from database %s." % db)
             self.appendGraph('pg_tup_return_detail', graph)
         if self.graphEnabled('pg_tup_fetch_detail'):
             graph = MuninGraph('PostgreSQL - Tuple Fetch Detail', 
                 'PostgreSQL DB',
                 info='Tuple fetches for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Tuples fetched per second from database %s." % db)
             self.appendGraph('pg_tup_fetch_detail', graph)
         if self.graphEnabled('pg_tup_delete_detail'):
             graph = MuninGraph('PostgreSQL - Tuple Delete Detail', 
                 'PostgreSQL DB',
                 info='Tuple deletes for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK',
                     type='DERIVE', min=0,
                     info="Tuples deleted per second from database %s." % db)
             self.appendGraph('pg_tup_delete_detail', graph)
         if self.graphEnabled('pg_tup_update_detail'):
             graph = MuninGraph('PostgreSQL - Tuple Updates Detail', 
                 'PostgreSQL DB',
                 info='Tuple updates for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Tuples updated per second in database %s." % db)
             self.appendGraph('pg_tup_update_detail', graph)
         if self.graphEnabled('pg_tup_insert_detail'):
             graph = MuninGraph('PostgreSQL - Tuple Inserts Detail', 
                 'PostgreSQL DB',
                 info='Tuple insertes for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Tuples inserted per second into database %s." % db)
             self.appendGraph('pg_tup_insert_detail', graph)
         for lock_state, desc in (('all', 
                               'Total number of locks grouped by database.'),
                              ('wait',
                               'Number of locks in wait state grouped by database.'),):
             graph_name = "pg_lock_%s_detail" % lock_state
             if self.graphEnabled(graph_name):
                 graph = MuninGraph("PostgreSQL - Locks (%s) Detail" % lock_state, 
                     'PostgreSQL Sys',
                     info=desc,
                     args='--base 1000 --lower-limit 0',
                     autoFixNames = True)
                 for db in dblist:
                     graph.addField(db, db, draw='AREASTACK', type='GAUGE', 
                                    min=0, 
                                    info="Number of locks for database: %s" % db)
                 self.appendGraph(graph_name, graph)
Exemplo n.º 47
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)
        self._category = 'Time'

        if self.graphEnabled('ntp_peer_stratum'):
            graph = MuninGraph(
                'NTP Stratum for System Peer',
                self._category,
                info='Stratum of the NTP Server the system is in sync with.',
                args='--base 1000 --lower-limit 0')
            graph.addField('stratum', 'stratum', type='GAUGE', draw='LINE2')
            self.appendGraph('ntp_peer_stratum', graph)

        if self.graphEnabled('ntp_peer_stats'):
            graph = MuninGraph(
                'NTP Timing Stats for System Peer',
                self._category,
                info=
                'Timing Stats for the NTP Server the system is in sync with.',
                args='--base 1000 --lower-limit 0',
                vlabel='seconds')
            graph.addField('offset', 'offset', type='GAUGE', draw='LINE2')
            graph.addField('delay', 'delay', type='GAUGE', draw='LINE2')
            graph.addField('jitter', 'jitter', type='GAUGE', draw='LINE2')
            self.appendGraph('ntp_peer_stats', graph)
Exemplo n.º 48
0
 def __init__(self, argv=(), env=None, debug=False):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self._host = self.envGet('host')
     self._port = self.envGet('port', None, int)
     self._user = self.envGet('user')
     self._password = self.envGet('password')
     self._statuspath = self.envGet('statuspath')
     self._ssl = self.envCheckFlag('ssl', False)
     self._numSamples = self.envGet('samples', defaultNumSamples, int)
     self._category = 'Nginx'
     
     if self.graphEnabled('nginx_activeconn'):
         graph = MuninGraph('Nginx - Active Connections', 
             self._category,
             info='Active connections to Nginx Web Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('proc', 'proc', draw='AREASTACK', type='GAUGE',
             info="Connections with Nginx reading request body, "
                   "processing request or writing response to client.")
         graph.addField('read', 'read', draw='AREASTACK', type='GAUGE',
             info="Connections with Nginx reading request headers.")
         graph.addField('wait', 'wait', draw='AREASTACK', type='GAUGE',
             info="Keep-alive connections with Nginx in wait state..")
         graph.addField('total', 'total', draw='LINE2', type='GAUGE',
             info="Total active connections.", colour='000000')
         self.appendGraph('nginx_activeconn', graph)
         
     if self.graphEnabled('nginx_connections'):
         graph = MuninGraph('Nginx - Connections per Second', 
             self._category,
             info='Connections per second to Nginx Web Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('handled', 'handled', draw='AREASTACK', type='DERIVE', 
                        min=0, info="Connections handled by Nginx per second.")
         graph.addField('nothandled', 'nothandled', draw='AREASTACK', type='DERIVE', 
                        min=0, info="Connections accepted, but not handled "
                                    "by Nginx per second.")
         self.appendGraph('nginx_connections', graph)
         
     if self.graphEnabled('nginx_requests'):
         graph = MuninGraph('Nginx - Requests per Second', 
             self._category,
             info='Requests per second to Nginx Web Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('requests', 'requests', draw='LINE2', type='DERIVE', 
                        min=0, info="Requests handled by Nginx per second.")
         self.appendGraph('nginx_requests', graph)
         
     if self.graphEnabled('nginx_requestsperconn'):
         graph = MuninGraph('Nginx - Requests per Connection', 
             self._category,
             info='Requests per handled connections for Nginx Web Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('requests', 'requests', draw='LINE2', type='GAUGE', 
                        min=0, info="Average number of requests per"
                                    " connections handled by Nginx.")
         self.appendGraph('nginx_requestsperconn', graph)
Exemplo n.º 49
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('engine', '^\w+$')

        self._host = self.envGet('host')
        self._port = self.envGet('port', None, int)
        self._database = self.envGet('database')
        self._user = self.envGet('user')
        self._password = self.envGet('password')
        self._category = 'MySQL'

        self._engines = None
        self._genStats = None
        self._genVars = None
        self._dbList = None
        self._dbconn = MySQLinfo(self._host, self._port, self._database,
                                 self._user, self._password)

        if self.graphEnabled('mysql_connections'):
            graph = MuninGraph(
                'MySQL - Connections per second',
                self._category,
                info='MySQL Server new and aborted connections per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField(
                'conn',
                'conn',
                draw='LINE2',
                type='DERIVE',
                min=0,
                info='The number of connection attempts to the MySQL server.')
            graph.addField(
                'abort_conn',
                'abort_conn',
                draw='LINE2',
                type='DERIVE',
                min=0,
                info=
                'The number of failed attempts to connect to the MySQL server.'
            )
            graph.addField(
                'abort_client',
                'abort_client',
                draw='LINE2',
                type='DERIVE',
                min=0,
                info='The number of connections that were aborted, because '
                'the client died without closing the connection properly.')
            self.appendGraph('mysql_connections', graph)

        if self.graphEnabled('mysql_traffic'):
            graph = MuninGraph(
                'MySQL - Network Traffic (bytes/sec)',
                self._category,
                info='MySQL Server Network Traffic in bytes per second.',
                args='--base 1000 --lower-limit 0',
                vlabel='bytes in (-) / out (+) per second')
            graph.addField('rx',
                           'bytes',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           graph=False)
            graph.addField('tx',
                           'bytes',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           negative='rx',
                           info="Bytes In (-) / Out (+) per second.")
            self.appendGraph('mysql_traffic', graph)

        if self.graphEnabled('mysql_slowqueries'):
            graph = MuninGraph(
                'MySQL - Slow Queries per second',
                self._category,
                info='The number of queries that have taken more than '
                'long_query_time seconds.',
                args='--base 1000 --lower-limit 0')
            graph.addField('queries',
                           'queries',
                           draw='LINE2',
                           type='DERIVE',
                           min=0)
            self.appendGraph('mysql_slowqueries', graph)

        if self.graphEnabled('mysql_rowmodifications'):
            graph = MuninGraph(
                'MySQL - Row Insert, Delete, Updates per second',
                self._category,
                info='MySQL Server Inserted, Deleted, Updated Rows per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField(
                'insert',
                'insert',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info='The number of requests to insert a rows into tables.')
            graph.addField(
                'update',
                'update',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info='The number of requests to update a rows in a tables.')
            graph.addField(
                'delete',
                'delete',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info='The number of requests to delete rows from tables.')
            self.appendGraph('mysql_rowmodifications', graph)

        if self.graphEnabled('mysql_rowreads'):
            graph = MuninGraph('MySQL - Row Reads per second',
                               self._category,
                               info='MySQL Server Row Reads per second.',
                               args='--base 1000 --lower-limit 0')
            for (field, desc) in (
                ('first', 'Requests to read first entry in index.'),
                ('key', 'Requests to read a row based on a key.'),
                ('next', 'Requests to read the next row in key order.'),
                ('prev', 'Requests to read the previous row in key order.'),
                ('rnd', 'Requests to read a row based on a fixed position.'),
                ('rnd_next',
                 'Requests to read the next row in the data file.'),
            ):
                graph.addField(field,
                               field,
                               draw='AREASTACK',
                               type='DERIVE',
                               min=0,
                               info=desc)
            self.appendGraph('mysql_rowreads', graph)

        if self.graphEnabled('mysql_tablelocks'):
            graph = MuninGraph('MySQL - Table Locks per second',
                               self._category,
                               info='MySQL Server Table Locks per second.',
                               args='--base 1000 --lower-limit 0')
            graph.addField(
                'waited',
                'waited',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info='The number of times that a request for a table lock '
                'could not be granted immediately and a wait was needed.')
            graph.addField(
                'immediate',
                'immediate',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info='The number of times that a request for a table lock '
                'could be granted immediately.')
            self.appendGraph('mysql_tablelocks', graph)

        if self.graphEnabled('mysql_threads'):
            graph = MuninGraph(
                'MySQL - Threads',
                self._category,
                info='Number of active and idle threads for MySQL Server.',
                args='--base 1000 --lower-limit 0')
            graph.addField('running',
                           'running',
                           draw='AREASTACK',
                           type='GAUGE',
                           info="Number of threads executing queries.")
            graph.addField(
                'idle',
                'idle',
                draw='AREASTACK',
                type='GAUGE',
                info="Number of idle threads with connected clients.")
            graph.addField(
                'cached',
                'cached',
                draw='AREASTACK',
                type='GAUGE',
                info="Number of cached threads without connected clients.")
            graph.addField('total',
                           'total',
                           draw='LINE2',
                           type='GAUGE',
                           colour='000000',
                           info="Total number of threads.")
            self.appendGraph('mysql_threads', graph)

        if self.graphEnabled('mysql_proc_status'):
            graph = MuninGraph(
                'MySQL - Process Status',
                self._category,
                info='Number of threads discriminated by process status.',
                args='--base 1000 --lower-limit 0')
            for (field, label, desc) in (
                ('locked', 'locked', 'The query is locked by another query.'),
                ('sending_data', 'sending',
                 'The thread is processing rows for a SELECT statement and also'
                 ' is sending data to the client.'),
                ('updating', 'updating',
                 'The thread is searching for rows to update and is updating them.'
                 ),
                ('sorting_result', 'sorting',
                 'For a SELECT statement, this is similar to Creating sort'
                 ' index, but for non-temporary tables.'),
                ('closing_tables', 'closing',
                 'The thread is flushing the changed table data to disk and'
                 ' closing the used tables.'),
                ('copying_to_tmp_table', 'copying',
                 'The thread is processing an ALTER TABLE statement. This state'
                 ' occurs after the table with the new structure has been'
                 ' created but before rows are copied into it.'),
                ('preparing', 'preparing',
                 'This state occurs during query optimization.'),
                ('statistics', 'statistics',
                 'The server is calculating statistics to develop a query'
                 ' execution plan. If a thread is in this state for a long'
                 ' time, the server is probably disk-bound performing other work.'
                 ),
                ('reading_from_net', 'net_read',
                 'The server is reading a packet from the network.'),
                ('writing_to_net', 'net_write',
                 'The server is writing a packet to the network.'),
                ('login', 'login',
                 'The initial state for a connection thread until the client'
                 ' has been authenticated successfully.'),
                ('init', 'init',
                 'This occurs before the initialization of ALTER TABLE, DELETE,'
                 ' INSERT, SELECT, or UPDATE statements.'),
                ('end', 'end',
                 'This occurs at the end but before the cleanup of ALTER TABLE,'
                 ' CREATE VIEW, DELETE, INSERT, SELECT, or UPDATE statements.'
                 ),
                ('freeing_items', 'freeing',
                 'The thread has executed a command. This state is usually'
                 ' followed by cleaning up.'),
                ('other', 'other', 'Other valid state.'),
                ('unknown', 'unknown',
                 'State not recognized by the monitoring application.'),
                ('idle', 'idle', 'Idle threads.'),
            ):
                graph.addField(field,
                               label,
                               draw='AREASTACK',
                               type='GAUGE',
                               info=desc)
            self.appendGraph('mysql_proc_status', graph)

        if self.graphEnabled('mysql_proc_db'):
            if self._dbList is None:
                self._dbList = self._dbconn.getDatabases()
                self._dbList.sort()
            graph = MuninGraph(
                'MySQL - Processes per Database',
                self._category,
                info='Number of Threads discriminated by database.',
                args='--base 1000 --lower-limit 0',
                autoFixNames=True)
            for db in self._dbList:
                graph.addField(
                    db,
                    db,
                    draw='AREASTACK',
                    type='GAUGE',
                    info=
                    "Number of threads attending connections for database %s."
                    % db)
            self.appendGraph('mysql_proc_db', graph)

        if self.graphEnabled('mysql_commits_rollbacks'):
            graph = MuninGraph(
                'MySQL - Commits and Rollbacks',
                self._category,
                info='MySQL Server Commits and Rollbacks per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField('commit',
                           'commit',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           info='The number of commits per second.')
            graph.addField('rollback',
                           'rollback',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           info='The number of rollbacks per second.')
            self.appendGraph('mysql_commits_rollbacks', graph)

        if self.graphEnabled('mysql_qcache_memory'):
            graph = MuninGraph(
                'MySQL - Query Cache - Memory Use (bytes)',
                self._category,
                info='Memory utilization for MySQL Server Query Cache.',
                args='--base 1000 --lower-limit 0')
            graph.addField('used',
                           'used',
                           draw='AREASTACK',
                           type='GAUGE',
                           info="Used space (bytes) in Query Cache.")
            graph.addField('free',
                           'free',
                           draw='AREASTACK',
                           type='GAUGE',
                           info="Free space (bytes) in Query Cache.")
            self.appendGraph('mysql_qcache_memory', graph)

        if self.graphEnabled('mysql_qcache_hits'):
            graph = MuninGraph(
                'MySQL - Query Cache - Hits',
                self._category,
                info='MySQL Server Query Cache Hits vs. Select Queries.',
                args='--base 1000 --lower-limit 0')
            graph.addField(
                'hits',
                'hits',
                draw='AREASTACK',
                type='DERIVE',
                min=0,
                info=
                'Hits - Number of select queries responded from query cache.')
            graph.addField('misses',
                           'misses',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info='Misses - Number of select queries executed.')
            self.appendGraph('mysql_qcache_hits', graph)

        if self.graphEnabled('mysql_qcache_prunes'):
            graph = MuninGraph(
                'MySQL - Query Cache - Inserts/Prunes per second',
                self._category,
                info='MySQL Server Query Cache Inserts and Low Memory Prune'
                ' operations per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField('insert',
                           'insert',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           info='Number of queries added to the query cache.')
            graph.addField(
                'prune',
                'prune',
                draw='LINE2',
                type='DERIVE',
                min=0,
                info='The number of queries that were deleted from the'
                ' query cache because of low memory.')
            self.appendGraph('mysql_qcache_prunes', graph)

        if self.engineIncluded('myisam'):

            if self.graphEnabled('mysql_myisam_key_buffer_util'):
                graph = MuninGraph(
                    'MyISAM - Key Buffer Utilization (bytes)',
                    self._category,
                    info='MySQL Server MyISAM Key Buffer Utilization'
                    ' in bytes.',
                    args='--base 1000 --lower-limit 0')
                graph.addField('dirty',
                               'dirty',
                               draw='AREASTACK',
                               type='GAUGE',
                               info="Key space used by dirty blocks.")
                graph.addField('clean',
                               'clean',
                               draw='AREASTACK',
                               type='GAUGE',
                               info="Key space used by dirty blocks..")
                graph.addField('free',
                               'free',
                               draw='AREASTACK',
                               type='GAUGE',
                               info="Free space in key buffer.")
                graph.addField('total',
                               'total',
                               draw='LINE2',
                               type='GAUGE',
                               colour='000000',
                               info="Total size of key buffer.")
                self.appendGraph('mysql_myisam_key_buffer_util', graph)

            if self.graphEnabled('mysql_myisam_key_read_reqs'):
                graph = MuninGraph(
                    'MyISAM - Key Block Read Requests per second',
                    self._category,
                    info='MySQL Server MyISAM Key block read requests satisfied '
                    ' from block cache (hits) vs. disk (misses).',
                    args='--base 1000 --lower-limit 0')
                graph.addField(
                    'disk',
                    'disk',
                    draw='AREASTACK',
                    type='DERIVE',
                    min=0,
                    info='Misses - Key block read requests requiring'
                    ' read from disk.')
                graph.addField(
                    'buffer',
                    'buffer',
                    draw='AREASTACK',
                    type='DERIVE',
                    min=0,
                    info='Misses - Key block read requests satisfied'
                    ' from block cache without requiring read'
                    ' from disk.')
                self.appendGraph('mysql_myisam_key_read_reqs', graph)

        if self.engineIncluded('innodb'):

            if self.graphEnabled('mysql_innodb_buffer_pool_util'):
                graph = MuninGraph(
                    'InnoDB - Buffer Pool Utilization (bytes)',
                    self._category,
                    info=
                    'MySQL Server InnoDB Buffer Pool Utilization in bytes.',
                    args='--base 1000 --lower-limit 0')
                graph.addField('dirty',
                               'dirty',
                               draw='AREASTACK',
                               type='GAUGE',
                               info="Buffer pool space used by dirty pages.")
                graph.addField('clean',
                               'clean',
                               draw='AREASTACK',
                               type='GAUGE',
                               info="Buffer pool space used by clean pages.")
                graph.addField(
                    'misc',
                    'misc',
                    draw='AREASTACK',
                    type='GAUGE',
                    info="Buffer pool space used for administrative overhead.")
                graph.addField('free',
                               'free',
                               draw='AREASTACK',
                               type='GAUGE',
                               info="Free space in buffer pool.")
                graph.addField('total',
                               'total',
                               draw='LINE2',
                               type='GAUGE',
                               colour='000000',
                               info="Total size of buffer pool.")
                self.appendGraph('mysql_innodb_buffer_pool_util', graph)

            if self.graphEnabled('mysql_innodb_buffer_pool_activity'):
                graph = MuninGraph(
                    'InnoDB - Buffer Pool Activity (Pages per second)',
                    self._category,
                    info='MySQL Server Pages read into, written from and created'
                    ' in InnoDB buffer pool.',
                    args='--base 1000 --lower-limit 0')
                for (field, desc) in (
                    ('created', 'Pages created in the buffer pool without'
                     ' reading corresponding disk pages.'),
                    ('read', 'Pages read into the buffer pool from disk.'),
                    ('written',
                     'Pages written to disk from the buffer pool.')):
                    graph.addField(field,
                                   field,
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   info=desc)
                self.appendGraph('mysql_innodb_buffer_pool_activity', graph)

            if self.graphEnabled('mysql_innodb_buffer_pool_read_reqs'):
                graph = MuninGraph(
                    'InnoDB - Buffer Pool Read Requests per second',
                    self._category,
                    info=
                    'MySQL Server read requests satisfied from InnoDB buffer'
                    ' pool (hits) vs. disk (misses).',
                    args='--base 1000 --lower-limit 0')
                graph.addField('disk',
                               'disk',
                               draw='AREASTACK',
                               type='DERIVE',
                               min=0,
                               info='Misses - Logical read requests requiring'
                               ' read from disk.')
                graph.addField('buffer',
                               'buffer',
                               draw='AREASTACK',
                               type='DERIVE',
                               min=0,
                               info='Misses - Logical read requests satisfied'
                               ' from buffer pool without requiring read'
                               ' from disk.')
                self.appendGraph('mysql_innodb_buffer_pool_read_reqs', graph)

            if self.graphEnabled('mysql_innodb_row_ops'):
                graph = MuninGraph(
                    'InnoDB - Row Operations per Second',
                    self._category,
                    info='MySQL Server InnoDB Inserted, updated, deleted, read'
                    ' rows per second.',
                    args='--base 1000 --lower-limit 0')
                for field in ('inserted', 'updated', 'deleted', 'read'):
                    graph.addField(field,
                                   field,
                                   draw='AREASTACK',
                                   type='DERIVE',
                                   min=0,
                                   info="Rows %s per second." % field)
                self.appendGraph('mysql_innodb_row_ops', graph)
Exemplo n.º 50
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('ports', '^\d+$')

        self._host = self.envGet('host')
        self._port = self.envGet('port', None, int)
        self._user = self.envGet('user')
        self._password = self.envGet('password')
        self._ssl = self.envCheckFlag('ssl', False)
        self._category = 'Tomcat'

        self._tomcatInfo = TomcatInfo(self._host, self._port, self._user,
                                      self._password, self._ssl)

        if self.graphEnabled('tomcat_memory'):
            graph = MuninGraph(
                'Apache Tomcat - Memory Usage',
                self._category,
                info='Memory Usage Stats for Apache Tomcat Server (bytes).',
                args='--base 1024 --lower-limit 0')
            graph.addField(
                'used',
                'used',
                draw='AREASTACK',
                type='GAUGE',
                info="Memory in use (bytes) by Apache Tomcat Server.")
            graph.addField('free',
                           'free',
                           draw='AREASTACK',
                           type='GAUGE',
                           info="Free memory (bytes) availabe for use by "
                           "Apache Tomcat Server.")
            graph.addField('max',
                           'max',
                           draw='LINE2',
                           type='GAUGE',
                           info="Maximum memory (bytes) availabe for use by "
                           "Apache Tomcat Server.",
                           colour='FF0000')
            self.appendGraph('tomcat_memory', graph)

        for (port, stats) in self._tomcatInfo.getConnectorStats().iteritems():
            proto = stats['proto']
            if self.portIncluded(port):
                if self.graphEnabled('tomcat_threads'):
                    name = "tomcat_threads_%d" % port
                    title = "Apache Tomcat - %s-%s - Threads" % (proto, port)
                    info = ("Thread stats for Apache Tomcat Connector %s-%s." %
                            (proto, port))
                    graph = MuninGraph(title,
                                       self._category,
                                       info=info,
                                       args='--base 1000 --lower-limit 0')
                    graph.addField('busy',
                                   'busy',
                                   draw='AREASTACK',
                                   type='GAUGE',
                                   info="Number of busy threads.")
                    graph.addField('idle',
                                   'idle',
                                   draw='AREASTACK',
                                   type='GAUGE',
                                   info="Number of idle threads.")
                    graph.addField('max',
                                   'max',
                                   draw='LINE2',
                                   type='GAUGE',
                                   info="Maximum number of threads permitted.",
                                   colour='FF0000')
                    self.appendGraph(name, graph)
                if self.graphEnabled('tomcat_access'):
                    name = "tomcat_access_%d" % port
                    title = ("Apache Tomcat - %s-%s - Requests / sec" %
                             (proto, port))
                    info = (
                        "Requests per second for Apache Tomcat Connector %s-%s."
                        % (proto, port))
                    graph = MuninGraph(title,
                                       self._category,
                                       info=info,
                                       args='--base 1000 --lower-limit 0')
                    graph.addField('reqs',
                                   'reqs',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   info="Requests per second.")
                    self.appendGraph(name, graph)
                if self.graphEnabled('tomcat_error'):
                    name = "tomcat_error_%d" % port
                    title = ("Apache Tomcat - %s-%s - Errors / sec" %
                             (proto, port))
                    info = (
                        "Errors per second for Apache Tomcat Connector %s-%s."
                        % (proto, port))
                    graph = MuninGraph(title,
                                       self._category,
                                       info=info,
                                       args='--base 1000 --lower-limit 0')
                    graph.addField('errors',
                                   'errors',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   info="Errors per second.")
                    self.appendGraph(name, graph)
                if self.graphEnabled('tomcat_traffic'):
                    name = "tomcat_traffic_%d" % port
                    title = ("Apache Tomcat - %s-%s - Traffic (bytes/sec)" %
                             (proto, port))
                    info = ("Traffic in bytes per second for "
                            "Apache Tomcat Connector %s-%s." % (proto, port))
                    graph = MuninGraph(
                        title,
                        self._category,
                        info=info,
                        args='--base 1024 --lower-limit 0',
                        vlabel='bytes in (-) / out (+) per second')
                    graph.addField('rx',
                                   'bytes',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   graph=False)
                    graph.addField('tx',
                                   'bytes',
                                   draw='LINE2',
                                   type='DERIVE',
                                   min=0,
                                   negative='rx',
                                   info="Bytes In (-) / Out (+) per second.")
                    self.appendGraph(name, graph)
Exemplo n.º 51
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._host = self.envGet('host')
        self._port = self.envGet('port')
        self._user = self.envGet('user')
        self._password = self.envGet('password')
        self._statuspath = self.envGet('statuspath')
        self._ssl = self.envCheckFlag('ssl', False)
        self._numSamples = self.envGet('samples', defaultNumSamples)

        if self.graphEnabled('nginx_activeconn'):
            graph = MuninGraph('Nginx - Active Connections',
                               'Nginx',
                               info='Active connections to Nginx Web Server.',
                               args='--base 1000 --lower-limit 0')
            graph.addField('proc',
                           'proc',
                           draw='AREASTACK',
                           type='GAUGE',
                           info="Connections with Nginx reading request body, "
                           "processing request or writing response to client.")
            graph.addField(
                'read',
                'read',
                draw='AREASTACK',
                type='GAUGE',
                info="Connections with Nginx reading request headers.")
            graph.addField(
                'wait',
                'wait',
                draw='AREASTACK',
                type='GAUGE',
                info="Keep-alive connections with Nginx in wait state..")
            graph.addField('total',
                           'total',
                           draw='LINE2',
                           type='GAUGE',
                           info="Total active connections.",
                           colour='000000')
            self.appendGraph('nginx_activeconn', graph)

        if self.graphEnabled('nginx_connections'):
            graph = MuninGraph(
                'Nginx - Connections per Second',
                'Nginx',
                info='Connections per second to Nginx Web Server.',
                args='--base 1000 --lower-limit 0')
            graph.addField('handled',
                           'handled',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info="Connections handled by Nginx per second.")
            graph.addField('nothandled',
                           'nothandled',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           info="Connections accepted, but not handled "
                           "by Nginx per second.")
            self.appendGraph('nginx_connections', graph)

        if self.graphEnabled('nginx_requests'):
            graph = MuninGraph('Nginx - Requests per Second',
                               'Nginx',
                               info='Requests per second to Nginx Web Server.',
                               args='--base 1000 --lower-limit 0')
            graph.addField('requests',
                           'requests',
                           draw='LINE2',
                           type='DERIVE',
                           min=0,
                           info="Requests handled by Nginx per second.")
            self.appendGraph('nginx_requests', graph)

        if self.graphEnabled('nginx_requestsperconn'):
            graph = MuninGraph(
                'Nginx - Requests per Connection',
                'Nginx',
                info='Requests per handled connections for Nginx Web Server.',
                args='--base 1000 --lower-limit 0')
            graph.addField('requests',
                           'requests',
                           draw='LINE2',
                           type='GAUGE',
                           min=0,
                           info="Average number of requests per"
                           " connections handled by Nginx.")
            self.appendGraph('nginx_requestsperconn', graph)
Exemplo n.º 52
0
 def __init__(self, argv=(), env=None, debug=False):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self.envRegisterFilter('engine', '^\w+$')
     
     self._host = self.envGet('host')
     self._port = self.envGet('port', None, int)
     self._database = self.envGet('database')
     self._user = self.envGet('user')
     self._password = self.envGet('password')
     self._engines = None
     self._genStats = None
     self._genVars = None
     self._dbList = None
     
     self._dbconn = MySQLinfo(self._host, self._port, self._database, 
                           self._user, self._password)
     
     if self.graphEnabled('mysql_connections'):
         graph = MuninGraph('MySQL - Connections per second', 
             'MySQL',
             info='MySQL Server new and aborted connections per second.',
             args='--base 1000 --lower-limit 0')
         graph.addField('conn', 'conn', draw='LINE2', 
             type='DERIVE', min=0,
             info='The number of connection attempts to the MySQL server.')
         graph.addField('abort_conn', 'abort_conn', draw='LINE2', 
             type='DERIVE', min=0,
             info='The number of failed attempts to connect to the MySQL server.')
         graph.addField('abort_client', 'abort_client', draw='LINE2', 
             type='DERIVE', min=0,
             info='The number of connections that were aborted, because '
                  'the client died without closing the connection properly.')
         self.appendGraph('mysql_connections', graph)
     
     if self.graphEnabled('mysql_traffic'):
         graph = MuninGraph('MySQL - Network Traffic (bytes/sec)', 
             'MySQL',
             info='MySQL Server Network Traffic in bytes per second.',
             args='--base 1000 --lower-limit 0',
             vlabel='bytes in (-) / out (+) per second')
         graph.addField('rx', 'bytes', draw='LINE2', type='DERIVE', 
                        min=0, graph=False)
         graph.addField('tx', 'bytes', draw='LINE2', type='DERIVE', 
                        min=0, negative='rx',
                 info="Bytes In (-) / Out (+) per second.")
         self.appendGraph('mysql_traffic', graph)
         
     if self.graphEnabled('mysql_slowqueries'):
         graph = MuninGraph('MySQL - Slow Queries per second', 
             'MySQL',
             info='The number of queries that have taken more than '
                  'long_query_time seconds.',
             args='--base 1000 --lower-limit 0')
         graph.addField('queries', 'queries', draw='LINE2', 
                        type='DERIVE', min=0)
         self.appendGraph('mysql_slowqueries', graph)
         
     if self.graphEnabled('mysql_rowmodifications'):
         graph = MuninGraph('MySQL - Row Insert, Delete, Updates per second', 
             'MySQL',
             info='MySQL Server Inserted, Deleted, Updated Rows per second.',
             args='--base 1000 --lower-limit 0')
         graph.addField('insert', 'insert', draw='AREASTACK', 
             type='DERIVE', min=0,
             info='The number of requests to insert a rows into tables.')
         graph.addField('update', 'update', draw='AREASTACK', 
             type='DERIVE', min=0,
             info='The number of requests to update a rows in a tables.')
         graph.addField('delete', 'delete', draw='AREASTACK', 
             type='DERIVE', min=0,
             info='The number of requests to delete rows from tables.')
         self.appendGraph('mysql_rowmodifications', graph)
         
     if self.graphEnabled('mysql_rowreads'):
         graph = MuninGraph('MySQL - Row Reads per second', 
             'MySQL',
             info='MySQL Server Row Reads per second.',
             args='--base 1000 --lower-limit 0')
         for (field, desc) in (('first', 
                                'Requests to read first entry in index.'),
                               ('key', 
                                'Requests to read a row based on a key.'),
                               ('next', 
                                'Requests to read the next row in key order.'),
                               ('prev', 
                                'Requests to read the previous row in key order.'),
                               ('rnd', 
                                'Requests to read a row based on a fixed position.'),
                               ('rnd_next', 
                                'Requests to read the next row in the data file.'),):
             graph.addField(field, field, draw='AREASTACK', 
                 type='DERIVE', min=0, info=desc)
         self.appendGraph('mysql_rowreads', graph)
         
     if self.graphEnabled('mysql_tablelocks'):
         graph = MuninGraph('MySQL - Table Locks per second', 
             'MySQL',
             info='MySQL Server Table Locks per second.',
             args='--base 1000 --lower-limit 0')
         graph.addField('waited', 'waited', draw='AREASTACK', 
             type='DERIVE', min=0,
             info='The number of times that a request for a table lock '
                  'could not be granted immediately and a wait was needed.')
         graph.addField('immediate', 'immediate', draw='AREASTACK', 
             type='DERIVE', min=0,
             info='The number of times that a request for a table lock '
                  'could be granted immediately.')
         self.appendGraph('mysql_tablelocks', graph)
     
     if self.graphEnabled('mysql_threads'):
         graph = MuninGraph('MySQL - Threads', 
             'MySQL',
             info='Number of active and idle threads for MySQL Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('running', 'running', draw='AREASTACK', type='GAUGE', 
             info="Number of threads executing queries.")
         graph.addField('idle', 'idle', draw='AREASTACK', type='GAUGE', 
             info="Number of idle threads with connected clients.")
         graph.addField('cached', 'cached', draw='AREASTACK', type='GAUGE', 
             info="Number of cached threads without connected clients.")
         graph.addField('total', 'total', draw='LINE2', type='GAUGE', 
                        colour='000000',
                        info="Total number of threads.")
         self.appendGraph('mysql_threads', graph)
         
     if self.graphEnabled('mysql_proc_status'):
         graph = MuninGraph('MySQL - Process Status', 
             'MySQL',
             info='Number of threads discriminated by process status.',
             args='--base 1000 --lower-limit 0')
         for (field, label, desc) in (
             ('locked', 'locked', 
              'The query is locked by another query.'),
             ('sending_data', 'sending', 
              'The thread is processing rows for a SELECT statement and also'
              ' is sending data to the client.'),
             ('updating', 'updating',
              'The thread is searching for rows to update and is updating them.'),
             ('sorting_result', 'sorting',
              'For a SELECT statement, this is similar to Creating sort'
              ' index, but for non-temporary tables.'),
             ('closing_tables', 'closing',
              'The thread is flushing the changed table data to disk and'
              ' closing the used tables.'),
             ('copying_to_tmp_table', 'copying',
              'The thread is processing an ALTER TABLE statement. This state'
              ' occurs after the table with the new structure has been'
              ' created but before rows are copied into it.'), 
             ('preparing', 'preparing',
              'This state occurs during query optimization.'),
             ('statistics', 'statistics',
              'The server is calculating statistics to develop a query'
              ' execution plan. If a thread is in this state for a long'
              ' time, the server is probably disk-bound performing other work.'),
             ('reading_from_net', 'net_read',
              'The server is reading a packet from the network.'),
             ('writing_to_net', 'net_write',
              'The server is writing a packet to the network.'),
             ('login', 'login',
              'The initial state for a connection thread until the client'
              ' has been authenticated successfully.'),
             ('init', 'init',
              'This occurs before the initialization of ALTER TABLE, DELETE,'
              ' INSERT, SELECT, or UPDATE statements.'),
             ('end', 'end',
              'This occurs at the end but before the cleanup of ALTER TABLE,'
              ' CREATE VIEW, DELETE, INSERT, SELECT, or UPDATE statements.'),
             ('freeing_items', 'freeing',
              'The thread has executed a command. This state is usually'
              ' followed by cleaning up.'),
             ('other', 'other',
              'Other valid state.'),
             ('unknown', 'unknown',
              'State not recognized by the monitoring application.'),
             ('idle', 'idle',
              'Idle threads.'),):
             graph.addField(field, label, draw='AREASTACK', type='GAUGE', 
                            info=desc)
         self.appendGraph('mysql_proc_status', graph)
     
     if self.graphEnabled('mysql_proc_db'):
         if self._dbList is None:
             self._dbList = self._dbconn.getDatabases()
             self._dbList.sort()
         graph = MuninGraph('MySQL - Processes per Database', 
             'MySQL',
             info='Number of Threads discriminated by database.',
             args='--base 1000 --lower-limit 0', autoFixNames=True)
         for db in self._dbList:
             graph.addField(db, db, draw='AREASTACK', type='GAUGE', 
             info="Number of threads attending connections for database %s." % db)
         self.appendGraph('mysql_proc_db', graph)
             
     if self.graphEnabled('mysql_commits_rollbacks'):
         graph = MuninGraph('MySQL - Commits and Rollbacks', 
             'MySQL',
             info='MySQL Server Commits and Rollbacks per second.',
             args='--base 1000 --lower-limit 0')
         graph.addField('commit', 'commit', draw='LINE2', 
             type='DERIVE', min=0,
             info='The number of commits per second.')
         graph.addField('rollback', 'rollback', draw='LINE2', 
             type='DERIVE', min=0,
             info='The number of rollbacks per second.')
         self.appendGraph('mysql_commits_rollbacks', graph)
         
     if self.graphEnabled('mysql_qcache_memory'):
         graph = MuninGraph('MySQL - Query Cache - Memory Use (bytes)', 
             'MySQL',
             info='Memory utilization for MySQL Server Query Cache.',
             args='--base 1000 --lower-limit 0')
         graph.addField('used', 'used', draw='AREASTACK', type='GAUGE', 
             info="Used space (bytes) in Query Cache.")
         graph.addField('free', 'free', draw='AREASTACK', type='GAUGE', 
             info="Free space (bytes) in Query Cache.")
         self.appendGraph('mysql_qcache_memory', graph)
         
     if self.graphEnabled('mysql_qcache_hits'):
         graph = MuninGraph('MySQL - Query Cache - Hits', 
             'MySQL',
             info='MySQL Server Query Cache Hits vs. Select Queries.',
             args='--base 1000 --lower-limit 0')
         graph.addField('hits', 'hits', draw='AREASTACK', 
             type='DERIVE', min=0,
             info='Hits - Number of select queries responded from query cache.')
         graph.addField('misses', 'misses', draw='AREASTACK', 
             type='DERIVE', min=0,
             info='Misses - Number of select queries executed.')
         self.appendGraph('mysql_qcache_hits', graph)
         
     if self.graphEnabled('mysql_qcache_prunes'):
         graph = MuninGraph('MySQL - Query Cache - Inserts/Prunes per second', 
             'MySQL',
             info='MySQL Server Query Cache Inserts and Low Memory Prune'
                  ' operations per second.',
             args='--base 1000 --lower-limit 0')
         graph.addField('insert', 'insert', draw='LINE2', 
             type='DERIVE', min=0,
             info='Number of queries added to the query cache.')
         graph.addField('prune', 'prune', draw='LINE2', 
             type='DERIVE', min=0,
             info='The number of queries that were deleted from the'
                  ' query cache because of low memory.')
         self.appendGraph('mysql_qcache_prunes', graph)
         
     if self.engineIncluded('myisam'):
         
         if self.graphEnabled('mysql_myisam_key_buffer_util'):
             graph = MuninGraph('MyISAM - Key Buffer Utilization (bytes)', 
                 'MySQL',
                 info='MySQL Server MyISAM Key Buffer Utilization'
                      ' in bytes.',
                 args='--base 1000 --lower-limit 0')
             graph.addField('dirty', 'dirty', draw='AREASTACK', type='GAUGE', 
                 info="Key space used by dirty blocks.")
             graph.addField('clean', 'clean', draw='AREASTACK', type='GAUGE', 
                 info="Key space used by dirty blocks..")
             graph.addField('free', 'free', draw='AREASTACK', type='GAUGE', 
                 info="Free space in key buffer.")
             graph.addField('total', 'total', draw='LINE2', type='GAUGE', 
                            colour='000000',
                            info="Total size of key buffer.")
             self.appendGraph('mysql_myisam_key_buffer_util', graph)
         
         if self.graphEnabled('mysql_myisam_key_read_reqs'):
             graph = MuninGraph('MyISAM - Key Block Read Requests per second', 
                 'MySQL',
                 info='MySQL Server MyISAM Key block read requests satisfied '
                      ' from block cache (hits) vs. disk (misses).',
                 args='--base 1000 --lower-limit 0')
             graph.addField('disk', 'disk', draw='AREASTACK', 
                            type='DERIVE', min=0, 
                            info='Misses - Key block read requests requiring'
                                 ' read from disk.')
             graph.addField('buffer', 'buffer', draw='AREASTACK', 
                            type='DERIVE', min=0, 
                            info='Misses - Key block read requests satisfied'
                                 ' from block cache without requiring read'
                                 ' from disk.')
             self.appendGraph('mysql_myisam_key_read_reqs', graph)
         
     if self.engineIncluded('innodb'):
         
         if self.graphEnabled('mysql_innodb_buffer_pool_util'):
             graph = MuninGraph('InnoDB - Buffer Pool Utilization (bytes)', 
                 'MySQL',
                 info='MySQL Server InnoDB Buffer Pool Utilization in bytes.',
                 args='--base 1000 --lower-limit 0')
             graph.addField('dirty', 'dirty', draw='AREASTACK', type='GAUGE', 
                 info="Buffer pool space used by dirty pages.")
             graph.addField('clean', 'clean', draw='AREASTACK', type='GAUGE', 
                 info="Buffer pool space used by clean pages.")
             graph.addField('misc', 'misc', draw='AREASTACK', type='GAUGE', 
                 info="Buffer pool space used for administrative overhead.")
             graph.addField('free', 'free', draw='AREASTACK', type='GAUGE', 
                 info="Free space in buffer pool.")
             graph.addField('total', 'total', draw='LINE2', type='GAUGE', 
                            colour='000000',
                            info="Total size of buffer pool.")
             self.appendGraph('mysql_innodb_buffer_pool_util', graph)
             
         if self.graphEnabled('mysql_innodb_buffer_pool_activity'):
             graph = MuninGraph('InnoDB - Buffer Pool Activity (Pages per second)', 
                 'MySQL',
                 info='MySQL Server Pages read into, written from and created'
                      ' in InnoDB buffer pool.',
                 args='--base 1000 --lower-limit 0')
             for (field, desc) in (('created',
                                    'Pages created in the buffer pool without'
                                    ' reading corresponding disk pages.'),
                                   ('read', 
                                    'Pages read into the buffer pool from disk.'),
                                   ('written', 
                                    'Pages written to disk from the buffer pool.')):
                 graph.addField(field, field, draw='LINE2', 
                                type='DERIVE', min=0, info=desc)
             self.appendGraph('mysql_innodb_buffer_pool_activity', graph)
             
         if self.graphEnabled('mysql_innodb_buffer_pool_read_reqs'):
             graph = MuninGraph('InnoDB - Buffer Pool Read Requests per second', 
                 'MySQL',
                 info='MySQL Server read requests satisfied from InnoDB buffer'
                      ' pool (hits) vs. disk (misses).',
                 args='--base 1000 --lower-limit 0')
             graph.addField('disk', 'disk', draw='AREASTACK', 
                            type='DERIVE', min=0, 
                            info='Misses - Logical read requests requiring'
                                 ' read from disk.')
             graph.addField('buffer', 'buffer', draw='AREASTACK', 
                            type='DERIVE', min=0, 
                            info='Misses - Logical read requests satisfied'
                                 ' from buffer pool without requiring read'
                                 ' from disk.')
             self.appendGraph('mysql_innodb_buffer_pool_read_reqs', graph)
                 
         if self.graphEnabled('mysql_innodb_row_ops'):
             graph = MuninGraph('InnoDB - Row Operations per Second', 
                 'MySQL',
                 info='MySQL Server InnoDB Inserted, updated, deleted, read'
                      ' rows per second.',
                 args='--base 1000 --lower-limit 0')
             for field in ('inserted', 'updated', 'deleted', 'read'):
                 graph.addField(field, field, draw='AREASTACK', 
                                type='DERIVE', min=0,
                                info="Rows %s per second." % field)
             self.appendGraph('mysql_innodb_row_ops', graph)
Exemplo n.º 53
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._instance = self.envGet('instance')
        self._category = 'Varnish'
        varnish_info = VarnishInfo(self._instance)
        self._stats = varnish_info.getStats()
        self._desc = varnish_info.getDescDict()

        graph_name = 'varnish_requests'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'Varnish - Client/Backend Requests / sec',
                self._category,
                info=
                'Number of client and backend requests per second for Varnish Cache.',
                args='--base 1000 --lower-limit 0')
            for flabel in (
                    'client',
                    'backend',
            ):
                fname = '%s_req' % flabel
                finfo = self._desc.get(fname, '')
                graph.addField(fname,
                               flabel,
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               info=finfo)
            self.appendGraph(graph_name, graph)

        graph_name = 'varnish_hits'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'Varnish - Cache Hits vs. Misses (%)',
                self._category,
                info='Number of Cache Hits and Misses per second.',
                args='--base 1000 --lower-limit 0')
            for flabel, fname in (('hit', 'cache_hit'),
                                  ('pass', 'cache_hitpass'), ('miss',
                                                              'cache_miss')):
                finfo = self._desc.get(fname, '')
                graph.addField(fname,
                               flabel,
                               draw='AREASTACK',
                               type='DERIVE',
                               min=0,
                               info=finfo)
            self.appendGraph(graph_name, graph)

        graph_name = 'varnish_client_conn'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'Varnish - Client Connections / sec',
                self._category,
                info='Client connections per second for Varnish Cache.',
                args='--base 1000 --lower-limit 0')
            for flabel in (
                    'conn',
                    'drop',
            ):
                fname = 'client_%s' % flabel
                finfo = self._desc.get(fname, '')
                graph.addField(fname,
                               flabel,
                               draw='AREASTACK',
                               type='DERIVE',
                               min=0,
                               info=finfo)
            self.appendGraph(graph_name, graph)

        graph_name = 'varnish_backend_conn'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'Varnish - Backend Connections / sec',
                self._category,
                info='Connections per second from Varnish Cache to backends.',
                args='--base 1000 --lower-limit 0')
            for flabel in (
                    'conn',
                    'reuse',
                    'busy',
                    'fail',
                    'retry',
                    'unhealthy',
            ):
                fname = 'backend_%s' % flabel
                finfo = self._desc.get(fname, '')
                graph.addField(fname,
                               flabel,
                               draw='AREASTACK',
                               type='DERIVE',
                               min=0,
                               info=finfo)
            self.appendGraph(graph_name, graph)

        graph_name = 'varnish_traffic'
        if self.graphEnabled(graph_name):
            graph = MuninGraph('Varnish - Traffic (bytes/sec)',
                               self._category,
                               info='HTTP Header and Body traffic. '
                               '(TCP/IP overhead not included.)',
                               args='--base 1024 --lower-limit 0')
            for flabel, fname in (
                ('header', 's_hdrbytes'),
                ('body', 's_bodybytes'),
            ):
                finfo = self._desc.get(fname, '')
                graph.addField(fname,
                               flabel,
                               draw='AREASTACK',
                               type='DERIVE',
                               min=0,
                               info=finfo)
            self.appendGraph(graph_name, graph)

        graph_name = 'varnish_workers'
        if self.graphEnabled(graph_name):
            graph = MuninGraph('Varnish - Worker Threads',
                               self._category,
                               info='Number of worker threads.',
                               args='--base 1000 --lower-limit 0')
            fname = 'n_wrk'
            flabel = 'req'
            finfo = self._desc.get(fname, '')
            graph.addField(fname,
                           flabel,
                           draw='LINE2',
                           type='GAUGE',
                           min=0,
                           info=finfo)
            self.appendGraph(graph_name, graph)

        graph_name = 'varnish_work_queue'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'Varnish - Queued/Dropped Work Requests / sec',
                self._category,
                info='Requests queued for waiting for a worker thread to become '
                'available and requests dropped because of overflow of queue.',
                args='--base 1000 --lower-limit 0')
            for flabel, fname in (('queued', 'n_wrk_queued'), ('dropped',
                                                               'n_wrk_drop')):
                finfo = self._desc.get(fname, '')
                graph.addField(fname,
                               flabel,
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               info=finfo)
            self.appendGraph(graph_name, graph)

        graph_name = 'varnish_memory'
        if self.graphEnabled(graph_name):
            graph = MuninGraph('Varnish - Cache Memory Usage (bytes)',
                               self._category,
                               info='Varnish cache memory usage in bytes.',
                               args='--base 1024 --lower-limit 0')
            for flabel, fname in (('used', 'SMA_s0_g_bytes'),
                                  ('free', 'SMA_s0_g_space')):
                finfo = self._desc.get(fname, '')
                graph.addField(fname,
                               flabel,
                               draw='AREASTACK',
                               type='GAUGE',
                               min=0,
                               info=finfo)
            self.appendGraph(graph_name, graph)

        graph_name = 'varnish_expire_purge'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'Varnish - Expired/Purged Objects / sec',
                self._category,
                info='Expired objects and LRU purged objects per second.',
                args='--base 1000 --lower-limit 0')
            for flabel, fname in (('expire', 'n_expired'), ('purge',
                                                            'n_lru_nuked')):
                finfo = self._desc.get(fname, '')
                graph.addField(fname,
                               flabel,
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               info=finfo)
            self.appendGraph(graph_name, graph)
Exemplo n.º 54
0
    def __init__(self, argv=(), env={}):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv: List of command line arguments.
        @param env:  Dictionary of environment variables.
        
        """
        MuninPlugin.__init__(self, argv, env)

        self.envRegisterFilter("ifaces", "^[\w\d]+$")

        self._wanpipeInfo = WanpipeInfo()
        self._ifaceStats = self._wanpipeInfo.getIfaceStats()
        self._ifaceList = []
        for iface in list(self._ifaceStats):
            if self.ifaceIncluded(iface):
                self._ifaceList.append(iface)
        self._ifaceList.sort()

        for iface in self._ifaceList:
            if self._reqIfaceList is None or iface in self._reqIfaceList:
                if self.graphEnabled("wanpipe_traffic"):
                    graph = MuninGraph(
                        "Wanpipe - Traffic - %s" % iface,
                        "Asterisk",
                        info="Traffic Stats for Wanpipe Interface %s " "in packets/sec." % iface,
                        args="--base 1000 --lower-limit 0",
                        vlabel="packets in (-) / out (+) per second",
                    )
                    graph.addField("rxpackets", "packets", draw="LINE2", type="DERIVE", min=0, graph=False)
                    graph.addField("txpackets", "packets", draw="LINE2", type="DERIVE", min=0, negative="rxpackets")
                    self.appendGraph("wanpipe_traffic_%s" % iface, graph)

                if self.graphEnabled("wanpipe_errors"):
                    graph = MuninGraph(
                        "Wanpipe - Errors - %s" % iface,
                        "Asterisk",
                        info="Error Stats for Wanpipe Interface %s" " in errors/sec." % iface,
                        args="--base 1000 --lower-limit 0",
                        vlabel="errors in (-) / out (+) per second",
                    )
                    graph.addField("rxerrs", "errors", draw="LINE2", type="DERIVE", min=0, graph=False)
                    graph.addField(
                        "txerrs",
                        "errors",
                        draw="LINE2",
                        type="DERIVE",
                        min=0,
                        negative="txerrs",
                        info="Rx(-)/Tx(+) Errors per second.",
                    )
                    graph.addField("rxframe", "frm/crr", draw="LINE2", type="DERIVE", min=0, graph=False)
                    graph.addField(
                        "txcarrier",
                        "frm/crr",
                        draw="LINE2",
                        type="DERIVE",
                        min=0,
                        negative="rxframe",
                        info="Frame(-)/Carrier(+) Errors per second.",
                    )
                    graph.addField("rxdrop", "drop", draw="LINE2", type="DERIVE", min=0, graph=False)
                    graph.addField(
                        "txdrop",
                        "drop",
                        draw="LINE2",
                        type="DERIVE",
                        min=0,
                        negative="rxdrop",
                        info="Rx(-)/Tx(+) Dropped Packets per second.",
                    )
                    graph.addField("rxfifo", "fifo", draw="LINE2", type="DERIVE", min=0, graph=False)
                    graph.addField(
                        "txfifo",
                        "fifo",
                        draw="LINE2",
                        type="DERIVE",
                        min=0,
                        negative="rxfifo",
                        info="Rx(-)/Tx(+) FIFO Errors per second.",
                    )
                    self.appendGraph("wanpipe_errors_%s" % iface, graph)

                if self.graphEnabled("wanpipe_pri_errors"):
                    graph = MuninGraph(
                        "Wanpipe - ISDN PRI Stats - %s" % iface,
                        "Asterisk",
                        info="ISDN PRI Error Stats for Wanpipe Interface %s" " in errors/sec." % iface,
                        args="--base 1000 --lower-limit 0",
                        vlabel="errors in (-) / out (+) per second",
                    )
                    graph.addField(
                        "linecodeviolation",
                        "Line Code Violation",
                        draw="LINE2",
                        type="DERIVE",
                        min=0,
                        info="Line Code Violation errors per second.",
                    )
                    graph.addField(
                        "farendblockerrors",
                        "Far End Block Errors",
                        draw="LINE2",
                        type="DERIVE",
                        min=0,
                        info="Far End Block errors per second.",
                    )
                    graph.addField(
                        "crc4errors", "CRC4 Errors", draw="LINE2", type="DERIVE", min=0, info="CRC4 errors per second."
                    )
                    graph.addField(
                        "faserrors", "FAS Errors", draw="LINE2", type="DERIVE", min=0, info="FAS errors per second."
                    )
                    self.appendGraph("wanpipe_pri_errors_%s" % iface, graph)

        if self.graphEnabled("wanpipe_pri_rxlevel"):
            graph = MuninGraph(
                "Wanpipe - ISDN PRI Signal Level",
                "Asterisk",
                info="ISDN PRI received signal level in DB.",
                args="--base 1000 --lower-limit 0",
                vlabel="db",
            )
            for iface in self._ifaceList:
                if self._reqIfaceList is None or iface in self._reqIfaceList:
                    graph.addField(iface, iface, draw="LINE2")
            self.appendGraph("wanpipe_pri_rxlevel", graph)
Exemplo n.º 55
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter("queues", "^[\w\-]+$")
        self._amihost = self.envGet("amihost")
        self._amiport = self.envGet("amiport", None, int)
        self._amiuser = self.envGet("amiuser")
        self._amipass = self.envGet("amipass")
        self._category = "Asterisk"

        self._ami = AsteriskInfo(self._amihost, self._amiport, self._amiuser, self._amipass)

        self._codecList = self.envGetList("codecs") or ["alaw", "ulaw", "gsm", "g729"]

        self._chanList = []
        for chanstr in self.envGetList("channels") or ["dahdi", "zap", "sip", "iax2", "local"]:
            chan = chanstr.lower()
            if self._ami.hasChannelType(chan):
                if chan in ("zap", "dahdi"):
                    if "dahdi" not in self._chanList:
                        self._chanList.append("dahdi")
                else:
                    self._chanList.append(chan)

        self._trunkList = []
        for trunk_entry in self.envGetList("trunks", None):
            mobj = re.match("(.*)=(.*)=(\d+)-(\d+)$", trunk_entry, re.IGNORECASE) or re.match(
                "(.*)=(.*)$", trunk_entry, re.IGNORECASE
            )
            if mobj:
                self._trunkList.append(mobj.groups())

        if self.graphEnabled("asterisk_calls"):
            graph = MuninGraph(
                "Asterisk - Call Stats",
                self._category,
                info="Asterisk - Information on Calls.",
                period="minute",
                args="--base 1000 --lower-limit 0",
            )
            graph.addField("active_calls", "active_calls", type="GAUGE", draw="LINE2", info="Active Calls")
            graph.addField(
                "calls_per_min", "calls_per_min", type="DERIVE", min=0, draw="LINE2", info="Calls per minute"
            )
            self.appendGraph("asterisk_calls", graph)

        if self.graphEnabled("asterisk_channels"):
            graph = MuninGraph(
                "Asterisk - Active Channels",
                self._category,
                info="Asterisk - Information on Active Channels.",
                args="--base 1000 --lower-limit 0",
            )
            for field in self._chanList:
                graph.addField(field, field, type="GAUGE", draw="AREASTACK")
            if "dahdi" in self._chanList:
                graph.addField("mix", "mix", type="GAUGE", draw="LINE2")
            self.appendGraph("asterisk_channels", graph)

        if self.graphEnabled("asterisk_peers_sip") and self._ami.hasChannelType("sip"):
            graph = MuninGraph(
                "Asterisk - VoIP Peers - SIP",
                self._category,
                info="Asterisk - Information on SIP VoIP Peers.",
                args="--base 1000 --lower-limit 0",
            )
            for field in ("online", "unmonitored", "unreachable", "lagged", "unknown"):
                graph.addField(field, field, type="GAUGE", draw="AREASTACK")
            self.appendGraph("asterisk_peers_sip", graph)

        if self.graphEnabled("asterisk_peers_iax2") and self._ami.hasChannelType("iax2"):
            graph = MuninGraph(
                "Asterisk - VoIP Peers - IAX2",
                self._category,
                info="Asterisk - Information on IAX2 VoIP Peers.",
                args="--base 1000 --lower-limit 0",
            )
            for field in ("online", "unmonitored", "unreachable", "lagged", "unknown"):
                graph.addField(field, field, type="GAUGE", draw="AREASTACK")
            self.appendGraph("asterisk_peers_iax2", graph)

        if self.graphEnabled("asterisk_voip_codecs") and (
            self._ami.hasChannelType("sip") or self._ami.hasChannelType("iax2")
        ):
            graph = MuninGraph(
                "Asterisk - VoIP Codecs for Active Channels",
                self._category,
                info="Asterisk - Codecs for Active VoIP Channels (SIP/IAX2)",
                args="--base 1000 --lower-limit 0",
            )
            for field in self._codecList:
                graph.addField(field, field, type="GAUGE", draw="AREASTACK")
            graph.addField("other", "other", type="GAUGE", draw="AREASTACK")
            self.appendGraph("asterisk_voip_codecs", graph)

        if self.graphEnabled("asterisk_conferences") and self._ami.hasConference():
            graph = MuninGraph(
                "Asterisk - Conferences",
                self._category,
                info="Asterisk - Information on Meetme Conferences",
                args="--base 1000 --lower-limit 0",
            )
            graph.addField("rooms", "rooms", type="GAUGE", draw="LINE2", info="Active conference rooms.")
            graph.addField("users", "users", type="GAUGE", draw="LINE2", info="Total number of users in conferences.")
            self.appendGraph("asterisk_conferences", graph)

        if self.graphEnabled("asterisk_voicemail") and self._ami.hasVoicemail():
            graph = MuninGraph(
                "Asterisk - Voicemail",
                self._category,
                info="Asterisk - Information on Voicemail Accounts",
                args="--base 1000 --lower-limit 0",
            )
            graph.addField("accounts", "accounts", type="GAUGE", draw="LINE2", info="Number of voicemail accounts.")
            graph.addField(
                "msg_avg",
                "msg_avg",
                type="GAUGE",
                draw="LINE2",
                info="Average number of messages per voicemail account.",
            )
            graph.addField(
                "msg_max",
                "msg_max",
                type="GAUGE",
                draw="LINE2",
                info="Maximum number of messages in one voicemail account.",
            )
            graph.addField(
                "msg_total",
                "msg_total",
                type="GAUGE",
                draw="LINE2",
                info="Total number of messages in all voicemail accounts.",
            )
            self.appendGraph("asterisk_voicemail", graph)

        if self.graphEnabled("asterisk_trunks") and len(self._trunkList) > 0:
            graph = MuninGraph(
                "Asterisk - Trunks",
                self._category,
                info="Asterisk - Active calls on trunks.",
                args="--base 1000 --lower-limit 0",
                autoFixNames=True,
            )
            for trunk in self._trunkList:
                graph.addField(trunk[0], trunk[0], type="GAUGE", draw="AREASTACK")
            self.appendGraph("asterisk_trunks", graph)

        self._queues = None
        self._queue_list = None
        if (
            self.graphEnabled("asterisk_queue_len")
            or self.graphEnabled("asterisk_queue_avg_hold")
            or self.graphEnabled("asterisk_queue_avg_talk")
            or self.graphEnabled("asterisk_queue_calls")
            or self.graphEnabled("asterisk_queue_abandon_pcent")
        ) and self._ami.hasQueue():
            self._queues = self._ami.getQueueStats()
            self._queue_list = [queue for queue in self._queues.keys() if self.envCheckFilter("queues", queue)]
            self._queue_list.sort()
            if self.graphEnabled("asterisk_queue_abandon_pcent"):
                self._queues_prev = self.restoreState()
                if self._queues_prev is None:
                    self._queues_prev = self._queues
                self.saveState(self._queues)

        if self._queues is not None and len(self._queue_list) > 0:
            if self.graphEnabled("asterisk_queue_len"):
                graph = MuninGraph(
                    "Asterisk - Queues - Calls in Queue",
                    self._category,
                    info="Asterisk - Queues - Number of calls in queues.",
                    args="--base 1000 --lower-limit 0",
                )
                for queue in self._queue_list:
                    graph.addField(
                        queue, queue, type="GAUGE", draw="AREASTACK", info="Number of calls in queue %s." % queue
                    )
                self.appendGraph("asterisk_queue_len", graph)
            if self.graphEnabled("asterisk_queue_avg_hold"):
                graph = MuninGraph(
                    "Asterisk - Queues - Average Hold Time (sec)",
                    self._category,
                    info="Asterisk - Queues - Average Hold Time.",
                    args="--base 1000 --lower-limit 0",
                )
                for queue in self._queue_list:
                    graph.addField(
                        queue, queue, type="GAUGE", draw="LINE2", info="Average hold time for queue %s." % queue
                    )
                self.appendGraph("asterisk_queue_avg_hold", graph)
            if self.graphEnabled("asterisk_queue_avg_talk"):
                graph = MuninGraph(
                    "Asterisk - Queues - Average Talk Time (sec)",
                    self._category,
                    info="Asterisk - Queues - Average Talk Time.).",
                    args="--base 1000 --lower-limit 0",
                )
                for queue in self._queue_list:
                    graph.addField(
                        queue, queue, type="GAUGE", draw="LINE2", info="Average talk time for queue %s." % queue
                    )
                self.appendGraph("asterisk_queue_avg_talk", graph)
            if self.graphEnabled("asterisk_queue_calls"):
                graph = MuninGraph(
                    "Asterisk - Queues - Calls per Minute",
                    self._category,
                    period="minute",
                    info="Asterisk - Queues - Abandoned/Completed Calls per minute.",
                    args="--base 1000 --lower-limit 0",
                )
                graph.addField(
                    "abandon", "abandon", type="DERIVE", draw="AREASTACK", info="Abandoned calls per minute."
                )
                graph.addField("answer", "answer", type="DERIVE", draw="AREASTACK", info="Answered calls per minute.")
                self.appendGraph("asterisk_queue_calls", graph)
            if self.graphEnabled("asterisk_queue_abandon_pcent"):
                graph = MuninGraph(
                    "Asterisk - Queues - Abandoned Calls (%)",
                    self._category,
                    info="Asterisk - Queues - Abandoned calls vs, total calls.",
                    args="--base 1000 --lower-limit 0",
                )
                for queue in self._queue_list:
                    graph.addField(
                        queue, queue, type="GAUGE", draw="LINE2", info="Abandoned vs. total calls for queue %s." % queue
                    )
                self.appendGraph("asterisk_queue_abandon_pcent", graph)

        if self._ami.hasFax():
            if self.graphEnabled("asterisk_fax_attempts"):
                graph = MuninGraph(
                    "Asterisk - Fax Stats",
                    self._category,
                    period="minute",
                    info="Asterisk - Fax - Fax Recv / Send Attempts per minute.",
                    args="--base 1000 --lower-limit 0",
                )
                graph.addField("send", "send", type="DERIVE", draw="AREASTACK", info="Fax send attempts per minute.")
                graph.addField("recv", "recv", type="DERIVE", draw="AREASTACK", info="Fax receive attempts per minute.")
                graph.addField("fail", "fail", type="DERIVE", draw="LINE2", info="Failed fax attempts per minute.")
                self.appendGraph("asterisk_fax_attempts", graph)
Exemplo n.º 56
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('queues', '^[\w\-]+$')
        self._amihost = self.envGet('amihost')
        self._amiport = self.envGet('amiport')
        self._amiuser = self.envGet('amiuser')
        self._amipass = self.envGet('amipass')
        self._ami = None

        self._codecList = (self.envGetList('codecs')
                           or ['alaw', 'ulaw', 'gsm', 'g729'])

        self._chanList = []
        for chanstr in (self.envGetList('channels')
                        or ['dahdi', 'zap', 'sip', 'iax2', 'local']):
            chan = chanstr.lower()
            if chan in ('zap', 'dahdi'):
                if 'dahdi' not in self._chanList:
                    self._chanList.append('dahdi')
            else:
                self._chanList.append(chan)

        self._trunkList = []
        for trunk_entry in self.envGetList('trunks', None):
            mobj = (re.match('(.*)=(.*)=(\d+)-(\d+)$', trunk_entry,
                             re.IGNORECASE)
                    or re.match('(.*)=(.*)$', trunk_entry, re.IGNORECASE))
            if mobj:
                self._trunkList.append(mobj.groups())

        if self.graphEnabled('asterisk_calls'):
            graph = MuninGraph('Asterisk - Call Stats',
                               'Asterisk',
                               info='Asterisk - Information on Calls.',
                               period='minute',
                               args='--base 1000 --lower-limit 0')
            graph.addField('active_calls',
                           'active_calls',
                           type='GAUGE',
                           draw='LINE2',
                           info='Active Calls')
            graph.addField('calls_per_min',
                           'calls_per_min',
                           type='DERIVE',
                           min=0,
                           draw='LINE2',
                           info='Calls per minute')
            self.appendGraph('asterisk_calls', graph)

        if self.graphEnabled('asterisk_channels'):
            graph = MuninGraph(
                'Asterisk - Active Channels',
                'Asterisk',
                info='Asterisk - Information on Active Channels.',
                args='--base 1000 --lower-limit 0')
            for field in self._chanList:
                graph.addField(field, field, type='GAUGE', draw='AREASTACK')
            if 'dahdi' in self._chanList:
                graph.addField('mix', 'mix', type='GAUGE', draw='LINE2')
            self.appendGraph('asterisk_channels', graph)

        if self.graphEnabled('asterisk_peers_sip'):
            graph = MuninGraph(
                'Asterisk - VoIP Peers - SIP',
                'Asterisk',
                info='Asterisk - Information on SIP VoIP Peers.',
                args='--base 1000 --lower-limit 0')
            for field in ('online', 'unmonitored', 'unreachable', 'lagged',
                          'unknown'):
                graph.addField(field, field, type='GAUGE', draw='AREASTACK')
            self.appendGraph('asterisk_peers_sip', graph)

        if self.graphEnabled('asterisk_peers_iax2'):
            graph = MuninGraph(
                'Asterisk - VoIP Peers - IAX2',
                'Asterisk',
                info='Asterisk - Information on IAX2 VoIP Peers.',
                args='--base 1000 --lower-limit 0')
            for field in ('online', 'unmonitored', 'unreachable', 'lagged',
                          'unknown'):
                graph.addField(field, field, type='GAUGE', draw='AREASTACK')
            self.appendGraph('asterisk_peers_iax2', graph)

        if self.graphEnabled('asterisk_voip_codecs'):
            graph = MuninGraph(
                'Asterisk - VoIP Codecs for Active Channels',
                'Asterisk',
                info='Asterisk - Codecs for Active VoIP Channels (SIP/IAX2)',
                args='--base 1000 --lower-limit 0')
            for field in self._codecList:
                graph.addField(field, field, type='GAUGE', draw='AREASTACK')
            graph.addField('other', 'other', type='GAUGE', draw='AREASTACK')
            self.appendGraph('asterisk_voip_codecs', graph)

        if self.graphEnabled('asterisk_conferences'):
            graph = MuninGraph(
                'Asterisk - Conferences',
                'Asterisk',
                info='Asterisk - Information on Meetme Conferences',
                args='--base 1000 --lower-limit 0')
            graph.addField('rooms',
                           'rooms',
                           type='GAUGE',
                           draw='LINE2',
                           info='Active conference rooms.')
            graph.addField('users',
                           'users',
                           type='GAUGE',
                           draw='LINE2',
                           info='Total number of users in conferences.')
            self.appendGraph('asterisk_conferences', graph)

        if self.graphEnabled('asterisk_voicemail'):
            graph = MuninGraph(
                'Asterisk - Voicemail',
                'Asterisk',
                info='Asterisk - Information on Voicemail Accounts',
                args='--base 1000 --lower-limit 0')
            graph.addField('accounts',
                           'accounts',
                           type='GAUGE',
                           draw='LINE2',
                           info='Number of voicemail accounts.')
            graph.addField(
                'msg_avg',
                'msg_avg',
                type='GAUGE',
                draw='LINE2',
                info='Average number of messages per voicemail account.')
            graph.addField(
                'msg_max',
                'msg_max',
                type='GAUGE',
                draw='LINE2',
                info='Maximum number of messages in one voicemail account.')
            graph.addField(
                'msg_total',
                'msg_total',
                type='GAUGE',
                draw='LINE2',
                info='Total number of messages in all voicemail accounts.')
            self.appendGraph('asterisk_voicemail', graph)

        if self.graphEnabled('asterisk_trunks') and len(self._trunkList) > 0:
            graph = MuninGraph('Asterisk - Trunks',
                               'Asterisk',
                               info='Asterisk - Active calls on trunks.',
                               args='--base 1000 --lower-limit 0',
                               autoFixNames=True)
            for trunk in self._trunkList:
                graph.addField(trunk[0],
                               trunk[0],
                               type='GAUGE',
                               draw='AREASTACK')
            self.appendGraph('asterisk_trunks', graph)

        self._queues = None
        self._queue_list = None
        if (self.graphEnabled('asterisk_queue_len')
                or self.graphEnabled('asterisk_queue_avg_hold')
                or self.graphEnabled('asterisk_queue_avg_talk')
                or self.graphEnabled('asterisk_queue_calls')
                or self.graphEnabled('asterisk_queue_abandon_pcent')):
            if self._ami is None:
                self._ami = AsteriskInfo(self._amihost, self._amiport,
                                         self._amiuser, self._amipass)
            self._queues = self._ami.getQueueStats()
            self._queue_list = [
                queue for queue in self._queues.keys()
                if self.envCheckFilter('queues', queue)
            ]
            self._queue_list.sort()
            if self.graphEnabled('asterisk_queue_abandon_pcent'):
                self._queues_prev = self.restoreState()
                if self._queues_prev is None:
                    self._queues_prev = self._queues
                self.saveState(self._queues)

        if self._queues is not None and len(self._queue_list) > 0:
            if self.graphEnabled('asterisk_queue_len'):
                graph = MuninGraph(
                    'Asterisk - Queues - Calls in Queue',
                    'Asterisk',
                    info='Asterisk - Queues - Number of calls in queues.',
                    args='--base 1000 --lower-limit 0')
                for queue in self._queue_list:
                    graph.addField(queue,
                                   queue,
                                   type='GAUGE',
                                   draw='AREASTACK',
                                   info='Number of calls in queue %s.' % queue)
                self.appendGraph('asterisk_queue_len', graph)
            if self.graphEnabled('asterisk_queue_avg_hold'):
                graph = MuninGraph(
                    'Asterisk - Queues - Average Hold Time (sec)',
                    'Asterisk',
                    info='Asterisk - Queues - Average Hold Time.',
                    args='--base 1000 --lower-limit 0')
                for queue in self._queue_list:
                    graph.addField(queue,
                                   queue,
                                   type='GAUGE',
                                   draw='LINE2',
                                   info='Average hold time for queue %s.' %
                                   queue)
                self.appendGraph('asterisk_queue_avg_hold', graph)
            if self.graphEnabled('asterisk_queue_avg_talk'):
                graph = MuninGraph(
                    'Asterisk - Queues - Average Talk Time (sec)',
                    'Asterisk',
                    info='Asterisk - Queues - Average Talk Time.).',
                    args='--base 1000 --lower-limit 0')
                for queue in self._queue_list:
                    graph.addField(queue,
                                   queue,
                                   type='GAUGE',
                                   draw='LINE2',
                                   info='Average talk time for queue %s.' %
                                   queue)
                self.appendGraph('asterisk_queue_avg_talk', graph)
            if self.graphEnabled('asterisk_queue_calls'):
                graph = MuninGraph(
                    'Asterisk - Queues - Calls per Minute',
                    'Asterisk',
                    period='minute',
                    info=
                    'Asterisk - Queues - Abandoned/Completed Calls per minute.',
                    args='--base 1000 --lower-limit 0')
                graph.addField('abandon',
                               'abandon',
                               type='DERIVE',
                               draw='AREASTACK',
                               info='Abandoned calls per minute.')
                graph.addField('answer',
                               'answer',
                               type='DERIVE',
                               draw='AREASTACK',
                               info='Answered calls per minute.')
                self.appendGraph('asterisk_queue_calls', graph)
            if self.graphEnabled('asterisk_queue_abandon_pcent'):
                graph = MuninGraph(
                    'Asterisk - Queues - Abandoned Calls (%)',
                    'Asterisk',
                    info='Asterisk - Queues - Abandoned calls vs, total calls.',
                    args='--base 1000 --lower-limit 0')
                for queue in self._queue_list:
                    graph.addField(
                        queue,
                        queue,
                        type='GAUGE',
                        draw='LINE2',
                        info='Abandoned vs. total calls for queue %s.' % queue)
                self.appendGraph('asterisk_queue_abandon_pcent', graph)

        self._fax_stats = None
        if (self.graphEnabled('asterisk_fax_attempts')
                or self.graphEnabled('asterisk_fax_errors')):
            if self._ami is None:
                self._ami = AsteriskInfo(self._amihost, self._amiport,
                                         self._amiuser, self._amipass)
            self._fax_stats = self._ami.getFaxStatsCounters()

        if self._fax_stats:
            if self.graphEnabled('asterisk_fax_stats'):
                graph = MuninGraph(
                    'Asterisk - Fax Stats',
                    'Asterisk',
                    period='minute',
                    info=
                    'Asterisk - Fax - Fax Recv / Send Attempts per minute.',
                    args='--base 1000 --lower-limit 0')
                graph.addField('send',
                               'send',
                               type='DERIVE',
                               draw='AREASTACK',
                               info='Fax send attempts per minute.')
                graph.addField('recv',
                               'recv',
                               type='DERIVE',
                               draw='AREASTACK',
                               info='Fax receive attempts per minute.')
                graph.addField('fail',
                               'fail',
                               type='DERIVE',
                               draw='LINE2',
                               info='Failed fax attempts per minute.')
                self.appendGraph('asterisk_fax_attempts', graph)
Exemplo n.º 57
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._host = self.envGet('host')
        self._port = self.envGet('port', None, int)
        self._user = self.envGet('user')
        self._monpath = self.envGet('monpath')
        self._password = self.envGet('password')
        self._ssl = self.envCheckFlag('ssl', False)
        self._category = 'PHP'

        graph_name = 'php_zop_memory'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP Zend Optimizer+ - Memory Usage (bytes)',
                self._category,
                info='Memory usage of Zend Optimizer+ in bytes.',
                total='Total Memory',
                args='--base 1024 --lower-limit 0')
            graph.addField('used_memory',
                           'Used Memory',
                           draw='AREASTACK',
                           type='GAUGE',
                           colour='FFCC33')
            graph.addField('wasted_memory',
                           'Wasted Memory',
                           draw='AREASTACK',
                           type='GAUGE',
                           colour='FF3333')
            graph.addField('free_memory',
                           'Free Memory',
                           draw='AREASTACK',
                           type='GAUGE',
                           colour='3790E8')

            self.appendGraph(graph_name, graph)

        graph_name = 'php_zop_opcache_statistics'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP Zend Optimizer+ - Opcache Statistics',
                self._category,
                info='Hits and Misses of Zend Optimizer+ Opcache.',
                args='--base 1000 --lower-limit 0')
            graph.addField('hits',
                           'hits',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           colour='3790E8')
            graph.addField('misses',
                           'misses',
                           draw='AREASTACK',
                           type='DERIVE',
                           min=0,
                           colour='FF3333')
            self.appendGraph(graph_name, graph)

        graph_name = 'php_zop_opcache_hitrate'
        if self.graphEnabled(graph_name):
            graph = MuninGraph('PHP Zend Optimizer+ - Hit Percent',
                               self._category,
                               info='Hit percent for PHP Zend Optimizer+.',
                               vlabel='%',
                               args='--base 1000 --lower-limit 0')
            graph.addField('opcache_hit_rate',
                           'Hit Percentage',
                           draw='LINE2',
                           type='GAUGE',
                           info='Hit Percentage',
                           min=0)

            self.appendGraph(graph_name, graph)

        graph_name = 'php_zop_key_status'
        if self.graphEnabled(graph_name):
            graph = MuninGraph('PHP Zend Optimizer+ - Key Statistics',
                               self._category,
                               info='Key usage of Zend Optimizer+ Opcache.',
                               total='Total Keys',
                               args='--base 1000 --lower-limit 0')
            graph.addField('num_cached_scripts',
                           'Used Key (for scripts)',
                           draw='AREASTACK',
                           type='GAUGE',
                           min=0,
                           colour='FFCC33')
            graph.addField('num_wasted_keys',
                           'Wasted Key',
                           draw='AREASTACK',
                           type='GAUGE',
                           colour='FF3333')
            graph.addField('num_free_keys',
                           'Free Key',
                           draw='AREASTACK',
                           type='GAUGE',
                           colour='3790E8')

            self.appendGraph(graph_name, graph)
Exemplo n.º 58
0
    def __init__(self, argv=(), env=None, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self._host = self.envGet('host')
        self._port = self.envGet('port', None, int)
        self._user = self.envGet('user')
        self._monpath = self.envGet('monpath')
        self._password = self.envGet('password')
        self._ssl = self.envCheckFlag('ssl', False)
        self._category = 'PHP'
        self._extras = False

        graph_name = 'php_apc_memory'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP APC Cache - Memory Usage (bytes)',
                self._category,
                info='Memory usage of PHP APC Cache in bytes.',
                args='--base 1024 --lower-limit 0')
            graph.addField(
                'filecache', 'File Cache', draw='AREASTACK', type='GAUGE')
            graph.addField(
                'usercache', 'User Cache', draw='AREASTACK', type='GAUGE')
            graph.addField('other', 'Other', draw='AREASTACK', type='GAUGE')
            graph.addField('free', 'Free', draw='AREASTACK', type='GAUGE')
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_items'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP APC Cache - Cached Items',
                self._category,
                info='Number of items (files, user data) in PHP APC Cache.',
                args='--base 1000 --lower-limit 0')
            graph.addField(
                'filecache', 'File Items', draw='AREASTACK', type='GAUGE')
            graph.addField(
                'usercache', 'User Items', draw='AREASTACK', type='GAUGE')
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_reqs_filecache'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP APC - File Cache Requests per second',
                self._category,
                info=
                'PHP APC File Cache Requests (Hits and Misses) per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField(
                'hits', 'hits', draw='AREASTACK', type='DERIVE', min=0)
            graph.addField(
                'misses', 'misses', draw='AREASTACK', type='DERIVE', min=0)
            graph.addField(
                'inserts', 'inserts', draw='LINE2', type='DERIVE', min=0)
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_reqs_usercache'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP APC - User Cache Requests per second',
                self._category,
                info=
                'PHP APC User Cache Requests (Hits and Misses) per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField(
                'hits', 'hits', draw='AREASTACK', type='DERIVE', min=0)
            graph.addField(
                'misses', 'misses', draw='AREASTACK', type='DERIVE', min=0)
            graph.addField(
                'inserts', 'inserts', draw='LINE2', type='DERIVE', min=0)
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_expunge'
        if self.graphEnabled(graph_name):
            graph = MuninGraph(
                'PHP APC - Cache Expunge Runs per second',
                self._category,
                info='PHP APC File and User Cache Expunge Runs per second.',
                args='--base 1000 --lower-limit 0')
            graph.addField(
                'filecache', 'File Cache', draw='LINE2', type='DERIVE', min=0)
            graph.addField(
                'usercache', 'User Cache', draw='LINE2', type='DERIVE', min=0)
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_mem_util_frag'
        if self.graphEnabled(graph_name):
            self._extras = True
            graph = MuninGraph(
                'PHP APC Cache - Memory Util. vs. Fragmentation (%)',
                self._category,
                info='PHP APC Cache Memory utilization and fragmentation.',
                args='--base 1000 --lower-limit 0',
                scale=False,
            )
            graph.addField(
                'util', 'util', draw='LINE2', type='GAUGE', min=0, max=100)
            graph.addField(
                'frag', 'frag', draw='LINE2', type='GAUGE', min=0, max=100)
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_mem_frag_count'
        if self.graphEnabled(graph_name):
            self._extras = True
            graph = MuninGraph(
                'PHP APC Cache - Fragment Count',
                self._category,
                info='Number of memory fragments for PHP APC Cache.',
                args='--base 1000 --lower-limit 0')
            graph.addField('num', 'num', draw='LINE2', type='GAUGE')
            self.appendGraph(graph_name, graph)

        graph_name = 'php_apc_mem_frag_avgsize'
        if self.graphEnabled(graph_name):
            self._extras = True
            graph = MuninGraph(
                'PHP APC Cache - Avg. Fragment Size (bytes)',
                self._category,
                info='Average memory fragment size in bytes for PHP APC Cache.',
                args='--base 1000 --lower-limit 0')
            graph.addField('size', 'size', draw='LINE2', type='GAUGE')
            self.appendGraph(graph_name, graph)
Exemplo n.º 59
0
 def __init__(self, argv=(), env={}, debug=False):
     """Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self.envRegisterFilter('db', '^\w+$')
     self._host = self.envGet('host')
     self._port = self.envGet('port')
     self._database = self.envGet('database')
     self._user = self.envGet('user')
     self._password = self.envGet('password')
     self._detailGraphs = self.envCheckFlag('detail_graphs', False)
     
     self._dbconn = PgInfo(self._host, self._port, self._database, 
                           self._user, self._password)
     dblist = [db for db in self._dbconn.getDatabases()
               if self.dbIncluded(db)]
     dblist.sort()
     
     if self.graphEnabled('pg_connections'):
         graph = MuninGraph('PostgreSQL - Active Connections', 
             'PostgreSQL Sys',
             info='Active connections for PostgreSQL Database Server.',
             args='--base 1000 --lower-limit 0',
             autoFixNames = True)
         for db in dblist:
             graph.addField(db, db, draw='AREASTACK', type='GAUGE',
                 info="Active connections to database %s." % db)
         graph.addField('total', 'total', draw='LINE2', type='GAUGE', 
                        colour='000000',
             info="Total number of active connections.")
         graph.addField('max_conn', 'max_conn', draw='LINE2', type='GAUGE', 
                        colour='FF0000',
             info="Global server level concurrent connections limit.")
         self.appendGraph('pg_connections', graph)
     
     if self.graphEnabled('pg_diskspace'):
         graph = MuninGraph('PostgreSQL - Database Disk Usage', 
             'PostgreSQL Sys',
             info='Disk usage of databases on PostgreSQL Server in bytes.',
             args='--base 1024 --lower-limit 0',
             autoFixNames = True)
         for db in dblist:
             graph.addField(db, db, draw='AREASTACK', type='GAUGE',
                 info="Disk usage of database %s." % db)
         graph.addField('total', 'total', draw='LINE2', type='GAUGE', 
             colour='000000', info="Total disk usage of all databases.")
         self.appendGraph('pg_diskspace', graph)
     
     if self.graphEnabled('pg_blockreads'):
         graph = MuninGraph('PostgreSQL - Block Read Stats', 'PostgreSQL Sys',
             info='Block read stats for PostgreSQL Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('blk_hit', 'cache hits', draw='AREASTACK', 
             type='DERIVE', min=0, 
             info="Blocks read from PostgreSQL Cache per second.")
         graph.addField('blk_read', 'disk reads', draw='AREASTACK', 
             type='DERIVE', min=0,
             info="Blocks read directly from disk or operating system "
                  "disk cache per second.")
         self.appendGraph('pg_blockreads', graph)
     
     if self.graphEnabled('pg_xact'):
         graph = MuninGraph('PostgreSQL - Transactions', 'PostgreSQL Sys',
             info='Transaction commit / rollback Stats for PostgreSQL Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('commits', 'commits', draw='LINE2', type='DERIVE', 
                        min=0, info="Transactions per second.")
         graph.addField('rollbacks', 'rollbacks', draw='LINE2', type='DERIVE', 
                        min=0, info="Rollbacks per second.")
         self.appendGraph('pg_xact', graph)
     
     if self._dbconn.checkVersion('8.3'):
         if self.graphEnabled('pg_checkpoints'):
             graph = MuninGraph('PostgreSQL - Checkpoints per minute', 
                 'PostgreSQL Sys',
                 info='Number of Checkpoints per Minute for PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0', period='minute')
             graph.addField('req', 'req', draw='LINE2', type='DERIVE', 
                            min=0, info="Requested checkpoints..")
             graph.addField('timed', 'timed', draw='LINE2', type='DERIVE', 
                            min=0, info="Check points started by timeout.")
             self.appendGraph('pg_checkpoints', graph)
         if self.graphEnabled('pg_bgwriter'):
             graph = MuninGraph('PostgreSQL - BgWriter Stats (blocks / second)', 
                 'PostgreSQL Sys',
                 info='PostgreSQL Server - Bgwriter - Blocks written per second.',
                 args='--base 1000 --lower-limit 0', period='minute')
             graph.addField('backend', 'backend', draw='LINE2', 
                            type='DERIVE', min=0, 
                            info="Buffers written by backend and not bgwriter.")
             graph.addField('clean', 'clean', draw='LINE2', 
                            type='DERIVE', min=0, 
                            info="Buffers cleaned by bgwriter runs.")
             graph.addField('chkpoint', 'chkpoint', draw='LINE2', type='DERIVE', 
                            min=0, info="Buffers written performing checkpoints.")
             self.appendGraph('pg_bgwriter', graph)
     
     if self.graphEnabled('pg_tup_read'):
         graph = MuninGraph('PostgreSQL - Tuple Reads', 'PostgreSQL Sys',
             info='Tuple return and fetch Stats for PostgreSQL Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('fetch', 'fetch', draw='AREASTACK', 
             type='DERIVE', min=0, 
             info="Tuples returned per second by table or index scans.")
         graph.addField('return', 'return', draw='AREASTACK', 
             type='DERIVE', min=0,
             info="Tuples fetched per second from tables using indices "
                  "or bitmap scans.")
         self.appendGraph('pg_tup_read', graph)
         
     if self.graphEnabled('pg_tup_write'):
         graph = MuninGraph('PostgreSQL - Tuple Writes', 'PostgreSQL Sys',
             info='Tuple insert, update and delete Stats for PostgreSQL Server.',
             args='--base 1000 --lower-limit 0')
         graph.addField('delete', 'delete', draw='AREASTACK', type='DERIVE', 
                        min=0, info="Tuples deleted per second.")
         graph.addField('update', 'update', draw='AREASTACK', type='DERIVE', 
                        min=0, info="Tuples updated per second.")
         graph.addField('insert', 'insert', draw='AREASTACK', type='DERIVE', 
                        min=0, info="Tuples inserted per second.")
         self.appendGraph('pg_tup_write', graph)
     
     if self._detailGraphs:        
         if self.graphEnabled('pg_blockread_detail'):
             graph = MuninGraph('PostgreSQL - Block Read Stats Detail', 
                 'PostgreSQL DB',
                 info='Block read stats for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Blocks read per second for database %s." % db)
             self.appendGraph('pg_blockread_detail', graph)
         if self.graphEnabled('pg_xact_commit_detail'):
             graph = MuninGraph('PostgreSQL - Transaction Commits Detail', 
                 'PostgreSQL DB',
                 info='Transaction commits for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Transaction commits per second for database %s." % db)
             self.appendGraph('pg_xact_commit_detail', graph)
         if self.graphEnabled('pg_xact_rollback_detail'):
             graph = MuninGraph('PostgreSQL - Transaction Rollbacks Detail', 
                 'PostgreSQL DB',
                 info='Transaction rollbacks for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Transaction rollbacks per second for database %s." % db)
             self.appendGraph('pg_xact_rollback_detail', graph)
         if self.graphEnabled('pg_tup_return_detail'):
             graph = MuninGraph('PostgreSQL - Tuple Scan Detail', 
                 'PostgreSQL DB',
                 info='Tuple scans for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Tuples scanned per second from database %s." % db)
             self.appendGraph('pg_tup_return_detail', graph)
         if self.graphEnabled('pg_tup_fetch_detail'):
             graph = MuninGraph('PostgreSQL - Tuple Fetch Detail', 
                 'PostgreSQL DB',
                 info='Tuple fetches for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Tuples fetched per second from database %s." % db)
             self.appendGraph('pg_tup_fetch_detail', graph)
         if self.graphEnabled('pg_tup_delete_detail'):
             graph = MuninGraph('PostgreSQL - Tuple Delete Detail', 
                 'PostgreSQL DB',
                 info='Tuple deletes for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK',
                     type='DERIVE', min=0,
                     info="Tuples deleted per second from database %s." % db)
             self.appendGraph('pg_tup_delete_detail', graph)
         if self.graphEnabled('pg_tup_update_detail'):
             graph = MuninGraph('PostgreSQL - Tuple Updates Detail', 
                 'PostgreSQL DB',
                 info='Tuple updates for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Tuples updated per second in database %s." % db)
             self.appendGraph('pg_tup_update_detail', graph)
         if self.graphEnabled('pg_tup_insert_detail'):
             graph = MuninGraph('PostgreSQL - Tuple Inserts Detail', 
                 'PostgreSQL DB',
                 info='Tuple insertes for each database in PostgreSQL Server.',
                 args='--base 1000 --lower-limit 0',
                 autoFixNames = True)
             for db in dblist:
                 graph.addField(db, db, draw='AREASTACK', 
                     type='DERIVE', min=0,
                     info="Tuples inserted per second into database %s." % db)
             self.appendGraph('pg_tup_insert_detail', graph)