diff options
Diffstat (limited to 'tests/utils')
-rwxr-xr-x | tests/utils/create-files.py | 2 | ||||
-rwxr-xr-x | tests/utils/gfid-access.py | 1 | ||||
-rwxr-xr-x | tests/utils/pidof.py | 45 |
3 files changed, 47 insertions, 1 deletions
diff --git a/tests/utils/create-files.py b/tests/utils/create-files.py index 0d937eff978..05cf1279999 100755 --- a/tests/utils/create-files.py +++ b/tests/utils/create-files.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2 # This script was developed by Vijaykumar Koppad (vkoppad@redhat.com) # The latest version of this script can found at diff --git a/tests/utils/gfid-access.py b/tests/utils/gfid-access.py index 25fe35bf50b..4fd4b6dfa8d 100755 --- a/tests/utils/gfid-access.py +++ b/tests/utils/gfid-access.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python2 # # Copyright (c) 2011-2014 Red Hat, Inc. <http://www.redhat.com> # This file is part of GlusterFS. diff --git a/tests/utils/pidof.py b/tests/utils/pidof.py new file mode 100755 index 00000000000..575b899b6cc --- /dev/null +++ b/tests/utils/pidof.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +import sys + +try: + import psutil +except ImportError: + print("Please install psutil --> pip install psutil") + sys.exit(1) + +def pmap_find(p, name): + for m in p.memory_maps(grouped=True): + if m.path.endswith("%s.so" % name): + return True + continue + return False + +def pidof(processname): + for p in psutil.process_iter(): + if p.pid == 0: + continue + if "gluster" in processname: + if processname == "glusterd" and pmap_find(p, "glusterd"): + print (p.pid) + if processname == "glusterfs" and pmap_find(p, "client"): + print (p.pid) + if processname == "glusterfsd" and pmap_find(p, "posix-acl"): + print (p.pid) + continue + if processname.strip() == p.name(): + print (p.pid) + +def main(argv): + if len(argv) < 2: + sys.stderr.write("Usage: %s <processname>\n" % (argv[0],)) + return 1 + try: + pidof(argv[1]) + except Exception as err: + print err + sys.stderr.write("Please be root - %s\n" % err); + sys.exit(1) + +if __name__ == "__main__": + main(sys.argv) |