21 |
|
# You'd be silly not to use this ;) |
22 |
|
use strict; |
23 |
|
|
24 |
+ |
# Path's |
25 |
+ |
my($topbin) = "/usr/local/sbin/top"; |
26 |
+ |
my($dfbin) = "/usr/bin/df"; |
27 |
+ |
my($usersbin) = "/usr/ucb/users"; |
28 |
+ |
my($unamebin) = "/usr/bin/uname"; |
29 |
+ |
|
30 |
|
# Run the following components: - |
31 |
|
&print_ident(); |
32 |
|
&include_osver(); |
80 |
|
sub include_disk() { |
81 |
|
|
82 |
|
# Run the df program. |
83 |
< |
my(@df) = `df -ak`; |
83 |
> |
my(@df) = `$dfbin -ak`; |
84 |
|
|
85 |
|
# Go through each line of the program, looking for each thing we want. |
86 |
|
my($partition_no) = 0; |
106 |
|
sub include_users() { |
107 |
|
|
108 |
|
# Find out all users on this machine. |
109 |
< |
my($users) = `users`; |
110 |
< |
my(@users) = split(/\s+/, $users); |
111 |
< |
|
112 |
< |
my($users_count) = $#users + 1; |
109 |
> |
my($users) = `$usersbin`; |
110 |
> |
chop($users); |
111 |
> |
$users = "" unless defined $users; |
112 |
> |
my($users_count) = 0; |
113 |
> |
$users_count++ while $users =~ /\w+/g; |
114 |
|
my($users_list) = $users; |
115 |
|
|
116 |
|
&print_pair(1, "packet.users.count", $users_count); |
123 |
|
sub include_top() { |
124 |
|
|
125 |
|
# Find out some numbers from top. |
126 |
< |
my(@top) = `top -d2 -s1 0`; |
126 |
> |
my(@top) = `$topbin -d2 -s1 0`; |
127 |
|
my($top) = join(" ", @top); |
128 |
|
$top =~ s/\n//g; |
129 |
|
|
145 |
|
# If they are preceeded by a G, then multiply by 1024. |
146 |
|
|
147 |
|
$top =~ /([^\s]+?)([MG]) real/; |
148 |
< |
my($real) = $1*1024 if $2 eq "G"; |
148 |
> |
my($real) = $1; |
149 |
> |
$real*=1024 if $2 eq "G"; |
150 |
|
&print_pair(1, "packet.memory.real", $real); |
151 |
|
|
152 |
|
$top =~ /([^\s]+?)([MG]) free/; |
153 |
< |
my($free) = $1*1024 if $2 eq "G"; |
153 |
> |
my($free) = $1; |
154 |
> |
$free*=1024 if $2 eq "G"; |
155 |
|
&print_pair(1, "packet.memory.free", $free); |
156 |
|
|
157 |
|
$top =~ /([^\s]+?)([MG]) swap in use/; |
158 |
< |
my($swap_in_use) = $1*1024 if $2 eq "G"; |
159 |
< |
&print_pair(1, "packet.memory.swap_in_use", $swap_in_use); |
158 |
> |
my($swap_in_use) = $1; |
159 |
> |
$swap_in_use*=1024 if $2 eq "G"; |
160 |
> |
# DO NOT print this one out... save it for in a moment... |
161 |
|
|
162 |
|
$top =~ /([^\s]+?)([MG]) swap free/; |
163 |
< |
my($swap_free) = $1*1024 if $2 eq "G"; |
163 |
> |
my($swap_free) = $1; |
164 |
> |
$swap_free*=1024 if $2 eq "G"; |
165 |
|
&print_pair(1, "packet.memory.swap_free", $swap_free); |
166 |
+ |
|
167 |
+ |
# AJ requested total swap instead of swap_in_use, so here we go! |
168 |
+ |
&print_pair(1, "packet.memory.swap_total", $swap_free + $swap_in_use); |
169 |
|
} |
170 |
|
|
171 |
|
# sub to get details of the machine's operating system. |
174 |
|
# Find out details about the operating system |
175 |
|
# If these values remain undefined, then the print_pair |
176 |
|
# function shall show the value to be the string "unknown". |
177 |
< |
my($os_name) = `uname -s`; |
178 |
< |
my($os_release) = `uname -r`; |
179 |
< |
my($os_platform) = `uname -m`; |
180 |
< |
my($os_sysname) = `uname -n`; |
181 |
< |
my($os_version) = `uname -v`; |
177 |
> |
my($os_name) = `$unamebin -s`; |
178 |
> |
my($os_release) = `$unamebin -r`; |
179 |
> |
my($os_platform) = `$unamebin -m`; |
180 |
> |
my($os_sysname) = `$unamebin -n`; |
181 |
> |
my($os_version) = `$unamebin -v`; |
182 |
|
|
183 |
|
&print_pair(0, "packet.os.name", $os_name); |
184 |
|
&print_pair(0, "packet.os.release", $os_release); |