Merge lp:~bisscuitt/percona-toolkit/lsof_find into lp:percona-toolkit/2.2

Proposed by Ian Bissett
Status: Needs review
Proposed branch: lp:~bisscuitt/percona-toolkit/lsof_find
Merge into: lp:percona-toolkit/2.2
Diff against target: 119 lines (+30/-20)
5 files modified
bin/pt-ioprofile (+6/-4)
bin/pt-mext (+6/-4)
bin/pt-pmp (+6/-4)
bin/pt-stalk (+6/-4)
bin/pt-summary (+6/-4)
To merge this branch: bzr merge lp:~bisscuitt/percona-toolkit/lsof_find
Reviewer Review Type Date Requested Status
Percona Toolkit developers Pending
Review via email: mp+244525@code.launchpad.net

Description of the change

This is similar to the proposed merge for percona-monitoring-tools:
https://code.launchpad.net/~bisscuitt/percona-monitoring-plugins/lsof_find/+merge/244524

find is much quicker than lsof on systems with a large number of open files

To post a comment you must log in.

Unmerged revisions

613. By Ian Bissett

Prefer find to lsof on linux systems

612. By Ian Bissett

pt-stalk: Prefer find to lsof on linux systems

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-ioprofile'
2--- bin/pt-ioprofile 2014-11-11 13:28:27 +0000
3+++ bin/pt-ioprofile 2014-12-12 01:10:41 +0000
4@@ -522,13 +522,15 @@
5
6 _lsof() {
7 local pid="$1"
8- if ! lsof -p $pid 2>/dev/null; then
9- /bin/ls -l /proc/$pid/fd 2>/dev/null
10+ if test -d "/proc/$pid/fd"
11+ then
12+ find /proc/$pid/fd -printf %l\\n 2>/dev/null
13+ true
14+ else
15+ lsof -p $pid 2>/dev/null
16 fi
17 }
18
19-
20-
21 _which() {
22 if [ -x /usr/bin/which ]; then
23 /usr/bin/which "$1" 2>/dev/null | awk '{print $1}'
24
25=== modified file 'bin/pt-mext'
26--- bin/pt-mext 2014-11-11 13:28:27 +0000
27+++ bin/pt-mext 2014-12-12 01:10:41 +0000
28@@ -522,13 +522,15 @@
29
30 _lsof() {
31 local pid="$1"
32- if ! lsof -p $pid 2>/dev/null; then
33- /bin/ls -l /proc/$pid/fd 2>/dev/null
34+ if test -d "/proc/$pid/fd"
35+ then
36+ find /proc/$pid/fd -printf %l\\n 2>/dev/null
37+ true
38+ else
39+ lsof -p $pid 2>/dev/null
40 fi
41 }
42
43-
44-
45 _which() {
46 if [ -x /usr/bin/which ]; then
47 /usr/bin/which "$1" 2>/dev/null | awk '{print $1}'
48
49=== modified file 'bin/pt-pmp'
50--- bin/pt-pmp 2014-11-11 13:28:27 +0000
51+++ bin/pt-pmp 2014-12-12 01:10:41 +0000
52@@ -524,13 +524,15 @@
53
54 _lsof() {
55 local pid="$1"
56- if ! lsof -p $pid 2>/dev/null; then
57- /bin/ls -l /proc/$pid/fd 2>/dev/null
58+ if test -d "/proc/$pid/fd"
59+ then
60+ find /proc/$pid/fd -printf %l\\n 2>/dev/null
61+ true
62+ else
63+ lsof -p $pid 2>/dev/null
64 fi
65 }
66
67-
68-
69 _which() {
70 if [ -x /usr/bin/which ]; then
71 /usr/bin/which "$1" 2>/dev/null | awk '{print $1}'
72
73=== modified file 'bin/pt-stalk'
74--- bin/pt-stalk 2014-11-11 13:28:27 +0000
75+++ bin/pt-stalk 2014-12-12 01:10:41 +0000
76@@ -631,13 +631,15 @@
77
78 _lsof() {
79 local pid="$1"
80- if ! lsof -p $pid 2>/dev/null; then
81- /bin/ls -l /proc/$pid/fd 2>/dev/null
82+ if test -d "/proc/$pid/fd"
83+ then
84+ find /proc/$pid/fd -printf %l\\n 2>/dev/null
85+ true
86+ else
87+ lsof -p $pid 2>/dev/null
88 fi
89 }
90
91-
92-
93 _which() {
94 if [ -x /usr/bin/which ]; then
95 /usr/bin/which "$1" 2>/dev/null | awk '{print $1}'
96
97=== modified file 'bin/pt-summary'
98--- bin/pt-summary 2014-11-11 13:28:27 +0000
99+++ bin/pt-summary 2014-12-12 01:10:41 +0000
100@@ -531,13 +531,15 @@
101
102 _lsof() {
103 local pid="$1"
104- if ! lsof -p $pid 2>/dev/null; then
105- /bin/ls -l /proc/$pid/fd 2>/dev/null
106+ if test -d "/proc/$pid/fd"
107+ then
108+ find /proc/$pid/fd -printf %l\\n 2>/dev/null
109+ true
110+ else
111+ lsof -p $pid 2>/dev/null
112 fi
113 }
114
115-
116-
117 _which() {
118 if [ -x /usr/bin/which ]; then
119 /usr/bin/which "$1" 2>/dev/null | awk '{print $1}'

Subscribers

People subscribed via source and target branches