Skip to content

Commit 29c5de2

Browse files
committed
Merge branch 'dev'
2 parents 02a210b + 11a7795 commit 29c5de2

16 files changed

+955
-119
lines changed

.github/workflows/mamonsu-tests-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ jobs:
8686
run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) bash /mamonsu/github-actions-tests/tools/zabbix_cli.sh --zbx-address="${{ steps.zabbix_address.outputs.zabbix_address }}" --zbx-version="${{ matrix.zabbix_version }}"
8787

8888
- name: Test Mamonsu metrics on master
89-
run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) bash /mamonsu/github-actions-tests/metrics.sh
89+
run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) bash /mamonsu/github-actions-tests/metrics.sh --pg-version="${{ matrix.pg_version }}" --os="${{ matrix.docker_os }}"

.github/workflows/mamonsu-tests-master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ jobs:
9090
run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) bash /mamonsu/github-actions-tests/tools/zabbix_cli.sh --zbx-address="${{ steps.zabbix_address.outputs.zabbix_address }}" --zbx-version="${{ matrix.zabbix_version }}"
9191

9292
- name: Test Mamonsu metrics on master
93-
run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) bash /mamonsu/github-actions-tests/metrics.sh
93+
run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) bash /mamonsu/github-actions-tests/metrics.sh --pg-version="${{ matrix.pg_version }}" --os="${{ matrix.docker_os }}"

github-actions-tests/metrics.sh

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,71 @@
11
#!/bin/sh
22

3+
# mamonsu metrics tests
4+
5+
# default parameters:
6+
PG_VERSION="14"
7+
OS="centos:7"
8+
9+
for i in "$@"
10+
do
11+
case $i in
12+
--os=*)
13+
OS="${i#*=}"
14+
shift
15+
;;
16+
--pg-version=*)
17+
PG_VERSION="${i#*=}"
18+
shift
19+
;;
20+
*)
21+
# unknown option
22+
;;
23+
esac
24+
done
25+
26+
METRICS_FILE="/mamonsu/github-actions-tests/sources/metrics-linux-${PG_VERSION}.txt"
27+
328
echo && echo
429
echo "================================================================================================================="
530
echo "---> Test MAMONSU metrics"
631
echo
732

33+
# ======================================================================================================================
34+
# some PG preparations
35+
36+
PG_PATH=""
37+
if [ "${OS%:*}" = "centos" ]; then
38+
PACKAGE="postgresql${PG_VERSION//./}-server postgresql${PG_VERSION//./}-contrib"
39+
PG_PATH="/usr/pgsql-${PG_VERSION}/bin/"
40+
elif [ "${OS%:*}" = "ubuntu" ]; then
41+
PACKAGE="postgresql-${PG_VERSION} postgresql-contrib-${PG_VERSION}"
42+
PG_PATH="/usr/lib/postgresql/${PG_VERSION}/bin/"
43+
fi
44+
45+
# archive_mode preps
46+
sudo -u postgres ${PG_PATH}psql -d mamonsu_test_db -c "DO
47+
\$do\$
48+
DECLARE
49+
func_name varchar;
50+
BEGIN
51+
SELECT proname INTO func_name FROM pg_proc WHERE proname LIKE 'pg_switch_%';
52+
EXECUTE FORMAT('SELECT %s();', func_name);
53+
END
54+
\$do\$;"
55+
56+
# pg_stat_statements preps
57+
sudo -u postgres ${PG_PATH}psql -d mamonsu_test_db -c "CREATE EXTENSION pg_stat_statements;"
58+
59+
# wait few intervals to get all possible metrics
60+
sleep 50
61+
62+
# read metric for specific version
863
while read metric; do
964
GREP=$( mamonsu agent metric-get ${metric} | grep "pgsql\|sys\|mamonsu" )
1065
if [ -z "$GREP" ]; then
1166
echo "---> ERROR: Cannot found metric $metric"
12-
# exit 11
67+
exit 11
1368
fi
14-
done </mamonsu/github-actions-tests/sources/metrics-linux.txt
69+
done <"${METRICS_FILE}"
1570

1671
echo && echo

github-actions-tests/pg_install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ sudo chmod 700 /pg${PG_VERSION}/data_slave_physical
6767

6868
# create master-slave cluster
6969
sudo -u postgres ${PG_PATH}initdb -D /pg${PG_VERSION}/data_master/
70+
sudo -u postgres echo "shared_preload_libraries='pg_stat_statements'" >> /pg${PG_VERSION}/data_master/postgresql.conf
7071
sudo -u postgres echo "archive_mode=on" >> /pg${PG_VERSION}/data_master/postgresql.conf
7172
sudo -u postgres echo "archive_command='cp %p /pg"${PG_VERSION}"/wals/%f'" >> /pg${PG_VERSION}/data_master/postgresql.conf
7273
sudo -u postgres echo "wal_level=replica" >> /pg${PG_VERSION}/data_master/postgresql.conf

