Skip to content

Commit

Permalink
Add page fault stats support
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfb committed Aug 7, 2020
1 parent 6fd95a9 commit 5e9489c
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
49 changes: 49 additions & 0 deletions template-app-varnish-cache.j2
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,42 @@
},
],
},
{
'name': 'PAGE_FAULTS.minor (minor page faults / sec)',
'type': 'DEPENDENT',
'key': 'varnish.stat["{#LOCATION_ID}","PAGE_FAULTS.minor"]',
'value_type': 'FLOAT',
'units': 'eps',
'master_item_key': master,
'preprocessing': [
{
'type': 'JSONPATH',
'params': '$[\'{#LOCATION_ID}.PAGE_FAULTS.minor\']',
'error_handler': 'DISCARD_VALUE',
},
{
'type': 'CHANGE_PER_SECOND',
},
],
},
{
'name': 'PAGE_FAULTS.major (major page faults / sec)',
'type': 'DEPENDENT',
'key': 'varnish.stat["{#LOCATION_ID}","PAGE_FAULTS.major"]',
'value_type': 'FLOAT',
'units': 'eps',
'master_item_key': master,
'preprocessing': [
{
'type': 'JSONPATH',
'params': '$[\'{#LOCATION_ID}.PAGE_FAULTS.major\']',
'error_handler': 'DISCARD_VALUE',
},
{
'type': 'CHANGE_PER_SECOND',
},
],
},
{
'name': 'MAIN.backend_busy (backend connections too many / sec)',
'type': 'DEPENDENT',
Expand Down Expand Up @@ -3183,6 +3219,19 @@
},
],
},
{
'name': 'Page faults',
'items': [
{
'color': '00C800',
'key': 'varnish.stat["{#LOCATION_ID}","PAGE_FAULTS.minor"]',
},
{
'color': '0000C8',
'key': 'varnish.stat["{#LOCATION_ID}","PAGE_FAULTS.major"]',
},
],
},
{
'name': 'Backends: connections activity',
'items': [
Expand Down
22 changes: 22 additions & 0 deletions zabbix-varnish-cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ def _stats(instance, backends_re=None, lite=False):
}) as f:
child_pid = f.readline().split(' ')[1]
_memory_stats(stats, child_pid)
_page_fault_stats(stats, child_pid)
except IOError:
pass

Expand Down Expand Up @@ -609,6 +610,27 @@ def _memory_stats(stats, pid):
stats.log('Failed to fetch /proc/{}/status stats'.format(pid))


def _page_fault_stats(stats, pid):
# Linux is assumed. See:
# - man proc
try:
with open('/proc/{}/stat'.format(pid), 'r') as fd:
for line in fd:
fields = line.split(' ')
if len(fields) > 11:
stats.add(Item(
name='PAGE_FAULTS.minor',
value=fields[9],
type=TYPE_COUNTER))
stats.add(Item(
name='PAGE_FAULTS.major',
value=fields[11],
type=TYPE_COUNTER))
break
except:
stats.log('Failed to fetch /proc/{}/stat stats'.format(pid))


def _rewrite(name):
result = name
for pattern, repl in REWRITES:
Expand Down

0 comments on commit 5e9489c

Please sign in to comment.