Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/docker/centreon-engine/bookworm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
FROM debian:12-slim

ARG STABILITY
ARG VERSION
ARG IS_CLOUD


ENV DEBIAN_FRONTEND=noninteractive

RUN --mount=type=secret,id=ARTIFACTORY_INTERNAL_REPO_USERNAME \
--mount=type=secret,id=ARTIFACTORY_INTERNAL_REPO_PASSWORD \
--mount=type=bind,src=packages-centreon,dst=/tmp/packages-centreon bash -e <<EOF

echo 'Acquire::Retries "10"; \
Acquire::https::Timeout "300"; \
Acquire::http::Timeout "300"; \
APT::Install-Recommends "false"; \
APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/99custom

VERSION_CODENAME=\$(
. /etc/os-release
echo \$VERSION_CODENAME
)

if [[ "${IS_CLOUD}" == "true" ]]; then
echo "deb https://$(cat /run/secrets/ARTIFACTORY_INTERNAL_REPO_USERNAME):$(cat /run/secrets/ARTIFACTORY_INTERNAL_REPO_PASSWORD)@packages.centreon.com/apt-standard-internal-unstable/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-unstable.list
else
echo "deb https://packages.centreon.com/apt-standard-${VERSION}-stable/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-stable.list
echo "deb https://packages.centreon.com/apt-standard-${VERSION}-testing/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-testing.list
echo "deb https://packages.centreon.com/apt-standard-${VERSION}-unstable/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-unstable.list
fi
echo "deb https://packages.centreon.com/apt-plugins-stable/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-plugins-stable.list
echo "deb https://packages.centreon.com/apt-plugins-testing/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-plugins-testing.list
echo "deb https://packages.centreon.com/apt-plugins-unstable/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-plugins-unstable.list
wget -O- https://packages.centreon.com/api/security/keypair/APT-GPG-KEY/public | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1

if [[ "$STABILITY" == "testing" ]]; then
for i in \$( ls /etc/apt/sources.list.d/centreon*unstable* ); do mv \$i \$i.disabled; done
elif [[ "$STABILITY" == "stable" ]]; then
for i in \$( ls /etc/apt/sources.list.d/centreon*{unstable,testing}* ); do mv \$i \$i.disabled; done
fi

groupadd -g 6000 centreon
useradd -u 6000 -g centreon -m -r -d /var/spool/centreon -c "Centreon" -s /bin/bash centreon
groupadd -g 6001 centreon-engine
useradd -u 6001 -g centreon-engine -m -r -d /var/lib/centreon-engine -c "Centreon Engine" -s /bin/bash centreon-engine
groupadd -g 6002 centreon-broker
useradd -u 6002 -g centreon-broker -m -r -d /var/lib/centreon-broker -c "Centreon Broker" -s /bin/bash centreon-broker
groupadd -g 6003 centreon-gorgone
useradd -u 6003 -g centreon-gorgone -m -r -d /var/lib/centreon-gorgone -c "Centreon Gorgone" -s /bin/bash centreon-gorgone

apt-get update
apt-get install -y \
lsb-release \
ca-certificates \
apt-transport-https \
software-properties-common \
wget \
gnupg2 \
curl \
libmariadb3 \
monitoring-plugins-basic \
python3 \
python3-venv \
iputils-ping

apt-get install -y /tmp/packages-centreon/centreon-engine-daemon*.deb
apt-get clean

