150 |
|
my($top) = join(" ", @top); |
151 |
|
$top =~ s/\n//g; |
152 |
|
|
153 |
< |
&print_pair(0, "packet.processes.total", $top =~ /([^\s]+?) processes:/); |
154 |
< |
&print_pair(0, "packet.processes.sleeping", $top =~ / ([^\s]+?) sleeping/); |
155 |
< |
&print_pair(0, "packet.processes.zombie", $top =~ / ([^\s]+?) zombie/); |
156 |
< |
&print_pair(0, "packet.processes.stopped", $top =~ / ([^\s]+?) stopped/); |
157 |
< |
&print_pair(0, "packet.processes.cpu", $top =~ /([^\s]+?)\s*on cpu/); |
158 |
< |
&print_pair(0, "packet.cpu.idle", $top =~ /([^\s]+?)% idle/); |
159 |
< |
&print_pair(0, "packet.cpu.user", $top =~ /([^\s]+?)% user/); |
160 |
< |
&print_pair(0, "packet.cpu.kernel", $top =~ /([^\s]+?)% kernel/); |
161 |
< |
&print_pair(0, "packet.cpu.iowait", $top =~ /([^\s]+?)% iowait/); |
162 |
< |
&print_pair(0, "packet.cpu.swap", $top =~ /([^\s]+?)% swap/); |
163 |
< |
|
164 |
< |
# The following need to be specified in megabytes. |
165 |
< |
# If they are preceeded by a G, then multiply by 1024. |
166 |
< |
|
167 |
< |
$top =~ /([^\s]+?)([MG]) real/; |
168 |
< |
my($real) = $1; |
169 |
< |
$real*=1024 if $2 eq "G"; |
170 |
< |
&print_pair(0, "packet.memory.total", $real); |
171 |
< |
|
172 |
< |
$top =~ /([^\s]+?)([MG]) free/; |
173 |
< |
my($free) = $1; |
174 |
< |
$free*=1024 if $2 eq "G"; |
175 |
< |
&print_pair(0, "packet.memory.free", $free); |
176 |
< |
|
177 |
< |
$top =~ /([^\s]+?)([MG]) swap in use/; |
178 |
< |
my($swap_in_use) = $1; |
179 |
< |
$swap_in_use*=1024 if $2 eq "G"; |
180 |
< |
# DO NOT print this one out... save it for in a moment... |
181 |
< |
|
182 |
< |
$top =~ /([^\s]+?)([MG]) swap free/; |
183 |
< |
my($swap_free) = $1; |
184 |
< |
$swap_free*=1024 if $2 eq "G"; |
185 |
< |
&print_pair(0, "packet.swap.free", $swap_free); |
186 |
< |
|
187 |
< |
# AJ requested total swap instead of swap_in_use, so here we go! |
188 |
< |
&print_pair(0, "packet.swap.total", $swap_free + $swap_in_use); |
153 |
> |
if($ostype eq "SunOS") { |
154 |
> |
&print_pair(0, "packet.processes.total", $top =~ /([^\s]+?) processes:/); |
155 |
> |
&print_pair(0, "packet.processes.sleeping", $top =~ / ([^\s]+?) sleeping/); |
156 |
> |
&print_pair(0, "packet.processes.zombie", $top =~ / ([^\s]+?) zombie/); |
157 |
> |
&print_pair(0, "packet.processes.stopped", $top =~ / ([^\s]+?) stopped/); |
158 |
> |
&print_pair(0, "packet.processes.cpu", $top =~ /([^\s]+?)\s*on cpu/); |
159 |
> |
&print_pair(0, "packet.cpu.idle", $top =~ /([^\s]+?)% idle/); |
160 |
> |
&print_pair(0, "packet.cpu.user", $top =~ /([^\s]+?)% user/); |
161 |
> |
&print_pair(0, "packet.cpu.kernel", $top =~ /([^\s]+?)% kernel/); |
162 |
> |
&print_pair(0, "packet.cpu.iowait", $top =~ /([^\s]+?)% iowait/); |
163 |
> |
&print_pair(0, "packet.cpu.swap", $top =~ /([^\s]+?)% swap/); |
164 |
> |
|
165 |
> |
# The following need to be specified in megabytes. |
166 |
> |
# If they are preceeded by a G, then multiply by 1024. |
167 |
> |
|
168 |
> |
$top =~ /([^\s]+?)([MG]) real/; |
169 |
> |
my($real) = $1; |
170 |
> |
$real*=1024 if $2 eq "G"; |
171 |
> |
&print_pair(0, "packet.memory.total", $real); |
172 |
> |
|
173 |
> |
$top =~ /([^\s]+?)([MG]) free/; |
174 |
> |
my($free) = $1; |
175 |
> |
$free*=1024 if $2 eq "G"; |
176 |
> |
&print_pair(0, "packet.memory.free", $free); |
177 |
> |
|
178 |
> |
$top =~ /([^\s]+?)([MG]) swap in use/; |
179 |
> |
my($swap_in_use) = $1; |
180 |
> |
$swap_in_use*=1024 if $2 eq "G"; |
181 |
> |
# DO NOT print this one out... save it for in a moment... |
182 |
> |
|
183 |
> |
$top =~ /([^\s]+?)([MG]) swap free/; |
184 |
> |
my($swap_free) = $1; |
185 |
> |
$swap_free*=1024 if $2 eq "G"; |
186 |
> |
&print_pair(0, "packet.swap.free", $swap_free); |
187 |
> |
|
188 |
> |
# AJ requested total swap instead of swap_in_use, so here we go! |
189 |
> |
&print_pair(0, "packet.swap.total", $swap_free + $swap_in_use); |
190 |
> |
} |
191 |
> |
elsif ($ostype eq "FreeBSD") { |
192 |
> |
&print_pair(0, "packet.processes.total", $top =~ /([^\s]+?) processes:/); |
193 |
> |
&print_pair(0, "packet.processes.sleeping", $top =~ / ([^\s]+?) sleeping/); |
194 |
> |
&print_pair(0, "packet.processes.zombie", $top =~ / ([^\s]+?) zombie/); |
195 |
> |
&print_pair(0, "packet.processes.stopped", $top =~ / ([^\s]+?) stopped/); |
196 |
> |
&print_pair(0, "packet.processes.cpu", $top =~ /([^\s]+?)\s*running/); |
197 |
> |
&print_pair(0, "packet.cpu.idle", $top =~ /([^\s]+?)% idle/); |
198 |
> |
&print_pair(0, "packet.cpu.user", $top =~ /([^\s]+?)% user/); |
199 |
> |
&print_pair(0, "packet.cpu.kernel", $top =~ /([^\s]+?)% system/); |
200 |
> |
&print_pair(0, "packet.cpu.iowait", $top =~ /([^\s]+?)% interrupt/); |
201 |
> |
&print_pair(0, "packet.cpu.swap", $top =~ /([^\s]+?)% swap/); |
202 |
> |
|
203 |
> |
# The following need to be specified in megabytes. |
204 |
> |
# If they are preceeded by a G, then multiply by 1024. |
205 |
> |
|
206 |
> |
# !! Can't get the total memory !! |
207 |
> |
#$top =~ /([^\s]+?)([MG]) real/; |
208 |
> |
#my($real) = $1; |
209 |
> |
#$real*=1024 if $2 eq "G"; |
210 |
> |
#&print_pair(0, "packet.memory.total", $real); |
211 |
> |
&print_pair(0, "packet.memory.total", 0); |
212 |
> |
|
213 |
> |
$top =~ /([^\s]+?)([MG]) Free/; |
214 |
> |
my($free) = $1; |
215 |
> |
$free*=1024 if $2 eq "G"; |
216 |
> |
&print_pair(0, "packet.memory.free", $free); |
217 |
> |
|
218 |
> |
$top =~ /Swap: ([^\s]+?)([MG]) Total/; |
219 |
> |
my($swap_total) = $1; |
220 |
> |
$swap_total*=1024 if $2 eq "G"; |
221 |
> |
&print_pair(0, "packet.swap.total", $swap_total); |
222 |
> |
|
223 |
> |
$top =~ /Swap:.*, ([^\s]+?)([MG]) Free/; |
224 |
> |
my($swap_free) = $1; |
225 |
> |
$swap_free*=1024 if $2 eq "G"; |
226 |
> |
&print_pair(0, "packet.swap.free", $swap_free); |
227 |
> |
} |
228 |
> |
elsif ($ostype eq "Linux") { |
229 |
> |
&print_pair(0, "packet.processes.total", $top =~ /([^\s]+?) processes:/); |
230 |
> |
&print_pair(0, "packet.processes.sleeping", $top =~ / ([^\s]+?) sleeping/); |
231 |
> |
&print_pair(0, "packet.processes.zombie", $top =~ / ([^\s]+?) zombie/); |
232 |
> |
&print_pair(0, "packet.processes.stopped", $top =~ / ([^\s]+?) stopped/); |
233 |
> |
&print_pair(0, "packet.processes.cpu", $top =~ /([^\s]+?)\s*running/); |
234 |
> |
&print_pair(0, "packet.cpu.idle", $top =~ /([^\s]+?)% idle/); |
235 |
> |
&print_pair(0, "packet.cpu.user", $top =~ /([^\s]+?)% user/); |
236 |
> |
&print_pair(0, "packet.cpu.kernel", $top =~ /([^\s]+?)% system/); |
237 |
> |
&print_pair(0, "packet.cpu.iowait", $top =~ /([^\s]+?)% interrupt/); |
238 |
> |
&print_pair(0, "packet.cpu.swap", $top =~ /([^\s]+?)% swap/); |
239 |
> |
|
240 |
> |
# The following need to be specified in megabytes. |
241 |
> |
# If they are preceeded by a G, then multiply by 1024. |
242 |
> |
|
243 |
> |
$top =~ / ([^\s]+?)([KMG]) av/; |
244 |
> |
my($real) = $1; |
245 |
> |
$real*=1024 if $2 eq "G"; |
246 |
> |
$real/=1024 if $2 eq "K"; |
247 |
> |
&print_pair(0, "packet.memory.total", int($real)); |
248 |
> |
|
249 |
> |
$top =~ / ([^\s]+?)([KMG]) free/; |
250 |
> |
my($free) = $1; |
251 |
> |
$free*=1024 if $2 eq "G"; |
252 |
> |
$free/=1024 if $2 eq "K"; |
253 |
> |
&print_pair(0, "packet.memory.free", int($free)); |
254 |
> |
|
255 |
> |
$top =~ /Swap:\s+([^\s]+?)([KMG]) av/; |
256 |
> |
my($swap_total) = $1; |
257 |
> |
$swap_total*=1024 if $2 eq "G"; |
258 |
> |
$swap_total/=1024 if $2 eq "K"; |
259 |
> |
&print_pair(0, "packet.swap.total", int($swap_total)); |
260 |
> |
|
261 |
> |
$top =~ /Swap:.*, ([^\s]+?)([KMG]) free/; |
262 |
> |
my($swap_free) = $1; |
263 |
> |
$swap_free*=1024 if $2 eq "G"; |
264 |
> |
$swap_free/=1024 if $2 eq "K"; |
265 |
> |
&print_pair(0, "packet.swap.free", int($swap_free)); |
266 |
> |
} |
267 |
> |
else { |
268 |
> |
# we could have some catchall here |
269 |
> |
# but as it stands this means we'll just skip top stuff |
270 |
> |
# for unknown systems |
271 |
> |
} |
272 |
|
} |
273 |
|
|
274 |
|
# sub to get details of the machine's operating system. |