Skip to content

Commit c183de3

Browse files
committed
Merge remote-tracking branch 'origin' into dev
2 parents 1691857 + c4f6418 commit c183de3

File tree

10 files changed

+63
-22
lines changed

10 files changed

+63
-22
lines changed

Makefile.pkg

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ build/all: build/pkg_debian build/pkg_ubuntu build/pkg_centos
4545
@echo Build for all platform: done
4646
touch build/all
4747

48-
build/pkg_debian: build/pkg_debian_7 build/pkg_debian_8
48+
build/pkg_debian: build/pkg_debian_7 build/pkg_debian_8 build/pkg_debian_9
4949
@echo Debian: done
5050

51-
build/pkg_ubuntu: build/pkg_ubuntu_14_04 build/pkg_ubuntu_16_04
51+
build/pkg_ubuntu: build/pkg_ubuntu_14_04 build/pkg_ubuntu_16_04 build/pkg_ubuntu_17_10
5252
@echo Ubuntu: done
5353

5454
build/pkg_centos: build/pkg_centos_6 build/pkg_centos_7
@@ -79,6 +79,10 @@ build/pkg_debian_8:
7979
$(call build_deb,debian,jessie)
8080
touch build/pkg_debian_8
8181

82+
build/pkg_debian_9:
83+
$(call build_deb,debian,stretch)
84+
touch build/pkg_debian_9
85+
8286
build/pkg_ubuntu_14_04:
8387
$(call build_deb,ubuntu,trusty)
8488
touch build/pkg_ubuntu_14_04
@@ -87,6 +91,10 @@ build/pkg_ubuntu_16_04:
8791
$(call build_deb,ubuntu,xenial)
8892
touch build/pkg_ubuntu_16_04
8993

94+
build/pkg_ubuntu_17_10:
95+
$(call build_deb,ubuntu,artful)
96+
touch build/pkg_ubuntu_17_10
97+
9098
build/pkg_centos_6:
9199
$(call build_rpm,centos,6)
92100
touch build/pkg_centos_6

mamonsu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__author__ = 'Dmitry Vasilyev'
22
__author_email__ = '[email protected]'
33
__description__ = 'Monitoring agent for PostgreSQL'
4-
__version__ = '2.3.2'
4+
__version__ = '2.3.3'
55
__licence__ = 'BSD'
66

77
__url__ = 'https://github.com/postgrespro/mamonsu'

mamonsu/lib/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
-a, --add-plugins <directory>
1010
-c, --config <file>
1111
-p, --pid <pid-file>
12-
-d run in foreground
12+
-d daemonize
1313
1414
Export example config with default variables:
1515
Command: export

