Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mstyushin committed Apr 5, 2024
2 parents f569a8e + 63c2887 commit 0656479
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 45 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/mamonsu-tests-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
- docker_os: 'centos:8'
pg_version: '16'
zabbix_version: '6.2.9'
- docker_os: 'centos:8'
pg_version: '16'
zabbix_version: '6.4.13'
exclude:
- docker_os: 'centos:8'
pg_version: '12'
Expand Down Expand Up @@ -74,7 +77,7 @@ jobs:
echo "zabbix_address=$(hostname -I | awk '{print $1}')" >> $GITHUB_OUTPUT
id: zabbix_address
- name: Edit Zabbix address in agent.conf
run: sed -i "s/\(address *= *\).*/\1 ${{ steps.zabbix_address.outputs.zabbix_address }}/" ${{ env.MAMONSU_PATH }}/github-actions-tests/sources/agent_3.5.6.conf
run: sed -i "s/\(address *= *\).*/\1 ${{ steps.zabbix_address.outputs.zabbix_address }}/" ${{ env.MAMONSU_PATH }}/github-actions-tests/sources/agent_3.5.7.conf

- name: Copy test scripts to container
run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) mkdir -p -m 755 /mamonsu/
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/mamonsu-tests-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ jobs:
- docker_os: 'centos:8'
pg_version: '16'
zabbix_version: '6.2.9'
- docker_os: 'centos:8'
pg_version: '16'
zabbix_version: '6.4.13'
- docker_os: 'ubuntu:20.04'
pg_version: '16'
zabbix_version: '6.4.13'
- docker_os: 'ubuntu:20.04'
pg_version: '15'
zabbix_version: '6.4.13'
exclude:
# excludes PG 15, 16 on CentOS
- docker_os: 'centos:7'
Expand Down Expand Up @@ -79,7 +88,7 @@ jobs:
echo "zabbix_address=$(hostname -I | awk '{print $1}')" >> $GITHUB_OUTPUT
id: zabbix_address
- name: Edit Zabbix address in agent.conf
run: sed -i "s/\(address *= *\).*/\1 ${{ steps.zabbix_address.outputs.zabbix_address }}/" ${{ env.MAMONSU_PATH }}/github-actions-tests/sources/agent_3.5.6.conf
run: sed -i "s/\(address *= *\).*/\1 ${{ steps.zabbix_address.outputs.zabbix_address }}/" ${{ env.MAMONSU_PATH }}/github-actions-tests/sources/agent_3.5.7.conf

- name: Copy test scripts to container
run: docker exec $( echo "${{ matrix.docker_os }}" | sed 's/://' | sed 's/\.//' ) mkdir -p -m 755 /mamonsu/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Supported platforms:
- FreeBSD;
- Windows;

Supported Zabbix server versions: 3.0 - 6.0
Supported PostgreSQL versions: 9.5 - 14
Supported Zabbix server versions: 4.0.44 - 6.4.13
Supported PostgreSQL versions: 12 - 16
***

***Table of Contents***
Expand Down
4 changes: 2 additions & 2 deletions github-actions-tests/mamonsu_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if [ "${OS%:*}" = "centos" ]; then
python3 setup.py build && python3 setup.py install
make rpm
sudo rpm -i ./mamonsu*.rpm
cat /mamonsu/github-actions-tests/sources/agent_3.5.6.conf > /etc/mamonsu/agent.conf
cat /mamonsu/github-actions-tests/sources/agent_3.5.7.conf > /etc/mamonsu/agent.conf
systemctl daemon-reload
systemctl restart mamonsu
sleep 5
Expand All @@ -64,7 +64,7 @@ elif [ "${OS%:*}" = "ubuntu" ]; then
python3 setup.py build && python3 setup.py install
make deb
sudo dpkg -i ./mamonsu*.deb
cat /mamonsu/github-actions-tests/sources/agent_3.5.6.conf > /etc/mamonsu/agent.conf
cat /mamonsu/github-actions-tests/sources/agent_3.5.7.conf > /etc/mamonsu/agent.conf
service mamonsu restart
sleep 5
echo && echo && echo "mamonsu version:"
Expand Down
2 changes: 1 addition & 1 deletion mamonsu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__author__ = 'Dmitry Vasilyev'
__author_email__ = '[email protected]'
__description__ = 'Monitoring agent for PostgreSQL'
__version__ = '3.5.6'
__version__ = '3.5.7'
__licence__ = 'BSD'