github-actions-tests/sources/agent_3.4.0.conf

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,87 +79,87 @@ format = [%(levelname)s] %(asctime)s - %(name)s - %(message)s
7979

8080
[health]
8181
max_memory_usage = 41943040
82-
interval = 60
82+
interval = 15
8383

8484
[bgwriter]
85-
interval = 60
85+
interval = 15
8686

8787
[connections]
8888
percent_connections_tr = 90
89-
interval = 60
89+
interval = 15
9090

9191
[databases]
9292
bloat_scale = 0.2
9393
min_rows = 50
94-
interval = 300
94+
interval = 15
9595

9696
[pghealth]
9797
uptime = 600
9898
cache = 80
99-
interval = 60
99+
interval = 15
100100

101101
[instance]
102-
interval = 60
102+
interval = 15
103103

104104
[xlog]
105105
lag_more_than_in_sec = 300
106-
interval = 60
106+
interval = 15
107107

108108
[pgstatstatement]
109-
interval = 60
109+
interval = 15
110110

111111
[pgbuffercache]
112-
interval = 60
112+
interval = 15
113113

114114
[pgwaitsampling]
115-
interval = 60
115+
interval = 15
116116

117117
[checkpoint]
118118
max_checkpoint_by_wal_in_hour = 12
119-
interval = 300
119+
interval = 15
120120

121121
[oldest]
122122
max_xid_age = 18000000
123123
max_query_time = 18000
124-
interval = 60
124+
interval = 15
125125

126126
[pglocks]
127-
interval = 60
127+
interval = 15
128128

129129
[cfs]
130130
force_enable = False
131-
interval = 60
131+
interval = 15
132132

133133
[archivecommand]
134134
max_count_files = 2
135-
interval = 60
135+
interval = 15
136136

137137
[procstat]
138-
interval = 60
138+
interval = 15
139139

140140
[diskstats]
141-
interval = 60
141+
interval = 15
142142

143143
[disksizes]
144144
vfs_percent_free = 10
145145
vfs_inode_percent_free = 10
146-
interval = 60
146+
interval = 15
147147

148148
[memory]
149-
interval = 60
149+
interval = 15
150150

151151
[systemuptime]
152152
up_time = 300
153-
interval = 60
153+
interval = 15
154154

155155
[openfiles]
156-
interval = 60
156+
interval = 15
157157

158158
[net]
159-
interval = 60
159+
interval = 15
160160

161161
[la]
162-
interval = 60
162+
interval = 15
163163

164164
[zbxsender]
165165
interval = 10
@@ -168,7 +168,7 @@ interval = 10
168168
interval = 2
169169

170170
[agentapi]
171-
interval = 60
171+
interval = 15
172172

173173
# Get age (in seconds) of the oldest running prepared transaction and number of all prepared transactions for two-phase commit.
174174
# https://www.postgresql.org/docs/current/sql-prepare-transaction.html
@@ -177,7 +177,7 @@ interval = 60
177177
# If pgsql.prepared.oldest exceeds max_prepared_transaction_time the trigger fires.
178178
[preparedtransaction]
179179
max_prepared_transaction_time = 60
180-
interval = 60
180+
interval = 15
181181

182182
# Get size of backup catalogs stroring all WAL and backup files using pg_probackup
183183
# (https://github.com/postgrespro/pg_probackup)
@@ -195,9 +195,9 @@ pg_probackup_path = /usr/bin/pg_probackup-11
195195
# If the relation is blocked by some process such as vacuum full or create index, the result will be -1
196196
# by default this plugin disabled. To enable this plugin - set bellow "enabled = False" and define a list of relations.
197197
[relationssize]
198-
enabled = False
199-
relations=postgres.pg_catalog.pg_class,postgres.pg_catalog.pg_user
200-
interval = 300
198+
enabled = True
199+
relations=postgres.pg_catalog.pg_class,mamonsu_test_db.mamonsu.config
200+
interval = 15
201201

