summaryrefslogtreecommitdiffstats
path: root/src/ps-ceph.pl
blob: 1e79e01a334eb96f46e6a33c50e84b9fad642e91 (plain)
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
#!/usr/bin/perl
use strict;

#
# ps-ceph.pl: Displays a list of ceph processes running locally
#
# Copyright (C) 2010, Dreamhost
#
# This is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software
# Foundation.  See file COPYING.
#

sub is_ceph_proc {
        my $cmdline = @_[0];
        return 0 if $cmdline =~ /\bps-ceph.pl\b/;

        return 1 if $cmdline =~ /\bceph\b/;
        return 1 if $cmdline =~ /\bceph-fuse\b/;
        return 1 if $cmdline =~ /\brbd-nbd\b/;
        return 1 if $cmdline =~ /\brbd-fuse\b/;
        return 1 if $cmdline =~ /\bceph-mds\b/;
        return 1 if $cmdline =~ /\bceph-mon\b/;
        return 1 if $cmdline =~ /\bceph-osd\b/;
        return 1 if $cmdline =~ /\bceph-mgr\b/;
        return 1 if $cmdline =~ /\brbd-mirror\b/;
        return 1 if $cmdline =~ /\bradosgw\b/;
        return 1 if $cmdline =~ /\bosdmaptool\b/;
        return 1 if $cmdline =~ /\brados\b/;
        return 1 if $cmdline =~ /test_/;
        return 1 if $cmdline =~ /\bvstart.sh\b/;

        return 0;
}

opendir PROC, "/proc";
while(my $pid = readdir PROC) {
        next if $pid =~ /\D/;        # not a pid
        next if !-o "/proc/$pid";    # not ours
        open CMDLINE, "/proc/$pid/cmdline" or next;
        my $cmdline = <CMDLINE>;
        $cmdline =~ s/[^\x20-\x7e]/ /g;
        close CMDLINE;
        if (is_ceph_proc($cmdline)) {
                print "$pid\t$cmdline\n";
        }
}