Skip to content

Commit

Permalink
centreon-agent => centreon-monitoring-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-christophe81 committed Jun 21, 2024
1 parent baa00c2 commit 1edd669
Show file tree
Hide file tree
Showing 24 changed files with 138 additions and 126 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/package-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
if: ${{ matrix.package_extension == 'rpm' }}
run: |
cd selinux
for MODULE in "centreon-engine" "centreon-broker" "centreon-agent"; do
for MODULE in "centreon-engine" "centreon-broker" "centreon-monitoring-agent"; do
cd $MODULE
sed -i "s/@VERSION@/${{ inputs.version }}/g" $MODULE.te
make -f /usr/share/selinux/devel/Makefile
Expand Down
6 changes: 3 additions & 3 deletions agent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ target_include_directories(${CENTREON_AGENT} PRIVATE
)

set(AGENT_VAR_LOG_DIR
"${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/centreon-agent")
"${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/centreon-monitoring-agent")


install(TARGETS ${CENTREON_AGENT} RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
Expand All @@ -150,8 +150,8 @@ if(WITH_TESTING)
endif()


set(PREFIX_AGENT_CONF "${CMAKE_INSTALL_FULL_SYSCONFDIR}/centreon-agent")
set(USER_AGENT centreon-agent)
set(PREFIX_AGENT_CONF "${CMAKE_INSTALL_FULL_SYSCONFDIR}/centreon-monitoring-agent")
set(USER_AGENT centreon-monitoring-agent)


if(WITH_CONF)
Expand Down
2 changes: 1 addition & 1 deletion agent/scripts/centagent.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ReloadPropagatedFrom=centreon.service
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/@CENTREON_AGENT@ @PREFIX_AGENT_CONF@/@[email protected]
ExecReload=/bin/kill -HUP $MAINPID
Type=simple
User=centreon-agent
User=@USER_AGENT@

[Install]
WantedBy=default.target
Expand Down
9 changes: 5 additions & 4 deletions agent/src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ int main(int argc, char* argv[]) {
}

SPDLOG_INFO(
"centreon-agent start, you can decrease log verbosity by kill -USR1 "
"centreon-monitoring-agent start, you can decrease log verbosity by kill "
"-USR1 "
"{} or increase by kill -USR2 {}",
getpid(), getpid());

const std::string logger_name = "centreon-agent";
const std::string logger_name = "centreon-monitoring-agent";

if (conf->get_log_type() == config::file) {
try {
Expand Down Expand Up @@ -129,7 +130,7 @@ int main(int argc, char* argv[]) {
g_logger->set_level(conf->get_log_level());

SPDLOG_LOGGER_INFO(g_logger,
"centreon-agent start, you can decrease log "
"centreon-monitoring-agent start, you can decrease log "
"verbosity by kill -USR1 {} or increase by kill -USR2 {}",
getpid(), getpid());
std::shared_ptr<com::centreon::common::grpc::grpc_config> grpc_conf;
Expand Down Expand Up @@ -159,7 +160,7 @@ int main(int argc, char* argv[]) {
return -1;
}

SPDLOG_LOGGER_INFO(g_logger, "centreon-agent end");
SPDLOG_LOGGER_INFO(g_logger, "centreon-monitoring-agent end");

return 0;
}
3 changes: 2 additions & 1 deletion agent/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ target_link_libraries(ut_agent PRIVATE
GTest::gmock_main
-L${Boost_LIBRARY_DIR_RELEASE}
boost_program_options
-L${PROTOBUF_LIB_DIR}
stdc++fs
-L${PROTOBUF_LIB_DIR}
gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc++_alts
fmt::fmt pthread
crypto ssl
Expand Down
40 changes: 0 additions & 40 deletions packaging/centreon-agent-selinux.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions packaging/centreon-engine-daemon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ contents:
owner: centreon-engine
group: centreon-engine

- src: "/usr/lib/nagios/plugins"
dst: "/usr/lib64/nagios/plugins"
type: symlink
packager: deb

scripts:
preinstall: ./scripts/centreon-engine-daemon-preinstall.sh
postinstall: ./scripts/centreon-engine-daemon-postinstall.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "centreon-agent-debuginfo"
name: "centreon-monitoring-agent-debuginfo"
arch: "${ARCH}"
platform: "linux"
version_schema: "none"
Expand All @@ -23,16 +23,16 @@ contents:
overrides:
rpm:
depends:
- centreon-agent = ${VERSION}-${RELEASE}${DIST}
- centreon-monitoring-agent = ${VERSION}-${RELEASE}${DIST}
deb:
depends:
- centreon-agent (= ${VERSION}-${RELEASE}${DIST})
- centreon-monitoring-agent (= ${VERSION}-${RELEASE}${DIST})
conflicts:
- centreon-agent-dbgsym
- centreon-monitoring-agent-dbgsym
replaces:
- centreon-agent-dbgsym
- centreon-monitoring-agent-dbgsym
provides:
- centreon-agent-dbgsym
- centreon-monitoring-agent-dbgsym

rpm:
summary: Debuginfo package for centagent.
Expand Down
40 changes: 40 additions & 0 deletions packaging/centreon-monitoring-agent-selinux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "centreon-monitoring-agent-selinux"
arch: "${ARCH}"
platform: "linux"
version_schema: "none"
version: "${VERSION}"
release: "${RELEASE}${DIST}"
section: "default"
priority: "optional"
maintainer: "Centreon <[email protected]>"
description: |
SELinux context for centreon-monitoring-agent
vendor: "Centreon"
homepage: "https://centreon.com"
license: "Apache-2.0"

depends:
- policycoreutils
- centreon-common-selinux
replaces:
- centreon-monitoring-agent-selinux-debuginfo
conflicts:
- centreon-monitoring-agent-selinux-debuginfo
provides:
- centreon-monitoring-agent-selinux-debuginfo

contents:
- src: "../selinux/centreon-monitoring-agent/centreon-monitoring-agent.pp"
dst: "/usr/share/selinux/packages/centreon/centreon-monitoring-agent.pp"
file_info:
mode: 0655

scripts:
postinstall: ./scripts/centreon-monitoring-agent-selinux-postinstall.sh
preremove: ./scripts/centreon-monitoring-agent-selinux-preremove.sh

rpm:
summary: SELinux context for centreon-monitoring-agent
signature:
key_file: ${RPM_SIGNING_KEY_FILE}
key_id: ${RPM_SIGNING_KEY_ID}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "centreon-agent"
name: "centreon-monitoring-agent"
arch: "${ARCH}"
platform: "linux"
version_schema: "none"
Expand All @@ -16,12 +16,12 @@ license: "Apache-2.0"

contents:
- src: "../agent/conf/centagent.json"
dst: "/etc/centreon-agent/centagent.json"
dst: "/etc/centreon-monitoring-agent/centagent.json"
type: config|noreplace
file_info:
mode: 0664
owner: centreon-agent
group: centreon-agent
owner: centreon-monitoring-agent
group: centreon-monitoring-agent

- src: "../agent/scripts/centagent.service"
dst: "/usr/lib/systemd/system/centagent.service"
Expand All @@ -37,25 +37,25 @@ contents:
- src: "../build/agent/centagent"
dst: "/usr/bin/centagent"

- dst: "/etc/centreon-agent"
- dst: "/etc/centreon-monitoring-agent"
type: dir
file_info:
mode: 0775
owner: centreon-agent
group: centreon-agent
owner: centreon-monitoring-agent
group: centreon-monitoring-agent

- dst: "/var/log/centreon-agent"
- dst: "/var/log/centreon-monitoring-agent"
type: dir
file_info:
mode: 0755
owner: centreon-agent
group: centreon-agent
owner: centreon-monitoring-agent
group: centreon-monitoring-agent

scripts:
preinstall: ./scripts/centreon-agent-daemon-preinstall.sh
postinstall: ./scripts/centreon-agent-daemon-postinstall.sh
preremove: ./scripts/centreon-agent-daemon-preremove.sh
postremove: ./scripts/centreon-agent-daemon-postremove.sh
preinstall: ./scripts/centreon-monitoring-agent-daemon-preinstall.sh
postinstall: ./scripts/centreon-monitoring-agent-daemon-postinstall.sh
preremove: ./scripts/centreon-monitoring-agent-daemon-preremove.sh
postremove: ./scripts/centreon-monitoring-agent-daemon-postremove.sh


rpm:
Expand Down
25 changes: 0 additions & 25 deletions packaging/scripts/centreon-agent-daemon-postinstall.sh

This file was deleted.

8 changes: 0 additions & 8 deletions packaging/scripts/centreon-agent-daemon-postremove.sh

This file was deleted.

10 changes: 0 additions & 10 deletions packaging/scripts/centreon-agent-daemon-preinstall.sh

This file was deleted.

5 changes: 0 additions & 5 deletions packaging/scripts/centreon-agent-selinux-preremove.sh

This file was deleted.

13 changes: 13 additions & 0 deletions packaging/scripts/centreon-engine-daemon-postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ startCentengine() {
systemctl restart centengine.service ||:
}

debianLinkNagios() {
if [ ! -r /usr/lib64/nagios/plugins ]; then
ln -s /usr/lib/nagios/plugins /usr/lib64/nagios/plugins
fi
}

# on debian, it is needed to recreate centreon-engine user at each upgrade because it is removed on postrm step on versions < 23.10
if [ "$1" = "configure" ] ; then
if [ ! "$(getent passwd centreon-engine)" ]; then
Expand Down Expand Up @@ -45,6 +51,13 @@ elif [ "$1" = "configure" ] && [ -n "$2" ]; then
action="upgrade"
fi

#In debian nagios plugins are stored in /usr/lib/nagios/plugins instead of /usr/lib64/nagios/plugins
#so we create a link /usr/lib/nagios/plugins instead => /usr/lib64/nagios/plugins in order to have
#the same commands configuration for all pollers
if [ "$1" = "configure" ]; then
debianLinkNagios
fi

case "$action" in
"1" | "install")
startCentengine
Expand Down
27 changes: 27 additions & 0 deletions packaging/scripts/centreon-monitoring-agent-postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

startCentagent() {
systemctl daemon-reload ||:
systemctl unmask centagent.service ||:
systemctl preset centagent.service ||:
systemctl enable centagent.service ||:
systemctl restart centagent.service ||:
}


debianLinkNagios() {
if [ ! -r /usr/lib64/nagios/plugins ]; then
ln -s /usr/lib/nagios/plugins /usr/lib64/nagios/plugins
fi
}

#In debian nagios plugins are stored in /usr/lib/nagios/plugins instead of /usr/lib64/nagios/plugins
#so we create a link /usr/lib/nagios/plugins instead => /usr/lib64/nagios/plugins in order to have
#the same commands configuration for all pollers
if [ "$1" = "configure" ]; then
debianLinkNagios
fi


startCentagent

8 changes: 8 additions & 0 deletions packaging/scripts/centreon-monitoring-agent-postremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

case "$1" in
purge)
deluser centreon-monitoring-agent || :
delgroup centreon-monitoring-agent || :
;;
esac
10 changes: 10 additions & 0 deletions packaging/scripts/centreon-monitoring-agent-preinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

if ! id centreon-monitoring-agent > /dev/null 2>&1; then
useradd -r centreon-monitoring-agent > /dev/null 2>&1
fi

if id -g nagios > /dev/null 2>&1; then
usermod -a -G centreon-monitoring-agent nagios
fi

Loading

0 comments on commit 1edd669

Please sign in to comment.