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.26 by pjm2, Mon Feb 5 17:13:26 2001 UTC vs.
Revision 1.27 by tdb, Mon Feb 5 17:21:04 2001 UTC

# Line 188 | Line 188 | sub include_osver() {
188   # sub to get system uptime.
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
214 <        $uptime =~ s/up ([0-9]+) .*, ([0-9]+) .*,/$1:$2:0/;
213 >      # two possible cases here
214 >        if($uptime =~ /day/) {
215 >          # 0 minutes
216 >            $uptime =~ /up\s+([0-9]+)\s+.*,\s+([0-9]+)\s+.*,/;
217 >            $uptime = "$1:$2:0";
218 >        }
219 >        else {
220 >          # 0 days and 0 minutes
221 >            $uptime =~ /up\s+([0-9]+)\s+/;
222 >            $uptime = "0:$1:0";
223 >        }
224      }
225      elsif ($uptime =~ /min/) {
226 <      # 0 hours
227 <        $uptime =~ s/up ([0-9]+) .*, ([0-9]+) .*,/$1:0:$2/;
226 >      # two possible cases here
227 >        if($uptime =~ /day/) {
228 >          # 0 hours
229 >            $uptime =~ /up\s+([0-9]+)\s+.*,\s+([0-9]+)\s+.*,/;
230 >            $uptime = "$1:0:$2";
231 >        }
232 >        else {
233 >          # 0 days and 0 hours
234 >            $uptime =~ /up\s+([0-9]+)\s+/;
235 >            $uptime = "0:0:$1";
236 >        }
237      }
238      elsif ($uptime =~ /day/) {
239 <      # normal
240 <        $uptime =~ s/up ([0-9]+) .*, ([0-9]+):([0-9]+)/$1:$2:$3/;
239 >        if ($uptime =~ /day.*,\s+([0-9]+):([0-9]+)/) {
240 >          # normal
241 >            $uptime =~ /up\s+([0-9]+)\s+.*,\s+([0-9]+):([0-9]+)/;
242 >            $uptime = "$1:$2:$3";
243 >        }
244 >        else {
245 >          # 0 hours and 0 mins
246 >            $uptime =~ /up\s+([0-9]+)/;
247 >            $uptime = "$1:0:0";
248 >        }
249      }
250      else {
251        # 0 days
252 <        $uptime =~ s/up ([0-9]+):([0-9]+)/0:$1:$2/;
252 >        $uptime =~ /up\s+([0-9]+):([0-9]+)/;
253 >        $uptime = "0:$1:$2";
254      }
255  
256      # turn into minutes

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines