mirror of
https://github.com/postgres/postgres.git
synced 2025-12-06 00:02:13 +03:00
Complete the following TODO items:
* Add session start time to pg_stat_activity * Add the client IP address and port to pg_stat_activity Original patch from Magnus Hagander, code review by Neil Conway. Catalog version bumped. This patch sends the client IP address and port number in every statistics message; that's not ideal, but will be fixed up shortly.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
*
|
||||
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.92 2005/04/14 20:32:42 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.93 2005/05/09 11:31:33 neilc Exp $
|
||||
* ----------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
@@ -1300,6 +1300,7 @@ pgstat_setheader(PgStat_MsgHdr *hdr, int mtype)
|
||||
hdr->m_procpid = MyProcPid;
|
||||
hdr->m_databaseid = MyDatabaseId;
|
||||
hdr->m_userid = GetSessionUserId();
|
||||
memcpy(&hdr->m_clientaddr, &MyProcPort->raddr, sizeof(hdr->m_clientaddr));
|
||||
}
|
||||
|
||||
|
||||
@@ -2032,12 +2033,15 @@ pgstat_add_backend(PgStat_MsgHdr *msg)
|
||||
beentry->databaseid = msg->m_databaseid;
|
||||
beentry->procpid = msg->m_procpid;
|
||||
beentry->userid = msg->m_userid;
|
||||
beentry->start_sec =
|
||||
GetCurrentAbsoluteTimeUsec(&beentry->start_usec);
|
||||
beentry->activity_start_sec = 0;
|
||||
beentry->activity_start_usec = 0;
|
||||
memcpy(&beentry->clientaddr, &msg->m_clientaddr, sizeof(beentry->clientaddr));
|
||||
MemSet(beentry->activity, 0, PGSTAT_ACTIVITY_SIZE);
|
||||
|
||||
/*
|
||||
* Lookup or create the database entry for this backends DB.
|
||||
* Lookup or create the database entry for this backend's DB.
|
||||
*/
|
||||
dbentry = (PgStat_StatDBEntry *) hash_search(pgStatDBHash,
|
||||
(void *) &(msg->m_databaseid),
|
||||
@@ -2072,9 +2076,7 @@ pgstat_add_backend(PgStat_MsgHdr *msg)
|
||||
HASH_ELEM | HASH_FUNCTION);
|
||||
}
|
||||
|
||||
/*
|
||||
* Count number of connects to the database
|
||||
*/
|
||||
/* Count the number of connects to the database */
|
||||
dbentry->n_connects++;
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user