/var/lib/pcp/testsuite/src/fsstats.python is in pcp-testsuite 4.0.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #!/usr/bin/env pmpython
#
# Copyright (C) 2015 Red Hat.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Iostat Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# pylint: disable=C0103,R0914,R0902
""" Display filesys and mount metrics """
import sys
from pcp import pmapi, pmcc
METRICS = [ 'filesys.capacity', 'filesys.used', 'filesys.free',
'filesys.maxfiles', 'filesys.usedfiles', 'filesys.freefiles',
'filesys.full', 'filesys.blocksize', 'filesys.avail',
'mounts.capacity', 'mounts.used', 'mounts.free',
'mounts.maxfiles', 'mounts.usedfiles', 'mounts.freefiles',
'mounts.full', 'mounts.blocksize', 'mounts.avail' ]
class FilesysReport(pmcc.MetricGroupPrinter):
_device = ''
_fspath = ''
def __init__(self, device, fspath):
pmcc.MetricGroupPrinter.__init__(self)
self._device = device
self._fspath = fspath
def currentValue(self, group, name):
return dict(map(lambda x: (x[1], x[2]), group[name].netValues))
def report(self, manager):
group = manager["fs"]
names = [ 'capacity', 'used', 'free', 'maxfiles', 'usedfiles',
'freefiles', 'full', 'blocksize', 'avail' ]
for name in names:
filesys = self.currentValue(group, 'filesys.' + name)
mounts = self.currentValue(group, 'mounts.' + name)
# print("%s %s %s" % (name, self._device, self._fspath))
print("%s %f %f" % (name,
filesys[self._device], mounts[self._fspath]))
sys.exit(0)
if __name__ == '__main__':
try:
options = pmapi.pmOptions('?')
options.pmSetShortUsage('[options] device fspath')
if len(sys.argv) != 3:
raise pmapi.pmUsageErr()
manager = pmcc.MetricGroupManager.builder(options, sys.argv)
manager["fs"] = METRICS
manager.printer = FilesysReport(sys.argv[1], sys.argv[2])
sts = manager.run()
sys.exit(sts)
except pmapi.pmErr as error:
print('%s: %s\n' % (error.progname(), error.message()))
except pmapi.pmUsageErr as usage:
usage.message()
sys.exit(1)
except KeyboardInterrupt:
pass
|