mamonsu/plugins/pgsql/driver/pool.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class Pool(object):
2121
"select count(*) from pg_catalog.pg_ls_dir('pg_xlog')",
2222
'select public.mamonsu_count_xlog_files()'
2323
),
24+
'count_wal_files': (
25+
"select count(*) from pg_catalog.pg_ls_dir('pg_wal')",
26+
'select public.mamonsu_count_wal_files()'
27+
),
2428
'count_autovacuum': (
2529
"""select count(*) from pg_catalog.pg_stat_activity where
2630
query like '%%autovacuum%%' and state <> 'idle'
@@ -77,7 +81,8 @@ def server_version_greater(self, version, db=None, bootstrap=False):
7781
db = self._normalize_db(db)
7882
return self.server_version(db) >= LooseVersion(version)
7983
else:
80-
return str(self._cache['bootstrap']['version']) >= LooseVersion(version)
84+
return str(
85+
self._cache['bootstrap']['version']) >= LooseVersion(version)
8186

8287
def server_version_less(self, version, db=None, bootstrap=False):
8388
if not bootstrap:

mamonsu/plugins/pgsql/xlog.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,23 @@ def run(self, zbx):
1717
else:
1818
Pooler.run_sql_type('replication_lag_master_query')
1919
# xlog location
20-
result = Pooler.query("""
21-
select pg_catalog.pg_xlog_location_diff
22-
(pg_catalog.pg_current_xlog_location(),'0/00000000')""")
23-
zbx.send('pgsql.wal.write[]', float(result[0][0]), self.DELTA_SPEED)
20+
if Pooler.server_version_greater('10.0'):
21+
result = Pooler.query("""
22+
select pg_catalog.pg_wal_lsn_diff
23+
(pg_catalog.pg_current_wal_lsn(), '0/00000000')""")
24+
else:
25+
result = Pooler.query("""
26+
select pg_catalog.pg_xlog_location_diff
27+
(pg_catalog.pg_current_xlog_location(), '0/00000000')""")
28+
zbx.send(
29+
'pgsql.wal.write[]',
30+
float(result[0][0]),
31+
self.DELTA_SPEED)
2432
# count of xlog files
25-
result = Pooler.run_sql_type('count_xlog_files')
33+
if Pooler.server_version_greater('10.0'):
34+
result = Pooler.run_sql_type('count_wal_files')
35+
else:
36+
result = Pooler.run_sql_type('count_xlog_files')
2637
zbx.send('pgsql.wal.count[]', int(result[0][0]))
2738

2839
def items(self, template):

mamonsu/tools/bootstrap/sql.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
RETURNS void AS $$
2727
UPDATE public.mamonsu_timestamp_master_{1} SET
2828
ts = extract(epoch from now() at time zone 'utc')::double precision,
29-
lsn = pg_catalog.pg_current_xlog_location()
29+
lsn = pg_catalog.pg_current_{4}()
3030
WHERE
3131
id = 1;
3232
$$ LANGUAGE SQL SECURITY DEFINER;
@@ -65,9 +65,9 @@
6565
FROM pg_catalog.pg_stat_activity
6666
$$ LANGUAGE SQL SECURITY DEFINER;
6767
68-
CREATE OR REPLACE FUNCTION public.mamonsu_count_xlog_files()
68+
CREATE OR REPLACE FUNCTION public.mamonsu_count_{3}_files()
6969
RETURNS BIGINT AS $$
70-
WITH list(filename) as (SELECT * FROM pg_catalog.pg_ls_dir('pg_xlog'))
70+
WITH list(filename) as (SELECT * FROM pg_catalog.pg_ls_dir('pg_{3}'))
7171
SELECT
7272
COUNT(*)::BIGINT
7373
FROM
@@ -85,9 +85,7 @@
8585
SUM(CASE isdirty WHEN true THEN 1 ELSE 0 END) * 8 * 1024
8686
FROM public.pg_buffercache
8787
$$ LANGUAGE SQL SECURITY DEFINER;
88-
""".format(
89-
mamonsu_version,
90-
mamonsu_version.replace('.', '_'), '[0-9A-F]{24}')
88+
"""
9189

9290
GrantsOnSchemaSQL = """
9391
ALTER TABLE public.mamonsu_config OWNER TO {1};
@@ -104,7 +102,7 @@
104102
105103
GRANT EXECUTE ON FUNCTION public.mamonsu_get_oldest_query() TO {1};
106104
107-
GRANT EXECUTE ON FUNCTION public.mamonsu_count_xlog_files() TO {1};
105+
GRANT EXECUTE ON FUNCTION public.mamonsu_count_{2}_files() TO {1};
108106
109107
GRANT EXECUTE ON FUNCTION public.mamonsu_buffer_cache() TO {1};
110108
"""

mamonsu/tools/bootstrap/start.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,18 @@ def run_deploy():
146146
sys.exit(1)
147147

148148
if not Pooler.is_superuser():
149-
sys.stderr.write("ERROR: Bootstrap must be run by PostgreSQL superuser\n")
149+
sys.stderr.write(
150+
"ERROR: Bootstrap must be run by PostgreSQL superuser\n")
150151
sys.exit(1)
151152

152153
try:
153-
for sql in CreateSchemaSQL.split(QuerySplit):
154+
for sql in CreateSchemaSQL.format(
155+
mamonsu_version,
156+
mamonsu_version.replace('.', '_'),
157+
'[0-9A-F]{24}',
158+
'wal' if Pooler.server_version_greater('10.0') else 'xlog',
159+
'wal_lsn' if Pooler.server_version_greater('10.0') else 'xlog_location'
160+
).split(QuerySplit):
154161
if args.args.verbose:
155162
sys.stdout.write("\nExecuting query:\n{0}\n".format(sql))
156163
Pooler.query(sql)
@@ -160,7 +167,10 @@ def run_deploy():
160167

161168
try:
162169
for sql in GrantsOnSchemaSQL.format(
163-
mamonsu_version.replace('.', '_'), args.args.mamonsu_username).split(QuerySplit):
170+
mamonsu_version.replace('.', '_'),
171+
args.args.mamonsu_username,
172+
'wal' if Pooler.server_version_greater('10.0') else 'xlog'
173+
).split(QuerySplit):
164174
if args.args.verbose:
165175
sys.stdout.write("\nExecuting query:\n{0}\n".format(sql))
166176
Pooler.query(sql)

packaging/debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
mamonsu (2.3.3-1) stable; urgency=low
2+
3+
* PostgreSQL 10 support
4+
5+
-- PostgresPro DBA <[email protected]> Fri, 19 Jan 2017 11:00:00 +0300
6+
17
mamonsu (2.3.2-1) stable; urgency=low
28

39
* bootstrap fixes

packaging/rpm/SPECS/mamonsu.spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: mamonsu
2-
Version: 2.3.2
2+
Version: 2.3.3
33
Release: 1%{?dist}
44
Summary: Monitoring agent for PostgreSQL
55
Group: Applications/Internet
@@ -70,6 +70,9 @@ chown mamonsu.mamonsu /var/log/mamonsu
7070
/sbin/chkconfig --del mamonsu
7171

7272
%changelog
73+
* Tue Dec 12 2017 Grigory Smolkin <[email protected]> - 2.3.2-1
74+
- PostgreSQL 10 support
75+
7376
* Tue Dec 12 2017 Grigory Smolkin <[email protected]> - 2.3.2-1
7477
- bootstrap fixes
7578

packaging/win/mamonsu.def.nsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
!define NAME Mamonsu
2-
!define VERSION 2.3.2
2+
!define VERSION 2.3.3
33
!define MAMONSU_REG_PATH "Software\PostgresPro\Mamonsu"
44
!define MAMONSU_REG_UNINSTALLER_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall"
55
!define EDB_REG "SOFTWARE\Postgresql"

0 commit comments

Comments
 (0)