|
|
|
@ -13,7 +13,7 @@ |
|
|
|
|
* |
|
|
|
|
* Copyright (c) 2001-2010, PostgreSQL Global Development Group |
|
|
|
|
* |
|
|
|
|
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.197 2010/01/10 14:16:07 mha Exp $ |
|
|
|
|
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.198 2010/01/19 14:11:30 mha Exp $ |
|
|
|
|
* ---------- |
|
|
|
|
*/ |
|
|
|
|
#include "postgres.h" |
|
|
|
@ -270,6 +270,7 @@ static void pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len); |
|
|
|
|
static void pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len); |
|
|
|
|
static void pgstat_recv_dropdb(PgStat_MsgDropdb *msg, int len); |
|
|
|
|
static void pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len); |
|
|
|
|
static void pgstat_recv_resetsharedcounter(PgStat_MsgResetsharedcounter *msg, int len); |
|
|
|
|
static void pgstat_recv_autovac(PgStat_MsgAutovacStart *msg, int len); |
|
|
|
|
static void pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len); |
|
|
|
|
static void pgstat_recv_analyze(PgStat_MsgAnalyze *msg, int len); |
|
|
|
@ -1153,6 +1154,38 @@ pgstat_reset_counters(void) |
|
|
|
|
pgstat_send(&msg, sizeof(msg)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
|
* pgstat_reset_shared_counters() - |
|
|
|
|
* |
|
|
|
|
* Tell the statistics collector to reset cluster-wide shared counters. |
|
|
|
|
* ---------- |
|
|
|
|
*/ |
|
|
|
|
void |
|
|
|
|
pgstat_reset_shared_counters(const char *target) |
|
|
|
|
{ |
|
|
|
|
PgStat_MsgResetsharedcounter msg; |
|
|
|
|
|
|
|
|
|
if (pgStatSock < 0) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (!superuser()) |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), |
|
|
|
|
errmsg("must be superuser to reset statistics counters"))); |
|
|
|
|
|
|
|
|
|
if (strcmp(target, "bgwriter") == 0) |
|
|
|
|
msg.m_resettarget = RESET_BGWRITER; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR), |
|
|
|
|
errmsg("unrecognized reset target: '%s'", target), |
|
|
|
|
errhint("allowed targets are 'bgwriter'."))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_RESETSHAREDCOUNTER); |
|
|
|
|
pgstat_send(&msg, sizeof(msg)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
|
* pgstat_report_autovac() - |
|
|
|
@ -2915,6 +2948,12 @@ PgstatCollectorMain(int argc, char *argv[]) |
|
|
|
|
len); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case PGSTAT_MTYPE_RESETSHAREDCOUNTER: |
|
|
|
|
pgstat_recv_resetsharedcounter( |
|
|
|
|
(PgStat_MsgResetsharedcounter *) &msg, |
|
|
|
|
len); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case PGSTAT_MTYPE_AUTOVAC_START: |
|
|
|
|
pgstat_recv_autovac((PgStat_MsgAutovacStart *) &msg, len); |
|
|
|
|
break; |
|
|
|
@ -3868,6 +3907,27 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len) |
|
|
|
|
HASH_ELEM | HASH_FUNCTION); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
|
* pgstat_recv_resetshared() - |
|
|
|
|
* |
|
|
|
|
* Reset some shared statistics of the cluster. |
|
|
|
|
* ---------- |
|
|
|
|
*/ |
|
|
|
|
static void |
|
|
|
|
pgstat_recv_resetsharedcounter(PgStat_MsgResetsharedcounter *msg, int len) |
|
|
|
|
{ |
|
|
|
|
if (msg->m_resettarget==RESET_BGWRITER) |
|
|
|
|
{ |
|
|
|
|
/* Reset the global background writer statistics for the cluster. */ |
|
|
|
|
memset(&globalStats, 0, sizeof(globalStats)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Presumably the sender of this message validated the target, don't |
|
|
|
|
* complain here if it's not valid |
|
|
|
|
*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
|
* pgstat_recv_autovac() - |
|
|
|
|
* |
|
|
|
|