Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 4045cc1

Browse files
committed
Updated metric suffixes
- Also fix PHP APC stats reporting differences between versions
1 parent 4e2486d commit 4045cc1

File tree

2 files changed

+68
-49
lines changed

2 files changed

+68
-49
lines changed

newrelic_plugin_agent/plugins/apache_httpd.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ class ApacheHTTPD(base.HTTPStatsPlugin):
1717
DEFAULT_QUERY = 'auto'
1818
GUID = 'com.meetme.newrelic_apache_httpd_agent'
1919
KEYS = {'Total Accesses': {'type': '',
20-
'label': 'Totals/Requests'},
20+
'label': 'Totals/Requests',
21+
'suffix': 'requests'},
2122
'BusyWorkers': {'type': 'gauge',
22-
'label': 'Workers/Busy'},
23+
'label': 'Workers/Busy',
24+
'suffix': 'workers'},
2325
'Total kBytes': {'type': '',
2426
'label': 'Totals/Bytes Sent',
2527
'suffix': 'kb'},
@@ -29,8 +31,10 @@ class ApacheHTTPD(base.HTTPStatsPlugin):
2931
'BytesPerReq': {'type': 'gauge',
3032
'label': 'Requests/Average Payload Size',
3133
'suffix': 'bytes'},
32-
'IdleWorkers': {'type': 'gauge', 'label': 'Workers/Idle'},
33-
'CPULoad': {'type': 'gauge', 'label': 'CPU Load'},
34+
'IdleWorkers': {'type': 'gauge', 'label': 'Workers/Idle',
35+
'suffix': 'workers'},
36+
'CPULoad': {'type': 'gauge', 'label': 'CPU Load',
37+
'suffix': 'processes'},
3438
'ReqPerSec': {'type': 'gauge', 'label': 'Requests/Velocity',
3539
'suffix': 'requests/sec'},
3640
'Uptime': {'type': 'gauge', 'label': 'Uptime', 'suffix': 'sec'},
@@ -50,12 +54,11 @@ class ApacheHTTPD(base.HTTPStatsPlugin):
5054
'I': {'type': 'gauge', 'label': 'Scoreboard/Idle Cleanup', 'suffix': 'slots'},
5155
'.': {'type': 'gauge', 'label': 'Scoreboard/Open Slot', 'suffix': 'slots'}}
5256

53-
5457
def error_message(self):
55-
LOGGER.error('Could not match any of the stats, please make ensure '
56-
'Apache HTTPd is configured correctly. If you report '
57-
'this as a bug, please include the full output of the '
58-
'status page from %s in your ticket', self.stats_url)
58+
LOGGER.error('Could not match any of the stats, please make ensure '
59+
'Apache HTTPd is configured correctly. If you report '
60+
'this as a bug, please include the full output of the '
61+
'status page from %s in your ticket', self.stats_url)
5962

