21 |
|
# You'd be silly not to use this ;) |
22 |
|
use strict; |
23 |
|
|
24 |
< |
# Path's |
24 |
> |
# Paths |
25 |
|
my($topbin) = "/usr/local/sbin/top"; |
26 |
|
my($dfbin) = "/usr/bin/df"; |
27 |
|
my($usersbin) = "/usr/ucb/users"; |
113 |
|
chop $users; |
114 |
|
my($users_count) = 0; |
115 |
|
$users_count++ while $users =~ /\w+/g; |
116 |
< |
my($users_list) = $users; |
116 |
> |
my($users_list) = $users." "; |
117 |
|
|
118 |
|
&print_pair(1, "packet.users.count", $users_count); |
119 |
|
&print_pair(0, "packet.users.list", $users_list); |
131 |
|
|
132 |
|
&print_pair(1, "packet.load.load1", $top =~ /load averages:\s*([^\s]+?),/); |
133 |
|
&print_pair(1, "packet.load.load5", $top =~ /load averages:\s*.+?,\s*([^\s]+?),/); |
134 |
< |
&print_pair(1, "packet.load.load15", $top =~ /load averages:\s*.+?,\s*.+?,\s*([^\s]+?)\s*/); |
134 |
> |
&print_pair(1, "packet.load.load15", $top =~ /load averages:\s*.+?,\s*.+?,\s*([^\s]+?)\s.*/); |
135 |
|
&print_pair(1, "packet.processes.total", $top =~ /([^\s]+?) processes:/); |
136 |
|
&print_pair(1, "packet.processes.sleeping", $top =~ / ([^\s]+?) sleeping/); |
137 |
|
&print_pair(1, "packet.processes.zombie", $top =~ / ([^\s]+?) zombie/); |
193 |
|
# sub to get system uptime. |
194 |
|
sub include_uptime() { |
195 |
|
|
196 |
< |
# Need a regexp guru to strip the junk on this line |
196 |
> |
# grab the uptime |
197 |
|
my($uptime) = `$uptimebin`; |
198 |
+ |
|
199 |
+ |
# work out the days, hours, and minutes |
200 |
+ |
if ($uptime =~ /hr/) { |
201 |
+ |
# 0 minutes |
202 |
+ |
$uptime =~ /up ([0-9]+) .*, ([0-9]+) .*,/; |
203 |
+ |
$uptime = "$1:$2:0"; |
204 |
+ |
} |
205 |
+ |
elsif ($uptime =~ /min/) { |
206 |
+ |
# 0 hours |
207 |
+ |
$uptime =~ /up ([0-9]+) .*, ([0-9]+) .*,/; |
208 |
+ |
$uptime = "$1:0:$2"; |
209 |
+ |
} |
210 |
+ |
elsif ($uptime =~ /day/) { |
211 |
+ |
# normal |
212 |
+ |
$uptime =~ /up ([0-9]+) .*, ([0-9]+):([0-9]+)/; |
213 |
+ |
$uptime = "$1:$2:$3"; |
214 |
+ |
} |
215 |
+ |
else { |
216 |
+ |
# 0 days |
217 |
+ |
$uptime =~ /up ([0-9]+):([0-9]+)/; |
218 |
+ |
$uptime = "0:$1:$2"; |
219 |
+ |
} |
220 |
+ |
|
221 |
+ |
# turn into minutes |
222 |
+ |
|
223 |
+ |
$uptime =~ /([0-9]+):([0-9]+):([0-9]+)/; |
224 |
+ |
$uptime = $3 + ($2 + $1*24)*60; |
225 |
|
|
226 |
|
&print_pair(0, "packet.os.uptime", $uptime); |
227 |
|
|
228 |
< |
} |
228 |
> |
} |