109 |
|
my($partition_no) = 0; |
110 |
|
for (my($i) = 0; $i < $#df; $i++) { |
111 |
|
my($line) = $df[$i]; |
112 |
< |
$line =~ /^(\/[^\s]*)\s*([0-9]*)\s*([0-9]*)\s*([0-9]*)\s*[^\s]*\s*(\/[^\s]*)\s*/; |
112 |
> |
$line =~ /^([^\s]*)\s*([0-9]*)\s*([0-9]*)\s*([0-9]*)\s*[^\s]*\s*(\/[^\s]*)\s*/; |
113 |
|
# $4 will not match unless everything before it does... |
114 |
|
if (defined $5) { |
115 |
|
my ($filesystem, $kbytes, $used, $avail, $mount) = ($1, $2, $3, $4, $5); |
168 |
|
$top =~ /([^\s]+?)([MG]) real/; |
169 |
|
my($real) = $1; |
170 |
|
$real*=1024 if $2 eq "G"; |
171 |
+ |
$real/=1024 if $2 eq "K"; |
172 |
|
&print_pair(0, "packet.memory.total", $real); |
173 |
|
|
174 |
|
$top =~ /([^\s]+?)([MG]) free/; |
175 |
|
my($free) = $1; |
176 |
|
$free*=1024 if $2 eq "G"; |
177 |
+ |
$free/=1024 if $2 eq "K"; |
178 |
|
&print_pair(0, "packet.memory.free", $free); |
179 |
|
|
180 |
|
$top =~ /([^\s]+?)([MG]) swap in use/; |
181 |
|
my($swap_in_use) = $1; |
182 |
|
$swap_in_use*=1024 if $2 eq "G"; |
183 |
+ |
$swap_in_use/=1024 if $2 eq "K"; |
184 |
|
# DO NOT print this one out... save it for in a moment... |
185 |
|
|
186 |
|
$top =~ /([^\s]+?)([MG]) swap free/; |
187 |
|
my($swap_free) = $1; |
188 |
|
$swap_free*=1024 if $2 eq "G"; |
189 |
+ |
$swap_free/=1024 if $2 eq "K"; |
190 |
|
&print_pair(0, "packet.swap.free", $swap_free); |
191 |
|
|
192 |
|
# AJ requested total swap instead of swap_in_use, so here we go! |
199 |
|
&print_pair(0, "packet.processes.stopped", $top =~ / ([^\s]+?) stopped/); |
200 |
|
&print_pair(0, "packet.processes.cpu", $top =~ /([^\s]+?)\s*running/); |
201 |
|
&print_pair(0, "packet.cpu.idle", $top =~ /([^\s]+?)% idle/); |
198 |
– |
&print_pair(0, "packet.cpu.user", $top =~ /([^\s]+?)% user/); |
202 |
|
&print_pair(0, "packet.cpu.kernel", $top =~ /([^\s]+?)% system/); |
203 |
|
&print_pair(0, "packet.cpu.iowait", $top =~ /([^\s]+?)% interrupt/); |
204 |
|
&print_pair(0, "packet.cpu.swap", $top =~ /([^\s]+?)% swap/); |
205 |
+ |
|
206 |
+ |
# FreeBSD is a bit different, we need to get user and nice. |
207 |
+ |
my($user) = 0; |
208 |
+ |
if($top =~ /([^\s]+?)% user/) { $user += $1; } |
209 |
+ |
if($top =~ /([^\s]+?)% nice/) { $user += $1; } |
210 |
+ |
&print_pair(0, "packet.cpu.user", $user); |
211 |
|
|
212 |
|
# The following need to be specified in megabytes. |
213 |
|
# If they are preceeded by a G, then multiply by 1024. |
234 |
|
$swap_free*=1024 if $2 eq "G"; |
235 |
|
&print_pair(0, "packet.swap.free", $swap_free); |
236 |
|
} |
237 |
+ |
elsif ($ostype eq "Linux") { |
238 |
+ |
&print_pair(0, "packet.processes.total", $top =~ /([^\s]+?) processes:/); |
239 |
+ |
&print_pair(0, "packet.processes.sleeping", $top =~ / ([^\s]+?) sleeping/); |
240 |
+ |
&print_pair(0, "packet.processes.zombie", $top =~ / ([^\s]+?) zombie/); |
241 |
+ |
&print_pair(0, "packet.processes.stopped", $top =~ / ([^\s]+?) stopped/); |
242 |
+ |
&print_pair(0, "packet.processes.cpu", $top =~ /([^\s]+?)\s*running/); |
243 |
+ |
&print_pair(0, "packet.cpu.idle", $top =~ /([^\s]+?)% idle/); |
244 |
+ |
&print_pair(0, "packet.cpu.user", $top =~ /([^\s]+?)% user/); |
245 |
+ |
&print_pair(0, "packet.cpu.kernel", $top =~ /([^\s]+?)% system/); |
246 |
+ |
&print_pair(0, "packet.cpu.iowait", $top =~ /([^\s]+?)% interrupt/); |
247 |
+ |
&print_pair(0, "packet.cpu.swap", $top =~ /([^\s]+?)% swap/); |
248 |
+ |
|
249 |
+ |
# The following need to be specified in megabytes. |
250 |
+ |
# If they are preceeded by a G, then multiply by 1024. |
251 |
+ |
|
252 |
+ |
$top =~ / ([^\s]+?)([KMG]) av/; |
253 |
+ |
my($real) = $1; |
254 |
+ |
$real*=1024 if $2 eq "G"; |
255 |
+ |
$real/=1024 if $2 eq "K"; |
256 |
+ |
&print_pair(0, "packet.memory.total", int($real)); |
257 |
+ |
|
258 |
+ |
$top =~ / ([^\s]+?)([KMG]) free/; |
259 |
+ |
my($free) = $1; |
260 |
+ |
$free*=1024 if $2 eq "G"; |
261 |
+ |
$free/=1024 if $2 eq "K"; |
262 |
+ |
&print_pair(0, "packet.memory.free", int($free)); |
263 |
+ |
|
264 |
+ |
$top =~ /Swap:\s+([^\s]+?)([KMG]) av/; |
265 |
+ |
my($swap_total) = $1; |
266 |
+ |
$swap_total*=1024 if $2 eq "G"; |
267 |
+ |
$swap_total/=1024 if $2 eq "K"; |
268 |
+ |
&print_pair(0, "packet.swap.total", int($swap_total)); |
269 |
+ |
|
270 |
+ |
$top =~ /Swap:.*, ([^\s]+?)([KMG]) free/; |
271 |
+ |
my($swap_free) = $1; |
272 |
+ |
$swap_free*=1024 if $2 eq "G"; |
273 |
+ |
$swap_free/=1024 if $2 eq "K"; |
274 |
+ |
&print_pair(0, "packet.swap.free", int($swap_free)); |
275 |
+ |
} |
276 |
|
else { |
277 |
|
# we could have some catchall here |
278 |
+ |
# but as it stands this means we'll just skip top stuff |
279 |
+ |
# for unknown systems |
280 |
|
} |
281 |
|
} |
282 |
|
|
331 |
|
|
332 |
|
if ($uptime =~ /day.*,\s+([0-9]+):([0-9]+)/) { |
333 |
|
# normal |
334 |
< |
$uptime =~ /up\s+([0-9]+)\s+.*,\s+([0-9]+):([0-9]+)/; |
334 |
> |
$uptime =~ /up\s+([0-9]+)\s+[^\s]+,\s+([0-9]+):([0-9]+)/; |
335 |
|
$uptime = "$1:$2:$3"; |
336 |
|
} |
337 |
|
else { |
338 |
|
if ($uptime =~ /day/) { |
339 |
|
if ($uptime =~ /hr/) { |
340 |
|
# 0 minutes |
341 |
< |
$uptime =~ /up\s+([0-9]+)\s+.*,\s+([0-9]+)\s+.*,/; |
341 |
> |
$uptime =~ /up\s+([0-9]+)\s+[^\s]+,\s+([0-9]+)\s+[^\s]+,/; |
342 |
|
$uptime = "$1:$2:0"; |
343 |
|
} |
344 |
|
elsif ($uptime =~ /min/) { |
345 |
|
# 0 hours |
346 |
< |
$uptime =~ /up\s+([0-9]+)\s+.*,\s+([0-9]+)\s+.*,/; |
346 |
> |
$uptime =~ /up\s+([0-9]+)\s+[^\s]+,\s+([0-9]+)\s+[^\s]+,/; |
347 |
|
$uptime = "$1:0:$2"; |
348 |
|
} |
349 |
|
else { |