Compare commits
5 Commits
v1.0.3
...
55b9b16deb
| Author | SHA1 | Date | |
|---|---|---|---|
|
55b9b16deb
|
|||
|
6a22597f1f
|
|||
|
295d1d6310
|
|||
|
8b804f3912
|
|||
|
bc9e039cb3
|
@@ -3,7 +3,7 @@ Version: 1.0
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
Depends: logrotate, python3 (>= 3.6), python3-psycopg2, python3-yaml, systemd
|
||||
Depends: logrotate, python3 (>= 3.6), python3-psycopg2, python3-requests, python3-yaml, systemd
|
||||
Maintainer: James Campbell <james@commandprompt.com>
|
||||
Homepage: https://www.commandprompt.com
|
||||
Description: A bridge to sit between monitoring tools and PostgreSQL
|
||||
|
||||
74
GENTOO/pgmon-1.0.3.ebuild
Normal file
74
GENTOO/pgmon-1.0.3.ebuild
Normal file
@@ -0,0 +1,74 @@
|
||||
# Copyright 2024 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
PYTHON_COMPAT=( python3_{6..13} )
|
||||
|
||||
inherit python-r1 systemd
|
||||
|
||||
DESCRIPTION="PostgreSQL monitoring bridge"
|
||||
HOMEPAGE="None"
|
||||
|
||||
LICENSE="BSD"
|
||||
SLOT="0"
|
||||
KEYWORDS="amd64"
|
||||
|
||||
SRC_URI="https://code2.shh-dot-com.org/james/${PN}/releases/download/v${PV}/${P}.tar.bz2"
|
||||
|
||||
IUSE="-systemd"
|
||||
|
||||
DEPEND="
|
||||
${PYTHON_DEPS}
|
||||
dev-python/psycopg:2
|
||||
dev-python/pyyaml
|
||||
dev-python/requests
|
||||
app-admin/logrotate
|
||||
"
|
||||
RDEPEND="${DEPEND}"
|
||||
BDEPEND=""
|
||||
|
||||
#RESTRICT="fetch"
|
||||
|
||||
#S="${WORKDIR}/${PN}"
|
||||
|
||||
#pkg_nofetch() {
|
||||
# einfo "Please download"
|
||||
# einfo " - ${P}.tar.bz2"
|
||||
# einfo "from ${HOMEPAGE} and place it in your DISTDIR directory."
|
||||
# einfo "The file should be owned by portage:portage."
|
||||
#}
|
||||
|
||||
src_compile() {
|
||||
true
|
||||
}
|
||||
|
||||
src_install() {
|
||||
# Install init script
|
||||
if ! use systemd ; then
|
||||
newinitd "openrc/pgmon.initd" pgmon
|
||||
newconfd "openrc/pgmon.confd" pgmon
|
||||
fi
|
||||
|
||||
# Install systemd unit
|
||||
if use systemd ; then
|
||||
systemd_dounit "systemd/pgmon.service"
|
||||
fi
|
||||
|
||||
# Install script
|
||||
exeinto /usr/bin
|
||||
newexe "src/pgmon.py" pgmon
|
||||
|
||||
# Install default config
|
||||
diropts -o root -g root -m 0755
|
||||
insinto /etc/pgmon
|
||||
doins "sample-config/pgmon.yml"
|
||||
doins "sample-config/pgmon-metrics.yml"
|
||||
|
||||
# Install logrotate config
|
||||
insinto /etc/logrotate.d
|
||||
newins "logrotate/pgmon.logrotate" pgmon
|
||||
|
||||
# Install man page
|
||||
doman manpages/pgmon.1
|
||||
}
|
||||
49
Makefile
49
Makefile
@@ -23,7 +23,7 @@ SUPPORTED := ubuntu-20.04 \
|
||||
# These targets are the main ones to use for most things.
|
||||
##
|
||||
|
||||
.PHONY: all clean tgz test query-tests install
|
||||
.PHONY: all clean tgz test query-tests install-common install-openrc install-systemd
|
||||
|
||||
|
||||
# Build all packages
|
||||
@@ -34,7 +34,7 @@ all: $(foreach distro_release, $(SUPPORTED), package-$(distro_release))
|
||||
.PHONY: package-gentoo
|
||||
package-gentoo:
|
||||
mkdir -p $(BUILD_DIR)/gentoo
|
||||
tar --transform "s,^\.,$(PACKAGE_NAME)-$(VERSION)," -acjf $(BUILD_DIR)/gentoo/$(PACKAGE_NAME)-$(VERSION).tar.bz2 --exclude .gitignore $(shell git ls-tree --full-tree --name-only -r HEAD)
|
||||
tar --transform "s,^,$(PACKAGE_NAME)-$(VERSION)/," -acjf $(BUILD_DIR)/gentoo/$(PACKAGE_NAME)-$(VERSION).tar.bz2 --exclude .gitignore $(shell git ls-tree --full-tree --name-only -r HEAD)
|
||||
|
||||
|
||||
# Create a deb package
|
||||
@@ -54,7 +54,7 @@ package-%:
|
||||
tgz:
|
||||
rm -rf $(BUILD_DIR)/tgz/root
|
||||
mkdir -p $(BUILD_DIR)/tgz/root
|
||||
$(MAKE) install DESTDIR=$(BUILD_DIR)/tgz/root
|
||||
$(MAKE) install-openrc DESTDIR=$(BUILD_DIR)/tgz/root
|
||||
tar -cz -f $(BUILD_DIR)/tgz/$(PACKAGE_NAME)-$(VERSION).tgz -C $(BUILD_DIR)/tgz/root .
|
||||
|
||||
# Clean up the build directory
|
||||
@@ -69,18 +69,17 @@ test:
|
||||
query-tests:
|
||||
cd tests ; ./run-tests.sh
|
||||
|
||||
# Install the script at the specified base directory
|
||||
install:
|
||||
# Install the script at the specified base directory (common components)
|
||||
install-common:
|
||||
# Set up directories
|
||||
mkdir -p $(DESTDIR)/etc/$(PACKAGE_NAME)
|
||||
mkdir -p ${DESTDIR}/etc/logrotate.d
|
||||
mkdir -p $(DESTDIR)/lib/systemd/system
|
||||
mkdir -p $(DESTDIR)/usr/local/bin
|
||||
mkdir -p $(DESTDIR)/usr/bin
|
||||
mkdir -p $(DESTDIR)/usr/share/man/man1
|
||||
|
||||
# Install script
|
||||
cp $(SCRIPT) $(DESTDIR)/usr/local/bin/$(PACKAGE_NAME)
|
||||
chmod 755 $(DESTDIR)/usr/local/bin/$(PACKAGE_NAME)
|
||||
cp $(SCRIPT) $(DESTDIR)/usr/bin/$(PACKAGE_NAME)
|
||||
chmod 755 $(DESTDIR)/usr/bin/$(PACKAGE_NAME)
|
||||
|
||||
# Install manpage
|
||||
cp manpages/* $(DESTDIR)/usr/share/man/man1/
|
||||
@@ -89,11 +88,35 @@ install:
|
||||
# Install sample config
|
||||
cp sample-config/* $(DESTDIR)/etc/$(PACKAGE_NAME)/
|
||||
|
||||
# Install logrotate config
|
||||
cp logrotate/${PACKAGE_NAME}.logrotate ${DESTDIR}/etc/logrotate.d/${PACKAGE_NAME}
|
||||
|
||||
# Install for systemd
|
||||
install-systemd:
|
||||
# Install the common stuff
|
||||
$(MAKE) install-common
|
||||
|
||||
# Set up directories
|
||||
mkdir -p $(DESTDIR)/lib/systemd/system
|
||||
|
||||
# Install systemd unit files
|
||||
cp systemd/* $(DESTDIR)/lib/systemd/system/
|
||||
|
||||
# Install logrotate config
|
||||
cp logrotate/${PACKAGE_NAME}.logrotate ${DESTDIR}/etc/logrotate.d/${PACKAGE_NAME}
|
||||
# Install for open-rc
|
||||
install-openrc:
|
||||
# Install the common stuff
|
||||
$(MAKE) install-common
|
||||
|
||||
# Set up directories
|
||||
mkdir -p $(DESTDIR)/etc/init.d
|
||||
mkdir -p $(DESTDIR)/etc/conf.d
|
||||
|
||||
# Install init script
|
||||
cp openrc/pgmon.initd $(DESTDIR)/etc/init.d/pgmon
|
||||
chmod 755 $(DESTDIR)/etc/init.d/pgmon
|
||||
|
||||
# Install init script config file
|
||||
cp openrc/pgmon.confd $(DESTDIR)/etc/conf.d/pgmon
|
||||
|
||||
|
||||
# Run all of the install tests
|
||||
@@ -167,7 +190,7 @@ package-image-%:
|
||||
|
||||
# Debian package creation
|
||||
actually-package-debian-%:
|
||||
$(MAKE) install DESTDIR=/output/debian-$*
|
||||
$(MAKE) install-systemd DESTDIR=/output/debian-$*
|
||||
cp -r --preserve=mode DEBIAN /output/debian-$*/
|
||||
dpkg-deb -Zgzip --build /output/debian-$* "/output/$(PACKAGE_NAME)-$(VERSION)-debian-$*.deb"
|
||||
|
||||
@@ -182,7 +205,7 @@ actually-package-rockylinux-%:
|
||||
|
||||
# Ubuntu package creation
|
||||
actually-package-ubuntu-%:
|
||||
$(MAKE) install DESTDIR=/output/ubuntu-$*
|
||||
$(MAKE) install-systemd DESTDIR=/output/ubuntu-$*
|
||||
cp -r --preserve=mode DEBIAN /output/ubuntu-$*/
|
||||
dpkg-deb -Zgzip --build /output/ubuntu-$* "/output/$(PACKAGE_NAME)-$(VERSION)-ubuntu-$*.deb"
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ License: MIT
|
||||
URL: https://www.commandprompt.com
|
||||
|
||||
BuildArch: noarch
|
||||
Requires: logrotate, python, python-psycopg2, PyYAML, systemd
|
||||
Requires: logrotate, python, python-psycopg2, PyYAML, python-requests, systemd
|
||||
|
||||
%description
|
||||
A bridge to sit between monitoring tools and PostgreSQL
|
||||
@@ -19,7 +19,7 @@ A bridge to sit between monitoring tools and PostgreSQL
|
||||
# Do nothing since we have nothing to build
|
||||
|
||||
%install
|
||||
make -C /src install DESTDIR=%{buildroot}
|
||||
make -C /src install-systemd DESTDIR=%{buildroot}
|
||||
|
||||
%files
|
||||
/etc/logrotate.d/pgmon
|
||||
@@ -28,7 +28,7 @@ make -C /src install DESTDIR=%{buildroot}
|
||||
/etc/pgmon/pgmon-service.conf
|
||||
/lib/systemd/system/pgmon.service
|
||||
/lib/systemd/system/pgmon@.service
|
||||
/usr/local/bin/pgmon
|
||||
/usr/bin/pgmon
|
||||
/usr/share/man/man1/pgmon.1.gz
|
||||
|
||||
%post
|
||||
|
||||
@@ -7,7 +7,7 @@ License: MIT
|
||||
URL: https://www.commandprompt.com
|
||||
|
||||
BuildArch: noarch
|
||||
Requires: logrotate, python3, python3-psycopg2, python3-pyyaml, systemd
|
||||
Requires: logrotate, python3, python3-psycopg2, python3-pyyaml, python3-requests, systemd
|
||||
|
||||
%description
|
||||
A bridge to sit between monitoring tools and PostgreSQL
|
||||
@@ -19,7 +19,7 @@ A bridge to sit between monitoring tools and PostgreSQL
|
||||
# Do nothing since we have nothing to build
|
||||
|
||||
%install
|
||||
make -C /src install DESTDIR=%{buildroot}
|
||||
make -C /src install-systemd DESTDIR=%{buildroot}
|
||||
|
||||
%files
|
||||
/etc/logrotate.d/pgmon
|
||||
@@ -28,7 +28,7 @@ make -C /src install DESTDIR=%{buildroot}
|
||||
/etc/pgmon/pgmon-service.conf
|
||||
/lib/systemd/system/pgmon.service
|
||||
/lib/systemd/system/pgmon@.service
|
||||
/usr/local/bin/pgmon
|
||||
/usr/bin/pgmon
|
||||
/usr/share/man/man1/pgmon.1.gz
|
||||
|
||||
%post
|
||||
|
||||
@@ -22,7 +22,7 @@ metrics:
|
||||
max_frozen_age:
|
||||
type: row
|
||||
query:
|
||||
0: SELECT max(age(datfrozenxid)), max(mxid_age(datminmxid)) FROM pg_database
|
||||
0: SELECT max(age(datfrozenxid)) AS xid_age, max(mxid_age(datminmxid)) AS mxid_age FROM pg_database
|
||||
|
||||
# Per-database metrics
|
||||
db_stats:
|
||||
@@ -47,12 +47,6 @@ metrics:
|
||||
test_args:
|
||||
repid: 127.0.0.1_test_rep
|
||||
|
||||
# Debugging
|
||||
sleep:
|
||||
type: value
|
||||
query:
|
||||
0: SELECT now(), pg_sleep(5);
|
||||
|
||||
# Per-slot metrics
|
||||
slot_stats:
|
||||
type: row
|
||||
|
||||
@@ -7,7 +7,7 @@ After=network.target
|
||||
[Service]
|
||||
EnvironmentFile=/etc/pgmon/%i-service.conf
|
||||
User=${SERVICE_USER:-postgres}
|
||||
ExecStart=/usr/local/bin/pgmon -c /etc/pgmon/%i.yml
|
||||
ExecStart=/usr/bin/pgmon -c /etc/pgmon/%i.yml
|
||||
ExecReload=kill -HUP $MAINPID
|
||||
Restart=on-failure
|
||||
Type=exec
|
||||
|
||||
@@ -2,6 +2,7 @@ FROM alpine:3.21
|
||||
|
||||
RUN apk update && \
|
||||
apk add py3-psycopg2 \
|
||||
py3-requests \
|
||||
py3-yaml \
|
||||
tini
|
||||
|
||||
|
||||
@@ -11,6 +11,44 @@ zabbix_export:
|
||||
groups:
|
||||
- name: 'My Templates'
|
||||
items:
|
||||
- uuid: cc4a50ca681b4c4fb8c1c98f4bc81c96
|
||||
name: 'Max Frozen MXID Age'
|
||||
type: DEPENDENT
|
||||
key: pgmon.age.mxid
|
||||
delay: '0'
|
||||
history: 90d
|
||||
description: 'Maximum age of any frozen MXID in any database'
|
||||
preprocessing:
|
||||
- type: JSONPATH
|
||||
parameters:
|
||||
- $.mxid_age
|
||||
- type: MATCHES_REGEX
|
||||
parameters:
|
||||
- '^[0-9]+$'
|
||||
master_item:
|
||||
key: 'pgmon[max_frozen_age]'
|
||||
tags:
|
||||
- tag: Application
|
||||
value: PostgreSQL
|
||||
- uuid: 2fa86d8c4a3a481e856a9414c5c70216
|
||||
name: 'Max Frozen XID Age'
|
||||
type: DEPENDENT
|
||||
key: pgmon.age.xid
|
||||
delay: '0'
|
||||
history: 90d
|
||||
description: 'Maximum age of any frozen XID in any database'
|
||||
preprocessing:
|
||||
- type: JSONPATH
|
||||
parameters:
|
||||
- $.xid_age
|
||||
- type: MATCHES_REGEX
|
||||
parameters:
|
||||
- '^[0-9]+$'
|
||||
master_item:
|
||||
key: 'pgmon[max_frozen_age]'
|
||||
tags:
|
||||
- tag: Application
|
||||
value: PostgreSQL
|
||||
- uuid: de1fa757395440118026f4c7a7c4ebbe
|
||||
name: 'PostgreSQL latest supported version'
|
||||
type: DEPENDENT
|
||||
@@ -71,15 +109,14 @@ zabbix_export:
|
||||
- tag: Application
|
||||
value: PostgreSQL
|
||||
- uuid: 8706eccb7edc4fa394f552fc31f401a9
|
||||
name: 'Max Frozen XID Age'
|
||||
name: 'PostgreSQL ID Age Info'
|
||||
type: HTTP_AGENT
|
||||
key: 'pgmon[max_frozen_age]'
|
||||
history: 90d
|
||||
description: 'Maximum age of any frozen XID in any database'
|
||||
preprocessing:
|
||||
- type: MATCHES_REGEX
|
||||
parameters:
|
||||
- '^[0-9]+$'
|
||||
delay: 5m
|
||||
history: '0'
|
||||
value_type: TEXT
|
||||
trends: '0'
|
||||
description: 'Maximum age of any frozen XID and MXID in any database'
|
||||
url: 'http://localhost:{$AGENT_PORT}/max_frozen_age'
|
||||
tags:
|
||||
- tag: Application
|
||||
|
||||
Reference in New Issue
Block a user