Skip to content

Commit

Permalink
move process common
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-christophe81 committed Jun 24, 2024
1 parent 922825b commit b6583ee
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 34 deletions.
10 changes: 5 additions & 5 deletions agent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ set(SCRIPT_DIR "${PROJECT_SOURCE_DIR}/scripts")
add_definitions("-D_GLIBCXX_USE_CXX11_ABI=1")
add_definitions(-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)

option(WITH_LIBCXX "compiles and link cbd with clang++/libc++")
option(WITH_LIBCXX "compiles and links cbd with clang++/libc++")

if(WITH_LIBCXX)
set(CMAKE_CXX_COMPILER "clang++")
Expand All @@ -47,7 +47,7 @@ foreach(name IN LISTS service_files)
set(proto_file "${name}.proto")
add_custom_command(
OUTPUT "${SRC_DIR}/${name}.grpc.pb.cc"
COMMENT "Generating grpc files of the otl service file ${proto_file}"
COMMENT "Generating grpc files from the otl service file ${proto_file}"
DEPENDS opentelemetry-proto-files
COMMAND
${Protobuf_PROTOC_EXECUTABLE} ARGS
Expand All @@ -69,7 +69,7 @@ foreach(name IN LISTS otl_protobuf_files)
set(proto_file "${name}.proto")
add_custom_command(
OUTPUT "${SRC_DIR}/${name}.pb.cc"
COMMENT "Generating interface files of the otl file ${proto_file}"
COMMENT "Generating interface files from the otl file ${proto_file}"
DEPENDS opentelemetry-proto-files
COMMAND
${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out=${SRC_DIR}
Expand All @@ -81,15 +81,15 @@ endforeach()
#centagent server and client
add_custom_command(
DEPENDS ${PROJECT_SOURCE_DIR}/proto/agent.proto
COMMENT "Generating interface files of the conf centagent proto file (grpc)"
COMMENT "Generating interface files from the conf centagent proto file (grpc)"
OUTPUT ${SRC_DIR}/agent.grpc.pb.cc
COMMAND
${Protobuf_PROTOC_EXECUTABLE} ARGS
--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}
--proto_path=${PROJECT_SOURCE_DIR}/proto --proto_path=${CMAKE_SOURCE_DIR}/opentelemetry-proto
--grpc_out=${SRC_DIR} ${PROJECT_SOURCE_DIR}/proto/agent.proto
DEPENDS ${PROJECT_SOURCE_DIR}/proto/agent.proto
COMMENT "Generating interface files of the conf centagent proto file (protobuf)"
COMMENT "Generating interface files from the conf centagent proto file (protobuf)"
OUTPUT ${SRC_DIR}/agent.pb.cc
COMMAND
${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out=${SRC_DIR}
Expand Down
24 changes: 12 additions & 12 deletions agent/doc/agent-doc.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Centreon Agent documentation {#mainpage}
# Centreon Monitoring Agent documentation {#mainpage}

## Introduction

The purpose of this program is to run checks in Windows and Linux operating systems. It is entirely asynchronous, with the exception of the gRPC layers. It is also single-threaded and therefore needs no mutexes, except in the gRPC part.
The purpose of this program is to run checks on the Windows and Linux operating systems. It is entirely asynchronous, with the exception of the gRPC layers. It is also single-threaded and therefore needs no mutexes, except in the gRPC part.
This is why, when a request is received, it is posted to ASIO for processing in the main thread.

## Configuration
configuration is given by Engine by a AgentConfiguration sent over grpc
The configuration is given by Engine by an AgentConfiguration message sent over gRPC.
The configuration object is embedded in MessageToAgent::config

## Scheduler
We trie to spread checks over check_period.
Example: We have 10 checks to execute during one second. check1 will start at now, second at now + 0.1s..
We try to spread checks over the check_period.
Example: We have 10 checks to execute during one second. Check1 will start at now, second at now + 0.1s..

When Agent receives configuration, all checks are recreated.
For example, we have 100 checks to execute in 10 minute, at it is 12:00:00.
First service check will start right now, second one at 12:00:06, third at 12:00:12... and the last one at 12:09:54
We don't care about tests duration, we work with time points.
In the previous example, time of second check of first service will be scheduled at 12:00:10 even if all other checks has not been yet started.
When the Agent receives configuration, all checks are recreated.
For example, we have 100 checks to execute in 10 minutes, at it is 12:00:00.
The first service check will start right now, the second one at 12:00:06, third at 12:00:12... and the last one at 12:09:54
We don't care about the duration of tests, we work with time points.
In the previous example, the second check for the first service will be scheduled at 12:00:10 even if all other checks has not been yet started.

In case of check duration is too long, we might exceed maximum of concurrent checks. In that case checks will b executed as soon one will be ended.
So second check may start later than scheduled time point (12:00:10) if other first checks are too long. Order of checks is always respected even in case of bottleneck.
In case of check duration is too long, we might exceed maximum of concurrent checks. In that case checks will be executed as soon one will be ended.
This means that the second check may start later than the scheduled time point (12:00:10) if the other first checks are too long. The order of checks is always respected even in case of a bottleneck.
24 changes: 12 additions & 12 deletions agent/src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ static constexpr std::string_view _config_schema(R"(
"title": "agent config",
"properties": {
"host": {
"description": "IP or dns name, if not given, hostname will be used",
"description": "name of host configured in centreon, if not given, hostname will be used",
"type": "string",
"minLength": 5
},
"endpoint": {
"description": "endpoint of poller where agent have to connect or listen endpoint in case of reverse_connection",
"description": "endpoint of poller where agent has to connect or listening endpoint in case of reverse_connection",
"type": "string",
"pattern": "[\\w\\.:]+:\\w+"
},
Expand All @@ -46,47 +46,47 @@ static constexpr std::string_view _config_schema(R"(
"type": "boolean"
},
"public_cert": {
"description": "path of certificate file .crt",
"description": "Path of the SSL certificate file .crt",
"type": "string"
},
"private_key": {
"description": "path of certificate file .key",
"description": "Path of the SSL private key file .key",
"type": "string"
},
"ca_certificate": {
"description": "path of authority certificate file .crt",
"description": "Path of the SSL authority certificate file .crt",
"type": "string"
},
"ca_name": {
"description": "name of authority certificate",
"description": "Name of the SSL certification authority",
"type": "string"
},
"reverse_connection": {
"description": "if true, centagent is a server and centengine will connect to, default:false",
"description": "Set to true to make Engine connect to the agent. Requires the agent to be configured as a server. Default: false",
"type": "boolean"
},
"log_level": {
"description": "log level, may be critical, error, info, debug, trace",
"description": "Minimal severity level to log, may be critical, error, info, debug, trace",
"type": "string",
"pattern": "critical|error|info|debug|trace"
},
"log_type": {
"description": "stdout or file if log to a file (path must be given by log_file), default: stdout",
"description": "Define whether logs must be sent to the standard output (stdout) or to a log file (file). A path will be required in log_file field if 'file' is chosen. Default: stdout",
"type": "string",
"pattern": "stdout|file"
},
"log_file": {
"description": "path of the log file",
"description": "Path of the log file. Mandatory if log_type is 'file'",
"type": "string",
"minLength": 5
},
"log_max_file_size": {
"description:": "max size in Mo of the log file before rotate, to be valid log_max_files must be also be specified",
"description:": "Maximum size (in megabytes) of the log file before it will be rotated. To be valid, log_max_files must be also be provided",
"type": "integer",
"min": 1
},
"log_max_files": {
"description:": "max of log files before remove, to be valid log_max_file_size must be also be specified",
"description:": "Maximum number of log files to keep. Supernumerary files will be deleted. To be valid, log_max_file_size must be also be provided",
"type": "integer",
"min": 1
}
Expand Down
2 changes: 0 additions & 2 deletions broker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,6 @@ target_link_libraries(
"-Wl,--no-whole-archive"
nlohmann_json::nlohmann_json
fmt::fmt
-L${Boost_LIBRARY_DIR_RELEASE}
boost_program_options
-L${PROTOBUF_LIB_DIR}
"-Wl,--whole-archive"
gRPC::grpc++
Expand Down
2 changes: 1 addition & 1 deletion common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ set(SOURCES
${SRC_DIR}/hex_dump.cc
${SRC_DIR}/perfdata.cc
${SRC_DIR}/pool.cc
${SRC_DIR}/process.cc
${SRC_DIR}/process_stat.cc
${SRC_DIR}/process_stat.pb.cc
${SRC_DIR}/process_stat.grpc.pb.cc
Expand All @@ -69,6 +68,7 @@ target_precompile_headers(centreon_common PRIVATE precomp_inc/precomp.hh)

add_subdirectory(http)
add_subdirectory(grpc)
add_subdirectory(process)

if(WITH_TESTING)
add_subdirectory(tests)
Expand Down
28 changes: 28 additions & 0 deletions common/process/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright 2024 Centreon
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# For more information : [email protected]
#

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_definitions(-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
add_definitions(${spdlog_DEFINITIONS})

add_library(
centreon_process STATIC
# Sources.
process.cc)

target_precompile_headers(centreon_process REUSE_FROM centreon_common)
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions common/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ target_link_libraries(
ut_common
PRIVATE centreon_common
centreon_http
centreon_process
-L${Boost_LIBRARY_DIR_RELEASE}
boost_program_options
re2::re2
Expand Down
4 changes: 2 additions & 2 deletions packaging/centreon-monitoring-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ section: "default"
priority: "optional"
maintainer: "Centreon <[email protected]>"
description: |
This software is an agent used to executes commands on remote computers as nsclient does.
This software is an agent used to execute commands on remote computers as nsclient does.
Commit: @COMMIT_HASH@
vendor: "Centreon"
homepage: "https://www.centreon.com"
Expand Down Expand Up @@ -59,7 +59,7 @@ scripts:


rpm:
summary: Centreon Collect Agent. It can be used to execute remotely plugins
summary: Centreon Collect Agent. It can be used to execute plugins remotely
compression: zstd
signature:
key_file: ${RPM_SIGNING_KEY_FILE}
Expand Down

0 comments on commit b6583ee

Please sign in to comment.