ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/generic/statgrab.pl
(Generate patch)

Comparing projects/cms/source/host/generic/statgrab.pl (file contents):
Revision 1.25 by pjm2, Mon Feb 5 17:05:22 2001 UTC vs.
Revision 1.28 by tdb, Mon Feb 5 17:43:45 2001 UTC

# Line 144 | Line 144 | sub include_top() {
144      $top =~ /([^\s]+?)([MG]) real/;
145      my($real) = $1;
146      $real*=1024 if $2 eq "G";
147 <    &print_pair(0, "packet.memory.real", $real);
147 >    &print_pair(0, "packet.memory.total", $real);
148  
149      $top =~ /([^\s]+?)([MG]) free/;
150      my($free) = $1;
# Line 159 | Line 159 | sub include_top() {
159      $top =~ /([^\s]+?)([MG]) swap free/;
160      my($swap_free) = $1;
161      $swap_free*=1024 if $2 eq "G";
162 <    &print_pair(0, "packet.memory.swap_free", $swap_free);
162 >    &print_pair(0, "packet.swap.free", $swap_free);
163  
164      # AJ requested total swap instead of swap_in_use, so here we go!
165 <    &print_pair(0, "packet.memory.swap_total", $swap_free + $swap_in_use);
165 >    &print_pair(0, "packet.swap.total", $swap_free + $swap_in_use);
166   }
167  
168   # sub to get details of the machine's operating system.
# Line 185 | Line 185 | sub include_osver() {
185  
186   }
187  
188 < # sub to get system uptime.
188 > # sub to get system uptime in seconds.
189   sub include_uptime() {
190  
191 +    # debug stuff, all the different cases
192 +
193 +    # normal
194 +    #my($uptime) = "  4:48pm  up 49 day(s),  6:30,  201 users,  load average: 0.33, 0.35, 0.38\n";
195 +    # 0 days
196 +    #my($uptime) = "  4:48pm  up 6:30,  201 users,  load average: 0.33, 0.35, 0.38\n";
197 +    # 0 hours
198 +    #my($uptime) = "  4:48pm  up 49 day(s),  30 min(s),  201 users,  load average: 0.33, 0.35, 0.38\n";
199 +    # 0 mins
200 +    #my($uptime) = "  4:48pm  up 49 day(s),  6 hr(s),  201 users,  load average: 0.33, 0.35, 0.38\n";
201 +    # 0 days and 0 mins
202 +    #my($uptime) = "  4:48pm  up 6 hr(s),  201 users,  load average: 0.33, 0.35, 0.38\n";
203 +    # 0 days and 0 hours
204 +    #my($uptime) = "  4:48pm  up 30 min(s),  201 users,  load average: 0.33, 0.35, 0.38\n";
205 +    # 0 hours and 0 mins
206 +    #my($uptime) = "  4:48pm  up 49 day(s), 201 users,  load average: 0.33, 0.35, 0.38\n";
207 +
208      # grab the uptime
209      my($uptime) = `$uptimebin`;
210  
211      # work out the days, hours, and minutes
212 <    if ($uptime =~ /hr/) {
213 <      # 0 minutes
197 <        $uptime =~ s/up ([0-9]+) .*, ([0-9]+) .*,/$1:$2:0/;
198 <    }
199 <    elsif ($uptime =~ /min/) {
200 <      # 0 hours
201 <        $uptime =~ s/up ([0-9]+) .*, ([0-9]+) .*,/$1:0:$2/;
202 <    }
203 <    elsif ($uptime =~ /day/) {
212 >
213 >    if ($uptime =~ /day.*,\s+([0-9]+):([0-9]+)/) {
214        # normal
215 <        $uptime =~ s/up ([0-9]+) .*, ([0-9]+):([0-9]+)/$1:$2:$3/;
215 >        $uptime =~ /up\s+([0-9]+)\s+.*,\s+([0-9]+):([0-9]+)/;
216 >        $uptime = "$1:$2:$3";
217      }
218      else {
219 <      # 0 days
220 <        $uptime =~ s/up ([0-9]+):([0-9]+)/0:$1:$2/;
219 >        if ($uptime =~ /day/) {
220 >            if ($uptime =~ /hr/) {
221 >              # 0 minutes
222 >                $uptime =~ /up\s+([0-9]+)\s+.*,\s+([0-9]+)\s+.*,/;
223 >                $uptime = "$1:$2:0";
224 >            }
225 >            elsif ($uptime =~ /min/) {
226 >              # 0 hours
227 >                $uptime =~ /up\s+([0-9]+)\s+.*,\s+([0-9]+)\s+.*,/;
228 >                $uptime = "$1:0:$2";
229 >            }
230 >            else {
231 >              # 0 hours and 0 mins
232 >                $uptime =~ /up\s+([0-9]+)/;
233 >                $uptime = "$1:0:0";
234 >            }
235 >        }
236 >        elsif ($uptime =~ /hr/) {
237 >          # 0 days and 0 minutes
238 >            $uptime =~ /up\s+([0-9]+)\s+/;
239 >            $uptime = "0:$1:0";
240 >        }
241 >        elsif ($uptime =~ /min/) {
242 >          # 0 days and 0 hours
243 >            $uptime =~ /up\s+([0-9]+)\s+/;
244 >            $uptime = "0:0:$1";
245 >        }
246 >        else {
247 >          # 0 days
248 >            $uptime =~ /up\s+([0-9]+):([0-9]+)/;
249 >            $uptime = "0:$1:$2";
250 >        }
251      }
252  
253 <    # turn into minutes
213 <
253 >    # turn into seconds
254      $uptime =~ /([0-9]+):([0-9]+):([0-9]+)/;
255 <    $uptime = $3 + ($2 + $1*24)*60;
256 <
255 >    $uptime = ($3+($2+($1*24))*60)*60;
256 >    
257 >    # print the value out
258      &print_pair("unknown", "packet.os.uptime", $uptime);
259  
260   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines