1 |
dilfridge 12/02/07 20:12:03 |
2 |
|
3 |
Modified: collectd.initd |
4 |
Added: collectd-5.0.2-irq.patch |
5 |
Log: |
6 |
Version bump, thanks Johan |
7 |
|
8 |
(Portage version: 2.1.10.44/cvs/Linux x86_64) |
9 |
|
10 |
Revision Changes Path |
11 |
1.6 app-admin/collectd/files/collectd.initd |
12 |
|
13 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/collectd/files/collectd.initd?rev=1.6&view=markup |
14 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/collectd/files/collectd.initd?rev=1.6&content-type=text/plain |
15 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/collectd/files/collectd.initd?r1=1.5&r2=1.6 |
16 |
|
17 |
Index: collectd.initd |
18 |
=================================================================== |
19 |
RCS file: /var/cvsroot/gentoo-x86/app-admin/collectd/files/collectd.initd,v |
20 |
retrieving revision 1.5 |
21 |
retrieving revision 1.6 |
22 |
diff -u -r1.5 -r1.6 |
23 |
--- collectd.initd 25 Aug 2011 21:02:37 -0000 1.5 |
24 |
+++ collectd.initd 7 Feb 2012 20:12:03 -0000 1.6 |
25 |
@@ -1,14 +1,14 @@ |
26 |
#!/sbin/runscript |
27 |
-# Copyright 1999-2011 Gentoo Foundation |
28 |
+# Copyright 1999-2012 Gentoo Foundation |
29 |
# Distributed under the terms of the GNU General Public License v2 |
30 |
-# $Header: /var/cvsroot/gentoo-x86/app-admin/collectd/files/collectd.initd,v 1.5 2011/08/25 21:02:37 dilfridge Exp $ |
31 |
+# $Header: /var/cvsroot/gentoo-x86/app-admin/collectd/files/collectd.initd,v 1.6 2012/02/07 20:12:03 dilfridge Exp $ |
32 |
|
33 |
: ${COLLECTD_PIDFILE:='/var/run/collectd/collectd.pid'} |
34 |
: ${COLLECTD_CFGFILE:='/etc/collectd.conf'} |
35 |
: ${COLLECTD_NICELVL:='5'} |
36 |
: ${COLLECTD_USER:='collectd'} |
37 |
|
38 |
-opts="${opts} configtest" |
39 |
+extra_commands="configtest" |
40 |
|
41 |
depend() { |
42 |
use net |
43 |
@@ -58,4 +58,3 @@ |
44 |
--pidfile "${COLLECTD_PIDFILE}" |
45 |
eend $? "Failed to stop collectd" |
46 |
} |
47 |
- |
48 |
|
49 |
|
50 |
|
51 |
1.1 app-admin/collectd/files/collectd-5.0.2-irq.patch |
52 |
|
53 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/collectd/files/collectd-5.0.2-irq.patch?rev=1.1&view=markup |
54 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/collectd/files/collectd-5.0.2-irq.patch?rev=1.1&content-type=text/plain |
55 |
|
56 |
Index: collectd-5.0.2-irq.patch |
57 |
=================================================================== |
58 |
From c72720c41bb2577b1b9db9e12b299869708491c7 Mon Sep 17 00:00:00 2001 |
59 |
From: Bostjan Skufca <bostjan@×××.si> |
60 |
Date: Fri, 3 Feb 2012 03:10:08 +0100 |
61 |
Subject: [PATCH] Changes in irq plugin: |
62 |
- fixes errors described here: http://mailman.verplant.org/pipermail/collectd/2011-July/004638.html |
63 |
- refactored parsing code in order to make it a bit more intuitive |
64 |
- added a few additional comments |
65 |
|
66 |
--- |
67 |
src/irq.c | 24 +++++++++++++++++++++--- |
68 |
1 files changed, 21 insertions(+), 3 deletions(-) |
69 |
|
70 |
diff --git a/src/irq.c b/src/irq.c |
71 |
index 96bf7f0..f3d5730 100644 |
72 |
--- a/src/irq.c |
73 |
+++ b/src/irq.c |
74 |
@@ -94,6 +94,8 @@ static int irq_read (void) |
75 |
{ |
76 |
FILE *fh; |
77 |
char buffer[1024]; |
78 |
+ int cpu_count; |
79 |
+ char *fields[64]; |
80 |
|
81 |
fh = fopen ("/proc/interrupts", "r"); |
82 |
if (fh == NULL) |
83 |
@@ -104,20 +106,36 @@ static int irq_read (void) |
84 |
return (-1); |
85 |
} |
86 |
|
87 |
+ /* Get CPU count from the first line */ |
88 |
+ if(fgets (buffer, sizeof (buffer), fh) != NULL) { |
89 |
+ cpu_count = strsplit (buffer, fields, 64); |
90 |
+ } else { |
91 |
+ ERROR ("irq plugin: unable to get CPU count from first line of /proc/interrupts"); |
92 |
+ return (-1); |
93 |
+ } |
94 |
+ |
95 |
while (fgets (buffer, sizeof (buffer), fh) != NULL) |
96 |
{ |
97 |
char *irq_name; |
98 |
size_t irq_name_len; |
99 |
derive_t irq_value; |
100 |
int i; |
101 |
- |
102 |
- char *fields[64]; |
103 |
int fields_num; |
104 |
+ int irq_values_to_parse; |
105 |
|
106 |
fields_num = strsplit (buffer, fields, 64); |
107 |
if (fields_num < 2) |
108 |
continue; |
109 |
|
110 |
+ /* Parse this many numeric fields, skip the rest |
111 |
+ * (+1 because first there is a name of irq in each line) */ |
112 |
+ if (fields_num >= cpu_count+1) { |
113 |
+ irq_values_to_parse = cpu_count; |
114 |
+ } else { |
115 |
+ irq_values_to_parse = fields_num - 1; |
116 |
+ } |
117 |
+ |
118 |
+ /* First field is irq name */ |
119 |
irq_name = fields[0]; |
120 |
irq_name_len = strlen (irq_name); |
121 |
if (irq_name_len < 2) |
122 |
@@ -132,7 +150,7 @@ static int irq_read (void) |
123 |
irq_name_len--; |
124 |
|
125 |
irq_value = 0; |
126 |
- for (i = 1; i < fields_num; i++) |
127 |
+ for (i = 1; i <= irq_values_to_parse; i++) |
128 |
{ |
129 |
/* Per-CPU value */ |
130 |
value_t v; |
131 |
-- |
132 |
1.7.3.4 |