From 972916463b1e4b8c375744a67f1894594571dc6c Mon Sep 17 00:00:00 2001 From: James Campbell Date: Mon, 3 Jun 2024 01:10:45 -0400 Subject: [PATCH] Improve Gentoo ebuild --- gentoo/files/pgmon.cfg | 70 ++++++++++++++++++++++++++++++++++++ gentoo/files/pgmon.logrotate | 10 ++++++ gentoo/files/pgmon.openrc | 3 +- gentoo/pgmon-0.0.1.ebuild | 39 ++++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 gentoo/files/pgmon.cfg create mode 100644 gentoo/files/pgmon.logrotate diff --git a/gentoo/files/pgmon.cfg b/gentoo/files/pgmon.cfg new file mode 100644 index 0000000..1c3c2bd --- /dev/null +++ b/gentoo/files/pgmon.cfg @@ -0,0 +1,70 @@ +## +# Misc agent settings +## + +# Where to write/find the agent PID +#pid_file=/tmt/pgmon.pid +pid_file=/run/pgmon/pgmon.pid + +## +# Agent communication settings +## + +# IPC socket +#ipc_socket=/tmp/pgmon.sock +ipc_socket=/run/pgmon/pgmon.sock + +# IPC communication timeout (s) +#ipc_timeout=10 + +# Request processing timeout (s) +#request_timeout=10 + +# Max size of the request queue before it blocks +#request_queue_size=100 + +# Max time to wait when queueing a request (s) +#request_queue_timeout=2 + +## +# Agent resource settings +## + +# Number of worker threads +#worker_count=4 + +## +# Logging settings +## + +# Log level for stderr logging (or 'off') +stderr_log_level=info + +# Log level for file logging (od 'off') +file_log_level=notice + +# Log file +#log_file=pgmon.log + +## +# DB connection settings +# +# Each cluster entry is of the form: +# name:address:port:dbname:user:password +# +# Any element other than the name can be left empty to use the defaults +## + +#cluster=local:/var/run/postgresql:5432:postgres:zbx_monitor: + +# Default database to connect to when none is specified for a metric +#dbname=postgres + +## +# Monitoring configuration +## + +# Metrics +#metrics={} + +include=pgmon-metrics.cfg diff --git a/gentoo/files/pgmon.logrotate b/gentoo/files/pgmon.logrotate new file mode 100644 index 0000000..6af0fb5 --- /dev/null +++ b/gentoo/files/pgmon.logrotate @@ -0,0 +1,10 @@ +/var/log/pgmon/*.log { + daily + missingok + rotate 7 + compress + delaycompress + copytruncate + notifempty + maxsize 1G +} diff --git a/gentoo/files/pgmon.openrc b/gentoo/files/pgmon.openrc index 760bcd4..67fe873 100644 --- a/gentoo/files/pgmon.openrc +++ b/gentoo/files/pgmon.openrc @@ -12,7 +12,8 @@ command_user="zabbix:zabbix" pidfile="/run/pgmon/${agent_name}.pid" start_pre() { - checkpath -d "/run/pgmon" + checkpath -d -m 0755 -o "${command_user}" "/run/pgmon" + checkpath -d -m 0755 -o "${command_user}" "/var/log/pgmon" } reload() { diff --git a/gentoo/pgmon-0.0.1.ebuild b/gentoo/pgmon-0.0.1.ebuild index 59b3599..49375b5 100644 --- a/gentoo/pgmon-0.0.1.ebuild +++ b/gentoo/pgmon-0.0.1.ebuild @@ -17,9 +17,48 @@ KEYWORDS="amd64" EGIT_REPO_URL="https://code2.shh-dot-com.org/pgmon.git" #EGIT_COMMIT="" +IUSE="+agent agent2" + DEPEND=" ${PYTHON_DEPS} dev-python/psycopg:2 + acct-user/zabbix + acct-group/zabbix + agent? ( net-analyzer/zabbix[agent] ) + agent2? ( net-analyzer/zabbix[agent2] ) + app-admin/logrotate " RDEPEND="${DEPEND}" BDEPEND="" + +src_install() { + default + + # Install init script + newinitd files/pgmon.openrc pgmon + + # Install default config + diropts -o root -g zabbix -m 0755 + insinto /etc/pgmon + doins "${FILESDIR}/pgmon.cfg" + doins "${S}/pgmon-metrics.cfg" + + # Install Zabbix userparams file + if use agent; then + insinto /etc/zabbix/zabbix_agent.d + newins "${S}/pgmon_userparameter.conf" pgmon.conf + fperms 0644 /etc/zabbix/zabbix_agent.d/pgmon.conf + fowners root:zabbix /etc/zabbix/zabbix_agent.d/pgmon.conf + fi + + if use agent2; then + insinto /etc/zabbix/zabbix_agent2.d + newins "${S}/pgmon_userparameter.conf" pgmon.conf + fperms 0644 /etc/zabbix/zabbix_agent2.d/pgmon.conf + fowners root:zabbix /etc/zabbix/zabbix_agent2.d/pgmon.conf + fi + + # Install logrotate config + insinto /etc/logrotate.d + newins "${FILESDIR}/pgmon.logrotate" pgmon +}