Révision 8e3f1d88
plugin ksm_: various improvements
- category can be parsed by plugin gallery
- python3 compatible
- more precise autoconf messages
- PEP8 clean
| plugins/other/ksm_ | ||
|---|---|---|
| 19 | 19 |
# Magic markers - optional - used by installation scripts and |
| 20 | 20 |
# munin-config: |
| 21 | 21 |
# |
| 22 |
#%# capabilities=autoconf suggest |
|
| 23 |
#%# family=auto |
|
| 24 |
|
|
| 25 |
########################################################### |
|
| 26 |
category = 'system' # 'upgrades' |
|
| 27 |
title = 'Kernel Samepage Merging' # 'Upgradeable packages' |
|
| 28 |
########################################################### |
|
| 22 |
# #%# capabilities=autoconf suggest |
|
| 23 |
# #%# family=auto |
|
| 29 | 24 |
|
| 30 | 25 |
import os |
| 31 | 26 |
import sys |
| 32 |
import warnings |
|
| 27 |
import warnings # noqa |
|
| 28 |
|
|
| 29 |
################################# |
|
| 30 |
title = 'Kernel Samepage Merging' |
|
| 31 |
################################# |
|
| 32 |
|
|
| 33 | 33 |
|
| 34 | 34 |
def autoconf(): |
| 35 | 35 |
if os.path.exists('/sys/kernel/mm/ksm/run'):
|
| 36 | 36 |
for line in open('/sys/kernel/mm/ksm/run'):
|
| 37 | 37 |
if line.strip() == '1': |
| 38 |
print 'yes' |
|
| 39 |
sys.exit(0) |
|
| 40 |
print 'no (/sys/kernel/mm/ksm/run must be present and value must be 1)' |
|
| 38 |
print('yes')
|
|
| 39 |
break |
|
| 40 |
else: |
|
| 41 |
print('no (/sys/kernel/mm/ksm/run does not contain "1")')
|
|
| 42 |
else: |
|
| 43 |
print('no (/sys/kernel/mm/ksm/run not found)')
|
|
| 41 | 44 |
sys.exit(0) |
| 42 | 45 |
|
| 46 |
|
|
| 43 | 47 |
def suggest(): |
| 44 |
print 'pages_absolute'
|
|
| 45 |
print 'pages_relative'
|
|
| 46 |
print 'full_scans'
|
|
| 48 |
print('pages_absolute')
|
|
| 49 |
print('pages_relative')
|
|
| 50 |
print('full_scans')
|
|
| 47 | 51 |
sys.exit(0) |
| 48 | 52 |
|
| 49 | 53 |
|
| 50 | 54 |
def config(): |
| 51 |
if('ksm_pages_absolute' in sys.argv[0]):
|
|
| 52 |
print 'graph_category %s' % (category)
|
|
| 53 |
print 'graph_title %s Pages Absolute' % (title)
|
|
| 54 |
print 'graph_order pages_unshared pages_volatile pages_shared pages_sharing'
|
|
| 55 |
print 'pages_shared.info how many shared pages are being used'
|
|
| 56 |
print 'pages_sharing.info how many more sites are sharing them i.e. how much saved'
|
|
| 57 |
print 'pages_unshared.info how many pages unique but repeatedly checked for merging'
|
|
| 58 |
print 'pages_volatile.info how many pages changing too fast to be placed in a tree'
|
|
| 59 |
print 'pages_shared.label pages_shared'
|
|
| 60 |
print 'pages_sharing.label pages_sharing'
|
|
| 61 |
print 'pages_unshared.label pages_unshared'
|
|
| 62 |
print 'pages_volatile.label pages_volatile'
|
|
| 63 |
print 'pages_shared.draw AREASTACK'
|
|
| 64 |
print 'pages_sharing.draw AREASTACK'
|
|
| 65 |
print 'pages_unshared.draw AREASTACK'
|
|
| 66 |
print 'pages_volatile.draw AREASTACK'
|
|
| 55 |
if('ksm_pages_absolute' in sys.argv[0]):
|
|
| 56 |
print('graph_category system')
|
|
| 57 |
print('graph_title %s Pages Absolute' % (title))
|
|
| 58 |
print('graph_order pages_unshared pages_volatile pages_shared pages_sharing')
|
|
| 59 |
print('pages_shared.info how many shared pages are being used')
|
|
| 60 |
print('pages_sharing.info how many more sites are sharing them i.e. how much saved')
|
|
| 61 |
print('pages_unshared.info how many pages unique but repeatedly checked for merging')
|
|
| 62 |
print('pages_volatile.info how many pages changing too fast to be placed in a tree')
|
|
| 63 |
print('pages_shared.label pages_shared')
|
|
| 64 |
print('pages_sharing.label pages_sharing')
|
|
| 65 |
print('pages_unshared.label pages_unshared')
|
|
| 66 |
print('pages_volatile.label pages_volatile')
|
|
| 67 |
print('pages_shared.draw AREASTACK')
|
|
| 68 |
print('pages_sharing.draw AREASTACK')
|
|
| 69 |
print('pages_unshared.draw AREASTACK')
|
|
| 70 |
print('pages_volatile.draw AREASTACK')
|
|
| 67 | 71 |
elif('ksm_pages_relative' in sys.argv[0]):
|
| 68 |
print 'graph_category %s' % (category)
|
|
| 69 |
print 'graph_title %s Pages Relative' % (title)
|
|
| 70 |
print 'pages_sharing_shared.info ratio of sharing to shared pages'
|
|
| 71 |
print 'pages_unshared_sharing.info ratio of unshared to sharing pages'
|
|
| 72 |
print 'pages_sharing_shared.label pages_sharing_shared'
|
|
| 73 |
print 'pages_unshared_sharing.label pages_unshared_sharing'
|
|
| 74 |
print 'pages_sharing_shared.cdef pages_sharing_shared,100,*'
|
|
| 75 |
print 'pages_unshared_sharing.cdef pages_unshared_sharing,100,*'
|
|
| 72 |
print('graph_category system')
|
|
| 73 |
print('graph_title %s Pages Relative' % (title))
|
|
| 74 |
print('pages_sharing_shared.info ratio of sharing to shared pages')
|
|
| 75 |
print('pages_unshared_sharing.info ratio of unshared to sharing pages')
|
|
| 76 |
print('pages_sharing_shared.label pages_sharing_shared')
|
|
| 77 |
print('pages_unshared_sharing.label pages_unshared_sharing')
|
|
| 78 |
print('pages_sharing_shared.cdef pages_sharing_shared,100,*')
|
|
| 79 |
print('pages_unshared_sharing.cdef pages_unshared_sharing,100,*')
|
|
| 76 | 80 |
elif('ksm_full_scans' in sys.argv[0]):
|
| 77 |
print 'graph_category %s' % (category)
|
|
| 78 |
print 'graph_title %s Full Scans' % (title)
|
|
| 79 |
print 'full_scans.info how many times all mergeable areas have been scanned'
|
|
| 80 |
print 'full_scans.label full_scans'
|
|
| 81 |
print('graph_category system')
|
|
| 82 |
print('graph_title %s Full Scans' % (title))
|
|
| 83 |
print('full_scans.info how many times all mergeable areas have been scanned')
|
|
| 84 |
print('full_scans.label full_scans')
|
|
| 81 | 85 |
sys.exit(0) |
| 82 | 86 |
|
| 87 |
|
|
| 83 | 88 |
if len(sys.argv) > 1: |
| 84 | 89 |
if sys.argv[1] == 'autoconf': |
| 85 | 90 |
autoconf() |
| ... | ... | |
| 91 | 96 |
print('unknown argument "' + sys.argv[1] + '"')
|
| 92 | 97 |
sys.exit(1) |
| 93 | 98 |
|
| 94 |
pages_shared=int(open('/sys/kernel/mm/ksm/pages_shared').read())
|
|
| 95 |
pages_sharing=int(open('/sys/kernel/mm/ksm/pages_sharing').read())
|
|
| 96 |
pages_unshared=int(open('/sys/kernel/mm/ksm/pages_unshared').read())
|
|
| 97 |
pages_volatile=int(open('/sys/kernel/mm/ksm/pages_volatile').read())
|
|
| 98 |
full_scans=int(open('/sys/kernel/mm/ksm/full_scans').read())
|
|
| 99 |
pages_shared = int(open('/sys/kernel/mm/ksm/pages_shared').read())
|
|
| 100 |
pages_sharing = int(open('/sys/kernel/mm/ksm/pages_sharing').read())
|
|
| 101 |
pages_unshared = int(open('/sys/kernel/mm/ksm/pages_unshared').read())
|
|
| 102 |
pages_volatile = int(open('/sys/kernel/mm/ksm/pages_volatile').read())
|
|
| 103 |
full_scans = int(open('/sys/kernel/mm/ksm/full_scans').read())
|
|
| 99 | 104 |
|
| 100 |
if('ksm_pages_absolute' in sys.argv[0]):
|
|
| 101 |
print 'pages_shared.value %i' % pages_shared |
|
| 102 |
print 'pages_sharing.value %i' % pages_sharing |
|
| 103 |
print 'pages_unshared.value %i' % pages_unshared |
|
| 104 |
print 'pages_volatile.value %i' % pages_volatile |
|
| 105 |
elif('ksm_pages_relative' in sys.argv[0]):
|
|
| 106 |
print 'pages_sharing_shared.value %f' % (float(pages_sharing)/float(pages_shared) if pages_shared>0 else 0) |
|
| 107 |
print 'pages_unshared_sharing.value %f' % (float(pages_unshared)/float(pages_sharing) if pages_sharing>0 else 0) |
|
| 108 |
elif('ksm_full_scans' in sys.argv[0]):
|
|
| 109 |
print 'full_scans.value %i' % full_scans |
|
| 105 |
if('ksm_pages_absolute' in sys.argv[0]):
|
|
| 106 |
print('pages_shared.value %i' % pages_shared)
|
|
| 107 |
print('pages_sharing.value %i' % pages_sharing)
|
|
| 108 |
print('pages_unshared.value %i' % pages_unshared)
|
|
| 109 |
print('pages_volatile.value %i' % pages_volatile)
|
|
| 110 |
elif('ksm_pages_relative' in sys.argv[0]):
|
|
| 111 |
print('pages_sharing_shared.value %f'
|
|
| 112 |
% (float(pages_sharing) / float(pages_shared) if pages_shared > 0 else 0)) |
|
| 113 |
print('pages_unshared_sharing.value %f'
|
|
| 114 |
% (float(pages_unshared) / float(pages_sharing) if pages_sharing > 0 else 0)) |
|
| 115 |
elif('ksm_full_scans' in sys.argv[0]):
|
|
| 116 |
print('full_scans.value %i' % full_scans)
|
|
Formats disponibles : Unified diff