]> git.proxmox.com Git - ceph.git/blame - ceph/src/ps-ceph.pl
import 15.2.1 Octopus source
[ceph.git] / ceph / src / ps-ceph.pl
CommitLineData
7c673cae
FG
1#!/usr/bin/perl
2use strict;
3
4#
5# ps-ceph.pl: Displays a list of ceph processes running locally
6#
7# Copyright (C) 2010, Dreamhost
8#
9# This is free software; you can redistribute it and/or
10# modify it under the terms of the GNU Lesser General Public
11# License version 2.1, as published by the Free Software
12# Foundation. See file COPYING.
13#
14
15sub is_ceph_proc {
16 my $cmdline = @_[0];
17 return 0 if $cmdline =~ /\bps-ceph.pl\b/;
18
19 return 1 if $cmdline =~ /\bceph\b/;
20 return 1 if $cmdline =~ /\bceph-fuse\b/;
21 return 1 if $cmdline =~ /\brbd-nbd\b/;
22 return 1 if $cmdline =~ /\brbd-fuse\b/;
23 return 1 if $cmdline =~ /\bceph-mds\b/;
24 return 1 if $cmdline =~ /\bceph-mon\b/;
25 return 1 if $cmdline =~ /\bceph-osd\b/;
26 return 1 if $cmdline =~ /\bceph-mgr\b/;
7c673cae
FG
27 return 1 if $cmdline =~ /\brbd-mirror\b/;
28 return 1 if $cmdline =~ /\bradosgw\b/;
29 return 1 if $cmdline =~ /\bosdmaptool\b/;
30 return 1 if $cmdline =~ /\brados\b/;
31 return 1 if $cmdline =~ /test_/;
32 return 1 if $cmdline =~ /\bvstart.sh\b/;
33
34 return 0;
35}
36
37opendir PROC, "/proc";
38while(my $pid = readdir PROC) {
39 next if $pid =~ /\D/; # not a pid
40 next if !-o "/proc/$pid"; # not ours
41 open CMDLINE, "/proc/$pid/cmdline" or next;
42 my $cmdline = <CMDLINE>;
43 $cmdline =~ s/[^\x20-\x7e]/ /g;
44 close CMDLINE;
45 if (is_ceph_proc($cmdline)) {
46 print "$pid\t$cmdline\n";
47 }
48}