202202
# This plugin allows detects possible memory leaks while working with PostgreSQL using /proc/pid/status and /proc/pid/statm
203203
# We use RES and SHR difference to calculate approximate volume of private anonymous backend memory.
@@ -211,6 +211,6 @@ interval = 300
211211
# private_anon_mem_threshold - memory volume threshold after which we need an investigation about memory leak. 1GB by default.
212212
# Possible values MB, GB, TB. For example 1GB
213213
[memoryleakdiagnostic]
214-
enabled = False
215-
interval = 60
214+
enabled = True
215+
interval = 15
216216
private_anon_mem_threshold = 1GB
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
mamonsu.memory.rss[max]
2+
mamonsu.plugin.errors[]
3+
mamonsu.plugin.keepalive[]
4+
pgsql.archive_command[archived_files]
5+
pgsql.archive_command[count_files_to_archive]
6+
pgsql.archive_command[failed_trying_to_archive]
7+
pgsql.archive_command[size_files_to_archive]
8+
pgsql.autovacumm.count[]
9+
pgsql.bgwriter[buffers_alloc]
10+
pgsql.bgwriter[buffers_backend]
11+
pgsql.bgwriter[buffers_backend_fsync]
12+
pgsql.bgwriter[buffers_checkpoint]
13+
pgsql.bgwriter[buffers_clean]
14+
pgsql.bgwriter[maxwritten_clean]
15+
pgsql.blocks[hit]
16+
pgsql.blocks[read]
17+
pgsql.buffers[dirty]
18+
pgsql.buffers[size]
19+
pgsql.buffers[twice_used]
20+
pgsql.checkpoint[checkpoint_sync_time]
21+
pgsql.checkpoint[count_timed]
22+
pgsql.checkpoint[count_wal]
23+
pgsql.checkpoint[write_time]
24+
pgsql.connections[active]
25+
pgsql.connections[disabled]
26+
pgsql.connections[fastpath_function_call]
27+
pgsql.connections[idle]
28+
pgsql.connections[idle_in_transaction]
29+
pgsql.connections[idle_in_transaction_aborted]
30+
pgsql.connections[max_connections]
31+
pgsql.connections[other]
32+
pgsql.connections[total]
33+
pgsql.connections[waiting]
34+
pgsql.database.discovery[]
35+
pgsql.database.bloating_tables[mamonsu_test_db]
36+
pgsql.database.bloating_tables[postgres]
37+
pgsql.database.invalid_indexes[mamonsu_test_db]
38+
pgsql.database.invalid_indexes[postgres]
39+
pgsql.database.max_age[mamonsu_test_db]
40+
pgsql.database.max_age[postgres]
41+
pgsql.database.size[mamonsu_test_db]
42+
pgsql.database.size[postgres]
43+
pgsql.events[conflicts]
44+
pgsql.events[deadlocks]
45+
pgsql.events[xact_rollback]
46+
pgsql.memory_leak_diagnostic.count_diff[]
47+
pgsql.memory_leak_diagnostic.msg_text[]
48+
pgsql.oldest[transaction_time]
49+
pgsql.oldest[xid_age]
50+
pgsql.ping[]
51+
pgsql.pg_locks[accessexclusive]
52+
pgsql.pg_locks[accessshare]
53+
pgsql.pg_locks[exclusive]
54+
pgsql.pg_locks[rowexclusive]
55+
pgsql.pg_locks[rowshare]
56+
pgsql.pg_locks[share]
57+
pgsql.pg_locks[sharerowexclusive]
58+
pgsql.pg_locks[shareupdateexclusive]
59+
pgsql.prepared.count
60+
pgsql.prepared.oldest
61+
pgsql.relation.size[]
62+
pgsql.relation.size[mamonsu_test_db.mamonsu.config]
63+
pgsql.relation.size[postgres.pg_catalog.pg_class]
64+
pgsql.replication.non_active_slots[]
65+
pgsql.replication_lag[sec]
66+
pgsql.replication_lag[sec]
67+
pgsql.stat[dirty_bytes]
68+
pgsql.stat[other_time]
69+
pgsql.stat[read_bytes]
70+
pgsql.stat[read_time]
71+
pgsql.stat[write_bytes]
72+
pgsql.stat[write_time]
73+
pgsql.temp[bytes]
74+
pgsql.temp[files]
75+
pgsql.transactions[committed]
76+
pgsql.tuples[deleted]
77+
pgsql.tuples[fetched]
78+
pgsql.tuples[inserted]
79+
pgsql.tuples[returned]
80+
pgsql.tuples[updated]
81+
pgsql.uptime[]
82+
pgsql.wal.count[]
83+
pgsql.wal.write[]
84+
system.cpu[idle]
85+
system.cpu[iowait]
86+
system.cpu[irq]
87+
system.cpu[nice]
88+
system.cpu[softirq]
89+
system.cpu[system]
90+
system.cpu[user]
91+
system.disk.discovery[]
92+
system.disk.all_read[]
93+
system.disk.all_write[]
94+
system.disk.all_read_b[]
95+
system.disk.all_write_b[]
96+
system.la[1]
97+
system.memory[active]
98+
system.memory[apps]
99+
system.memory[available]
100+
system.memory[buffers]
101+
system.memory[cached]
102+
system.memory[committed]
103+
system.memory[inactive]
104+
system.memory[mapped]
105+
system.memory[page_tables]
106+
system.memory[slab]
107+
system.memory[swap]
108+
system.memory[swap_cache]
109+
system.memory[vmalloc_used]
110+
system.memory[unused]
111+
system.net.discovery[]
112+
system.open_files[]
113+
system.processes[blocked]
114+
system.processes[forkrate]
115+
system.processes[running]
116+
system.vfs.discovery[]
117+
system.vfs.free[/]
118+
system.vfs.percent_free[/]
119+
system.vfs.percent_inode_free[/]
120+
system.vfs.used[/]
121+
system.up_time[]

0 commit comments

Comments
 (0)