[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-users] OT: Showing uptime via web
- Subject: Re: [cobalt-users] OT: Showing uptime via web
- From: Jeff Bilicki <jeff@xxxxxxxxxxx>
- Date: Wed Aug 23 13:26:08 2000
I think you going to run into problems parsing uptime this way.
The following uptimes would report wrong information:
1:24pm up 27 days, 8 min, 10 users, load average: 0.01, 0.05, 0.01
1:14pm up 2:31, 4 users, load average: 0.00, 0.00, 0.00
1:20pm up 7 min, 2 users, load average: 0.00, 0.05, 0.03
This is what I came up with
#!/usr/bin/perl
print "Content-Type:text/html\n\n";
print "This server has been up for ";
chop($_ = `uptime`);
/(^.* up\s)(.*)(\s+\d*\suser.*)/;
my @time = split(/,/, $2);
for (@time) {
next unless($_);
s/min/minutes/;
s/days/days, /;
s/\s*(\d+):(\d\d)\s*/$1 hours and $2 minutes/;
print;
}
print "<br>\n";
exit;
Jeff-
> This is it below:
> ------------------------------------------
> #!/usr/bin/perl
> chop($uptime = `uptime`);
> @_=split(" ",$uptime);
> $updays=@_[2];
> $uphours=@_[4];
> print ("Content-Type:text/html\n\n");
> print "This server has been up for $updays days and $uphours hours.";
> exit;
> --------------------------------------
> Hope it works for you.
> Sincerely,
> Cody Watkins
> ________________________________________________
> Paradox Web Hosting
> codyw@xxxxxxxxxxxxxxxxxxxxx
> www.paradoxwebhosting.com
> At 09:54 PM 8/21/00 -0700, you wrote:
>>At 8:10 PM -0700 8/21/00, Cody Watkins wrote:
>>>I want to show the number of days my RaQ3 has been up for in a Perl Cgi
>>>script. I found a script to call the following up:
>>>
>>>6:58pm up 43 days, 3:38, 1 user, load average: 0.05, 0.05, 0.05
>>>
>>
>> Hey, why not throw out the script that you are using - with
>>the limitations described, above - for everyone? Might be fun to use
>>this in an include(SSI) tag. Should work.
>>
>> I'd like to see the CGI script for this. Would you Email me?
>>
>>
>>
>>Patrick Beart
>>--
>>-------------------------------------------------------------------
>>patrick@xxxxxxxxxxxxxxxxxxx 503-558-8322 Clackamas(Portland), OR
>>Web Architecture: http://www.WebArchitecture.com
>>Intelligent Internet consulting, site development, and hosting
>>solutions since 1994
>>
>>* Founding MEMBER -- Internet Professionals Northwest. (www.ipn.org)
>>* MEMBER -- Webmaster's Guild/ Association of Internet Professionals
>> -------------------------------------------------------------------
>>
>>
>>_______________________________________________
>>cobalt-users mailing list
>>cobalt-users@xxxxxxxxxxxxxxx
>>To Subscribe or Unsubscribe, please go to:
>>http://list.cobalt.com/mailman/listinfo/cobalt-users
>>
> _______________________________________________
> cobalt-users mailing list
> cobalt-users@xxxxxxxxxxxxxxx
> To Subscribe or Unsubscribe, please go to:
> http://list.cobalt.com/mailman/listinfo/cobalt-users