Skip to content

Commit e008c6c

Browse files
committed
Quick fixes from upstream pull requests
- vimeo#80 - vimeo#119
1 parent d8c86ba commit e008c6c

File tree

2 files changed

+97
-7
lines changed

2 files changed

+97
-7
lines changed

graph_explorer/backend.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, config, logger=logging):
2222
self.logger = logger
2323

2424
def download_metrics_json(self):
25-
url = urljoin(self.config.graphite_url_server, "metrics/index.json")
25+
url = urljoin(self.config.graphite_url_server, "metrics/expand?query=**")
2626
if self.config.graphite_username is not None and self.config.graphite_password is not None:
2727
username = self.config.graphite_username
2828
password = self.config.graphite_password
@@ -49,6 +49,8 @@ def load_metrics(self):
4949
# workaround for graphite bug where metrics can have leading dots
5050
# has been fixed (https://github.com/graphite-project/graphite-web/pull/293)
5151
# but older graphite versions still do it
52+
if 'results' in metrics:
53+
metrics = metrics['results'][1:]
5254
if len(metrics) and metrics[0][0] == '.':
5355
metrics = [m.lstrip('.') for m in metrics]
5456
return metrics

graph_explorer/structured_metrics/plugins/collectd.py

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def __init__(self, config):
1010

1111
self.targets = [
1212
{
13-
'match': prefix + '(?P<server>[^\.]+)\.(?P<collectd_plugin>cpu)\.(?P<core>[^\.]+)\.cpu\.(?P<type>[^\.]+)$',
13+
'match': prefix + '(?P<server>[^\.]+)\.(?P<collectd_plugin>cpu)[\-\.](?P<core>[^\.]+)\.cpu[\-\.](?P<type>[^\.]+)$',
1414
'target_type': 'gauge_pct',
1515
'tags': {
1616
'unit': 'Jiff',
@@ -23,28 +23,116 @@ def __init__(self, config):
2323
'configure': lambda self, target: self.fix_load(target)
2424
},
2525
{
26-
'match': prefix + '(?P<server>[^\.]+)\.interface\.(?P<device>[^\.]+)\.if_(?P<wt>[^\.]+)\.(?P<dir>[^\.]+)$',
26+
'match': prefix + '(?P<server>[^\.]+)\.interface[\-\.](?P<device>[^\.]+)\.if_(?P<wt>[^\.]+)\.(?P<dir>[^\.]+)$',
2727
'target_type': 'counter',
2828
'tags': {'collectd_plugin': 'network'},
2929
'configure': lambda self, target: self.fix_network(target)
3030
},
3131
{
32-
'match': prefix + '(?P<server>[^\.]+)\.memory\.memory\.(?P<type>[^\.]+)$',
32+
'match': prefix + '(?P<server>[^\.]+)\.memory\.memory[\-\.](?P<type>[^\.]+)$',
3333
'target_type': 'gauge',
3434
'tags': {
3535
'unit': 'B',
3636
'where': 'system_memory'
3737
}
3838
},
3939
{
40-
'match': prefix + '(?P<server>[^\.]+)\.df\.(?P<mountpoint>[^\.]+)\.df_complex\.(?P<type>[^\.]+)$',
40+
'match': prefix + '(?P<server>[^\.]+)\.df[\-\.](?P<mountpoint>[^\.]+)\.df_complex[\-\.](?P<type>[^\.]+)$',
4141
'target_type': 'gauge',
4242
'tags': {'unit': 'B'}
4343
},
4444
{
45-
'match': prefix + '(?P<server>[^\.]+)\.(?P<collectd_plugin>disk)\.(?P<device>[^\.]+)\.disk_(?P<wt>[^\.]+)\.(?P<operation>[^\.]+)$',
45+
'match': prefix + '(?P<server>[^\.]+)\.(?P<collectd_plugin>disk)[\-\.](?P<device>[^\.]+)\.disk_(?P<wt>[^\.]+)\.(?P<operation>[^\.]+)$',
4646
'configure': lambda self, target: self.fix_disk(target)
47-
}
47+
},
48+
{
49+
'match': prefix + '(?P<server>.+?)\.(?P<collectd_plugin>irq)\.irq[\-\.](?P<wt>.*)$',
50+
'target_type': 'counter',
51+
'tags': {
52+
'unit': 'calls',
53+
'what': 'irq_calls'
54+
}
55+
56+
},
57+
{
58+
'match': prefix + '(?P<server>.+?)\.(?P<collectd_plugin>processes)\.ps_state[\-\.](?P<state>.*)$',
59+
'target_type': 'gauge',
60+
'tags': {
61+
'unit': 'procs',
62+
'what': 'procs_in_state'
63+
}
64+
65+
},
66+
{
67+
'match': prefix + '(?P<server>.+?)\.(?P<collectd_plugin>processes)\.(?P<value>fork_rate)$',
68+
'target_type': 'counter',
69+
'tags': {
70+
'unit': 'procs',
71+
'what': 'fork_rate'
72+
}
73+
74+
},
75+
{
76+
'match': prefix + '(?P<server>[^\.]+)\.swap\.swap[\-\.](?P<type>[^\.]+)$',
77+
'target_type': 'gauge',
78+
'tags': {
79+
'unit': 'B',
80+
'where': 'swap'
81+
}
82+
},
83+
{
84+
'match': prefix + '(?P<server>[^\.]+)\.swap\.swap_io[\-\.](?P<dir>[^\.]+)$',
85+
'target_type': 'counter',
86+
'tags': {
87+
'unit': 'B',
88+
'where': 'swap_io'
89+
}
90+
},
91+
{
92+
'match': prefix + '(?P<server>.+?)\.(?P<collectd_plugin>tcpconns)[\-\.](?P<port>\d+)[\-\.]local\.tcp_connections[\-\.](?P<state>.*)$',
93+
'target_type': 'gauge',
94+
'tags': {
95+
'unit': 'connections',
96+
'what': 'tcp_connections_in_state'
97+
}
98+
99+
},
100+
{
101+
'match': prefix + '(?P<server>.+?)\.(?P<collectd_plugin>contextswitch)\.(?P<value>contextswitch)$',
102+
'target_type': 'counter',
103+
'tags': {
104+
'unit': 'fork/s',
105+
'what': 'contextswitch'
106+
}
107+
108+
},
109+
{
110+
'match': prefix + '(?P<server>.+?)\.(?P<collectd_plugin>users)\.(?P<value>users)$',
111+
'target_type': 'gauge',
112+
'tags': {
113+
'unit': 'users',
114+
'what': 'users_logged'
115+
}
116+
117+
},
118+
{
119+
'match': prefix + '(?P<server>.+?)\.(?P<collectd_plugin>entropy)\.(?P<value>entropy)$',
120+
'target_type': 'gauge',
121+
'tags': {
122+
'unit': 'bits',
123+
'what': 'entropy'
124+
}
125+
126+
},
127+
{
128+
'match': prefix + '(?P<server>.+?)\.(?P<collectd_plugin>conntrack)\.(?P<value>conntrack)$',
129+
'target_type': 'gauge',
130+
'tags': {
131+
'unit': 'entries',
132+
'what': 'conntrack'
133+
}
134+
135+
},
48136
]
49137
super(CollectdPlugin, self).__init__(config)
50138

0 commit comments

Comments
 (0)