本文整理汇总了Python中pymunin.MuninGraph类的典型用法代码示例。如果您正苦于以下问题:Python MuninGraph类的具体用法?Python MuninGraph怎么用?Python MuninGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MuninGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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)
示例2: _configDevBytes
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)
示例3: __init__
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)
示例4: __init__
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)
示例5: __init__
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)
示例6: __init__
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)
示例7: __init__
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)
示例8: __init__
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)
示例9: __init__
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)
示例10: __init__
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)
示例11: __init__
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)
示例12: __init__
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)
示例13: __init__
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)
示例14: _configDevActive
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)
示例15: __init__
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)