/[smecontribs]/rpms/zabbix/contribs7/zabbix-1.6.2-cpustats.patch
ViewVC logotype

Contents of /rpms/zabbix/contribs7/zabbix-1.6.2-cpustats.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Mon Apr 6 15:08:55 2009 UTC (15 years, 7 months ago) by vip-ire
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
upstream upgrade to 1.6.4

1 diff --git a/src/libs/zbxsysinfo/linux/cpu.c b/src/libs/zbxsysinfo/linux/cpu.c
2 index 67dd157..cdf4952 100644
3 --- a/src/libs/zbxsysinfo/linux/cpu.c
4 +++ b/src/libs/zbxsysinfo/linux/cpu.c
5 @@ -125,6 +125,36 @@ int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RE
6 else if (ZBX_AVG5 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].system5)
7 else if (ZBX_AVG15 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].system15)
8 }
9 + else if( 0 == strcmp(type,"interrupt"))
10 + {
11 + if (ZBX_AVG1 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].interrupt1)
12 + else if (ZBX_AVG5 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].interrupt5)
13 + else if (ZBX_AVG15 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].interrupt15)
14 + }
15 + else if( 0 == strcmp(type,"wait"))
16 + {
17 + if(ZBX_AVG1 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].iowait1)
18 + else if(ZBX_AVG5 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].iowait5)
19 + else if(ZBX_AVG15 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].iowait15)
20 + }
21 + else if( 0 == strcmp(type,"irq"))
22 + {
23 + if(ZBX_AVG1 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].irq1)
24 + else if(ZBX_AVG5 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].irq5)
25 + else if(ZBX_AVG15 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].irq15)
26 + }
27 + else if( 0 == strcmp(type,"softirq"))
28 + {
29 + if(ZBX_AVG1 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].softirq1)
30 + else if(ZBX_AVG5 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].softirq5)
31 + else if(ZBX_AVG5 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].softirq15)
32 + }
33 + else if( 0 == strcmp(type,"steal"))
34 + {
35 + if(ZBX_AVG1 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].steal1)
36 + else if(ZBX_AVG1 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].steal5)
37 + else if(ZBX_AVG1 == mode) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].steal15)
38 + }
39 else
40 return SYSINFO_RET_FAIL;
41
42 diff --git a/src/zabbix_agent/cpustat.c b/src/zabbix_agent/cpustat.c
43 index 2dd2103..cccf1d2 100644
44 --- a/src/zabbix_agent/cpustat.c
45 +++ b/src/zabbix_agent/cpustat.c
46 @@ -184,7 +184,10 @@ static int get_cpustat(
47 zbx_uint64_t *cpu_nice,
48 zbx_uint64_t *cpu_idle,
49 zbx_uint64_t *cpu_interrupt,
50 - zbx_uint64_t *cpu_iowait
51 + zbx_uint64_t *cpu_iowait,
52 + zbx_uint64_t *cpu_irq,
53 + zbx_uint64_t *cpu_softirq,
54 + zbx_uint64_t *cpu_steal
55 )
56 {
57 #if defined(HAVE_PROC_STAT)
58 @@ -235,6 +238,9 @@ static int get_cpustat(
59 *cpu_user = *cpu_system = *cpu_nice = *cpu_idle = -1;
60 *cpu_interrupt = 0;
61 *cpu_iowait = 0;
62 + *cpu_irq = 0;
63 + *cpu_softirq = 0;
64 + *cpu_steal = 0;
65
66 zbx_snprintf(cpu_name, sizeof(cpu_name), "cpu%c ", cpuid > 0 ? '0' + (cpuid - 1) : ' ');
67
68 @@ -242,7 +248,8 @@ static int get_cpustat(
69 {
70 if(strstr(line, cpu_name) == NULL) continue;
71
72 - sscanf(line, "%*s " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64, cpu_user, cpu_nice, cpu_system, cpu_idle);
73 + sscanf(line, "%*s " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64,
74 + cpu_user, cpu_nice, cpu_system, cpu_idle, cpu_iowait, cpu_irq, cpu_softirq, cpu_steal);
75 break;
76 }
77 zbx_fclose(file);
78 @@ -389,7 +396,10 @@ static void apply_cpustat(
79 zbx_uint64_t cpu_nice,
80 zbx_uint64_t cpu_idle,
81 zbx_uint64_t cpu_interrupt,
82 - zbx_uint64_t cpu_iowait
83 + zbx_uint64_t cpu_iowait,
84 + zbx_uint64_t cpu_irq,
85 + zbx_uint64_t cpu_softirq,
86 + zbx_uint64_t cpu_steal
87 )
88 {
89 register int i = 0;
90 @@ -401,6 +411,9 @@ static void apply_cpustat(
91 idle = 0, idle1 = 0, idle5 = 0, idle15 = 0,
92 interrupt = 0, interrupt1 = 0, interrupt5 = 0, interrupt15 = 0,
93 iowait = 0, iowait1 = 0, iowait5 = 0, iowait15 = 0,
94 + irq = 0, irq1 = 0, irq5 = 0, irq15 = 0,
95 + softirq = 0, softirq1 = 0, softirq5 = 0, softirq15 = 0,
96 + steal = 0, steal1 = 0, steal5 = 0, steal15 = 0,
97 all = 0, all1 = 0, all5 = 0, all15 = 0;
98
99 ZBX_SINGLE_CPU_STAT_DATA
100 @@ -418,8 +431,11 @@ static void apply_cpustat(
101 curr_cpu->h_idle[i] = idle = cpu_idle;
102 curr_cpu->h_interrupt[i] = interrupt = cpu_interrupt;
103 curr_cpu->h_iowait[i] = iowait = cpu_iowait;
104 + curr_cpu->h_irq[i] = irq = cpu_irq;
105 + curr_cpu->h_softirq[i] = softirq = cpu_softirq;
106 + curr_cpu->h_steal[i] = steal = cpu_steal;
107
108 - all = cpu_user + cpu_system + cpu_nice + cpu_idle + cpu_interrupt + cpu_iowait;
109 + all = cpu_user + cpu_system + cpu_nice + cpu_idle + cpu_interrupt + cpu_iowait + cpu_irq + cpu_softirq + cpu_steal;
110 break;
111 }
112
113 @@ -440,8 +456,11 @@ static void apply_cpustat(
114 idle ## t = curr_cpu->h_idle[i]; \
115 interrupt ## t = curr_cpu->h_interrupt[i]; \
116 iowait ## t = curr_cpu->h_iowait[i]; \
117 + irq ## t = curr_cpu->h_irq[i]; \
118 + softirq ## t = curr_cpu->h_softirq[i]; \
119 + steal ## t = curr_cpu->h_steal[i]; \
120 all ## t = user ## t + system ## t + nice ## t + idle ## t + \
121 - interrupt ## t + iowait ## t; \
122 + interrupt ## t + iowait ## t + irq ## t + softirq ## t + steal ## t; \
123 }
124
125 SAVE_CPU_CLOCK_FOR(1);
126 @@ -483,6 +502,18 @@ static void apply_cpustat(
127 CALC_CPU_LOAD(iowait, 1);
128 CALC_CPU_LOAD(iowait, 5);
129 CALC_CPU_LOAD(iowait, 15);
130 +
131 + CALC_CPU_LOAD(irq, 1);
132 + CALC_CPU_LOAD(irq, 5);
133 + CALC_CPU_LOAD(irq, 15);
134 +
135 + CALC_CPU_LOAD(softirq, 1);
136 + CALC_CPU_LOAD(softirq, 5);
137 + CALC_CPU_LOAD(softirq, 15);
138 +
139 + CALC_CPU_LOAD(steal, 1);
140 + CALC_CPU_LOAD(steal, 5);
141 + CALC_CPU_LOAD(steal, 15);
142 }
143
144 #endif /* not _WINDOWS */
145 @@ -602,14 +633,14 @@ void collect_cpustat(ZBX_CPUS_STAT_DATA *pcpus)
146 register int i = 0;
147 int now = 0;
148
149 - zbx_uint64_t cpu_user, cpu_nice, cpu_system, cpu_idle, cpu_interrupt, cpu_iowait;
150 + zbx_uint64_t cpu_user, cpu_nice, cpu_system, cpu_idle, cpu_interrupt, cpu_iowait, cpu_irq, cpu_softirq, cpu_steal;
151
152 for ( i = 0; i <= pcpus->count; i++ )
153 {
154 - if(0 != get_cpustat(i, &now, &cpu_user, &cpu_system, &cpu_nice, &cpu_idle, &cpu_interrupt, &cpu_iowait))
155 + if(0 != get_cpustat(i, &now, &cpu_user, &cpu_system, &cpu_nice, &cpu_idle, &cpu_interrupt, &cpu_iowait, &cpu_irq, &cpu_softirq, &cpu_steal))
156 continue;
157
158 - apply_cpustat(pcpus, i, now, cpu_user, cpu_system, cpu_nice, cpu_idle, cpu_interrupt, cpu_iowait);
159 + apply_cpustat(pcpus, i, now, cpu_user, cpu_system, cpu_nice, cpu_idle, cpu_interrupt, cpu_iowait, cpu_irq, cpu_softirq, cpu_steal);
160 }
161
162 #endif /* _WINDOWS */
163 diff --git a/src/zabbix_agent/cpustat.h b/src/zabbix_agent/cpustat.h
164 index 9551707..412e0d3 100644
165 --- a/src/zabbix_agent/cpustat.h
166 +++ b/src/zabbix_agent/cpustat.h
167 @@ -72,6 +72,9 @@
168 zbx_uint64_t h_idle[MAX_CPU_HISTORY];
169 zbx_uint64_t h_interrupt[MAX_CPU_HISTORY];
170 zbx_uint64_t h_iowait[MAX_CPU_HISTORY];
171 + zbx_uint64_t h_irq[MAX_CPU_HISTORY];
172 + zbx_uint64_t h_softirq[MAX_CPU_HISTORY];
173 + zbx_uint64_t h_steal[MAX_CPU_HISTORY];
174
175 /* public */
176 double user1;
177 @@ -92,6 +95,15 @@
178 double iowait1;
179 double iowait5;
180 double iowait15;
181 + double irq1;
182 + double irq5;
183 + double irq15;
184 + double softirq1;
185 + double softirq5;
186 + double softirq15;
187 + double steal1;
188 + double steal5;
189 + double steal15;
190
191 } ZBX_SINGLE_CPU_STAT_DATA;
192

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed