Skip to content

Commit c6e480d

Browse files
committed
Initial commit
0 parents  commit c6e480d

File tree

101 files changed

+43671
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+43671
-0
lines changed

LICENSE

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Copyright (c) 2009-2022, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
2+
3+
Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
4+
Portions Copyright (c) 1994, The Regents of the University of California
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
* Neither the name of the NIPPON TELEGRAPH AND TELEPHONE CORPORATION
15+
(NTT) nor the names of its contributors may be used to endorse or
16+
promote products derived from this software without specific prior
17+
written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Makefile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# pg_statsinfo: Makefile
3+
#
4+
# Copyright (c) 2009-2022, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
5+
#
6+
SUBDIRS = agent reporter
7+
REGTEST = \
8+
function-snapshot \
9+
function-snapshot_replication \
10+
function-logger \
11+
function-logstore \
12+
function-alert \
13+
function-maintenance \
14+
function-report \
15+
function-command_option
16+
17+
ifndef USE_PGXS
18+
top_builddir = ../..
19+
makefile_global = $(top_builddir)/src/Makefile.global
20+
ifeq "$(wildcard $(makefile_global))" ""
21+
USE_PGXS = 1 # use pgxs if not in contrib directory
22+
endif
23+
endif
24+
25+
ifdef USE_PGXS
26+
PG_CONFIG = pg_config
27+
PGXS := $(shell $(PG_CONFIG) --pgxs)
28+
include $(PGXS)
29+
else
30+
subdir = pg_statsinfo
31+
include $(makefile_global)
32+
include $(top_srcdir)/contrib/contrib-global.mk
33+
endif
34+
35+
all install installdirs uninstall distprep clean distclean maintainer-clean:
36+
@for dir in $(SUBDIRS); do \
37+
$(MAKE) -C $$dir $@ || exit; \
38+
done
39+
40+
installcheck:
41+
( cd test && ./regress.sh $(REGTEST))

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# pg_statsinfo
2+
3+
PostgreSQL サーバの利用統計情報を定期的に収集・蓄積することで、DB設計やPostgreSQLの運用(日々の処理傾向の把握、 性能劣化などの兆候や問題発生時の原因の把握等)に役立つツールです。
4+
起動や終了、パラメータの設定は PostgreSQL と密に連携しており、手間をかけずに導入可能です。
5+
6+
[日本語のマニュアルはこちら](/doc/pg_statsinfo-ja.md)
7+
8+
[English version here](/doc/pg_statsinfo.md)
9+
10+
-----
11+
Copyright (c) 2009-2022, NIPPON TELEGRAPH AND TELEPHONE CORPORATION

README_REGTEST

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
How to run the regression tests.
2+
=====================================
3+
4+
$ gmake
5+
$ su
6+
# gmake install
7+
# exit
8+
$ gmake installcheck
9+
10+
Requirements
11+
-------------------------------------
12+
* pg_stat_statements should be installed for PostgreSQL 8.4 or later.
13+
14+
$ cd <postgresql-source>/contrib/pg_stat_statements
15+
$ gmake
16+
$ su
17+
# gmake install

agent/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# pg_statsinfo: Makefile
3+
#
4+
# Copyright (c) 2009-2022, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
5+
#
6+
SUBDIRS = bin lib
7+
8+
all install installdirs uninstall distprep clean distclean maintainer-clean:
9+
@for dir in $(SUBDIRS); do \
10+
$(MAKE) -C $$dir $@ || exit; \
11+
done

agent/bin/Makefile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#
2+
# pg_statsinfo: bin/Makefile
3+
#
4+
# Copyright (c) 2009-2022, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
5+
#
6+
SRCS = \
7+
pg_statsinfod.c \
8+
autovacuum.c \
9+
checkpoint.c \
10+
collector.c \
11+
collector_wait_sampling.c \
12+
logger.c \
13+
logger_send.c \
14+
logger_common.c \
15+
logger_in.c \
16+
logger_out.c \
17+
maintenance.c \
18+
snapshot.c \
19+
writer.c \
20+
pg_control.c \
21+
pgut/pgut.c \
22+
pgut/pgut-list.c \
23+
pgut/pgut-pthread.c
24+
25+
OBJS = $(SRCS:.c=.o)
26+
DATA = pg_statsrepo.sql pg_statsrepo_alert.sql uninstall_pg_statsrepo.sql
27+
SCRIPTS = archive_pglog.sh
28+
PROGRAM = pg_statsinfod
29+
30+
PG_CPPFLAGS = -I$(libpq_srcdir) -DFRONTEND -DPGUT_MULTI_THREADED -DPGUT_OVERRIDE_ELOG
31+
PG_LIBS = $(libpq) -lpthread
32+
33+
ifndef USE_PGXS
34+
top_builddir = ../../../..
35+
makefile_global = $(top_builddir)/src/Makefile.global
36+
ifeq "$(wildcard $(makefile_global))" ""
37+
USE_PGXS = 1 # use pgxs if not in contrib directory
38+
endif
39+
endif
40+
41+
ifdef USE_PGXS
42+
PG_CONFIG = pg_config
43+
PGXS := $(shell $(PG_CONFIG) --pgxs)
44+
include $(PGXS)
45+
else
46+
subdir = contrib/$(MODULE_big)
47+
include $(makefile_global)
48+
include $(top_srcdir)/contrib/contrib-global.mk
49+
endif
50+
51+
# exclude libraries which are not required
52+
LIBS := $(filter -lpgport -lpgcommon, $(LIBS))

agent/bin/archive_pglog.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
#############################################################################
3+
# Copyright (c) 2009-2022, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
4+
#############################################################################
5+
6+
log_directory="${1}"
7+
archive_directory="${log_directory}/log_archive"
8+
archive_filename="${archive_directory}/$(date +postgresql-%Y%m%d.tar.gz)"
9+
10+
# change the current directory to log directory
11+
cd "${log_directory}" || exit 1
12+
13+
# create a directory that store archive file
14+
mkdir -p "${archive_directory}" || exit 1
15+
16+
# search the csv log files that have been updated in more than one day ago
17+
target_files=($(find -maxdepth 1 -type f -name "*.csv" -daystart -ctime +0)) || exit 1
18+
19+
# create archive file
20+
if [ ${#target_files[@]} -gt 0 ] ; then
21+
22+
if [ -e "${archive_filename}" ] ; then
23+
echo "archive file \"${archive_filename}\" already exists" 1>&2
24+
exit 1
25+
fi
26+
27+
tar cfz "${archive_filename}" ${target_files[@]} --remove-files || exit 1
28+
fi
29+
30+
exit 0

0 commit comments

Comments
 (0)