6063
def get_scoreboard(self, data):
6164
"""Fetch the scoreboard from the stats URL
@@ -101,8 +104,8 @@ def add_datapoints(self, stats):
101104
self.KEYS[key].get('suffix', ''),
102105
value)
103106
else:
104-
LOGGER.warning('Found unmapped key/value pair: %s = %s',
105-
key, value)
107+
LOGGER.debug('Found unmapped key/value pair: %s = %s',
108+
key, value)
106109

107110
score_data = self.get_scoreboard(stats)
108111
for key, value in score_data.iteritems():
@@ -116,6 +119,6 @@ def add_datapoints(self, stats):
116119
self.KEYS[key].get('suffix', ''),
117120
value)
118121
else:
119-
LOGGER.warning('Found unmapped key/value pair: %s = %s',
120-
key, value)
122+
LOGGER.debug('Found unmapped key/value pair: %s = %s',
123+
key, value)
121124

newrelic_plugin_agent/plugins/php_apc.py

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,61 +19,77 @@ def add_datapoints(self, stats):
1919
:param dict stats: The stats content from APC as a string
2020
2121
"""
22-
#APC Shared Memory Stats
22+
# APC Shared Memory Stats
2323
shared_memory = stats.get('shared_memory', dict())
24-
self.add_gauge_value('Shared Memory/Available', 'Bytes',
24+
self.add_gauge_value('Shared Memory/Available', 'bytes',
2525
shared_memory.get('avail_mem', 0))
26-
self.add_gauge_value('Shared Memory/Segment Size', 'Bytes',
26+
self.add_gauge_value('Shared Memory/Segment Size', 'bytes',
2727
shared_memory.get('seg_size', 0))
28-
self.add_gauge_value('Shared Memory/Segment Count', '',
29-
shared_memory.get('num_seg', 0))
28+
self.add_gauge_value('Shared Memory/Segment Count', 'segments',
29+
shared_memory.get('nseg',
30+
shared_memory.get('num_seg',
31+
0)))
3032

31-
#APC System Stats
32-
system_stats = stats.get('system_stats', dict())
33-
self.add_gauge_value('System Cache/Slots', '',
34-
system_stats.get('num_slots', 0))
35-
self.add_gauge_value('System Cache/Entries', '',
36-
system_stats.get('num_entries', 0))
37-
self.add_gauge_value('System Cache/Size', 'Bytes',
33+
# APC System Stats
34+
system_stats = stats.get('system_stats', dict())
35+
self.add_gauge_value('System Cache/Slots', 'slots',
36+
system_stats.get('nslots',
37+
system_stats.get('num_slots',
38+
0)))
39+
self.add_gauge_value('System Cache/Entries', 'files',
40+
system_stats.get('nentries',
41+
system_stats.get('num_entries',
42+
0)))
43+
self.add_gauge_value('System Cache/Size', 'bytes',
3844
system_stats.get('mem_size', 0))
39-
self.add_gauge_value('System Cache/Expunges', '',
40-
system_stats.get('expunges', 0))
45+
self.add_gauge_value('System Cache/Expunges', 'files',
46+
system_stats.get('nexpunges',
47+
system_stats.get('num_expunges',
48+
0)))
4149

42-
hits = system_stats.get('num_hits', 0)
43-
misses = system_stats.get('num_misses', 0)
50+
hits = system_stats.get('nhits', system_stats.get('num_hits', 0))
51+
misses = system_stats.get('nmisses', system_stats.get('num_misses', 0))
4452
total = hits + misses
4553
if total > 0:
4654
effectiveness = float(float(hits) / float(total)) * 100
4755
else:
4856
effectiveness = 0
49-
self.add_gauge_value('System Cache/Effectiveness', '%', effectiveness)
57+
self.add_gauge_value('System Cache/Effectiveness', 'percent',
58+
effectiveness)
5059

51-
self.add_derive_value('System Cache/Hits', '', hits)
52-
self.add_derive_value('System Cache/Misses', '', misses)
53-
self.add_derive_value('System Cache/Inserts', '',
54-
system_stats.get('num_inserts', 0))
60+
self.add_derive_value('System Cache/Hits', 'files', hits)
61+
self.add_derive_value('System Cache/Misses', 'files', misses)
62+
self.add_derive_value('System Cache/Inserts', 'files',
63+
system_stats.get('ninserts',
64+
system_stats.get('num_inserts',
65+
0)))
5566

56-
#APC User Stats
67+
# APC User Stats
5768
user_stats = stats.get('user_stats', dict())
58-
self.add_gauge_value('User Cache/Slots', '',
59-
user_stats.get('num_slots', 0))
60-
self.add_gauge_value('User Cache/Entries', '',
61-
user_stats.get('num_entries', 0))
62-
self.add_gauge_value('User Cache/Size', 'Bytes',
69+
self.add_gauge_value('User Cache/Slots', 'slots',
70+
user_stats.get('nslots',
71+
user_stats.get('num_slots', 0)))
72+
self.add_gauge_value('User Cache/Entries', 'keys',
73+
user_stats.get('nentries',
74+
user_stats.get('num_entries', 0)))
75+
self.add_gauge_value('User Cache/Size', 'bytes',
6376
user_stats.get('mem_size', 0))
64-
self.add_gauge_value('User Cache/Expunges', '',
65-
user_stats.get('expunges', 0))
77+
self.add_gauge_value('User Cache/Expunges', 'keys',
78+
user_stats.get('nexpunges',
79+
user_stats.get('num_expunges', 0)))
6680

67-
hits = user_stats.get('num_hits', 0)
68-
misses = user_stats.get('num_misses', 0)
81+
hits = user_stats.get('nhits', user_stats.get('num_hits', 0))
82+
misses = user_stats.get('nmisses', user_stats.get('num_misses', 0))
6983
total = hits + misses
7084
if total > 0:
7185
effectiveness = float(float(hits) / float(total)) * 100
7286
else:
7387
effectiveness = 0
74-
self.add_gauge_value('User Cache/Effectiveness', '%', effectiveness)
88+
self.add_gauge_value('User Cache/Effectiveness', 'percent',
89+
effectiveness)
7590

76-
self.add_derive_value('User Cache/Hits', '', hits)
77-
self.add_derive_value('User Cache/Misses', '', misses)
78-
self.add_derive_value('User Cache/Inserts', '',
79-
user_stats.get('num_inserts', 0))
91+
self.add_derive_value('User Cache/Hits', 'keys', hits)
92+
self.add_derive_value('User Cache/Misses', 'keys', misses)
93+
self.add_derive_value('User Cache/Inserts', 'keys',
94+
user_stats.get('ninserts',
95+
user_stats.get('num_inserts',0)))

0 commit comments

Comments
 (0)