-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6135dc0
commit 5c0ff3f
Showing
6 changed files
with
190 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2019 Jesper Pedersen <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the "Software"), | ||
# to deal in the Software without restriction, including without limitation | ||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
# and/or sell copies of the Software, and to permit persons to whom the Software | ||
# is furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
# pgsql11-pgexporter-centos7 | ||
FROM centos:centos7 | ||
|
||
LABEL maintainer="Jesper Pedersen <[email protected]>" | ||
|
||
LABEL summary="PostgreSQL 11 postgres_exporter" \ | ||
description="PostgreSQL 11 postgres_exporter" | ||
|
||
# COPY conf/licenses /licenses | ||
|
||
ENV PGVERSION="11" | ||
ENV PGROOT="/usr/pgsql-${PGVERSION}" | ||
|
||
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ | ||
&& rpm -Uvh https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm \ | ||
&& yum -y install wget tar \ | ||
&& yum -y update \ | ||
&& yum -y clean all | ||
|
||
COPY root/ / | ||
|
||
RUN mkdir -p /usr/local/bin | ||
RUN cd /tmp \ | ||
&& wget https://github.com/wrouesnel/postgres_exporter/releases/download/v0.4.7/postgres_exporter_v0.4.7_linux-amd64.tar.gz \ | ||
&& tar xzf postgres_exporter_v0.4.7_linux-amd64.tar.gz \ | ||
&& mv postgres_exporter_v0.4.7_linux-amd64/postgres_exporter /usr/local/bin/postgres_exporter \ | ||
&& rm -Rf postgres_exporter_v0.4.7_linux-amd64 postgres_exporter_v0.4.7_linux-amd64.tar.gz \ | ||
&& chown daemon:daemon /usr/local/bin/postgres_exporter | ||
|
||
EXPOSE 9187 | ||
|
||
USER 2 | ||
|
||
CMD ["/usr/bin/run-pgexporter"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2019 Jesper Pedersen <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the "Software"), | ||
# to deal in the Software without restriction, including without limitation | ||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
# and/or sell copies of the Software, and to permit persons to whom the Software | ||
# is furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
IMAGE_NAME = pgsql11-pgexporter-centos7 | ||
|
||
.PHONY: build | ||
build: | ||
podman build --no-cache -t $(IMAGE_NAME) . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# PostgreSQL postgres_exporter | ||
|
||
This project contains the PostgreSQL postgres_exporter image. | ||
|
||
## Getting Started | ||
|
||
```bash | ||
# Create the image | ||
make build | ||
|
||
# Run, and register the container under postgresql-pgexporter | ||
podman run -p 9187:9187 --name postgresql-pgexporter -d -e PG_SERVER_NAME=192.168.1.2 -e PG_SERVER_PORT=5432 -e PG_MONITOR_NAME=monuser -e PG_MONITOR_PASSWORD=monpass pgsql11-pgexporter-centos7 | ||
|
||
# Shell to postgresql- | ||
podman exec -it postgresql-pgexporter /usr/bin/bash | ||
|
||
# Stop the container | ||
podman stop postgresql-pgexporter | ||
|
||
# Start the container | ||
podman start postgresql-pgexporter | ||
|
||
# Remove the container | ||
podman rm postgresql-pgexporter | ||
``` | ||
|
||
## Configuration | ||
|
||
| Property | Default | Unit | Required | Description | | ||
|----------|---------|------|----------|-------------| | ||
| PG_SERVER_NAME | | | Yes | The IP of the PostgreSQL server | | ||
| PG_SERVER_PORT | | | Yes | The port of the PostgreSQL server | | ||
| PG_MONITOR_NAME | | | Yes | The name of the monitor user | | ||
| PG_MONITOR_PASSWORD | | | Yes | The password of the monitor user | | ||
|
||
|
||
Note, that `PG_PASSWORD_ENCRYPTION` needs to be set to `md5` for now. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2019 Jesper Pedersen <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the "Software"), | ||
# to deal in the Software without restriction, including without limitation | ||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
# and/or sell copies of the Software, and to permit persons to whom the Software | ||
# is furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
|
||
POSTGRES_EXPORTER_PIDFILE=/tmp/postgres_exporter.pid | ||
|
||
function trap_sigterm() { | ||
kill -SIGINT $(head -1 $POSTGRES_EXPORTER_PIDFILE) | ||
} | ||
|
||
trap 'trap_sigterm' SIGINT SIGTERM | ||
|
||
export PG_SERVER_NAME=${PG_SERVER_NAME} | ||
export PG_SERVER_PORT=${PG_SERVER_PORT} | ||
export PG_MONITOR_NAME=${PG_MONITOR_NAME} | ||
export PG_MONITOR_PASSWORD=${PG_MONITOR_PASSWORD} | ||
|
||
if [ -z "${PG_SERVER_NAME}" ] || [ -z "${PG_SERVER_PORT}" ] || | ||
[ -z "${PG_MONITOR_NAME}" ] || [ -z "${PG_MONITOR_PASSWORD}" ]; then | ||
echo "PG_SERVER_NAME, PG_SERVER_PORT, PG_MONITOR_NAME and PG_MONITOR_PASSWORD needs to be defined." | ||
exit 1 | ||
fi | ||
|
||
export DATA_SOURCE_NAME="postgresql://$PG_MONITOR_NAME:$PG_MONITOR_PASSWORD@$PG_SERVER_NAME:$PG_SERVER_PORT/postgres?sslmode=disable" | ||
|
||
/usr/local/bin/postgres_exporter >> /tmp/postgres_exporter.log 2>&1 & | ||
echo $! > $POSTGRES_EXPORTER_PIDFILE | ||
|
||
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters