Thread: Patch for Postmaster Uptime (from the TODO)

Patch for Postmaster Uptime (from the TODO)

From
"Eric Crampton"
Date:
Hello hackers,

I noticed in the TODO that there is an item requesting a function which
returns the uptime of the postmaster. I've wanted that as well. So, I've
added just such a thing: server_start_time(). This function returns the
time when the postmaster was started; a simple now() - server_start_time()
returns the uptime.

The below patches are for four files:

* postmaster.c: Now calls a new function, MarkServerStartTime(), before
calling ServerLoop().

* timestamp.h/timestamp.c: New functions: MarkServerStartTime() (called
from postmaster.c) and server_start_time(), a new SQL function which may
be called.

* pg_proc.h: Added DATA and DESCR to the very end of the list (OID=2557)
for the server_start_time function.

I didn't bother to include the generated fmgroids.h and fmgrtab.c. Since
they are small, I've attached the four unified diffs against the 8.0.1
code. Let me know if there's anything different the code should have done.

--Eric

Attachment

Re: Patch for Postmaster Uptime (from the TODO)

From
Tom Lane
Date:
"Eric Crampton" <escpg@eonomine.com> writes:
> I noticed in the TODO that there is an item requesting a function which
> returns the uptime of the postmaster. I've wanted that as well. So, I've
> added just such a thing: server_start_time(). This function returns the
> time when the postmaster was started; a simple now() - server_start_time()
> returns the uptime.

Isn't there one of these in the patch queue already?

The patch as given won't work on Windows, because it depends on fork
inheritance of the value.  I think the previous patcher fixed that.

            regards, tom lane

Where to see the patch queue (was Re: Patch for Postmaster Uptime (from the TODO))

From
Eric Crampton
Date:
On Feb 24, 2005, at 5:38 PM, Tom Lane wrote:

> "Eric Crampton" <escpg@eonomine.com> writes:
>> I noticed in the TODO that there is an item requesting a function
>> which
>> returns the uptime of the postmaster. I've wanted that as well. So,
>> I've
>> added just such a thing: server_start_time(). This function returns
>> the
>> time when the postmaster was started; a simple now() -
>> server_start_time()
>> returns the uptime.
>
> Isn't there one of these in the patch queue already?

There could be, but I didn't see one because perhaps I'm looking in the
wrong place. I referenced the TODO list here:

    http://developer.postgresql.org/todo.php

and I referenced the unapplied patches here:

    http://momjian.postgresql.org/cgi-bin/pgpatches

Where should I be looking?

Thanks,
--Eric


Re: Patch for Postmaster Uptime (from the TODO)

From
Bruce Momjian
Date:
Tom Lane wrote:
> "Eric Crampton" <escpg@eonomine.com> writes:
> > I noticed in the TODO that there is an item requesting a function which
> > returns the uptime of the postmaster. I've wanted that as well. So, I've
> > added just such a thing: server_start_time(). This function returns the
> > time when the postmaster was started; a simple now() - server_start_time()
> > returns the uptime.
>
> Isn't there one of these in the patch queue already?

Yes.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Where to see the patch queue (was Re: Patch for Postmaster

From
Bruce Momjian
Date:
Eric Crampton wrote:
> On Feb 24, 2005, at 5:38 PM, Tom Lane wrote:
>
> > "Eric Crampton" <escpg@eonomine.com> writes:
> >> I noticed in the TODO that there is an item requesting a function
> >> which
> >> returns the uptime of the postmaster. I've wanted that as well. So,
> >> I've
> >> added just such a thing: server_start_time(). This function returns
> >> the
> >> time when the postmaster was started; a simple now() -
> >> server_start_time()
> >> returns the uptime.
> >
> > Isn't there one of these in the patch queue already?
>
> There could be, but I didn't see one because perhaps I'm looking in the
> wrong place. I referenced the TODO list here:
>
>     http://developer.postgresql.org/todo.php
>
> and I referenced the unapplied patches here:
>
>     http://momjian.postgresql.org/cgi-bin/pgpatches
>
> Where should I be looking?
>

Sure:

    http://momjian.postgresql.org/cgi-bin/pgpatches2

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073