__url__ = 'https://github.com/postgrespro/mamonsu'
Expand Down
17 changes: 7 additions & 10 deletions mamonsu/plugins/pgsql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class Connections(Plugin):
WHERE (backend_type NOT IN ('{0}'));
""".format("', '".join(default_backend_types))

Max_connections = None

query_agent = """
SELECT count(*)
FROM pg_catalog.pg_stat_activity
Expand Down Expand Up @@ -125,14 +123,13 @@ def run(self, zbx):
"(backend_type = 'client backend' OR backend_type = 'parallel worker')" if Pooler.server_version_greater(
"10.0") else "state IS NOT NULL"))
zbx.send("pgsql.connections[waiting]", int(result[0][0]))
if self.Max_connections is None:
result = Pooler.query("""
SELECT setting
FROM pg_settings
WHERE name = 'max_connections';
""")
self.Max_connections = result[0][0]
zbx.send("pgsql.connections[max_connections]", int(self.Max_connections))

result = Pooler.query("""
SELECT setting
FROM pg_settings
WHERE name = 'max_connections';
""")
zbx.send("pgsql.connections[max_connections]", int(result[0][0]))

if Pooler.server_version_greater("10.0"):
result = Pooler.query(self.query_other_connections)
Expand Down
11 changes: 7 additions & 4 deletions mamonsu/tools/zabbix_cli/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from collections import OrderedDict


from distutils.version import LooseVersion
import urllib.request as urllib2


Expand All @@ -13,20 +14,22 @@ class Request(object):
def __init__(self, url, user, passwd):
self._url, self._user, self._passwd = url, user, passwd
self._id, self._auth_tocken = 0, None

self._api_version = self.post(method='apiinfo.version', params=[])

def set_user(self, user):
self._user=user

def set_passwd(self, passwd):
self._passwd=passwd

def _auth(self):
if self._auth_tocken is None:
if not self._user:
return None
user_field = 'user' if LooseVersion(self._api_version) < LooseVersion('6.4') else 'username'
self._auth_tocken = self.post(
'user.login',
{'user': self._user, 'password': self._passwd})
{user_field: self._user, 'password': self._passwd})
return self._auth_tocken

def _get_id(self):
Expand Down
5 changes: 5 additions & 0 deletions packaging/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
mamonsu (3.5.7-1) stable; urgency=low
* added support for Zabbix 6.4 API: handle deprecated parameters for auth request;
* removed caching of pgsql.connections[max_connections] metric;
* update default logrotate rules;

mamonsu (3.5.6-1) stable; urgency=low
* changed pg_locks plugin metrics names. Warning: custom user-defined triggers and processing functions may be broken if they use item.name parameter.;

Expand Down
27 changes: 5 additions & 22 deletions packaging/rpm/SOURCES/mamonsu-logrotate.in
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/var/log/mamonsu/agent.log {
daily
rotate 7
compress
missingok
notifempty
create 0640 mamonsu mamonsu
sharedscripts
postrotate
[ -e /var/run/mamonsu/mamonsu.pid ] && /etc/init.d/mamonsu restart >/dev/null
endscript
}

/var/log/mamonsu/mamonsu.log {
daily
rotate 7
Expand All @@ -20,15 +7,11 @@
create 0640 mamonsu mamonsu
sharedscripts
postrotate
[ -e /var/run/mamonsu/mamonsu.pid ] && /etc/init.d/mamonsu restart >/dev/null
if [ -d "/run/systemd/system" -a -x "/bin/systemctl" ]; then
/bin/systemctl condrestart mamonsu >/dev/null
else
/etc/init.d/mamonsu condrestart >/dev/null
fi
endscript
}

/var/log/mamonsu/localhost.log {
daily
rotate 7
compress
missingok
notifempty
create 0640 mamonsu mamonsu
}
7 changes: 6 additions & 1 deletion packaging/rpm/SPECS/mamonsu.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mamonsu
Version: 3.5.6
Version: 3.5.7
Release: 1%{?dist}
Summary: Monitoring agent for PostgreSQL
Group: Applications/Internet
Expand Down Expand Up @@ -73,6 +73,11 @@ chown -R mamonsu.mamonsu /var/log/mamonsu
chown -R mamonsu.mamonsu /etc/mamonsu

%changelog
* Fri Apr 5 2024 Maxim Styushin <[email protected]> - 3.5.7-1
- added support for Zabbix 6.4 API: handle deprecated parameters for auth request;
- removed caching of pgsql.connections[max_connections] metric;
- update default logrotate rules;

* Thu Jan 11 2024 Alexandra Kuznetsova <[email protected]> - 3.5.6-1
- changed pg_locks plugin metrics names. Warning: custom user-defined triggers and processing functions may be broken if they use item.name parameter.;

Expand Down
2 changes: 1 addition & 1 deletion packaging/win/mamonsu.def.nsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!define NAME Mamonsu
!define VERSION 3.5.6
!define VERSION 3.5.7
!define MAMONSU_REG_PATH "Software\PostgresPro\Mamonsu"
!define MAMONSU_REG_UNINSTALLER_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall"
!define EDB_REG "SOFTWARE\Postgresql"
Expand Down

0 comments on commit 0656479

Please sign in to comment.