mkdir -p /etc/centreon-broker/ /var/log/centreon-engine/ /var/log/centreon-broker/ /var/lib/centreon-engine/rw
touch /var/log/centreon-engine/retention.dat
chown -R centreon-engine:centreon-engine /etc/centreon-engine
chmod 775 /etc/centreon-engine /etc/centreon-broker
chmod +x /usr/share/centreon/lib/centreon-broker/*

EOF

COPY --chmod=755 ./.github/docker/centreon-engine/bookworn/entrypoint /usr/share/centreon
#COPY --chmod=600 ./.github/docker/centreon-poller/sudoersCentreon /etc/sudoers.d/centreon
COPY --chmod=755 ./.github/docker/centreon-engine/scripts/api_control.py /var/lib/centreon-engine/api_control.py

ENTRYPOINT ["/usr/share/centreon/entrypoint.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

rm -f /tmp/docker.ready
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

python3 -m venv .
source bin/activate
pip install --upgrade pip
pip install fastapi uvicorn

# Lancer l’API
uvicorn api_control:app --host 0.0.0.0 --port 8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh

WEB_HOST=${WEB_HOST:-web}
WEB_GORGONE_PORT=${WEB_GORGONE_PORT:-8085}
WEB_API_USERNAME=${WEB_API_USERNAME:-admin}
WEB_API_PASSWORD=${WEB_API_PASSWORD:-Centreon\!2021}

if getent hosts "${WEB_HOST}"; then
# Set HOSTNAME if not already set
: "${HOSTNAME:=$(hostname)}"

API_RESPONSE=$(curl -s -X POST --insecure -H "Content-Type: application/json" \
-d "{\"security\":{\"credentials\":{\"login\":\"${WEB_API_USERNAME}\", \"password\":\"${WEB_API_PASSWORD}\"}}}" \
"http://${WEB_HOST}/centreon/api/latest/login")

API_TOKEN=$(echo "${API_RESPONSE}" | grep -o '"token":"[^"]*' | cut -d'"' -f4)

PAYLOAD='{"name":"'"$HOSTNAME"'","hostname":"'"$HOSTNAME"'","type":"'"poller"'","address":"'"$HOSTNAME"'","parent_address":"'"127.0.0.1"'"}'

curl -s -X POST --insecure -H "Content-Type: application/json" -H "X-AUTH-TOKEN: ${API_TOKEN}" \
-d "${PAYLOAD}" \
"http://${WEB_HOST}/centreon/api/latest/platform/topology"

CENTRAL_IP_ADDRESS=$(getent hosts "${WEB_HOST}" | awk '{print $1;}') || {
echo "Failed to resolve ${WEB_HOST} hostname"
exit 1
}

curl -s -X POST --insecure -H "Content-Type: application/json" -H "centreon-auth-token: ${API_TOKEN}" \
-d "{\"linked_remote_master\":\"\",\"linked_remote_slaves\":[],\"open_broker_flow\":false,\"centreon_central_ip\":\"${CENTRAL_IP_ADDRESS}\",\"server_ip\":\"$HOSTNAME\",\"server_name\":\"$HOSTNAME\",\"server_type\":\"poller\"}" \
"http://${WEB_HOST}/centreon/api/index.php?object=centreon_configuration_remote&action=linkCentreonRemoteServer"

MAX_RETRIES=120
retry_count=0
until [ "$THUMBPRINT" != '' ] || [ $retry_count -ge $MAX_RETRIES ]; do
sleep 1
API_RESPONSE=$(curl -s -X GET -H "accept: application/json" "http://${WEB_HOST}:${WEB_GORGONE_PORT}/api/internal/thumbprint")
THUMBPRINT=$(echo $API_RESPONSE | grep -o '"thumbprint":\"[^\"]*' | cut -d'"' -f4)
retry_count=$((retry_count + 1))
done
if [ -z "$THUMBPRINT" ]; then
echo "Failed to retrieve thumbprint after $MAX_RETRIES attempts"
exit 1
fi

cat <<EOF > /etc/centreon-gorgone/config.d/40-gorgoned.yaml
name: gorgoned-$HOSTNAME
description: Configuration for poller $HOSTNAME
gorgone:
gorgonecore:
id: 2
external_com_type: tcp
external_com_path: "*:5556"
authorized_clients:
- key: $THUMBPRINT
privkey: "/var/lib/centreon-gorgone/.keys/rsakey.priv.pem"
pubkey: "/var/lib/centreon-gorgone/.keys/rsakey.pub.pem"
modules:
- name: engine
package: gorgone::modules::centreon::engine::hooks
enable: true
command_file: "/var/lib/centreon-engine/rw/centengine.cmd"

EOF

systemctl start gorgoned

until [ "$PING_OK" -gt "0" ] 2>/dev/null; do
sleep 5
PING_OK=$(curl -s -X GET -H "accept: application/json" "http://${WEB_HOST}:${WEB_GORGONE_PORT}/api/internal/constatus" | grep -o '"ping_ok":[0-9]*' | cut -d':' -f2)
if [ "$PING_OK" -gt "0" ] 2>/dev/null; then
for action in POLLERGENERATE CFGMOVE POLLERRESTART; do
curl -X POST --insecure -H "Content-Type: application/json" -H "centreon-auth-token: ${API_TOKEN}" \
-d "{\"action\":\"$action\",\"values\":\"$HOSTNAME\"}" \
"http://${WEB_HOST}/centreon/api/index.php?action=action&object=centreon_clapi"
done
fi
done
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

touch /tmp/docker.ready
echo "Centreon is ready"

tail -f \
/var/log/centreon-engine/centengine.log
23 changes: 23 additions & 0 deletions .github/docker/centreon-engine/bookworm/entrypoint/container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

set -e
[ "${DEBUG:-0}" = "1" ] && set -x

# Run each startup script located in BASEDIR.
# ls is required to ensure that the scripts are properly sorted by name.
BASEDIR="/usr/share/centreon/container.d"
for file in `ls $BASEDIR` ; do
case "$file" in
*_background*)
# Execute background script and store PID
. "$BASEDIR/$file" &
echo $! >> /tmp/background_pids
;;
*)
if ! . "$BASEDIR/$file"; then
echo "Error executing $file"
exit 1
fi
;;
esac
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

python3 -m venv .
source bin/activate
pip install --upgrade pip
pip install fastapi uvicorn

# Lancer l’API
uvicorn api_control:app --host 0.0.0.0 --port 8000
42 changes: 42 additions & 0 deletions .github/docker/centreon-engine/scripts/api_control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from fastapi import FastAPI
import subprocess
import os
import signal

app = FastAPI()
centengine_proc = None

@app.on_event("startup")
def start_centengine():
global centengine_proc
centengine_proc = subprocess.Popen(
["/usr/sbin/centengine", "/etc/centreon-engine/centengine.cfg"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=os.setpgrp
)

@app.post("/restart")
def restart_centengine():
global centengine_proc
# Stop only the process we started
if centengine_proc is not None:
centengine_proc.terminate() # sends SIGTERM
try:
centengine_proc.wait(timeout=5)
except Exception:
pass
# Start centengine detached
centengine_proc = subprocess.Popen(
["/usr/sbin/centengine", "/etc/centreon-engine/centengine.cfg"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=os.setpgrp
)
return {
"start_pid": centengine_proc.pid
}

@app.post("/reload")
def reload_centengine():
global centengine_proc
if centengine_proc is not None:
centengine_proc.send_signal(signal.SIGHUP)
return {"reload": "sent SIGHUP"}
return {"reload": "centengine not running"}
10 changes: 0 additions & 10 deletions gorgone/packaging/centreon-gorgone-centreon-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ contents:
scripts:
postinstall: ./scripts/centreon-gorgone-centreon-config-postinstall.sh

overrides:
rpm:
depends:
- centreon-gorgone = ${VERSION}-${RELEASE}${DIST}
deb:
depends:
- centreon-gorgone (= ${VERSION}-${RELEASE}${DIST})
replaces:
- centreon-gorgone (<< 24.11.0)

deb:
breaks:
- centreon-gorgone (<< 24.11.0)
Expand Down
1 change: 0 additions & 1 deletion gorgone/packaging/centreon-gorgone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ overrides:
- perl(Tie::File) # required by MBI module
deb:
depends: # those dependencies are taken from centreon-gorgone/packaging/debian/control
- centreon-common
- centreon-perl-libs-common
- libdatetime-perl
- libtime-parsedate-perl
Expand Down
2 changes: 0 additions & 2 deletions packaging/centreon-collect/centreon-broker-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ overrides:
depends:
- lua
- centreon-clib = ${VERSION}-${RELEASE}${DIST}
- centreon-broker = ${VERSION}-${RELEASE}${DIST}
- gnutls >= 3.6.0
- mariadb-connector-c >= 3.1.10
conflicts:
Expand All @@ -64,7 +63,6 @@ overrides:
depends:
- ${LUA_VERSION}
- centreon-clib (= ${VERSION}-${RELEASE}${DIST})
- centreon-broker (= ${VERSION}-${RELEASE}${DIST})
- libgnutls30
- libssl1.1 | libssl3
- libmariadb3
Expand Down
6 changes: 2 additions & 4 deletions packaging/centreon-collect/centreon-broker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ scripts:
overrides:
rpm:
depends:
- centreon-clib = ${VERSION}-${RELEASE}${DIST}
- centreon-broker-core = ${VERSION}-${RELEASE}${DIST}
- centreon-broker-cbd = ${VERSION}-${RELEASE}${DIST}
conflicts:
- centreon-broker-devel
replaces:
Expand All @@ -54,8 +53,7 @@ overrides:
- centreon-broker-devel
deb:
depends:
- centreon-clib (= ${VERSION}-${RELEASE}${DIST})
- centreon-broker-core (= ${VERSION}-${RELEASE}${DIST})
- centreon-broker-cbd (= ${VERSION}-${RELEASE}${DIST})
conflicts:
- centreon-broker-dev
replaces:
Expand Down
2 changes: 0 additions & 2 deletions packaging/centreon-collect/centreon-engine-daemon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ overrides:
rpm:
depends:
- centreon-clib = ${VERSION}-${RELEASE}${DIST}
- centreon-engine = ${VERSION}-${RELEASE}${DIST}
- centreon-engine-opentelemetry = ${VERSION}-${RELEASE}${DIST}
- gnutls >= 3.6.0
- mariadb-connector-c >= 3.1.10
Expand All @@ -163,7 +162,6 @@ overrides:
deb:
depends:
- centreon-clib (= ${VERSION}-${RELEASE}${DIST})
- centreon-engine (= ${VERSION}-${RELEASE}${DIST})
- centreon-engine-opentelemetry (= ${VERSION}-${RELEASE}${DIST})
- libgnutls30
- libssl1.1 | libssl3
Expand Down
8 changes: 0 additions & 8 deletions packaging/centreon-common/centreon-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,9 @@ scripts:
overrides:
rpm:
depends:
- centreon-broker >= ${MAJOR_VERSION}
- centreon-broker < ${NEXT_MAJOR_VERSION}
- centreon-engine-daemon >= ${MAJOR_VERSION}
- centreon-engine-daemon < ${NEXT_MAJOR_VERSION}
- sudo
deb:
depends:
- "centreon-broker (>= ${MAJOR_VERSION}~)"
- "centreon-broker (<< ${NEXT_MAJOR_VERSION}~)"
- "centreon-engine-daemon (>= ${MAJOR_VERSION}~)"
- "centreon-engine-daemon (<< ${NEXT_MAJOR_VERSION}~)"
- sudo

rpm:
Expand Down
Loading