Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

By default ignore file systems below certain size. It should eliminate

lots of file systems we don't care about. Use name matching to include disk space
for all file systems
  • Loading branch information...
commit 2c8459dabb287839f0da28021959db074767c8d0 1 parent 5023fb1
vuksan authored
Showing with 28 additions and 32 deletions.
  1. +1 −13 diskfree/conf.d/diskfree.pyconf
  2. +27 −19 diskfree/python_modules/diskfree.py
View
14 diskfree/conf.d/diskfree.pyconf
@@ -12,20 +12,8 @@ collection_group {
collect_every = 60
time_threshold = 180
metric {
- name = "disk_free_absolute_rootfs"
- title = "Disk Space Available On /"
+ name_match = "disk_free_(.+)"
}
- metric {
- name = "disk_free_percent_rootfs"
- title = "Disk Space Available On / in %"
- }
-
-# Add additional by specifying the mount point e.g.
-# metric {
-# name = "disk_free_percent_mnt"
-# title = "Disk Space Available On /mnt in %"
-# }
-#
}
View
46 diskfree/python_modules/diskfree.py
@@ -28,6 +28,8 @@
import re
import os
+# Minimum disk size
+MIN_DISK_SIZE=1
NAME_PREFIX = 'disk_free_'
PARAMS = {
@@ -66,7 +68,7 @@ def get_value(name):
def metric_init(lparams):
"""Initialize metric descriptors"""
- global PARAMS
+ global PARAMS, MIN_DISK_SIZE
# set parameters
for key in lparams:
@@ -81,7 +83,8 @@ def metric_init(lparams):
# parse mounts and create descriptors
descriptors = []
for line in f:
- if line.startswith('/'):
+ # We only want local file systems
+ if line.startswith('/') or line.startswith('tmpfs'):
mount_info = line.split()
# create key from path
@@ -89,23 +92,28 @@ def metric_init(lparams):
path_key = 'rootfs'
else:
path_key = mount_info[1][1:].replace('/', '_')
-
- for unit_type in ['absolute', 'percent']:
- if unit_type == 'percent':
- units = '%'
- else:
- units = 'GB'
- descriptors.append({
- 'name': NAME_PREFIX + unit_type + '_' + path_key,
- 'call_back': get_value,
- 'time_max': 60,
- 'value_type': 'float',
- 'units': units,
- 'slope': 'both',
- 'format': '%f',
- 'description': "Disk space available (%s) on %s" % (units, mount_info[1]),
- 'groups': 'disk'
- })
+
+ # Calculate the size of the disk. We'll use it exclude small disks
+ disk = os.statvfs(mount_info[1])
+ disk_size = (disk.f_blocks * disk.f_frsize) / float(2**30)
+
+ if disk_size > MIN_DISK_SIZE and mount_info[1] != "/dev":
+ for unit_type in ['absolute', 'percent']:
+ if unit_type == 'percent':
+ units = '%'
+ else:
+ units = 'GB'
+ descriptors.append({
+ 'name': NAME_PREFIX + unit_type + '_' + path_key,
+ 'call_back': get_value,
+ 'time_max': 60,
+ 'value_type': 'float',
+ 'units': units,
+ 'slope': 'both',
+ 'format': '%f',
+ 'description': "Disk space available (%s) on %s" % (units, mount_info[1]),
+ 'groups': 'disk'
+ })
return descriptors
Please sign in to comment.
Something went wrong with that request. Please try again.