diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index b91c977..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,236 +0,0 @@ -build:trusty: - image: ubuntu:trusty - stage: build - script: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install cmake3 gcc g++ build-essential libglib2.0-dev libgearman-dev uuid-dev libicu-dev libjson-c-dev libssl-dev pkg-config librabbitmq-dev - - | - set -e - mkdir -p /usr/local/lib/pkgconfig /opt/naemon/include - ln -s $(readlink -f devtools/ci/naemon) /opt/naemon/include/naemon - ln -s $(readlink -f devtools/ci/naemon.pc) /usr/local/lib/pkgconfig/naemon.pc - - | - mkdir build - cd build - cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ .. - make -j5 - mv libstatusengine.so .. - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" - paths: - - libstatusengine.so - - README.md - - VERSION - - LICENSE - -build:xenial: - image: ubuntu:xenial - stage: build - script: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install cmake gcc g++ build-essential libglib2.0-dev libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev - - | - set -e - mkdir -p /usr/local/lib/pkgconfig /opt/naemon/include - ln -s $(readlink -f devtools/ci/naemon) /opt/naemon/include/naemon - ln -s $(readlink -f devtools/ci/naemon.pc) /usr/local/lib/pkgconfig/naemon.pc - - | - mkdir build - cd build - cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ .. - make -j5 - mv libstatusengine.so .. - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" - paths: - - libstatusengine.so - - README.md - - VERSION - - LICENSE - -build:bionic: - image: ubuntu:bionic - stage: build - script: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install cmake gcc g++ build-essential libglib2.0-dev libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev - - | - set -e - mkdir -p /usr/local/lib/pkgconfig /opt/naemon/include - ln -s $(readlink -f devtools/ci/naemon) /opt/naemon/include/naemon - ln -s $(readlink -f devtools/ci/naemon.pc) /usr/local/lib/pkgconfig/naemon.pc - - | - mkdir build - cd build - cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ .. - make -j5 - mv libstatusengine.so .. - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" - paths: - - libstatusengine.so - - README.md - - VERSION - - LICENSE - -build:jessie: - image: debian:jessie - stage: build - script: - - echo "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/backports.list - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y -t jessie-backports install cmake gcc g++ build-essential libglib2.0-dev libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev - - | - set -e - mkdir -p /usr/local/lib/pkgconfig /opt/naemon/include - ln -s $(readlink -f devtools/ci/naemon) /opt/naemon/include/naemon - ln -s $(readlink -f devtools/ci/naemon.pc) /usr/local/lib/pkgconfig/naemon.pc - - | - mkdir build - cd build - cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ .. - make -j5 - mv libstatusengine.so .. - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" - paths: - - libstatusengine.so - - README.md - - VERSION - - LICENSE - -build:stretch: - image: debian:stretch - stage: build - script: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install cmake gcc g++ build-essential libglib2.0-dev libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev - - | - set -e - mkdir -p /usr/local/lib/pkgconfig /opt/naemon/include - ln -s $(readlink -f devtools/ci/naemon) /opt/naemon/include/naemon - ln -s $(readlink -f devtools/ci/naemon.pc) /usr/local/lib/pkgconfig/naemon.pc - - | - mkdir build - cd build - cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ .. - make -j5 - mv libstatusengine.so .. - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" - paths: - - libstatusengine.so - - README.md - - VERSION - - LICENSE - -build:nagios:trusty: - image: ubuntu:trusty - stage: build - script: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install cmake3 gcc g++ build-essential libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev libglib2.0-dev librabbitmq-dev - - | - set -e - mkdir -p /opt/nagios/include - ln -s $(readlink -f devtools/ci/nagios) /opt/nagios/include/nagios - - | - mkdir build - cd build - cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DBUILD_NAGIOS=ON -DNAGIOS_INCLUDE_DIR=/opt/nagios/include .. - make -j5 - mv libstatusengine.so .. - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" - paths: - - libstatusengine.so - - README.md - - VERSION - - LICENSE - -build:nagios:xenial: - image: ubuntu:xenial - stage: build - script: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install cmake gcc g++ build-essential libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev libglib2.0-dev - - | - set -e - mkdir -p /opt/nagios/include - ln -s $(readlink -f devtools/ci/nagios) /opt/nagios/include/nagios - - | - mkdir build - cd build - cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DBUILD_NAGIOS=ON -DNAGIOS_INCLUDE_DIR=/opt/nagios/include .. - make -j5 - mv libstatusengine.so .. - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" - paths: - - libstatusengine.so - - README.md - - VERSION - - LICENSE - -build:nagios:bionic: - image: ubuntu:bionic - stage: build - script: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install cmake gcc g++ build-essential libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev libglib2.0-dev - - | - set -e - mkdir -p /opt/nagios/include - ln -s $(readlink -f devtools/ci/nagios) /opt/nagios/include/nagios - - | - mkdir build - cd build - cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DBUILD_NAGIOS=ON -DNAGIOS_INCLUDE_DIR=/opt/nagios/include .. - make -j5 - mv libstatusengine.so .. - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" - paths: - - libstatusengine.so - - README.md - - VERSION - - LICENSE - -build:nagios:jessie: - image: debian:jessie - stage: build - script: - - echo "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/backports.list - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y -t jessie-backports install cmake gcc g++ build-essential libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev libglib2.0-dev - - | - set -e - mkdir -p /opt/nagios/include - ln -s $(readlink -f devtools/ci/nagios) /opt/nagios/include/nagios - - | - mkdir build - cd build - cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DBUILD_NAGIOS=ON -DNAGIOS_INCLUDE_DIR=/opt/nagios/include .. - make -j5 - mv libstatusengine.so .. - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" - paths: - - libstatusengine.so - - README.md - - VERSION - - LICENSE - -build:nagios:stretch: - image: debian:stretch - stage: build - script: - - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install cmake gcc g++ build-essential libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev libglib2.0-dev - - | - set -e - mkdir -p /opt/nagios/include - ln -s $(readlink -f devtools/ci/nagios) /opt/nagios/include/nagios - - | - mkdir build - cd build - cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DBUILD_NAGIOS=ON -DNAGIOS_INCLUDE_DIR=/opt/nagios/include .. - make -j5 - mv libstatusengine.so .. - artifacts: - name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" - paths: - - libstatusengine.so - - README.md - - VERSION - - LICENSE diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9d41a8a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,92 @@ +cmake_minimum_required(VERSION 3.11) + +set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard to use") +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +option(WITH_GEARMAN "enable gearman" OFF) +option(WITH_RABBITMQ "enable rabbitmq" OFF) +option(NAGIOS_INCLUDE_DIR "path to nagios include dir" OFF) +option(NAEMON_INCLUDE_DIR "path to naemon include dir" OFF) + +if(${CMAKE_VERSION} VERSION_LESS 3.14) + macro(FetchContent_MakeAvailable NAME) + FetchContent_GetProperties(${NAME}) + if(NOT ${NAME}_POPULATED) + FetchContent_Populate(${NAME}) + add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR}) + endif() + endmacro() +endif() + +find_package(PkgConfig REQUIRED) +include(FetchContent) + +project( + statusengine + VERSION 4.2 + LANGUAGES CXX +) + +pkg_check_modules(UCHARDET REQUIRED uchardet) +pkg_check_modules(JSONC REQUIRED json-c) +set(STATUSENGINE_LIBS ${UCHARDET_LIBRARIES} ${JSONC_LIBRARIES}) +set(STATUSENGINE_INCLUDES ${UCHARDET_INCLUDE_DIRS} ${JSONC_INCLUDE_DIRS}) + +if(WITH_GEARMAN) + pkg_check_modules(GEARMAN REQUIRED gearmand) + set(STATUSENGINE_LIBS ${GEARMAN_LIBRARIES} ${STATUSENGINE_LIBS}) + set(STATUSENGINE_INCLUDES ${GEARMAN_INCLUDE_DIRS} ${STATUSENGINE_INCLUDES}) + add_definitions(-DWITH_GEARMAN) +endif() +if(WITH_RABBITMQ) + pkg_check_modules(RABBITMQ REQUIRED librabbitmq) + set(STATUSENGINE_LIBS ${RABBITMQ_LIBRARIES} ${STATUSENGINE_LIBS}) + set(STATUSENGINE_INCLUDES ${RABBITMQ_INCLUDE_DIRS} ${STATUSENGINE_INCLUDES}) + add_definitions(-DWITH_RABBITMQ) +endif() + +if(NAGIOS_INCLUDE_DIR) + set(STATUSENGINE_INCLUDES ${NAGIOS_INCLUDE_DIR} ${STATUSENGINE_INCLUDES}) +endif() + +if(NAEMON_INCLUDE_DIR) +set(STATUSENGINE_INCLUDES ${NAEMON_INCLUDE_DIR} ${STATUSENGINE_INCLUDES}) +endif() + +if(NOT NAGIOS_INCLUDE_DIR AND NOT NAEMON_INCLUDE_DIR) + pkg_check_modules(NAEMON REQUIRED naemon) + set(STATUSENGINE_INCLUDES ${NAEMON_INCLUDE_DIRS} ${STATUSENGINE_INCLUDES}) +endif() + +if(NOT NAGIOS_INCLUDE_DIR) + pkg_check_modules(GLIB2 REQUIRED glib-2.0) + set(STATUSENGINE_LIBS ${GLIB2_LIBRARIES} ${STATUSENGINE_LIBS}) + set(STATUSENGINE_INCLUDES ${GLIB2_INCLUDE_DIRS} ${STATUSENGINE_INCLUDES}) +endif() + + +set(toml11_BUILD_TEST OFF CACHE INTERNAL "") +FetchContent_Declare( + toml11 + GIT_REPOSITORY https://github.com/ToruNiina/toml11.git + GIT_TAG v3.7.1 +) + +FetchContent_GetProperties(toml11) +if(NOT toml11_POPULATED) + FetchContent_Populate(toml11) + add_subdirectory(${toml11_SOURCE_DIR} ${toml11_BINARY_DIR} EXCLUDE_FROM_ALL) +endif() + +set(STATUSENGINE_INCLUDES ${toml11_SOURCE_DIR} ${toml11_SOURCE_DIR}/toml ${STATUSENGINE_INCLUDES}) + +if(MSVC) + add_compile_options(/W4 /WX) +else() + add_compile_options(-Wall -Wextra -Wpedantic -Werror) +endif() + +add_subdirectory(src) + diff --git a/README.md b/README.md index 70e3d39..9dfaf2c 100644 --- a/README.md +++ b/README.md @@ -11,18 +11,14 @@ Visit the [documentation](https://statusengine.org/broker/) for more information Please compile and install the newest version of naemon or nagios. We need the header files for building the broker. ### Dependencies -#### Meson -https://mesonbuild.com/Getting-meson.html #### Ubuntu/Debian ```bash -apt install git python3-pip gcc g++ cmake build-essential libglib2.0-dev libgearman-dev uuid-dev libuchardet-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev -pip3 install meson ninja +apt install git gcc g++ cmake build-essential libglib2.0-dev libgearman-dev uuid-dev libuchardet-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev ``` #### CentOS ```bash -yum install git python-pip gcc gcc-c++ cmake3 pkgconfig librabbitmq-devel libgearman-devel libuchardet-devel json-c-devel openssl-devel glib2-devel -pip install meson ninja +yum install git gcc gcc-c++ cmake3 pkgconfig librabbitmq-devel libgearman-devel libuchardet-devel json-c-devel openssl-devel glib2-devel ``` ### Sources @@ -40,46 +36,40 @@ Please make sure you have set up Naemon like described in the [docs](https://sta Then create the make files ```bash export PKG_CONFIG_PATH=/opt/naemon/lib/pkgconfig/ -meson setup --buildtype=release build -ninja -C build +mkdir build && cd build && cmake .. -DWITH_GEARMAN=ON -DWITH_RABBITMQ=ON ``` ### Nagios Please make sure you have set up Nagios like described in the [docs](https://statusengine.org/tutorials/install-nagios4-focal/). -#### Ubuntu/Debian ```bash -meson setup -Dnagios=true -Dnagios_include_dir=/opt/nagios/include build +mkdir build && cd build && cmake .. -DWITH_GEARMAN=ON -DWITH_RABBITMQ=ON -DNAGIOS_INCLUDE_DIR=/opt/nagios/include ``` -#### RHEL/CentOS -```bash -meson setup -Dnagios=true -Dnagios_include_dir=/opt/nagios/include build -``` ### Build ```bash -ninja -C build +make -j ``` ### Installation ```bash -ninja -C build install +make install ``` -## Additional meson build flags +## Additional cmake build flags ### Installation path The default installation path for the library is /usr/local, which means that the so file will be placed under /usr/local/lib/libstatusengine.so. -You can specify --prefix=/opt/naemon as meson argument to change the path. +You can specify -DCMAKE_INSTALL_PREFIX=/opt/naemon as cmake argument to change the path. ### Disable RabbitMQ or Gearman -You can specify -Dgearman=false or -Drabbitmq=false as meson argument to disable gearman or rabbitmq. +You can specify -DWITH_GEARMAN=OFF or -DWITH_RABBITMQ=OFF as cmake argument to disable gearman or rabbitmq. ## Configuration diff --git a/devtools/buildenv/statusengine.cfg b/devtools/buildenv/statusengine.cfg index aea2c28..2bc218c 100644 --- a/devtools/buildenv/statusengine.cfg +++ b/devtools/buildenv/statusengine.cfg @@ -1 +1 @@ -broker_module=/opt/naemon/lib/libstatusengine.so /opt/naemon/etc/statusengine.toml +broker_module=/broker/build/src/libstatusengine.so /opt/naemon/etc/statusengine.toml diff --git a/devtools/ci/naemon.pc b/devtools/ci/naemon.pc deleted file mode 100644 index 5ace274..0000000 --- a/devtools/ci/naemon.pc +++ /dev/null @@ -1,15 +0,0 @@ -prefix=/opt/naemon -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -includedir=${prefix}/include -sysconfdir=${prefix}/etc - -mainconf=${sysconfdir}/naemon/naemon.cfg -naemon_user=naemon -naemon_group=naemon - -Name: Naemon -Description: Naemon network monitoring -Version: 1.0.6-source -Libs: -L${libdir} -lnaemon -ldl -lm -lglib-2.0 -Cflags: -I${includedir} -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include \ No newline at end of file diff --git a/devtools/ci/naemon/broker.h b/devtools/ci/naemon/broker.h deleted file mode 100644 index 94b05fc..0000000 --- a/devtools/ci/naemon/broker.h +++ /dev/null @@ -1,196 +0,0 @@ -#ifndef _BROKER_H -#define _BROKER_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "checks.h" -#include "objects_host.h" -#include "objects_contact.h" -#include "objects_service.h" -#include "nebmods.h" - -/*************** EVENT BROKER OPTIONS *****************/ - -#define BROKER_NOTHING 0 -#define BROKER_EVERYTHING 1048575 - -#define BROKER_PROGRAM_STATE 1 /* DONE */ -#define BROKER_TIMED_EVENTS 2 /* DONE, DEPRECATED */ -#define BROKER_SERVICE_CHECKS 4 /* DONE */ -#define BROKER_HOST_CHECKS 8 /* DONE */ -#define BROKER_EVENT_HANDLERS 16 /* DONE */ -#define BROKER_LOGGED_DATA 32 /* DONE */ -#define BROKER_NOTIFICATIONS 64 /* DONE */ -#define BROKER_FLAPPING_DATA 128 /* DONE */ -#define BROKER_COMMENT_DATA 256 /* DONE */ -#define BROKER_DOWNTIME_DATA 512 /* DONE */ -#define BROKER_SYSTEM_COMMANDS 1024 /* DONE */ -#define BROKER_OCP_DATA_UNUSED 2048 /* reusable */ -#define BROKER_STATUS_DATA 4096 /* DONE */ -#define BROKER_ADAPTIVE_DATA 8192 /* DONE */ -#define BROKER_EXTERNALCOMMAND_DATA 16384 /* DONE */ -#define BROKER_RETENTION_DATA 32768 /* DONE */ -#define BROKER_ACKNOWLEDGEMENT_DATA 65536 -#define BROKER_STATECHANGE_DATA 131072 -#define BROKER_RESERVED18 262144 -#define BROKER_RESERVED19 524288 - - -/****** EVENT TYPES ************************/ - -#define NEBTYPE_NONE 0 - -#define NEBTYPE_HELLO 1 -#define NEBTYPE_GOODBYE 2 -#define NEBTYPE_INFO 3 - -#define NEBTYPE_PROCESS_START 100 -#define NEBTYPE_PROCESS_DAEMONIZE 101 -#define NEBTYPE_PROCESS_RESTART 102 -#define NEBTYPE_PROCESS_SHUTDOWN 103 -#define NEBTYPE_PROCESS_PRELAUNCH 104 /* before objects are read or verified */ -#define NEBTYPE_PROCESS_EVENTLOOPSTART 105 -#define NEBTYPE_PROCESS_EVENTLOOPEND 106 - -#define NEBTYPE_TIMEDEVENT_ADD 200 -#define NEBTYPE_TIMEDEVENT_REMOVE 201 -#define NEBTYPE_TIMEDEVENT_EXECUTE 202 -#define NEBTYPE_TIMEDEVENT_DELAY 203 /* NOT IMPLEMENTED */ -#define NEBTYPE_TIMEDEVENT_SKIP 204 /* NOT IMPLEMENTED */ -#define NEBTYPE_TIMEDEVENT_SLEEP 205 - -#define NEBTYPE_LOG_DATA 300 -#define NEBTYPE_LOG_ROTATION 301 - -#define NEBTYPE_SYSTEM_COMMAND_START 400 -#define NEBTYPE_SYSTEM_COMMAND_END 401 - -#define NEBTYPE_EVENTHANDLER_START 500 -#define NEBTYPE_EVENTHANDLER_END 501 - -#define NEBTYPE_NOTIFICATION_START 600 -#define NEBTYPE_NOTIFICATION_END 601 -#define NEBTYPE_CONTACTNOTIFICATION_START 602 -#define NEBTYPE_CONTACTNOTIFICATION_END 603 -#define NEBTYPE_CONTACTNOTIFICATIONMETHOD_START 604 -#define NEBTYPE_CONTACTNOTIFICATIONMETHOD_END 605 - -#define NEBTYPE_SERVICECHECK_INITIATE 700 -#define NEBTYPE_SERVICECHECK_PROCESSED 701 -#define NEBTYPE_SERVICECHECK_RAW_START 702 /* NOT IMPLEMENTED */ -#define NEBTYPE_SERVICECHECK_RAW_END 703 /* NOT IMPLEMENTED */ -#define NEBTYPE_SERVICECHECK_ASYNC_PRECHECK 704 - -#define NEBTYPE_HOSTCHECK_INITIATE 800 /* a check of the route to the host has been initiated */ -#define NEBTYPE_HOSTCHECK_PROCESSED 801 /* the processed/final result of a host check */ -#define NEBTYPE_HOSTCHECK_RAW_START 802 /* the start of a "raw" host check */ -#define NEBTYPE_HOSTCHECK_RAW_END 803 /* a finished "raw" host check */ -#define NEBTYPE_HOSTCHECK_ASYNC_PRECHECK 804 -#define NEBTYPE_HOSTCHECK_SYNC_PRECHECK 805 - -#define NEBTYPE_COMMENT_ADD 900 -#define NEBTYPE_COMMENT_DELETE 901 -#define NEBTYPE_COMMENT_LOAD 902 - -#define NEBTYPE_FLAPPING_START 1000 -#define NEBTYPE_FLAPPING_STOP 1001 - -#define NEBTYPE_DOWNTIME_ADD 1100 -#define NEBTYPE_DOWNTIME_DELETE 1101 -#define NEBTYPE_DOWNTIME_LOAD 1102 -#define NEBTYPE_DOWNTIME_START 1103 -#define NEBTYPE_DOWNTIME_STOP 1104 - -#define NEBTYPE_PROGRAMSTATUS_UPDATE 1200 -#define NEBTYPE_HOSTSTATUS_UPDATE 1201 -#define NEBTYPE_SERVICESTATUS_UPDATE 1202 -#define NEBTYPE_CONTACTSTATUS_UPDATE 1203 - -#define NEBTYPE_ADAPTIVEPROGRAM_UPDATE 1300 -#define NEBTYPE_ADAPTIVEHOST_UPDATE 1301 -#define NEBTYPE_ADAPTIVESERVICE_UPDATE 1302 -#define NEBTYPE_ADAPTIVECONTACT_UPDATE 1303 - -#define NEBTYPE_EXTERNALCOMMAND_START 1400 -#define NEBTYPE_EXTERNALCOMMAND_END 1401 - -#define NEBTYPE_AGGREGATEDSTATUS_STARTDUMP 1500 -#define NEBTYPE_AGGREGATEDSTATUS_ENDDUMP 1501 - -#define NEBTYPE_RETENTIONDATA_STARTLOAD 1600 -#define NEBTYPE_RETENTIONDATA_ENDLOAD 1601 -#define NEBTYPE_RETENTIONDATA_STARTSAVE 1602 -#define NEBTYPE_RETENTIONDATA_ENDSAVE 1603 - -#define NEBTYPE_ACKNOWLEDGEMENT_ADD 1700 -#define NEBTYPE_ACKNOWLEDGEMENT_REMOVE 1701 /* NOT IMPLEMENTED */ -#define NEBTYPE_ACKNOWLEDGEMENT_LOAD 1702 /* NOT IMPLEMENTED */ - -#define NEBTYPE_STATECHANGE_START 1800 /* NOT IMPLEMENTED */ -#define NEBTYPE_STATECHANGE_END 1801 - - - -/****** EVENT FLAGS ************************/ - -#define NEBFLAG_NONE 0 -#define NEBFLAG_PROCESS_INITIATED 1 /* event was initiated by Nagios process */ -#define NEBFLAG_USER_INITIATED 2 /* event was initiated by a user request */ -#define NEBFLAG_MODULE_INITIATED 3 /* event was initiated by an event broker module */ - - - - -/****** EVENT ATTRIBUTES *******************/ - -#define NEBATTR_NONE 0 - -#define NEBATTR_SHUTDOWN_NORMAL 1 -#define NEBATTR_SHUTDOWN_ABNORMAL 2 -#define NEBATTR_RESTART_NORMAL 4 -#define NEBATTR_RESTART_ABNORMAL 8 - -#define NEBATTR_FLAPPING_STOP_NORMAL 1 -#define NEBATTR_FLAPPING_STOP_DISABLED 2 /* flapping stopped because flap detection was disabled */ - -#define NEBATTR_DOWNTIME_STOP_NORMAL 1 -#define NEBATTR_DOWNTIME_STOP_CANCELLED 2 - -#define NEBATTR_CHECK_ALERT 1 -#define NEBATTR_CHECK_FIRST 2 - - -/****** EVENT BROKER FUNCTIONS *************/ - -NAGIOS_BEGIN_DECL - -void broker_program_state(int, int, int); -void broker_log_data(int, int, int, char *, unsigned long, time_t); -int broker_event_handler(int, int, int, int, void *, int, int, struct timeval, struct timeval, double, int, int, int, char *, char *, char *); -void broker_system_command(int, int, int, struct timeval, struct timeval, double, int, int, int, char *, char *); -int broker_host_check(int, int, int, host *, int, int, int, struct timeval, struct timeval, char *, double, double, int, int, int, char *, char *, char *, char *, check_result *); -int broker_service_check(int, int, int, service *, int, struct timeval, struct timeval, char *, double, double, int, int, int, char *, check_result *); -void broker_comment_data(int, int, int, int, int, char *, char *, time_t, char *, char *, int, int, int, time_t, unsigned long); -void broker_downtime_data(int, int, int, int, char *, char *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long, unsigned long); -void broker_flapping_data(int, int, int, int, void *, double, double, double); -void broker_program_status(int, int, int); -void broker_host_status(int, int, int, host *); -void broker_service_status(int, int, int, service *); -void broker_contact_status(int, int, int, contact *); -neb_cb_resultset * broker_notification_data(int, int, int, int, int, struct timeval, struct timeval, void *, char *, char *, int, int); -int broker_contact_notification_data(int, int, int, int, int, struct timeval, struct timeval, void *, contact *, char *, char *, int); -int broker_contact_notification_method_data(int, int, int, int, int, struct timeval, struct timeval, void *, contact *, char *, char *, char *, int); -void broker_adaptive_program_data(int, int, int, int, unsigned long, unsigned long, unsigned long, unsigned long); -void broker_adaptive_host_data(int, int, int, host *, int, unsigned long, unsigned long); -void broker_adaptive_service_data(int, int, int, service *, int, unsigned long, unsigned long); -void broker_adaptive_contact_data(int, int, int, contact *, int, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); -int broker_external_command(int, int, int, int, time_t, char *, char *); -void broker_aggregated_status_data(int, int, int); -void broker_retention_data(int, int, int); -void broker_acknowledgement_data(int, int, int, int, void *, char *, char *, int, int, int); -void broker_statechange_data(int, int, int, int, void *, int, int, int, int); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/buildopts.h b/devtools/ci/naemon/buildopts.h deleted file mode 100644 index e9021f8..0000000 --- a/devtools/ci/naemon/buildopts.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef NAEMON_BUILDOPTS_H__ -#define NAEMON_BUILDOPTS_H__ -#define NAEMON_SYSCONFDIR "/opt/statusengine/etc/naemon" -#define NAEMON_LOCALSTATEDIR "/opt/statusengine/var" -#define NAEMON_LOGDIR "/opt/statusengine/var/log/naemon" -#define NAEMON_LOCKFILE "/opt/statusengine/var/cache/naemon/naemon.pid" -#define NAEMON_GROUP "jdrummer" -#define NAEMON_USER "jdrummer" -#endif diff --git a/devtools/ci/naemon/checks.h b/devtools/ci/naemon/checks.h deleted file mode 100644 index 3ccb194..0000000 --- a/devtools/ci/naemon/checks.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef _CHECKS_H -#define _CHECKS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lib/lnae-utils.h" -#include -#include - -/************ SERVICE DEPENDENCY VALUES ***************/ - -#define DEPENDENCIES_OK 0 -#define DEPENDENCIES_FAILED 1 - -/***************** OBJECT CHECK TYPES *****************/ -#define SERVICE_CHECK 0 -#define HOST_CHECK 1 - -/* useful for hosts and services to determine time 'til next check */ -#define normal_check_window(o) ((time_t)(o->check_interval * interval_length)) -#define retry_check_window(o) ((time_t)(o->retry_interval * interval_length)) -/* - * NOTE: This macro exists for convenience reasons, to avoid having one - * function for hosts and services each. As such, it's makes a bunch of assumptions, namely; - * - the passed object has a state_type, current_state, retry_interval and a - * check_interval field - * - the value of STATE_OK (for services) is equal to that of STATE_UP (for hosts) - **/ -#define check_window(o) \ - ((o->current_state != STATE_OK && o->state_type == SOFT_STATE) ? \ - retry_check_window(o) : \ - normal_check_window(o)) - -NAGIOS_BEGIN_DECL - -/* - * *name can be "Nagios Core", "Merlin", "mod_gearman" or "DNX", fe. - * source_name gets passed the 'source' pointer from check_result - * and must return a non-free()'able string useful for printing what - * we need to determine exactly where the check was received from, - * such as "mod_gearman worker@10.11.12.13", or "Nagios Core command - * file worker" (for passive checks submitted locally), which will be - * stashed with hosts and services and used as the "CHECKSOURCE" macro. - */ -struct check_engine { - char *name; /* "Nagios Core", "Merlin", "Mod Gearman" fe */ - const char *(*source_name)(void *); - void (*clean_result)(void *); -}; - -typedef struct check_result { - int object_check_type; /* is this a service or a host check? */ - char *host_name; /* host name */ - char *service_description; /* service description */ - int check_type; /* was this an active or passive service check? */ - int check_options; - int scheduled_check; /* was this a scheduled or an on-demand check? */ - char *output_file; /* what file is the output stored in? */ - FILE *output_file_fp; - double latency; - struct timeval start_time; /* time the service check was initiated */ - struct timeval finish_time; /* time the service check was completed */ - int early_timeout; /* did the service check timeout? */ - int exited_ok; /* did the plugin check return okay? */ - int return_code; /* plugin return code */ - char *output; /* plugin output */ - struct rusage rusage; /* resource usage by this check */ - struct check_engine *engine; /* where did we get this check from? */ - void *source; /* engine handles this */ -} check_result; - -struct check_output { - char *short_output; - char *long_output; - char *perf_data; -}; - -void checks_init(void); /* Init check execution, schedule events */ - -int parse_check_output(char *, char **, char **, char **, int, int); -struct check_output *parse_output(const char *, struct check_output *); - -int process_check_result_queue(char *); -int process_check_result_file(char *); -int process_check_result(check_result *); -int delete_check_result_file(char *); -int init_check_result(check_result *); -int free_check_result(check_result *); /* frees memory associated with a host/service check result */ - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/checks_host.h b/devtools/ci/naemon/checks_host.h deleted file mode 100644 index 2fa9308..0000000 --- a/devtools/ci/naemon/checks_host.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef CHECKS_HOST_H_ -#define CHECKS_HOST_H_ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "objects_host.h" - -NAGIOS_BEGIN_DECL - -/* initialize host check subsystem */ -void checks_init_hosts(void); - -/* Scheduling, reschedule host to be checked */ -void schedule_next_host_check(host *hst, time_t delay, int options); -void schedule_host_check(host *hst, time_t check_time, int options); /* DEPRECATED */ - -/* Result handling, Update a host given a check result */ -int handle_async_host_check_result(host *temp_host, check_result *queued_check_result); - -/* set host variables based on a check result */ -int update_host_state_post_check(host *hst, check_result *cr); - -/* Immutable, check if host is reachable */ -int check_host_dependencies(host *hst, int dependency_type); - -/* adjusts current host check attempt when a check is processed */ -int adjust_host_check_attempt(host *hst, int is_active); - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/checks_service.h b/devtools/ci/naemon/checks_service.h deleted file mode 100644 index a781c6f..0000000 --- a/devtools/ci/naemon/checks_service.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef CHECKS_SERVICE_H_ -#define CHECKS_SERVICE_H_ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "objects_service.h" - -NAGIOS_BEGIN_DECL - -/* initialize service check subsystem */ -void checks_init_services(void); - -/* Schedule next service check */ -void schedule_next_service_check(service *svc, time_t delay, int options); - -/* Scheduling, reschedule service to be checked, DEPRECATED */ -void schedule_service_check(service *, time_t, int); - -/* Result handling, Update a service given a check result */ -int handle_async_service_check_result(service *, check_result *); - -/* Immutable, check if service is reachable */ -int check_service_dependencies(service *, int); - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/commands.h b/devtools/ci/naemon/commands.h deleted file mode 100644 index b7539d9..0000000 --- a/devtools/ci/naemon/commands.h +++ /dev/null @@ -1,225 +0,0 @@ -#ifndef _COMMANDS_H -#define _COMMANDS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include "objects_contact.h" -#include "objects_host.h" -#include "objects_service.h" - -NAGIOS_BEGIN_DECL - -/**************************** COMMAND ERRORS *****************************/ -enum NmCommandError { - CMD_ERROR_OK = 0, /* No errors encountered */ - CMD_ERROR_UNKNOWN_COMMAND, /* Unknown/unsupported command */ - CMD_ERROR_MALFORMED_COMMAND, /* Command malformed/missing timestamp? */ - CMD_ERROR_INTERNAL_ERROR, /* Internal error */ - CMD_ERROR_FAILURE, /* Command routine failed */ - CMD_ERROR_PARSE_MISSING_ARG, /*Missing required argument for command*/ - CMD_ERROR_PARSE_EXCESS_ARG, /*Too many arguments for command*/ - CMD_ERROR_PARSE_TYPE_MISMATCH, /*Wrong type for argument, the argument could not be parsed*/ - CMD_ERROR_UNSUPPORTED_ARG_TYPE, /*Unsupported argument type - indicative of implementation bug*/ - CMD_ERROR_VALIDATION_FAILURE, /*Invalid value for argument (validator failed)*/ - CMD_ERROR_UNSUPPORTED_PARSE_MODE, /*Unsupported parse mode*/ - CMD_ERROR_CUSTOM_COMMAND, /*Backwards compat. custom command*/ -}; -#define NM_COMMAND_ERROR nm_command_error_quark () -GQuark nm_command_error_quark (void); - -#define GV(NAME) command_argument_get_value(ext_command, NAME) -#define GV_INT(NAME) (*(int *) GV(NAME)) -#define GV_BOOL(NAME) (GV_INT(NAME)) -#define GV_ULONG(NAME) (*(unsigned long*)GV(NAME)) -#define GV_TIMESTAMP(NAME) (*(time_t *) GV(NAME)) -#define GV_TIMEPERIOD(NAME) ((struct timeperiod *) GV(NAME)) -#define GV_CONTACT(NAME) ((struct contact *) GV(NAME)) -#define GV_CONTACTGROUP(NAME) ((struct contactgroup *) GV(NAME)) -#define GV_HOST(NAME) ((host *) GV(NAME)) -#define GV_HOSTGROUP(NAME) ((struct hostgroup *) GV(NAME)) -#define GV_SERVICE(NAME) ((struct service *) GV(NAME)) -#define GV_SERVICEGROUP(NAME) ((struct servicegroup *) GV(NAME)) -#define GV_STRING(NAME) ((char *) GV(NAME)) -#define GV_DOUBLE(NAME) (*(double *) GV(DOUBLE)) - -typedef enum { - UNKNOWN_TYPE, - CONTACT, - CONTACTGROUP, - TIMEPERIOD, - HOST, - HOSTGROUP, - SERVICE, - SERVICEGROUP, - STRING, - BOOL, - INTEGER, - ULONG, - TIMESTAMP, - DOUBLE -} arg_t; - -/*** PARSE MODES ***/ - -/** - * XXX: PARSE MODE PLACEHOLDER - * TODO: This is not yet implemented, and subject to change! - * Parse a command of the form [] ;=;=;=. - * Note the space between the end of the entry time and the name of the command, - * it is significant. Optional arguments (i.e arguments with default values) can be omitted - * by not specifying them. - * */ -#define COMMAND_SYNTAX_KV (1 << 1) - -/** - * Parse a command of the form [] ;;;. - * Note the space between the end of the entry time and the name of the command, - * it is significant. Optional arguments (i.e arguments with default values) can be omitted - * by replacing their position in the command string with and empty string (semicolons are still - * required to denote the absence of a value). - * - * Command strings in this form rely on the order of the arguments. - * */ -#define COMMAND_SYNTAX_NOKV (1 << 2) - - -typedef int (*arg_validator_fn)(void *value); - -struct external_command_argument; -struct external_command; -typedef int (*ext_command_handler)(const struct external_command *command, time_t entry_time); - -/** - * Create a command from the given parameters. argspec is a string specifying the argument template - * of the form "=name;=name2" where type is one of [timeperiod, host, hostgroup, service, - * servicegroup, str, bool, int, ulong, timestamp, double, contact, contactgroup]. argspecs do not - * support default values/optional arguments or custom validators, so if those are required you need - * to use the somewhat more laborious command_argument_add() interface. - * @param cmd The name of the command. Names must be unique within a register. Custom commands are denoted by a leading _ (underscore) - * @param handler Callback to be invoked for this command on command_execute_handler() - * @param description Text describing the purpose and any caveats of this command - * @param argspec Optional argument template specification. Pass NULL if no arguments are required or you want to add them manually with command_argument_add() - * @return Pointer to a command. To free the object, use command_destroy() - */ -struct external_command /*@null@*/ * command_create(char *cmd, ext_command_handler handler, char *description, char *argspec); - -/** - * Adds a template for one argument to a command. - * @param command The command to add an argument to - * @param name The name of the argument - * @param type The type of the argument, will be used to determine how to validate the argument if no validator callback is provided - * @param default_value A default value for this argument if no other value is passed. Must validate. Pass NULL if the argument is required (not optional) - * @param validator Callback that will be called upon parsing of this argument. - */ -void command_argument_add(struct external_command *command, char *name, arg_t type, void * default_value, arg_validator_fn validator); - - -/** - * Adds a command to the command register. Commands in the command register are susceptible to parsing. - * It is an error to deallocate/destroy a command which has been successfully registered. - * @param command The command to register - * @param id A unique ID for this command. Mainly intended for backwards compatibility for core commands. A negative value enables automatic ID allocation. - * @return On success, the allocated ID for the command is returned. On error, a negative value is returned. - */ -int command_register(struct external_command *command, int id); - -/** - * Does a lookup in the command register for a command name. - * @param command The name of the command - * @return If found, the command with the given name is returned. Otherwise, NULL is returned. - */ -struct external_command /*@null@*/ * command_lookup(const char *command); - -/** - * Returns the value of an argument for a command. If the command was retrieved by command_parse(), - * the parsed, validated argument value is returned. Otherwise, the default argument value is returned. - * @param command Command - * @param arg_name Name of the command (as specified in command_argument_add()) - * @return A pointer to the value of the argument. Use the GV* macros for convenient casting of argument values. - */ -void * command_argument_get_value(const struct external_command *command, const char *arg_name); - -/** - * Copies the argument value in src to dst. Space for the destination is allocated by the function. - * @param dst The destination. To free the destination, use free(). - * @param src The source - * @return On success, 0 is returned. Otherwise, a negative value is returned. - */ -int command_argument_value_copy(void **dst, const void *src, arg_t type); - -/** - * Unregisters and deallocates the given command. This has the effect of - * disabling the command for future invocations. - * @param command The command to unregister - */ -void command_unregister(struct external_command *command); - -/** - * Allocates space for and initializes the command register. The register grows as needed on - * @param initial_size The initial size (number of commands) of the register - */ -void registered_commands_init(int initial_size); - -/** - * Deinitializes the command register including deregistration and deallocation of all currently registered commands. - */ -void registered_commands_deinit(void); - -/** - * Destroys a command. - */ -void command_destroy(struct external_command * command); - -/** - * Parses a string in accordance with the specified mode. The mode is a bitwise or of modes to attempt - - * one or more of CMD_SYNTAX_NOKV and CMD_SYNTAX_KV - in that order. When a command is successfully parsed, - * a handle to the matching registered command is returned. - * @param cmdstr A command string - * @param mode Parse modes to attempt - * @param error Pointer to an integer in which to store error codes on failure. This code can be passed to cmd_error_strerror() for conversion to a human readable message. - * @return The parsed command, or NULL on failure. - */ -struct external_command /*@null@*/ * command_parse(const char * cmdstr, int mode, GError ** error); - -/** - * Executes the handler associated with a command. - * @param command Command - * @return One of OK or ERROR, signifying the success or failure, respectively, of the command handler - */ -int command_execute_handler(const struct external_command * command); - -/** - * For core use only. - */ -void register_core_commands(void); - -/* Various accessors */ -time_t command_entry_time(const struct external_command * command); -const char *command_raw_arguments(const struct external_command * command); -int command_id(const struct external_command * command); -const char *command_name(const struct external_command * command); - - -int open_command_file(void); /* creates the external command file as a named pipe (FIFO) and opens it for reading */ -int close_command_file(void); /* closes and deletes the external command file (FIFO) */ - -int process_external_command(char *cmd, int mode, GError **error); /* processes an external command given mode flags */ -int process_external_command1(char *cmd); /* DEPRECATED: top-level external old style command processor */ -int process_external_command2(int cmd, time_t entry_time, char *args); /* DEPRECATED: for backwards NEB compatibility only */ -int process_external_commands_from_file(char *, int); /* process external commands in a file */ - -int process_passive_service_check(time_t, char *, char *, int, char *); -int process_passive_host_check(time_t, char *, int, char *); - -int launch_command_file_worker(void); -int shutdown_command_file_worker(void); -int disconnect_command_file_worker(void); -int command_worker_get_pid(void); - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/comments.h b/devtools/ci/naemon/comments.h deleted file mode 100644 index ea176a7..0000000 --- a/devtools/ci/naemon/comments.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef _COMMENTS_H -#define _COMMENTS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "common.h" -#include "objects_host.h" -#include "objects_service.h" - - -/**************************** COMMENT SOURCES ******************************/ -#define COMMENTSOURCE_INTERNAL 0 -#define COMMENTSOURCE_EXTERNAL 1 - - -/***************************** COMMENT TYPES *******************************/ -#define HOST_COMMENT 1 -#define SERVICE_COMMENT 2 - - -/****************************** ENTRY TYPES ********************************/ -#define USER_COMMENT 1 -#define DOWNTIME_COMMENT 2 -#define FLAPPING_COMMENT 3 -#define ACKNOWLEDGEMENT_COMMENT 4 - - -/*************************** CHAINED HASH LIMITS ***************************/ -#define COMMENT_HASHSLOTS 1024 - - -/**************************** DATA STRUCTURES ******************************/ - -NAGIOS_BEGIN_DECL - -/* COMMENT structure */ -typedef struct comment { - int comment_type; - int entry_type; - unsigned long comment_id; - int source; - int persistent; - time_t entry_time; - int expires; - time_t expire_time; - char *host_name; - char *service_description; - char *author; - char *comment_data; - struct comment *next; - struct comment *nexthash; -} comment; - -extern struct comment *comment_list; - -int initialize_comment_data(void); /* initializes comment data */ -int add_new_comment(int, int, char *, char *, time_t, char *, char *, int, int, int, time_t, unsigned long *); /* adds a new host or service comment */ -int add_new_host_comment(int, char *, time_t, char *, char *, int, int, int, time_t, unsigned long *); /* adds a new host comment */ -int add_new_service_comment(int, char *, char *, time_t, char *, char *, int, int, int, time_t, unsigned long *); /* adds a new service comment */ -int delete_comment(int, unsigned long); /* deletes a host or service comment */ -int delete_host_comment(unsigned long); /* deletes a host comment */ -int delete_service_comment(unsigned long); /* deletes a service comment */ -int delete_all_comments(int, char *, char *); /* deletes all comments for a particular host or service */ -int delete_all_host_comments(char *); /* deletes all comments for a specific host */ -int delete_host_acknowledgement_comments(struct host *); /* deletes all non-persistent ack comments for a specific host */ -int delete_all_service_comments(char *, char *); /* deletes all comments for a specific service */ -int delete_service_acknowledgement_comments(struct service *); /* deletes all non-persistent ack comments for a specific service */ - -struct comment *find_comment(unsigned long, int); /* finds a specific comment */ -struct comment *find_service_comment(unsigned long); /* finds a specific service comment */ -struct comment *find_host_comment(unsigned long); /* finds a specific host comment */ - -struct comment *get_first_comment_by_host(char *); -struct comment *get_next_comment_by_host(char *, struct comment *); - -int number_of_host_comments(char *); /* returns the number of comments associated with a particular host */ -int number_of_service_comments(char *, char *); /* returns the number of comments associated with a particular service */ - -int add_comment(int, int, char *, char *, time_t, char *, char *, unsigned long, int, int, time_t, int); /* adds a comment (host or service) */ -int sort_comments(void); -int add_host_comment(int, char *, time_t, char *, char *, unsigned long, int, int, time_t, int); /* adds a host comment */ -int add_service_comment(int, char *, char *, time_t, char *, char *, unsigned long, int, int, time_t, int); /* adds a service comment */ - -int add_comment_to_hashlist(struct comment *); - -void free_comment_data(void); /* frees memory allocated to the comment list */ - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/common.h b/devtools/ci/naemon/common.h deleted file mode 100644 index a96c5eb..0000000 --- a/devtools/ci/naemon/common.h +++ /dev/null @@ -1,499 +0,0 @@ -#ifndef INCLUDE_COMMON_H -#define INCLUDE_COMMON_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "shared.h" - -NAGIOS_BEGIN_DECL - -/*************************************************************/ -/************** SHARED GLOBAL VARIABLES **********************/ -/*************************************************************/ -extern int date_format; -extern int interval_length; -extern char *illegal_output_chars; -extern char illegal_output_char_map[256]; - -extern int log_rotation_method; -extern int check_external_commands; -/* set this if you're going to add a ton of comments at once */ -extern int defer_comment_sorting; -extern unsigned long next_downtime_id; - -extern char *object_cache_file; -extern char *status_file; - -extern time_t program_start; -extern int nagios_pid; -extern int daemon_mode; - -extern time_t last_log_rotation; - -extern int process_performance_data; -extern int enable_flap_detection; -extern int enable_notifications; -extern int execute_service_checks; -extern int accept_passive_service_checks; -extern int execute_host_checks; -extern int accept_passive_host_checks; -extern int enable_event_handlers; -extern int obsess_over_services; -extern int obsess_over_hosts; - -extern int enable_timing_point; - -extern char *config_file_dir; - -#ifdef HAVE_TZNAME -#ifdef CYGWIN -char *_tzname[2] __declspec(dllimport); -#else -extern char *tzname[2]; -#endif -#endif - - -NAGIOS_END_DECL - - -/* Experimental performance tweaks - use with caution */ -#undef USE_MEMORY_PERFORMANCE_TWEAKS - - -/****************** OBJECT STATES ********************/ -#define STATE_OK 0 -#define STATE_WARNING 1 -#define STATE_CRITICAL 2 -#define STATE_UNKNOWN 3 -#define STATE_UP 0 -#define STATE_DOWN 1 -#define STATE_UNREACHABLE 2 - -/***************************** COMMANDS *********************************/ - -#define CMD_NONE 0 - -#define CMD_ADD_HOST_COMMENT 1 -#define CMD_DEL_HOST_COMMENT 2 - -#define CMD_ADD_SVC_COMMENT 3 -#define CMD_DEL_SVC_COMMENT 4 - -#define CMD_ENABLE_SVC_CHECK 5 -#define CMD_DISABLE_SVC_CHECK 6 - -#define CMD_SCHEDULE_SVC_CHECK 7 - -#define CMD_DELAY_SVC_NOTIFICATION 9 - -#define CMD_DELAY_HOST_NOTIFICATION 10 - -#define CMD_DISABLE_NOTIFICATIONS 11 -#define CMD_ENABLE_NOTIFICATIONS 12 - -#define CMD_RESTART_PROCESS 13 -#define CMD_SHUTDOWN_PROCESS 14 - -#define CMD_ENABLE_HOST_SVC_CHECKS 15 -#define CMD_DISABLE_HOST_SVC_CHECKS 16 - -#define CMD_SCHEDULE_HOST_SVC_CHECKS 17 - -#define CMD_DELAY_HOST_SVC_NOTIFICATIONS 19 /* currently unimplemented */ - -#define CMD_DEL_ALL_HOST_COMMENTS 20 -#define CMD_DEL_ALL_SVC_COMMENTS 21 - -#define CMD_ENABLE_SVC_NOTIFICATIONS 22 -#define CMD_DISABLE_SVC_NOTIFICATIONS 23 -#define CMD_ENABLE_HOST_NOTIFICATIONS 24 -#define CMD_DISABLE_HOST_NOTIFICATIONS 25 -#define CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST 26 -#define CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST 27 -#define CMD_ENABLE_HOST_SVC_NOTIFICATIONS 28 -#define CMD_DISABLE_HOST_SVC_NOTIFICATIONS 29 - -#define CMD_PROCESS_SERVICE_CHECK_RESULT 30 - -#define CMD_SAVE_STATE_INFORMATION 31 -#define CMD_READ_STATE_INFORMATION 32 - -#define CMD_ACKNOWLEDGE_HOST_PROBLEM 33 -#define CMD_ACKNOWLEDGE_SVC_PROBLEM 34 - -#define CMD_START_EXECUTING_SVC_CHECKS 35 -#define CMD_STOP_EXECUTING_SVC_CHECKS 36 - -#define CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS 37 -#define CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS 38 - -#define CMD_ENABLE_PASSIVE_SVC_CHECKS 39 -#define CMD_DISABLE_PASSIVE_SVC_CHECKS 40 - -#define CMD_ENABLE_EVENT_HANDLERS 41 -#define CMD_DISABLE_EVENT_HANDLERS 42 - -#define CMD_ENABLE_HOST_EVENT_HANDLER 43 -#define CMD_DISABLE_HOST_EVENT_HANDLER 44 - -#define CMD_ENABLE_SVC_EVENT_HANDLER 45 -#define CMD_DISABLE_SVC_EVENT_HANDLER 46 - -#define CMD_ENABLE_HOST_CHECK 47 -#define CMD_DISABLE_HOST_CHECK 48 - -#define CMD_START_OBSESSING_OVER_SVC_CHECKS 49 -#define CMD_STOP_OBSESSING_OVER_SVC_CHECKS 50 - -#define CMD_REMOVE_HOST_ACKNOWLEDGEMENT 51 -#define CMD_REMOVE_SVC_ACKNOWLEDGEMENT 52 - -#define CMD_SCHEDULE_FORCED_HOST_SVC_CHECKS 53 -#define CMD_SCHEDULE_FORCED_SVC_CHECK 54 - -#define CMD_SCHEDULE_HOST_DOWNTIME 55 -#define CMD_SCHEDULE_SVC_DOWNTIME 56 - -#define CMD_ENABLE_HOST_FLAP_DETECTION 57 -#define CMD_DISABLE_HOST_FLAP_DETECTION 58 - -#define CMD_ENABLE_SVC_FLAP_DETECTION 59 -#define CMD_DISABLE_SVC_FLAP_DETECTION 60 - -#define CMD_ENABLE_FLAP_DETECTION 61 -#define CMD_DISABLE_FLAP_DETECTION 62 - -#define CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS 63 -#define CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS 64 - -#define CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS 65 -#define CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS 66 - -#define CMD_ENABLE_HOSTGROUP_SVC_CHECKS 67 -#define CMD_DISABLE_HOSTGROUP_SVC_CHECKS 68 - -/* commands 69-77 are unimplemented */ -#define CMD_UNIMPLEMENTED_69 69 -#define CMD_UNIMPLEMENTED_70 70 -#define CMD_UNIMPLEMENTED_71 71 -#define CMD_UNIMPLEMENTED_72 72 -#define CMD_UNIMPLEMENTED_73 73 -#define CMD_UNIMPLEMENTED_74 74 -#define CMD_UNIMPLEMENTED_75 75 -#define CMD_UNIMPLEMENTED_76 76 -#define CMD_UNIMPLEMENTED_77 77 - -#define CMD_DEL_HOST_DOWNTIME 78 -#define CMD_DEL_SVC_DOWNTIME 79 - -#define CMD_ENABLE_PERFORMANCE_DATA 82 -#define CMD_DISABLE_PERFORMANCE_DATA 83 - -#define CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME 84 -#define CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME 85 -#define CMD_SCHEDULE_HOST_SVC_DOWNTIME 86 - -/* new commands in Nagios 2.x found below... */ -#define CMD_PROCESS_HOST_CHECK_RESULT 87 - -#define CMD_START_EXECUTING_HOST_CHECKS 88 -#define CMD_STOP_EXECUTING_HOST_CHECKS 89 - -#define CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS 90 -#define CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS 91 - -#define CMD_ENABLE_PASSIVE_HOST_CHECKS 92 -#define CMD_DISABLE_PASSIVE_HOST_CHECKS 93 - -#define CMD_START_OBSESSING_OVER_HOST_CHECKS 94 -#define CMD_STOP_OBSESSING_OVER_HOST_CHECKS 95 - -#define CMD_SCHEDULE_HOST_CHECK 96 -#define CMD_SCHEDULE_FORCED_HOST_CHECK 98 - -#define CMD_START_OBSESSING_OVER_SVC 99 -#define CMD_STOP_OBSESSING_OVER_SVC 100 - -#define CMD_START_OBSESSING_OVER_HOST 101 -#define CMD_STOP_OBSESSING_OVER_HOST 102 - -#define CMD_ENABLE_HOSTGROUP_HOST_CHECKS 103 -#define CMD_DISABLE_HOSTGROUP_HOST_CHECKS 104 - -#define CMD_ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS 105 -#define CMD_DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS 106 - -#define CMD_ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS 107 -#define CMD_DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS 108 - -#define CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS 109 -#define CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS 110 - -#define CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS 111 -#define CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS 112 - -#define CMD_ENABLE_SERVICEGROUP_SVC_CHECKS 113 -#define CMD_DISABLE_SERVICEGROUP_SVC_CHECKS 114 - -#define CMD_ENABLE_SERVICEGROUP_HOST_CHECKS 115 -#define CMD_DISABLE_SERVICEGROUP_HOST_CHECKS 116 - -#define CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS 117 -#define CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS 118 - -#define CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS 119 -#define CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS 120 - -#define CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME 121 -#define CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME 122 - -#define CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER 123 -#define CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER 124 - -#define CMD_CHANGE_HOST_EVENT_HANDLER 125 -#define CMD_CHANGE_SVC_EVENT_HANDLER 126 - -#define CMD_CHANGE_HOST_CHECK_COMMAND 127 -#define CMD_CHANGE_SVC_CHECK_COMMAND 128 - -#define CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL 129 -#define CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL 130 -#define CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL 131 - -#define CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS 132 -#define CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS 133 - -#define CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME 134 - -#define CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS 135 -#define CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS 136 - -#define CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME 137 - -#define CMD_ENABLE_SERVICE_FRESHNESS_CHECKS 138 -#define CMD_DISABLE_SERVICE_FRESHNESS_CHECKS 139 - -#define CMD_ENABLE_HOST_FRESHNESS_CHECKS 140 -#define CMD_DISABLE_HOST_FRESHNESS_CHECKS 141 - -#define CMD_SET_HOST_NOTIFICATION_NUMBER 142 -#define CMD_SET_SVC_NOTIFICATION_NUMBER 143 - -/* new commands in Nagios 3.x found below... */ -#define CMD_CHANGE_HOST_CHECK_TIMEPERIOD 144 -#define CMD_CHANGE_SVC_CHECK_TIMEPERIOD 145 - -#define CMD_PROCESS_FILE 146 - -#define CMD_CHANGE_CUSTOM_HOST_VAR 147 -#define CMD_CHANGE_CUSTOM_SVC_VAR 148 -#define CMD_CHANGE_CUSTOM_CONTACT_VAR 149 - -#define CMD_ENABLE_CONTACT_HOST_NOTIFICATIONS 150 -#define CMD_DISABLE_CONTACT_HOST_NOTIFICATIONS 151 -#define CMD_ENABLE_CONTACT_SVC_NOTIFICATIONS 152 -#define CMD_DISABLE_CONTACT_SVC_NOTIFICATIONS 153 - -#define CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS 154 -#define CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS 155 -#define CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS 156 -#define CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS 157 - -#define CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL 158 - -#define CMD_SEND_CUSTOM_HOST_NOTIFICATION 159 -#define CMD_SEND_CUSTOM_SVC_NOTIFICATION 160 - -#define CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD 161 -#define CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD 162 -#define CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD 163 -#define CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD 164 - -#define CMD_CHANGE_HOST_MODATTR 165 -#define CMD_CHANGE_SVC_MODATTR 166 -#define CMD_CHANGE_CONTACT_MODATTR 167 -#define CMD_CHANGE_CONTACT_MODHATTR 168 -#define CMD_CHANGE_CONTACT_MODSATTR 169 - -#define CMD_DEL_DOWNTIME_BY_HOST_NAME 170 -#define CMD_DEL_DOWNTIME_BY_HOSTGROUP_NAME 171 -#define CMD_DEL_DOWNTIME_BY_START_TIME_COMMENT 172 - -/* custom command introduced in Nagios 3.x */ -#define CMD_CUSTOM_COMMAND 999 - -/**************************** CHECK TYPES ********************************/ - -#define CHECK_TYPE_ACTIVE 0 -#define CHECK_TYPE_PASSIVE 1 -#define CHECK_TYPE_PARENT 2 /* (active) check for the benefit of dependent objects */ -#define CHECK_TYPE_FILE 3 /* from spool files (yuck) */ -#define CHECK_TYPE_OTHER 4 /* for modules to use */ - - -/************* LEGACY (deprecated) CHECK TYPES ***************************/ - -#define SERVICE_CHECK_ACTIVE CHECK_TYPE_ACTIVE -#define SERVICE_CHECK_PASSIVE CHECK_TYPE_PASSIVE -#define HOST_CHECK_ACTIVE CHECK_TYPE_ACTIVE -#define HOST_CHECK_PASSIVE CHECK_TYPE_PASSIVE - - -/************************ SERVICE STATE TYPES ****************************/ - -#define SOFT_STATE 0 -#define HARD_STATE 1 - - -/************************* SCHEDULED DOWNTIME TYPES **********************/ - -#define SERVICE_DOWNTIME 1 /* service downtime */ -#define HOST_DOWNTIME 2 /* host downtime */ -#define ANY_DOWNTIME 3 /* host or service downtime */ - - -/************************** NOTIFICATION OPTIONS *************************/ - -#define NOTIFICATION_OPTION_NONE 0 -#define NOTIFICATION_OPTION_BROADCAST 1 -#define NOTIFICATION_OPTION_FORCED 2 -#define NOTIFICATION_OPTION_INCREMENT 4 - - -/************************** ACKNOWLEDGEMENT TYPES ************************/ - -#define HOST_ACKNOWLEDGEMENT 0 -#define SERVICE_ACKNOWLEDGEMENT 1 - -#define ACKNOWLEDGEMENT_NONE 0 -#define ACKNOWLEDGEMENT_NORMAL 1 -#define ACKNOWLEDGEMENT_STICKY 2 - - -/**************************** DEPENDENCY TYPES ***************************/ - -#define NOTIFICATION_DEPENDENCY 1 -#define EXECUTION_DEPENDENCY 2 - - - -/********************** HOST/SERVICE CHECK OPTIONS ***********************/ - -#define CHECK_OPTION_NONE 0 /* no check options */ -#define CHECK_OPTION_FORCE_EXECUTION 1 /* force execution of a check (ignores disabled services/hosts, invalid timeperiods) */ -#define CHECK_OPTION_FRESHNESS_CHECK 2 /* this is a freshness check */ -#define CHECK_OPTION_ORPHAN_CHECK 4 /* flag for scheduled checks from orphan event handler */ -#define CHECK_OPTION_DEPENDENCY_CHECK 8 /* dependency check. different scheduling rules apply */ -#define CHECK_OPTION_ALLOW_POSTPONE 16 /* allow the check to take precedence over an earlier (sooner) scheduled check */ - - -/**************************** PROGRAM MODES ******************************/ - -#define STANDBY_MODE 0 -#define ACTIVE_MODE 1 - - -/************************** LOG ROTATION MODES ***************************/ - -#define LOG_ROTATION_NONE 0 -#define LOG_ROTATION_HOURLY 1 -#define LOG_ROTATION_DAILY 2 -#define LOG_ROTATION_WEEKLY 3 -#define LOG_ROTATION_MONTHLY 4 - - -/***************************** LOG VERSIONS ******************************/ - -#define LOG_VERSION_1 "1.0" -#define LOG_VERSION_2 "2.0" - - - -/*************************** CHECK STATISTICS ****************************/ - -#define ACTIVE_SCHEDULED_SERVICE_CHECK_STATS 0 -#define ACTIVE_ONDEMAND_SERVICE_CHECK_STATS 1 -#define PASSIVE_SERVICE_CHECK_STATS 2 -#define ACTIVE_SCHEDULED_HOST_CHECK_STATS 3 -#define ACTIVE_ONDEMAND_HOST_CHECK_STATS 4 -#define PASSIVE_HOST_CHECK_STATS 5 -#define ACTIVE_CACHED_HOST_CHECK_STATS 6 -#define ACTIVE_CACHED_SERVICE_CHECK_STATS 7 -#define EXTERNAL_COMMAND_STATS 8 -#define PARALLEL_HOST_CHECK_STATS 9 -#define SERIAL_HOST_CHECK_STATS 10 -#define MAX_CHECK_STATS_TYPES 11 - - -/****************** HOST CONFIG FILE READING OPTIONS ********************/ - -#define READ_HOSTS 1 -#define READ_HOSTGROUPS 2 -#define READ_CONTACTS 4 -#define READ_CONTACTGROUPS 8 -#define READ_SERVICES 16 -#define READ_COMMANDS 32 -#define READ_TIMEPERIODS 64 -#define READ_SERVICEESCALATIONS 128 -#define READ_HOSTGROUPESCALATIONS 256 /* no longer implemented */ -#define READ_SERVICEDEPENDENCIES 512 -#define READ_HOSTDEPENDENCIES 1024 -#define READ_HOSTESCALATIONS 2048 -#define READ_HOSTEXTINFO 4096 -#define READ_SERVICEEXTINFO 8192 -#define READ_SERVICEGROUPS 16384 - -#define READ_ALL_OBJECT_DATA READ_HOSTS | READ_HOSTGROUPS | READ_CONTACTS | READ_CONTACTGROUPS | READ_SERVICES | READ_COMMANDS | READ_TIMEPERIODS | READ_SERVICEESCALATIONS | READ_SERVICEDEPENDENCIES | READ_HOSTDEPENDENCIES | READ_HOSTESCALATIONS | READ_HOSTEXTINFO | READ_SERVICEEXTINFO | READ_SERVICEGROUPS - - -/************************** DATE/TIME TYPES *****************************/ - -#define LONG_DATE_TIME 0 -#define SHORT_DATE_TIME 1 -#define SHORT_DATE 2 -#define SHORT_TIME 3 -#define HTTP_DATE_TIME 4 /* time formatted for use in HTTP headers */ - - -/**************************** DATE FORMATS ******************************/ - -#define DATE_FORMAT_US 0 /* U.S. (MM-DD-YYYY HH:MM:SS) */ -#define DATE_FORMAT_EURO 1 /* European (DD-MM-YYYY HH:MM:SS) */ -#define DATE_FORMAT_ISO8601 2 /* ISO8601 (YYYY-MM-DD HH:MM:SS) */ -#define DATE_FORMAT_STRICT_ISO8601 3 /* ISO8601 (YYYY-MM-DDTHH:MM:SS) */ - - -/************************** MISC DEFINITIONS ****************************/ - -#define MAX_FILENAME_LENGTH 256 /* max length of path/filename that Nagios will process */ -#define MAX_INPUT_BUFFER 1024 /* size in bytes of max. input buffer (for reading files, misc stuff) */ -#define MAX_COMMAND_BUFFER 8192 /* max length of raw or processed command line */ -#define MAX_EXTERNAL_COMMAND_LENGTH 8192 /* max length of an external command */ - -#define MAX_DATETIME_LENGTH 48 - - -/************************* MODIFIED ATTRIBUTES **************************/ - -#define MODATTR_NONE 0 -#define MODATTR_NOTIFICATIONS_ENABLED 1 -#define MODATTR_ACTIVE_CHECKS_ENABLED 2 -#define MODATTR_PASSIVE_CHECKS_ENABLED 4 -#define MODATTR_EVENT_HANDLER_ENABLED 8 -#define MODATTR_FLAP_DETECTION_ENABLED 16 -#define MODATTR_FAILURE_PREDICTION_ENABLED 32 -#define MODATTR_PERFORMANCE_DATA_ENABLED 64 -#define MODATTR_OBSESSIVE_HANDLER_ENABLED 128 -#define MODATTR_EVENT_HANDLER_COMMAND 256 -#define MODATTR_CHECK_COMMAND 512 -#define MODATTR_NORMAL_CHECK_INTERVAL 1024 -#define MODATTR_RETRY_CHECK_INTERVAL 2048 -#define MODATTR_MAX_CHECK_ATTEMPTS 4096 -#define MODATTR_FRESHNESS_CHECKS_ENABLED 8192 -#define MODATTR_CHECK_TIMEPERIOD 16384 -#define MODATTR_CUSTOM_VARIABLE 32768 -#define MODATTR_NOTIFICATION_TIMEPERIOD 65536 -#endif /* INCLUDE_COMMON_H */ diff --git a/devtools/ci/naemon/configuration.h b/devtools/ci/naemon/configuration.h deleted file mode 100644 index 4bcc9a6..0000000 --- a/devtools/ci/naemon/configuration.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _CONFIGURATION_H -#define _CONFIGURATION_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lib/lnae-utils.h" - -NAGIOS_BEGIN_DECL - -int read_main_config_file(const char *); /* reads the main config file (naemon.cfg) */ -int read_resource_file(const char *); /* processes macros in resource file */ -int read_all_object_data(const char *); /* reads all object config data */ - -int pre_flight_check(void); /* try and verify the configuration data */ -int pre_flight_object_check(int *, int *); /* verify object relationships and settings */ -int pre_flight_circular_check(int *, int *); /* detects circular dependencies and paths */ - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/defaults.h b/devtools/ci/naemon/defaults.h deleted file mode 100644 index 749d6a2..0000000 --- a/devtools/ci/naemon/defaults.h +++ /dev/null @@ -1,136 +0,0 @@ -#ifndef INCLUDE_defaults_h__ -#define INCLUDE_defaults_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "buildopts.h" - -/******************* DEFAULT VALUES *******************/ - -#define DEFAULT_LOG_LEVEL 1 /* log all events to main log file */ -#define DEFAULT_USE_SYSLOG 1 /* log events to syslog? 1=yes, 0=no */ -#define DEFAULT_SYSLOG_LEVEL 2 /* log only severe events to syslog */ - -#define DEFAULT_NOTIFICATION_LOGGING 1 /* log notification events? 1=yes, 0=no */ -#define DEFAULT_NSR_LOGGING 1 /* log notification suppression reasons? 1=yes, 0=no */ -#define DEFAULT_INTER_CHECK_DELAY 5.0 /* seconds between initial service check scheduling */ -#define DEFAULT_INTERLEAVE_FACTOR 1 /* default interleave to use when scheduling checks */ -#define DEFAULT_RETRY_INTERVAL 30 /* services are retried in 30 seconds if they're not OK */ -#define DEFAULT_CHECK_REAPER_INTERVAL 10 /* interval in seconds to reap host and service check results */ -#define DEFAULT_MAX_REAPER_TIME 30 /* maximum number of seconds to spend reaping service checks before we break out for a while */ -#define DEFAULT_MAX_CHECK_RESULT_AGE 3600 /* maximum number of seconds that a check result file is considered to be valid */ -#define DEFAULT_MAX_PARALLEL_SERVICE_CHECKS 0 /* maximum number of service checks we can have running at any given time (0=unlimited) */ -#define DEFAULT_RETENTION_UPDATE_INTERVAL 60 /* minutes between auto-save of retention data */ -#define DEFAULT_RETAINED_SCHEDULING_RANDOMIZE_WINDOW 60 /* number of seconds used for randomizing the re-scheduling of checks missed over a restart */ -#define DEFAULT_RETENTION_SCHEDULING_HORIZON 900 /* max seconds between program restarts that we will preserve scheduling information */ -#define DEFAULT_STATUS_UPDATE_INTERVAL 60 /* seconds between aggregated status data updates */ -#define DEFAULT_FRESHNESS_CHECK_INTERVAL 60 /* seconds between service result freshness checks */ -#define DEFAULT_ORPHAN_CHECK_INTERVAL 60 /* seconds between checks for orphaned hosts and services */ - -#define DEFAULT_INTERVAL_LENGTH 60 /* seconds per interval unit for check scheduling */ - -#define DEFAULT_NOTIFICATION_TIMEOUT 30 /* max time in seconds to wait for notification commands to complete */ -#define DEFAULT_EVENT_HANDLER_TIMEOUT 30 /* max time in seconds to wait for event handler commands to complete */ -#define DEFAULT_HOST_CHECK_TIMEOUT 30 /* max time in seconds to wait for host check commands to complete */ -#define DEFAULT_SERVICE_CHECK_TIMEOUT 60 /* max time in seconds to wait for service check commands to complete */ -#define DEFAULT_OCSP_TIMEOUT 15 /* max time in seconds to wait for obsessive compulsive processing commands to complete */ -#define DEFAULT_OCHP_TIMEOUT 15 /* max time in seconds to wait for obsessive compulsive processing commands to complete */ -#define DEFAULT_PERFDATA_TIMEOUT 5 /* max time in seconds to wait for performance data commands to complete */ -#define DEFAULT_TIME_CHANGE_THRESHOLD 900 /* compensate for time changes of more than 15 minutes */ - -#define DEFAULT_LOG_HOST_RETRIES 0 /* don't log host retries */ -#define DEFAULT_LOG_SERVICE_RETRIES 0 /* don't log service retries */ -#define DEFAULT_LOG_EVENT_HANDLERS 1 /* log event handlers */ -#define DEFAULT_LOG_INITIAL_STATES 0 /* don't log initial service and host states */ -#define DEFAULT_LOG_CURRENT_STATES 1 /* log current service and host states after rotating log */ -#define DEFAULT_LOG_EXTERNAL_COMMANDS 1 /* log external commands */ -#define DEFAULT_LOG_PASSIVE_CHECKS 1 /* log passive service checks */ - -#define DEFAULT_DEBUG_LEVEL 0 /* don't log any debugging information */ -#define DEFAULT_DEBUG_VERBOSITY 1 -#define DEFAULT_MAX_DEBUG_FILE_SIZE 1000000 /* max size of debug log */ - -#define DEFAULT_AGGRESSIVE_HOST_CHECKING 0 /* don't use "aggressive" host checking */ -#define DEFAULT_CHECK_EXTERNAL_COMMANDS 1 /* check for external commands */ -#define DEFAULT_CHECK_ORPHANED_SERVICES 1 /* check for orphaned services */ -#define DEFAULT_CHECK_ORPHANED_HOSTS 1 /* check for orphaned hosts */ -#define DEFAULT_ENABLE_FLAP_DETECTION 0 /* don't enable flap detection */ -#define DEFAULT_PROCESS_PERFORMANCE_DATA 0 /* don't process performance data */ -#define DEFAULT_CHECK_SERVICE_FRESHNESS 1 /* check service result freshness */ -#define DEFAULT_CHECK_HOST_FRESHNESS 0 /* don't check host result freshness */ -#define DEFAULT_TRANSLATE_PASSIVE_HOST_CHECKS 0 /* should we translate DOWN/UNREACHABLE passive host checks? */ -#define DEFAULT_PASSIVE_HOST_CHECKS_SOFT 0 /* passive host checks are treated as HARD by default */ - -#define DEFAULT_LOW_SERVICE_FLAP_THRESHOLD 20.0 /* low threshold for detection of service flapping */ -#define DEFAULT_HIGH_SERVICE_FLAP_THRESHOLD 30.0 /* high threshold for detection of service flapping */ -#define DEFAULT_LOW_HOST_FLAP_THRESHOLD 20.0 /* low threshold for detection of host flapping */ -#define DEFAULT_HIGH_HOST_FLAP_THRESHOLD 30.0 /* high threshold for detection of host flapping */ - -#define DEFAULT_CACHED_HOST_CHECK_HORIZON 15 /* max age in seconds that cached host checks can be used */ -#define DEFAULT_CACHED_SERVICE_CHECK_HORIZON 15 /* max age in seconds that cached service checks can be used */ -#define DEFAULT_ENABLE_PREDICTIVE_HOST_DEPENDENCY_CHECKS 1 /* should we use predictive host dependency checks? */ -#define DEFAULT_ENABLE_PREDICTIVE_SERVICE_DEPENDENCY_CHECKS 1 /* should we use predictive service dependency checks? */ - -#define DEFAULT_USE_LARGE_INSTALLATION_TWEAKS 0 /* don't use tweaks for large Nagios installations */ - -#define DEFAULT_ADDITIONAL_FRESHNESS_LATENCY 15 /* seconds to be added to freshness thresholds when automatically calculated by Nagios */ - -#define DEFAULT_CHECK_FOR_UPDATES 1 /* should we check for new Nagios releases? */ -#define DEFAULT_BARE_UPDATE_CHECK 0 /* report current version and new installs */ -#define MINIMUM_UPDATE_CHECK_INTERVAL 60*60*22 /* 22 hours minimum between checks - please be kind to our servers! */ -#define BASE_UPDATE_CHECK_INTERVAL 60*60*22 /* 22 hours base interval */ -#define UPDATE_CHECK_INTERVAL_WOBBLE 60*60*4 /* 4 hour wobble on top of base interval */ -#define BASE_UPDATE_CHECK_RETRY_INTERVAL 60*60*1 /* 1 hour base retry interval */ -#define UPDATE_CHECK_RETRY_INTERVAL_WOBBLE 60*60*3 /* 3 hour wobble on top of base retry interval */ - -#define DEFAULT_ALLOW_EMPTY_HOSTGROUP_ASSIGNMENT 2 /* Allow assigning to empty hostgroups by default, but warn about it */ -#define DEFAULT_ALLOW_CIRCULAR_DEPENDENCIES 0 /* Allow circular depdendencies */ -#define DEFAULT_HOST_DOWN_DISABLE_SERVICE_CHECKS 0 /* run service checks if the host is down */ - -#define DEFAULT_HOST_PERFDATA_FILE_TEMPLATE "[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$" -#define DEFAULT_SERVICE_PERFDATA_FILE_TEMPLATE "[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$" -#define DEFAULT_HOST_PERFDATA_PROCESS_EMPTY_RESULTS 1 -#define DEFAULT_SERVICE_PERFDATA_PROCESS_EMPTY_RESULTS 1 - - -/* Legacy way to find out default locations - do not go near these, as they - * cause configure options to trigger ABI breaks. At some point, they'll become - * hidden */ -#define DEFAULT_TEMP_FILE NAEMON_LOCALSTATEDIR "/tempfile" -#define DEFAULT_TEMP_PATH "/tmp" -#define DEFAULT_CHECK_RESULT_PATH NAEMON_LOCALSTATEDIR "/spool/checkresults" -#define DEFAULT_STATUS_FILE NAEMON_LOCALSTATEDIR "/status.dat" -#define DEFAULT_LOG_FILE NAEMON_LOGDIR "/naemon.log" -#define DEFAULT_LOG_ARCHIVE_PATH NAEMON_LOGDIR "/archives/" -#define DEFAULT_DEBUG_FILE NAEMON_LOCALSTATEDIR "/naemon.debug" -#define DEFAULT_COMMENT_FILE NAEMON_LOCALSTATEDIR "/comments.dat" /* not used anywhere */ -#define DEFAULT_DOWNTIME_FILE NAEMON_LOCALSTATEDIR "/downtime.dat" /* not used anywhere */ -#define DEFAULT_RETENTION_FILE NAEMON_LOCALSTATEDIR "/retention.dat" -#define DEFAULT_COMMAND_FILE NAEMON_LOCALSTATEDIR "/naemon.cmd" -#define DEFAULT_QUERY_SOCKET NAEMON_LOCALSTATEDIR "/naemon.qh" -#define DEFAULT_CONFIG_FILE NAEMON_SYSCONFDIR "/naemon.cfg" -#define DEFAULT_LOCK_FILE NAEMON_LOCKFILE -#define DEFAULT_OBJECT_CACHE_FILE NAEMON_LOCALSTATEDIR "/objects.cache" -#define DEFAULT_PRECACHED_OBJECT_FILE NAEMON_LOCALSTATEDIR "/objects.precache" -#define DEFAULT_EVENT_BROKER_FILE NAEMON_LOCALSTATEDIR "/broker.socket" - -/* modern way to find out default locations */ -const char *get_default_temp_file(void); -const char *get_default_temp_path(void); -const char *get_default_check_result_path(void); -const char *get_default_status_file(void); -const char *get_default_log_file(void); -const char *get_default_log_archive_path(void); -const char *get_default_debug_file(void); -const char *get_default_retention_file(void); -const char *get_default_command_file(void); -const char *get_default_query_socket(void); -const char *get_default_config_file(void); -const char *get_default_lock_file(void); -const char *get_default_object_cache_file(void); -const char *get_default_precached_object_file(void); -const char *get_default_event_broker_file(void); - -#endif /* INCLUDE_defaults_h__ */ diff --git a/devtools/ci/naemon/downtime.h b/devtools/ci/naemon/downtime.h deleted file mode 100644 index c7cfa23..0000000 --- a/devtools/ci/naemon/downtime.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef _DOWNTIME_H -#define _DOWNTIME_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "common.h" -#include "objects_host.h" -#include "objects_service.h" - -NAGIOS_BEGIN_DECL - -/* SCHEDULED_DOWNTIME_ENTRY structure */ -typedef struct scheduled_downtime { - int type; - char *host_name; - char *service_description; - time_t entry_time; - time_t start_time; - time_t flex_downtime_start; /* Time the flexible downtime started */ - time_t end_time; - int fixed; - unsigned long triggered_by; - unsigned long duration; - unsigned long downtime_id; - int is_in_effect; - int start_notification_sent; - char *author; - char *comment; - unsigned long comment_id; - int start_flex_downtime; - int incremented_pending_downtime; /* UNUSED */ - struct scheduled_downtime *next; - struct timed_event *start_event, *stop_event; - struct scheduled_downtime *prev; -} scheduled_downtime; - -extern struct scheduled_downtime *scheduled_downtime_list; - - -int initialize_downtime_data(void); /* initializes scheduled downtime data */ -int cleanup_downtime_data(void); /* cleans up scheduled downtime data */ - -int add_new_downtime(int, char *, char *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long, unsigned long *, int, int); -int add_new_host_downtime(char *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long, unsigned long *, int, int); -int add_new_service_downtime(char *, char *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long, unsigned long *, int, int); - -int delete_host_downtime(unsigned long); -int delete_service_downtime(unsigned long); -int delete_downtime(int, unsigned long); - -int schedule_downtime(int, char *, char *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long, unsigned long *); -int unschedule_downtime(int, unsigned long); - -int register_downtime(int, unsigned long); -int handle_scheduled_downtime(struct scheduled_downtime *); -int handle_scheduled_downtime_by_id(unsigned long); - -int check_pending_flex_host_downtime(struct host *); -int check_pending_flex_service_downtime(struct service *); - -int add_host_downtime(char *, time_t, char *, char *, time_t, time_t, time_t, int, unsigned long, unsigned long, unsigned long, int, int, unsigned long *); -int add_service_downtime(char *, char *, time_t, char *, char *, time_t, time_t, time_t, int, unsigned long, unsigned long, unsigned long, int, int, unsigned long *); - -/* If you are going to be adding a lot of downtime in sequence, set - defer_downtime_sorting to 1 before you start and then call - sort_downtime afterwards. Things will go MUCH faster. */ - -extern int defer_downtime_sorting; -int add_downtime(int, char *, char *, time_t, char *, char *, time_t, time_t, time_t, int, unsigned long, unsigned long, unsigned long, int, int, unsigned long *); -int sort_downtime(void); - -struct scheduled_downtime *find_downtime(int, unsigned long); -struct scheduled_downtime *find_host_downtime(unsigned long); -struct scheduled_downtime *find_service_downtime(unsigned long); - -void free_downtime_data(void); /* frees memory allocated to scheduled downtime list */ - -int delete_downtime_by_hostname_service_description_start_time_comment(char *, char *, time_t, char *); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/events.h b/devtools/ci/naemon/events.h deleted file mode 100644 index 3868261..0000000 --- a/devtools/ci/naemon/events.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _EVENTS_H -#define _EVENTS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lib/lnae-utils.h" -#include "lib/iobroker.h" - -/******************* EVENT TYPES **********************/ - -NAGIOS_BEGIN_DECL - -extern iobroker_set *nagios_iobs; - -/* Set if execution of the callback is done normally because of timed event */ -enum nm_exec_type { - EVENT_EXEC_NORMAL, /* Everything was fine, the event is a proper event */ - EVENT_EXEC_ABORTED, /* The event wasn't completed: a timeout for timed events, or a socket problem for input events */ -}; - -enum nm_event_type { - EVENT_TYPE_TIMED, -}; - -struct timed_event; -typedef struct timed_event timed_event; - -struct nm_event_execution_properties { - enum nm_exec_type execution_type; - enum nm_event_type event_type; - void *user_data; - union { - struct { - timed_event *event; - double latency; - } timed; /* only available if event_type is EVENT_EXEC_FLAG_TIMED */ - } attributes; -}; - -typedef void (*event_callback)(struct nm_event_execution_properties *); - -/** - * Schedule a timed event. At the given time, the callback is executed - */ -timed_event *schedule_event(time_t delay, event_callback callback, void *user_data); -void destroy_event(timed_event *event); - -/** - * Gets the number of milliseconds until the supplied event's scheduled - * execution time - * @param ev the \p timed_event - * @return The number of milliseconds - */ -long get_timed_event_time_left_ms(timed_event *ev); - -/* Main function */ -void init_event_queue(void); /* creates the queue nagios_squeue */ -int event_poll(void); /* main monitoring/event handler loop */ -void destroy_event_queue(void); /* destroys the queue nagios_squeue */ - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/flapping.h b/devtools/ci/naemon/flapping.h deleted file mode 100644 index 4bffcc4..0000000 --- a/devtools/ci/naemon/flapping.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _FLAPPING_H -#define _FLAPPING_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "objects_host.h" -#include "objects_service.h" - - -#define HOST_FLAPPING 0 -#define SERVICE_FLAPPING 1 - -NAGIOS_BEGIN_DECL - -void check_for_service_flapping(service *, int); /* determines whether or not a service is "flapping" between states */ -void check_for_host_flapping(host *, int, int); /* determines whether or not a host is "flapping" between states */ -void set_service_flap(service *, double, double, double); /* handles a service that is flapping */ -void clear_service_flap(service *, double, double, double); /* handles a service that has stopped flapping */ -void set_host_flap(host *, double, double, double); /* handles a host that is flapping */ -void clear_host_flap(host *, double, double, double); /* handles a host that has stopped flapping */ -void enable_flap_detection_routines(void); /* enables flap detection on a program-wide basis */ -void disable_flap_detection_routines(void); /* disables flap detection on a program-wide basis */ -void enable_host_flap_detection(host *); /* enables flap detection for a particular host */ -void disable_host_flap_detection(host *); /* disables flap detection for a particular host */ -void enable_service_flap_detection(service *); /* enables flap detection for a particular service */ -void disable_service_flap_detection(service *); /* disables flap detection for a particular service */ -void handle_host_flap_detection_disabled(host *); /* handles the details when flap detection is disabled globally or on a per-host basis */ -void handle_service_flap_detection_disabled(service *); /* handles the details when flap detection is disabled globally or on a per-service basis */ - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/globals.h b/devtools/ci/naemon/globals.h deleted file mode 100644 index 768f236..0000000 --- a/devtools/ci/naemon/globals.h +++ /dev/null @@ -1,170 +0,0 @@ -#ifndef GLOBALS_H_ -#define GLOBALS_H_ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "common.h" -#include "objectlist.h" -#include "objects_command.h" -#include "macros.h" /* For MAX_USER_MACROS */ - -NAGIOS_BEGIN_DECL - -/* - * global variables only used in the core. Reducing this list would be - * a Good Thing(tm). - */ -extern char *naemon_binary_path; -extern char *config_file; -extern char *command_file; -extern char *temp_file; -extern char *temp_path; -extern char *check_result_path; -extern char *lock_file; -extern char *object_precache_file; -extern objectlist *objcfg_files; -extern objectlist *objcfg_dirs; - -extern unsigned int nofile_limit, nproc_limit, max_apps; - -extern int num_check_workers; -extern char *qh_socket_path; - -extern char *macro_user[MAX_USER_MACROS]; - -extern char *ocsp_command; -extern char *ochp_command; -extern command *ocsp_command_ptr; -extern command *ochp_command_ptr; -extern int ocsp_timeout; -extern int ochp_timeout; - -extern char *global_host_event_handler; -extern char *global_service_event_handler; -extern command *global_host_event_handler_ptr; -extern command *global_service_event_handler_ptr; - -extern int use_regexp_matches; -extern int use_true_regexp_matching; - -extern int use_syslog; -extern char *log_file; -extern char *log_archive_path; -extern int log_notifications; -extern int enable_notification_suppression_reason_logging; -extern int log_service_retries; -extern int log_host_retries; -extern int log_event_handlers; -extern int log_external_commands; -extern int log_passive_checks; -extern unsigned long logging_options; -extern unsigned long syslog_options; - -extern int service_check_timeout; -extern int service_check_timeout_state; -extern int host_check_timeout; -extern int event_handler_timeout; -extern int notification_timeout; - -extern volatile sig_atomic_t sig_id; - -extern int verify_config; -extern int precache_objects; -extern int use_precached_objects; - -extern int max_parallel_service_checks; - -extern int check_reaper_interval; -extern int max_check_reaper_time; -extern int service_freshness_check_interval; -extern int host_freshness_check_interval; -extern int auto_rescheduling_interval; -extern int auto_rescheduling_window; - -extern int check_orphaned_services; -extern int check_orphaned_hosts; -extern int check_service_freshness; -extern int check_host_freshness; - -extern int additional_freshness_latency; - -extern int check_for_updates; -extern int bare_update_check; -extern time_t last_update_check; -extern unsigned long update_uid; -extern int update_available; -extern char *last_program_version; -extern char *new_program_version; - -extern int use_aggressive_host_checking; -extern time_t cached_host_check_horizon; -extern time_t cached_service_check_horizon; -extern int enable_predictive_host_dependency_checks; -extern int enable_predictive_service_dependency_checks; - -extern int soft_state_dependencies; - -extern int retain_state_information; -extern int retention_update_interval; -extern int use_retained_program_state; -extern int use_retained_scheduling_info; -extern int retained_scheduling_randomize_window; -extern int retention_scheduling_horizon; -extern char *retention_file; -extern unsigned long retained_host_attribute_mask; -extern unsigned long retained_service_attribute_mask; -extern unsigned long retained_contact_host_attribute_mask; -extern unsigned long retained_contact_service_attribute_mask; -extern unsigned long retained_process_host_attribute_mask; -extern unsigned long retained_process_service_attribute_mask; - -extern int translate_passive_host_checks; -extern int passive_host_checks_are_soft; - -extern int status_update_interval; - -extern int time_change_threshold; - -extern unsigned long event_broker_options; - -extern double low_service_flap_threshold; -extern double high_service_flap_threshold; -extern double low_host_flap_threshold; -extern double high_host_flap_threshold; - -extern char *use_timezone; - -extern time_t max_check_result_file_age; - -extern char *debug_file; -extern int debug_level; -extern int debug_verbosity; -extern unsigned long max_debug_file_size; - -extern int allow_empty_hostgroup_assignment; -extern int allow_circular_dependencies; -extern int host_down_disable_service_checks; - -extern time_t last_program_stop; -extern time_t event_start; - -extern volatile sig_atomic_t sigshutdown, sigrestart, sigrotate, sigfilesize; -extern int currently_running_service_checks; -extern int currently_running_host_checks; - -extern unsigned long next_event_id; -extern unsigned long next_problem_id; -extern unsigned long next_comment_id; -extern unsigned long next_notification_id; - -extern unsigned long modified_process_attributes; -extern unsigned long modified_host_process_attributes; -extern unsigned long modified_service_process_attributes; - -extern struct check_engine nagios_check_engine; - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/lib/bitmap.h b/devtools/ci/naemon/lib/bitmap.h deleted file mode 100644 index bdca6b3..0000000 --- a/devtools/ci/naemon/lib/bitmap.h +++ /dev/null @@ -1,167 +0,0 @@ -#ifndef LIBNAEMON_bitmap_h__ -#define LIBNAEMON_bitmap_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lnae-utils.h" - -NAGIOS_BEGIN_DECL - -/** - * @file bitmap.h - * @brief Bit map API - * - * The bitmap api is useful for running set operations on objects - * indexed by unsigned integers. - * @{ - */ -struct bitmap; -typedef struct bitmap bitmap; - -/** - * Resize a bitmap - * If the bitmap is made smaller, data will silently be lost. - * - * @param bm The bitmap to resize - * @param size The new desired size of the bitmap - * @return 0 on success, -1 on errors. - */ -extern int bitmap_resize(bitmap *bm, unsigned long size); - -/** - * Create a bitmaptor of size 'size' - * @param size Desired storage capacity - * @return A bitmap pointer on success, NULL on errors - */ -extern bitmap *bitmap_create(unsigned long size); - -/** - * Destroy a bitmaptor by freeing all the memory it uses - * @param bm The bitmaptor to destroy - */ -extern void bitmap_destroy(bitmap *bm); - -/** - * Copy a bitmaptor - * @param bm The bitmaptor to copy - * @return Pointer to an identical bitmap on success, NULL on errors - */ -extern bitmap *bitmap_copy(const bitmap *bm); - -/** - * Set a bit in the map - * @param bm The bitmaptor to operate on - * @param pos Position of the bit to set - * @return 0 on success, -1 on errors - */ -extern int bitmap_set(bitmap *bm, unsigned long pos); - -/** - * Check if a particular bit is set in the map - * @param bm The bitmaptor to check - * @param pos Position of the bit to check - * @return 1 if set, otherwise 0 - */ -extern int bitmap_isset(const bitmap *bm, unsigned long pos); - -/** - * Unset a particular bit in the map - * @param bm The bitmaptor to operate on - * @param pos Position of the bit to unset - */ -extern int bitmap_unset(bitmap *bm, unsigned long pos); - -/** - * Obtain cardinality (max number of elements) of the bitmaptor - * @param bm The bitmaptor to check - * @return The cardinality of the bitmaptor - */ -extern unsigned long bitmap_cardinality(const bitmap *bm); -#define bitmap_size bitmap_cardinality - -/** - * Count set bits in map. Completed in O(n/8) time. - * @param bm The bitmaptor to count bits in - * @return The number of set bits - */ -extern unsigned long bitmap_count_set_bits(const bitmap *bm); - -/** - * Count unset bits in map. Completed in O(n/8) time. - * @param bm The bitmaptor to count bits in - * @return The number of set bits - */ -extern unsigned long bitmap_count_unset_bits(const bitmap *bm); - -/** - * Unset all bits in a bitmap - * @param bm The bitmap to clear - */ -extern void bitmap_clear(bitmap *bm); - -/** - * Calculate intersection of two bitmaps - * The intersection is defined as all bits that are members of - * both A and B. It's equivalent to bitwise AND. - * This function completes in O(n/sizeof(long)) operations. - * @param a The first bitmaptor - * @param b The second bitmaptor - * @return NULL on errors; A newly created bitmaptor on success. - */ -extern bitmap *bitmap_intersect(const bitmap *a, const bitmap *b); - -/** - * Calculate union of two bitmaps - * The union is defined as all bits that are members of - * A or B or both A and B. It's equivalent to bitwise OR. - * This function completes in O(n/sizeof(long)) operations. - * @param a The first bitmaptor - * @param b The second bitmaptor - * @return NULL on errors; A newly created bitmaptor on success. - */ -extern bitmap *bitmap_union(const bitmap *a, const bitmap *b); - -/** - * Calculate union of two bitmaps and store result in one of them - * @param res The first bitmap - * @param addme The bitmap to unite to the first bitmap - * @return NULL on errors, res on success - */ -extern bitmap *bitmap_unite(bitmap *res, const bitmap *addme); - -/** - * Calculate set difference between two bitmaps - * The set difference of A / B is defined as all members of A - * that isn't members of B. Note that parameter ordering matters - * for this function. - * This function completes in O(n/sizeof(long)) operations. - * @param a The first bitmaptor (numerator) - * @param b The first bitmaptor (denominator) - * @return NULL on errors; A newly created bitmaptor on success. - */ -extern bitmap *bitmap_diff(const bitmap *a, const bitmap *b); - -/** - * Calculate symmetric difference between two bitmaps - * The symmetric difference between A and B is the set that - * contains all elements in either set but not in both. - * This function completes in O(n/sizeof(long)) operations. - * @param a The first bitmaptor - * @param b The second bitmaptor - */ -extern bitmap *bitmap_symdiff(const bitmap *a, const bitmap *b); - -/** - * Compare two bitmaps for equality - * @param a The first bitmaptor - * @param b The other bitmaptor - * @return Similar to memcmp(), with tiebreaks determined by cardinality - */ -extern int bitmap_cmp(const bitmap *a, const bitmap *b); -/** @} */ - -NAGIOS_END_DECL - -#endif /* LIBNAEMON_bitmap_h__ */ diff --git a/devtools/ci/naemon/lib/bufferqueue.h b/devtools/ci/naemon/lib/bufferqueue.h deleted file mode 100644 index 1054db1..0000000 --- a/devtools/ci/naemon/lib/bufferqueue.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef LIBNAEMON_bufferqueue_h__ -#define LIBNAEMON_bufferqueue_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include -#include "lnae-utils.h" - -NAGIOS_BEGIN_DECL - -/** - * @file bufferqueue.h - * @brief A simple queue of buffers of binary data - * - * The bufferqueue library is intended for working with sockets. - * It accepts/reads data as it becomes available, and returns/sends - * it on demand. - * - * You should generally not use this directly, but instead use the iobroker - * to push and poll data across sockets. - * - * @{ - */ - -/** opaque type for bufferqueue operations */ -struct nm_bufferqueue; -typedef struct nm_bufferqueue nm_bufferqueue; - -/** - * Returns the number of unread bytes in all buffers - * - * @param[in] bq The bufferqueue we should look at - * @return The number of bytes left in the bufferqueue - */ -size_t nm_bufferqueue_get_available(nm_bufferqueue *bq); - -/** - * Creates the bufferqueue object - * @return Pointer to a valid bufferqueue object - */ -nm_bufferqueue *nm_bufferqueue_create(void); - -/** - * Destroys an bufferqueue object, freeing all memory allocated to it. - * @param[in] bq The bufferqueue object to destroy - */ -void nm_bufferqueue_destroy(nm_bufferqueue *bq); - -/** - * Enqueue data at the end of the bufferqueue - * The data is copied, so it can safely be taken from the stack in a - * function that returns before the data is used. - * - * @param[in] bq The bufferqueue to add to - * @param[in] buf Pointer to the data we should add - * @param[in] len Length (in bytes) of data pointed to by buf - * @return 0 on success, -1 on errors - */ -int nm_bufferqueue_push(nm_bufferqueue *bq, const void *buf, size_t len); - -/** - * Like nm_bufferqueue_push, except it doesn't copy all the data - instead, - * it takes over ownership of buf. - * - * @param[in] bq The bufferqueue to append the data to - * @param[in] buf The buffer we should use - * @param[in] len The size of the buffer we should use - * @return 0 on success, non-zero otherwise - */ -int nm_bufferqueue_push_block(nm_bufferqueue *bq, void *buf, size_t len); - -/** - * Returns a chunk of data from the front of the bufferqueue based on - * size, but leaves the data in place for reading later. - * - * @param[in] bq The bufferqueue we should use data from - * @param[in]size The size of the data we want returned - * @param[out] buffer If not NULL and call was successful, will contain the peeked data - * @return 0 on success, non-zero otherwise - */ -int nm_bufferqueue_peek(nm_bufferqueue *bq, size_t size, void *buffer); - -/** - * Drops a chunk of data from the front of the bufferqueue based on - * size. This is the same as unshift, with a NULL buffer. - * - * @param[in] bq The bufferqueue we should use data from - * @param[in]size The size of the data we want to drop - * @return 0 on success, non-zero otherwise - */ -int nm_bufferqueue_drop(nm_bufferqueue *bq, size_t size); - -/** - * Dequeue a chunk of data from the front of the bufferqueue based on - * size. If the buffer argument is not NULL, it should point to a - * memory block large enough to hold the dequeued data. If the buffer - * argument is NULL, the dequeued data will simply be deleted. - * This is the same as doing peek and drop in one operation. - * - * @param[in] bq The bufferqueue we should use data from - * @param[in]size The size of the data we want returned - * @param[out] buffer If not NULL and call was successful, will contain the dequeued data - * @return 0 on success, non-zero otherwise - */ -int nm_bufferqueue_unshift(nm_bufferqueue *bq, size_t size, void *buffer); - -/** - * Dequeue a chunk of data from the front of the bufferqueue based on - * delimiter. If buffer is NULL, the data will simply be - * discarded. Otherwise, *buffer will point to a newly-allocated block - * of memory containing the dequeued data. - * - * The returned size and data will include the trailing delimiter. - * - * @param[in] bq The bufferqueue to use data from - * @param[in] delim The delimiter - * @param[in] delim_len Length of the delimiter - * @param[out] size Length of the returned buffer - * @param[out] buffer If not NULL and call was successful, will contain (caller-owned) dequeued data - * @return 0 on success, non-zero otherwise - */ -int nm_bufferqueue_unshift_to_delim(nm_bufferqueue *bq, const char *delim, size_t delim_len, size_t *size, void **buffer); - -/** - * Read data into the bufferqueue. - * @param[in] bq The bufferqueue we should read into - * @param[in] fd The filedescriptor we should read from - * @return The number of bytes read on success. < 0 on errors - */ -int nm_bufferqueue_read(nm_bufferqueue *bq, int fd); - -/** - * Like write() for buffered data - * - * @param[in] bq The bufferqueue to empty - * @param[in] fd The file descriptor to send to - * @return bytes sent on success, -ERRNO on errors - */ -int nm_bufferqueue_write(nm_bufferqueue *bq, int fd); - -NAGIOS_END_DECL -#endif /* INCLUDE_bufferqueue_h__ */ -/** @} */ diff --git a/devtools/ci/naemon/lib/iobroker.h b/devtools/ci/naemon/lib/iobroker.h deleted file mode 100644 index 880522a..0000000 --- a/devtools/ci/naemon/lib/iobroker.h +++ /dev/null @@ -1,199 +0,0 @@ -#ifndef LIBNAEMON_iobroker_h__ -#define LIBNAEMON_iobroker_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lnae-utils.h" - -/** - * @file iobroker.h - * @brief I/O broker library function declarations - * - * The I/O broker library handles multiplexing between hundreds or - * thousands of sockets with a few simple calls. It's designed to - * be as lightweight as possible so as to not cause memory bloat, - * and is therefore highly suitable for use by processes that are - * fork()-intensive. - * - * @{ - */ - -#if (_POSIX_C_SOURCE - 0) >= 200112L -#include -# define IOBROKER_POLLIN POLLIN -# define IOBROKER_POLLPRI POLLPRI -# define IOBROKER_POLLOUT POLLOUT - -# define IOBROKER_POLLERR POLLERR -# define IOBROKER_POLLHUP POLLHUP -# define IOBROKER_POLLNVAL POLLNVAL -#else -# define IOBROKER_POLLIN 0x001 /* there is data to read */ -# define IOBROKER_POLLPRI 0x002 /* there is urgent data to read */ -# define IOBROKER_POLLOUT 0x004 /* writing now will not block */ - -# define IOBROKER_POLLERR 0x008 /* error condition */ -# define IOBROKER_POLLHUP 0x010 /* hung up */ -# define IOBROKER_POLLNVAL 0x020 /* invalid polling request */ -#endif - -/** return codes */ -#define IOBROKER_SUCCESS 0 -#define IOBROKER_ENOSET (-1) -#define IOBROKER_ENOINIT (-2) -#define IOBROKER_ELIB (-3) -#define IOBROKER_EALREADY (-EALREADY) -#define IOBROKER_EINVAL (-EINVAL) - - -/** Flags for iobroker_destroy() */ -#define IOBROKER_CLOSE_SOCKETS 1 - -NAGIOS_BEGIN_DECL - -/* Opaque type. Callers needn't worry about this */ -struct iobroker_set; -typedef struct iobroker_set iobroker_set; - -/** - * Get a string describing the error in the last iobroker call. - * The returned string must not be free()'d. - * @param error The error code - * @return A string describing the meaning of the error code - */ -extern const char *iobroker_strerror(int error); - -/** - * Create a new socket set - * @return An iobroker_set on success. NULL on errors. - */ -extern iobroker_set *iobroker_create(void); - -/** - * Published utility function used to determine the max number of - * file descriptors this process can keep open at any one time. - * @return Max number of filedescriptors we can keep open - */ -extern int iobroker_max_usable_fds(void); - -/** - * Register a socket for input polling with the broker. - * - * @param iobs The socket set to add the socket to. - * @param sd The socket descriptor to add - * @param arg Argument passed to input handler on available input - * @param handler The callback function to call when input is available - * - * @return 0 on succes. < 0 on errors. - */ -extern int iobroker_register(iobroker_set *iobs, int sd, void *arg, int (*handler)(int, int, void *)); - - -/** - * Register a socket for output polling with the broker - * @note There's no guarantee that *ALL* data is writable just - * because the socket won't block you completely. - * - * @param iobs The socket set to add the socket to. - * @param sd The socket descriptor to add - * @param arg Argument passed to output handler on ready-to-write - * @param handler The function to call when output won't block - * - * @return 0 on success. < 0 on errors - */ -extern int iobroker_register_out(iobroker_set *iobs, int sd, void *arg, int (*handler)(int, int, void *)); - -/** - * Check if a particular filedescriptor is registered with the iobroker set - * @param[in] iobs The iobroker set the filedescriptor should be member of - * @param[in] fd The filedescriptor to check for - * @return 1 if the filedescriptor is registered and 0 otherwise - */ -extern int iobroker_is_registered(iobroker_set *iobs, int fd); - -/** - * Getter function for number of file descriptors registered in - * the set specified. - * @param iobs The io broker set to query - * @return Number of file descriptors registered in the set - */ -extern int iobroker_get_num_fds(iobroker_set *iobs); - -/** - * Getter function for the maximum amount of file descriptors this - * set can handle. - * @param iobs The io broker set to query - * @return Max file descriptor capacity for the set - */ -extern int iobroker_get_max_fds(iobroker_set *iobs); - -/** - * Unregister a socket for input polling with the broker. - * - * @param iobs The socket set to remove the socket from - * @param sd The socket descriptor to remove - * @return 0 on succes. < 0 on errors. - */ -extern int iobroker_unregister(iobroker_set *iobs, int sd); - -/** - * Deregister a socket for input polling with the broker - * (this is identical to iobroker_unregister()) - * @param iobs The socket set to remove the socket from - * @param sd The socket descriptor to remove - * @return 0 on success. < 0 on errors. - */ -extern int iobroker_deregister(iobroker_set *iobs, int sd); - -/** - * Unregister and close(2) a socket registered for input with the - * broker. This is a convenience function which exists only to avoid - * doing multiple calls when read() returns 0, as closed sockets must - * always be removed from the socket set to avoid consuming tons of - * cpu power from iterating "too fast" over the file descriptors. - * - * @param iobs The socket set to remove the socket from - * @param sd The socket descriptor to remove and close - * @return 0 on success. < 0 on errors - */ -extern int iobroker_close(iobroker_set *iobs, int sd); - -/** - * Destroy a socket set as created by iobroker_create - * @param iobs The socket set to destroy - * @param flags If set, close(2) all registered sockets - */ -extern void iobroker_destroy(iobroker_set *iobs, int flags); - -/** - * Wait for input on any of the registered sockets. - * @param iobs The socket set to wait for. - * @param timeout Timeout in milliseconds. -1 is "wait indefinitely" - * @return -1 on errors, or number of filedescriptors with input - */ -extern int iobroker_poll(iobroker_set *iobs, int timeout); -/** - * Push any pending outgoing data - * @param iobs The socket set to push everything in. - * @returns 0 if any data was pushed, non-zero otherwise - */ -int iobroker_push(iobroker_set *iobs); - -/** - * Write data to this specific fd that is part of this iobroker_set - * This data is guaranteed to be sent off in sequence. Two sequential - * calls to iobroker_write_packet are not, due to concurrency. - * - * @param[in] iobs The socket set to send data to - * @param[in] fd The socket descriptor to add data to. Must be registered in the set. - * @param[in] buf The data to send. Binary-safe. - * @param[in] len The length of the data. - * @returns 0 if everything worked, non-zero otherwise - */ -int iobroker_write_packet(iobroker_set *iobs, int fd, char *buf, size_t len); - -NAGIOS_END_DECL -#endif /* INCLUDE_iobroker_h__ */ -/** @} */ diff --git a/devtools/ci/naemon/lib/kvvec.h b/devtools/ci/naemon/lib/kvvec.h deleted file mode 100644 index 9437448..0000000 --- a/devtools/ci/naemon/lib/kvvec.h +++ /dev/null @@ -1,265 +0,0 @@ -#ifndef LIBNAEMON_kvvec_h__ -#define LIBNAEMON_kvvec_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lnae-utils.h" - -NAGIOS_BEGIN_DECL - -/** - * @file kvvec.h - * @brief Key/value vector library function and type declarations - * - * The kvvec library is nifty as either a configuration meta-format - * or for IPC purposes. Take a look at the buf2kvvec() and kvvec2buf() - * pair of functions for the latter. - * @{ - */ - -/** - * key/value pair - * One of the two major components of the kvvec api - */ -struct key_value { - char *key; /**< The key */ - char *value; /**< The value */ - int key_len; /**< Length of key */ - int value_len; /**< Length of value */ -}; - -/** - * key/value vector buffer. Actually just a buffer, but one that gets - * used as return value and internal tracker for kvvec2buf() - */ -struct kvvec_buf { - char *buf; /**< The buffer */ - unsigned long buflen; /**< Length of buffer */ - unsigned long bufsize; /**< Size of buffer (includes overalloc) */ -}; - -/** - * key/value vector struct - * This is the main component of the kvvec library - * @note This should be made opaque, with a kvvec_foreach() using a - * callback to iterate over key/value pairs. - */ -struct kvvec { - struct key_value *kv; /**< The key/value array */ - int kv_alloc; /**< Allocated size of key/value array */ - int kv_pairs; /**< Number of key/value pairs */ - int kvv_sorted; /**< Determines if this kvvec has been sorted */ -}; - -/** Portable initializer for stack-allocated key/value vectors */ -#define KVVEC_INITIALIZER { NULL, 0, 0, 0 } - -/** Parameters for kvvec_destroy() */ -#define KVVEC_FREE_KEYS 1 /**< Free keys when destroying a kv vector */ -#define KVVEC_FREE_VALUES 2 /**< Free values when destroying a kv vector */ -/** Free both keys and values when destroying a kv vector */ -#define KVVEC_FREE_ALL (KVVEC_FREE_KEYS | KVVEC_FREE_VALUES) - -#define KVVEC_ASSIGN 0 /**< Assign from buf in buf2kvvec_prealloc() */ -#define KVVEC_COPY 1 /**< Copy from buf in buf2kvvec_prealloc() */ -#define KVVEC_APPEND 2 /**< Don't reset kvvec in buf2kvvec_prealloc() */ - -/** - * Initialize a previously allocated key/value vector - * - * @param kvv The key/value vector to initialize - * @param hint Number of key/value pairs we expect to store - * @return Pointer to a struct kvvec, properly initialized - */ -extern struct kvvec *kvvec_init(struct kvvec *kvv, int hint); - -/** - * Create a key/value vector - * - * @param hint Number of key/value pairs we expect to store - * @return Pointer to a struct kvvec, properly initialized - */ -extern struct kvvec *kvvec_create(int hint); - -/** - * Resize a key/value vector - * Used by kvvec_grow(). If size is smaller than the current number of - * used key/value slots, -1 is returned. - * - * @param[in] kvv The key/value vector to resize - * @param[in] size The size to grow to - * @return 0 on success, < 0 on errors - */ -extern int kvvec_resize(struct kvvec *kvv, int size); - -/** - * Grow a key/value vector. - * Used internally as needed by the kvvec api. If 'hint' is zero, the - * key/value capacity is increased by a third of the current capacity - * plus a small constant number. This uses kvvec_resize() internally. - * - * @param kvv The key/value vector to grow - * @param hint The amount of key/value slots we should grow by - * @return 0 on success, < 0 on errors - */ -extern int kvvec_grow(struct kvvec *kvv, int hint); - -/** - * Return remaining storage capacity of key/value vector - * @param[in] kvv The key/value vector to check - * @return Number of key/value pairs that can be stored without growing - */ -extern unsigned int kvvec_capacity(struct kvvec *kvv); - -/** - * Sort a key/value vector alphabetically by key name - * @param kvv The key/value vector to sort - * @return 0 - */ -extern int kvvec_sort(struct kvvec *kvv); - -/** - * Fetch a string from a kvvec given a string key. - * This uses kvvec_fetch. - * - * @param kvv The key/value vector to search in - * @param key The key to search for - * @return The value - */ -extern char *kvvec_fetch_str_str(struct kvvec *kvv, const char *key); - -/** - * Fetch an element from a kvvec given key. - * - * The complexity of this method is O(log N), given that the kvvec is sorted, - * O(n) Otherwise. - * - * @param kvv The key/value vector to search in - * @param key The key to search for - * @param keylen The length of the key. If 0, keylen is guessed with strlen - * @return pointer to an internal key_value struct, stored within kvv (don't free) - */ -extern struct key_value *kvvec_fetch(struct kvvec *kvv, const char *key, int keylen); - -/** - * Add a string key with a long value to an existing key/value vector. This - * assumes the key is a valid C string. If it does, you need to use - * kvvec_addkv_wlen. - * @param kvv The key/value vector to add this key/value pair to - * @param key The string key - * @param value The long value - * @return 0 on success, < 0 on errors - */ -int kvvec_addkv_long(struct kvvec *kvv, const char *key, long value); - -/** - * Add a string key with a timeval value to an existing key/value vector. This - * assumes the key is a valid C string. If it isn't, you need to use - * kvvec_addkv_wlen. - * @param kvv The key/value vector to add this key/value pair to - * @param key The string key - * @param value The long value - * @return 0 on success, < 0 on errors - */ -int kvvec_addkv_tv(struct kvvec *kvv, const char *key, const struct timeval *value); - -/** - * Add a string key with a string value to an existing key/value vector. This - * assumes both the key and the value is a valid C string. If either - * isn't, you need to use kvvec_addkv_wlen. - * @param kvv The key/value vector to add this key/value pair to - * @param key The string key - * @param value The long value - * @return 0 on success, < 0 on errors - */ -int kvvec_addkv_str(struct kvvec *kvv, const char *key, const char *value); - -/** - * Add a key/value pair to an existing key/value vector, with - * lengths of strings already calculated - * @param kvv The key/value vector to add this key/value pair to - * @param key The key - * @param keylen Length of the key - * @param value The value - * @param valuelen Length of the value - * @return 0 on success, < 0 on errors - */ -extern int kvvec_addkv_wlen(struct kvvec *kvv, const char *key, int keylen, const char *value, int valuelen); - -/** - * Walk each key/value pair in a key/value vector, sending them - * as arguments to a callback function. The callback function has - * no control over the iteration process and must not delete or - * modify the key/value vector it's operating on. - * @param kvv The key/value vector to walk - * @param arg Extra argument to the callback function - * @param callback Callback function - * @return 0 on success, < 0 on errors - */ -extern int kvvec_foreach(struct kvvec *kvv, void *arg, int (*callback)(struct key_value *, void *)); - -/** - * Destroy a key/value vector - * @param kvv The key/value vector to destroy - * @param flags or'ed combination of KVVEC_FREE_{KEYS,VALUES}, or KVVEC_FREE_ALL - * @return 0 on success, < 0 on errors - */ -extern int kvvec_destroy(struct kvvec *kvv, int flags); - -/** - * Free key/value pairs associated with a key/value vector - * @param kvv The key/value vector to operate on - * @param flags flags or'ed combination of KVVEC_FREE_{KEYS,VALUES}, or KVVEC_FREE_ALL - */ -void kvvec_free_kvpairs(struct kvvec *kvv, int flags); - -/** - * Create a linear buffer of all the key/value pairs and - * return it as a kvvec_buf. The caller must free() all - * pointers in the returned kvvec_buf - * (FIXME: add kvvec_buf_destroy(), or move this and its counterpart - * out of the kvvec api into a separate one) - * - * @param kvv The key/value vector to convert - * @param kv_sep Character separating keys and their values - * @param pair_sep Character separating key/value pairs - * @param overalloc Integer determining how much extra data we should - * allocate. The overallocated memory is filled with - * nul bytes. - * @return A pointer to a newly created kvvec_buf structure - */ -extern struct kvvec_buf *kvvec2buf(struct kvvec *kvv, char kv_sep, char pair_sep, int overalloc); - -/** - * Create a key/value vector from a pre-parsed buffer. Immensely - * useful for ipc in combination with kvvec2buf(). - * - * @param str The buffer to convert to a key/value vector - * @param len Length of buffer to convert - * @param kvsep Character separating key and value - * @param pair_sep Character separating key/value pairs - * @param flags bitmask. See KVVEC_{ASSIGN,COPY,APPEND} for values - * @return The created key/value vector - */ -extern struct kvvec *buf2kvvec(char *str, unsigned int len, const char kvsep, const char pair_sep, int flags); - -/** - * Parse a buffer into the pre-allocated key/value vector. Immensely - * useful for ipc in combination with kvvec2buf(). - * - * @param kvv A pre-allocated key/value vector to populate - * @param str The buffer to convert to a key/value vector - * @param len Length of buffer to convert - * @param kvsep Character separating key and value - * @param pair_sep Character separating key/value pairs - * @param flags bitmask. See KVVEC_{ASSIGN,COPY,APPEND} for values - * @return The number of pairs in the created key/value vector - */ -extern int buf2kvvec_prealloc(struct kvvec *kvv, char *str, unsigned int len, const char kvsep, const char pair_sep, int flags); -/** @} */ - -NAGIOS_END_DECL - -#endif /* INCLUDE_kvvec_h__ */ diff --git a/devtools/ci/naemon/lib/kvvec_ekvstr.h b/devtools/ci/naemon/lib/kvvec_ekvstr.h deleted file mode 100644 index 15d38da..0000000 --- a/devtools/ci/naemon/lib/kvvec_ekvstr.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * kvvec_ekvstr.h - * - * Created on: Mar 6, 2013 - * Author: msikstrom - */ - -#ifndef KVVEC_EKVSTR_H_ -#define KVVEC_EKVSTR_H_ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lnae-utils.h" -#include "kvvec.h" - -NAGIOS_BEGIN_DECL - -/** - * This module packs and unpacks kvvecs to strings, to be sent through a data - * stream. - * - * The stream is defined to contain only writable characters, and no newlines. - * - * The data is packed as key=value;key=value with ; and = as delimiters. - * - * The key an value is escaped as follows: - * - * ASCII character 9 (tab) is escaped to \t - * ASCII character 10 (line feed) is escaped to \n - * ASCII character 13 (carrage return) is escaped to \r - * ASCII character 59 (;) is escaped \; - * ASCII character 61 (=) is escaped \= - * ASCII character 92 (\) is escaped \\ - * ASCII characters 31 and below, and 127 and above is escaped as \xNN where NN - * is the byte in hex - * all other chars is unescaped - */ - -/** - * Convert a kvvec to a string of format: key=value;key=value, having both key - * and value escaped, so both key and value is binary safe. - * - * - */ -char *kvvec_to_ekvstr( const struct kvvec *kvv ); - -/** - * Unpack a string of escaped kvvec to a kvvec - */ -struct kvvec *ekvstr_to_kvvec( const char *inbuf ); - -NAGIOS_END_DECL - -#endif /* KVVEC_EKVSTR_H_ */ diff --git a/devtools/ci/naemon/lib/libnaemon.h b/devtools/ci/naemon/lib/libnaemon.h deleted file mode 100644 index bf44129..0000000 --- a/devtools/ci/naemon/lib/libnaemon.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef LIBNAEMON_libnaemon_h__ -#define LIBNAEMON_libnaemon_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -/** - * @file libnaemon.h - * - * @brief Compat header to facilitate using Nagios projects with Naemon - */ -#include "lnae-utils.h" -#include "nsutils.h" -#include "kvvec.h" -#include "kvvec_ekvstr.h" -#include "iobroker.h" -#include "bufferqueue.h" -#include "runcmd.h" -#include "bitmap.h" -#include "worker.h" -#include "nsock.h" -#include "nspath.h" -#include "snprintf.h" -#include "objutils.h" -#endif /* LIB_libnaemon_h__ */ diff --git a/devtools/ci/naemon/lib/lnae-utils.h b/devtools/ci/naemon/lib/lnae-utils.h deleted file mode 100644 index 5965e03..0000000 --- a/devtools/ci/naemon/lib/lnae-utils.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef LIBNAEMON_lnae_utils_h__ -#define LIBNAEMON_lnae_utils_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include /* for sysconf() */ -#include /* for rand() */ - -/** - * @file lnae-utils.h - * @brief helper and compatibility macros that lack a "real" home. - * - * This is the home of random macros that must be present for compilation - * to succeed but are missing on some platforms. - * - * @{ - */ - -#define NAEMON_MKVERSION(a, b, c) \ - (((a) * 10000) + ((b) * 100) + (c)) - -#ifdef __cplusplus -/** C++ compatibility macro that avoids confusing indentation programs */ -# define NAEMON_BEGIN_DECL extern "C" { -/** - * Use at end of header file declarations to obtain C++ compatibility - * ... without confusing indentation programs - */ -# define NAEMON_END_DECL } -#else -/** C++ compatibility macro that avoids confusing indentation programs */ -# define NAEMON_BEGIN_DECL /* nothing */ -/** C++ compatibility macro that avoid confusing indentation programs */ -# define NAEMON_END_DECL /* more of nothing */ -#endif - -/** Compat macro */ -#define NAGIOS_BEGIN_DECL NAEMON_BEGIN_DECL -/** Compat macro */ -#define NAGIOS_END_DECL NAEMON_END_DECL - -#ifndef NODOXY /* doxy comments are useless here */ -# ifndef __GNUC__ -# define GCC_VERSION 0 -# define __attribute__(x) /* nothing */ -# else -# ifdef __GNUC_PATCHLEVEL__ -# define GCC_VERSION NAEMON_MKVERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -# else -# define GCC_VERSION NAEMON_MKVERSION(__GNUC__, __GNUC_MINOR__, 0) -# endif /* __GNUC_PATCHLEVEL__ */ -# endif /* __GNUC__ */ -#endif /* NODOXY */ - -#if GCC_VERSION >= NAEMON_MKVERSION(4, 5, 0) -# define NAEMON_DEPRECATED(version, hint) \ - __attribute__((deprecated("This function will be removed in version " #version ". Please use " #hint " instead"))) -#else -/** Macro for alerting module authors to function deprecation */ -# define NAEMON_DEPRECATED(version, hint) \ - __attribute__((deprecated)) -#endif - -/* - * These macros are widely used throughout Nagios - */ -#define OK 0 /**< Indicates successful function call in Nagios */ -#define ERROR -2 /**< Non-successful function call in Nagios */ - -#ifdef FALSE -#undef FALSE -#endif -#define FALSE 0 /**< Not true */ - -#ifdef TRUE -#undef TRUE -#endif -#define TRUE (!FALSE) /**< Not false */ - -#ifndef ARRAY_SIZE -/** Useful for iterating over all elements in a static array */ -# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif -#ifndef veclen -/** useful for iterating over all elements in a static array */ -# define veclen ARRAY_SIZE -#endif - -#ifndef offsetof -/** standard offsetof macro */ -# define offsetof(t, f) ((unsigned long)&((t *)0)->f) -#endif - -/** character map initialization for .bss-allocated char maps */ -#define CHAR_MAP_INIT(k) { \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - } - -/** @} */ -#endif diff --git a/devtools/ci/naemon/lib/lnag-utils.h b/devtools/ci/naemon/lib/lnag-utils.h deleted file mode 100644 index c08fba5..0000000 --- a/devtools/ci/naemon/lib/lnag-utils.h +++ /dev/null @@ -1 +0,0 @@ -#include "lnae-utils.h" diff --git a/devtools/ci/naemon/lib/nsock.h b/devtools/ci/naemon/lib/nsock.h deleted file mode 100644 index 142d5a3..0000000 --- a/devtools/ci/naemon/lib/nsock.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef LIBNAEMON_nsock_h__ -#define LIBNAEMON_nsock_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -/** - * @file nsock.h - * @brief Nagios socket helper library - * - * This is a pretty stupid library, but since so many addons and - * now Nagios core itself makes use of sockets, we might as well - * have some simple wrappers for it that handle the most common - * cases. - * - * @{ - */ - -#define NSOCK_EBIND (-1) /**< failed to bind() */ -#define NSOCK_ELISTEN (-2) /**< failed to listen() */ -#define NSOCK_ESOCKET (-3) /**< failed to socket() */ -#define NSOCK_EUNLINK (-4) /**< failed to unlink() */ -#define NSOCK_ECONNECT (-5) /**< failed to connect() */ -#define NSOCK_EFCNTL (-6) /**< failed to fcntl() */ -#define NSOCK_EINVAL (-EINVAL) /**< -22, normally */ - -/* flags for the various create calls */ -#define NSOCK_TCP (1 << 0) /**< use tcp mode */ -#define NSOCK_UDP (1 << 1) /**< use udp mode */ -#define NSOCK_UNLINK (1 << 2) /**< unlink existing path (only nsock_unix) */ -#define NSOCK_REUSE (1 << 2) /**< reuse existing address */ -#define NSOCK_CONNECT (1 << 3) /**< connect rather than create */ -#define NSOCK_BLOCK (1 << 4) /**< socket should be in blocking mode */ - -NAGIOS_BEGIN_DECL - -/** - * Grab an error string relating to nsock_unix() - * @param code The error code return by the nsock library - * @return An error string describing the error - */ -extern const char *nsock_strerror(int code); - -/** - * Create or connect to a unix socket - * To control permissions on sockets when NSOCK_LISTEN is specified, - * callers will have to modify their umask() before (and possibly - * after) the nsock_unix() call. - * - * @param path The path to connect to or create - * @param flags Various options controlling the mode of the socket - * @return An NSOCK_E macro on errors, the created socket on succes - */ -extern int nsock_unix(const char *path, unsigned int flags); - -/** - * Write a nul-terminated message to the socket pointed to by sd. - * This isn't quite the same as dprintf(), which doesn't include - * the terminating nul byte. - * @note This function may block, so poll(2) for writability - * @param sd The socket to write to - * @param fmt The format string - * @return Whatever write() returns - */ -extern int nsock_printf_nul(int sd, const char *fmt, ...) - __attribute__((__format__(__printf__, 2, 3))); - -/** - * Write a printf()-formatted string to the socket pointed to by sd. - * This is identical to dprintf(), which is unfortunately GNU only. - * @note This function may block, so poll(2) for writability - * @param sd The socket to write to - * @param fmt The format string - * @return Whatever write() returns - */ -extern int nsock_printf(int sd, const char *fmt, ...) - __attribute__((__format__(__printf__, 2, 3))); - - -/** - * Write all of nbyte bytes of buf to fd, and don't let EINTR/EAGAIN stop you. - * Returns 0 on success. On error, returns -1 and errno is set to indicate the - * error - */ -int nsock_write_all(int fd, const void *buf, size_t nbyte); - -NAGIOS_END_DECL - -/** @} */ -#endif /* LIBNAEMON_nsock_h__ */ diff --git a/devtools/ci/naemon/lib/nspath.h b/devtools/ci/naemon/lib/nspath.h deleted file mode 100644 index 87702d6..0000000 --- a/devtools/ci/naemon/lib/nspath.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef LIBNAEMON_nspath_h__ -#define LIBNAEMON_nspath_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef _GNU_SOURCE -# ifndef NODOXY -# define _GNU_SOURCE 1 -# endif -#endif -#include -#include -#include "snprintf.h" -#include "lnae-utils.h" - -NAGIOS_BEGIN_DECL - -/** - * @file nspath.h - * @brief path handling functions - * - * This library handles path normalization and resolution. It's nifty - * if you want to turn relative paths into absolute ones, or if you - * want to make insane ones sane, but without chdir()'ing your way - * around the filesystem. - * - * @{ - */ - -/** - * Normalize a path - * By "normalize", we mean that we convert dot-slash and dot-dot-slash - * embedded components into a legible continuous string of characters. - * Leading and trailing slashes are kept exactly as they are in input, - * but with sequences of slashes reduced to a single one. - * - * "foo/bar/.././lala.txt" becomes "foo/lala.txt" - * "../../../../bar/../foo/" becomes "/foo/" - * "////foo////././bar" becomes "/foo/bar" - * @param orig_path The path to normalize - * @return A newly allocated string containing the normalized path - */ -extern char *nspath_normalize(const char *orig_path); - -/** - * Make the "base"-relative path "rel_path" absolute. - * Turns the relative path "rel_path" into an absolute path and - * resolves it as if we were currently in "base". If "base" is - * NULL, the current working directory is used. If "base" is not - * null, it should be an absolute path for the result to make - * sense. - * - * @param rel_path The relative path to convert - * @param base The base directory (if NULL, we use current working dir) - * @return A newly allocated string containing the absolute path - */ -extern char *nspath_absolute(const char *rel_path, const char *base); - -/** - * Canonicalize the "base"-relative path "rel_path". - * errno gets properly set in case of errors. - * @param rel_path The path to transform - * @param base The base we should operate relative to - * @return Newly allocated canonical path on succes, NULL on errors - */ -extern char *nspath_real(const char *rel_path, const char *base); - -/** - * Get absolute dirname of "path", relative to "base" - * @param path Full path to target object (file or subdir) - * @param base The base directory (if NULL, we use current working dir) - * @return NULL on errors, allocated absolute directory name on success - */ -extern char *nspath_absolute_dirname(const char *path, const char *base); - - -/** - * Recursively create a directory, just like mkdir_p would. - * @note This function *will* taint errno with ENOENT if any path - * component has to be created. - * @note If "path" has a trailing slash, NSPATH_MKDIR_SKIP_LAST - * won't have any effect. That's considered a feature, since the - * option is designed so one can send a file-path to the function - * and have it create the directory structure for it. - * @param path Path to create, in normalized form - * @param mode Filemode (same as mkdir() takes) - * @param options Options flag. See NSPATH_MKDIR_* for or-able options - * @return 0 on success, -1 on errors and errno will hold error code - * from either stat() or mkdir(). - */ -extern int nspath_mkdir_p(const char *path, mode_t mode, int options); - -/** Don't mkdir() last element of path when calling nspath_mkdir_p() */ -#define NSPATH_MKDIR_SKIP_LAST (1 << 0) - -NAGIOS_END_DECL -/** @} */ -#endif diff --git a/devtools/ci/naemon/lib/nsutils.h b/devtools/ci/naemon/lib/nsutils.h deleted file mode 100644 index 7b610b2..0000000 --- a/devtools/ci/naemon/lib/nsutils.h +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef LIBNAEMON_nsutils_h__ -#define LIBNAEMON_nsutils_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -NAGIOS_BEGIN_DECL - -/** - * @file nsutils.h - * @brief Non-Standard (or Nagios) utility functions and macros. - * - * This is where we house all helpers and macros that fall outside - * the "standard-ish" norm. The prefixes "nsu_" and NSU_ are - * reserved for this purpose, so we avoid clashing with other - * applications that may have similarly-acting functions with - * identical names. - * - * The functions already here lack the nsu_ prefix for backwards - * compatibility reasons. It's possible we'll have to fix that - * some day, but let's leave that for later. - * - * @{ - */ - -/** Macro for dynamically increasing vector lengths */ -#define alloc_nr(x) (((x)+16)*3/2) - -/** - * Check if a number is a power of 2 - * @param x The number to check - * @return 1 if the number is a power of 2, 0 if it's not - */ -static inline int nsu_ispow2(unsigned int x) -{ - return x > 1 ? !(x & (x - 1)) : 0; -} - -/** - * Round up to a power of 2 - * Yes, this is the most cryptic function name in all of Nagios, but I - * like it, so shush. - * @param r The number to round up - * @return r, rounded up to the nearest power of 2. - */ -static inline unsigned int rup2pof2(unsigned int r) -{ - r--; - if (!r) - return 2; - r |= r >> 1; - r |= r >> 2; - r |= r >> 4; - r |= r >> 8; - r |= r >> 16; - - return r + 1; -} - -/** - * Grab a random unsigned int in the range between low and high. - * Note that the PRNG has to be seeded prior to calling this. - * @param low The lower bound, inclusive - * @param high The higher bound, inclusive - * @return An unsigned integer in the mathematical range [low, high] - */ -static inline unsigned int ranged_urand(unsigned int low, unsigned int high) -{ - return low + (rand() * (1.0 / (RAND_MAX + 1.0)) * (high - low)); -} - -/** - * Get number of online cpus - * @return Active cpu cores detected on success. 0 on failure. - */ -extern int real_online_cpus(void); - -/** - * Wrapper for real_online_cpus(), returning 1 in case we can't - * detect any active cpus. - * @return Number of active cpu cores on success. 1 on failure. - */ -extern int online_cpus(void); - -/** - * Create a short-lived string in stack-allocated memory - * The number and size of strings is limited (currently to 256 strings of - * 32 bytes each), so beware and use this sensibly. Intended for - * number-to-string conversion and other short strings. - * @note The returned string must *not* be free()'d! - * @param[in] fmt The format string - * @return A pointer to the formatted string on success. Undefined on errors - */ -extern const char *mkstr(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); - -/** - * Calculate the millisecond delta between two timeval structs - * @param[in] start The start time - * @param[in] stop The stop time - * @return The millisecond delta between the two structs - */ -extern int tv_delta_msec(const struct timeval *start, const struct timeval *stop); - - -/** - * Get timeval delta as seconds - * @param start The start time - * @param stop The stop time - * @return time difference in fractions of seconds - */ -extern float tv_delta_f(const struct timeval *start, const struct timeval *stop); - -NAGIOS_END_DECL - -/** @} */ -#endif /* LIBNAEMON_nsutils_h__ */ diff --git a/devtools/ci/naemon/lib/objutils.h b/devtools/ci/naemon/lib/objutils.h deleted file mode 100644 index 9e9473d..0000000 --- a/devtools/ci/naemon/lib/objutils.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef LIBNAEMON_objutils_h__ -#define LIBNAEMON_objutils_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lnae-utils.h" - -NAEMON_BEGIN_DECL - -typedef struct nm_service_key { - char *hostname; - char *service_description; -} nm_service_key; - -int nm_service_equal(const void *a, const void *b); -unsigned int nm_service_hash(const void *key); - -nm_service_key * nm_service_key_create(const char *hostname, const char *service_description); -void nm_service_key_destroy(nm_service_key *k); - -NAEMON_END_DECL -#endif diff --git a/devtools/ci/naemon/lib/runcmd.h b/devtools/ci/naemon/lib/runcmd.h deleted file mode 100644 index fa2ef1d..0000000 --- a/devtools/ci/naemon/lib/runcmd.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef LIBNAEMON_runcmd_h__ -#define LIBNAEMON_runcmd_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lnae-utils.h" - -/** - * @file runcmd.h - * @brief runcmd library function declarations - * - * @note This is inherited from the nagiosplugins project, although - * I (AE) wrote the original code, and it might need refactoring - * for performance later. - * @{ - */ - -/** Return code bitflags for runcmd_cmd2strv() */ -#define RUNCMD_HAS_REDIR (1 << 0) /**< I/O redirection */ -#define RUNCMD_HAS_SUBCOMMAND (1 << 1) /**< subcommands present */ -#define RUNCMD_HAS_PAREN (1 << 2) /**< parentheses present in command */ -#define RUNCMD_HAS_JOBCONTROL (1 << 3) /**< job control stuff present */ -#define RUNCMD_HAS_UBSQ (1 << 4) /**< unbalanced single quotes */ -#define RUNCMD_HAS_UBDQ (1 << 5) /**< unbalanced double quotes */ -#define RUNCMD_HAS_WILDCARD (1 << 6) /**< wildcards present */ -#define RUNCMD_HAS_SHVAR (1 << 7) /**< shell variables present */ - - -#define RUNCMD_EFD (-1) /**< Failed to pipe() or open() */ -#define RUNCMD_EALLOC (-2) /**< Failed to alloc */ -#define RUNCMD_ECMD (-3) /**< Bad command */ -#define RUNCMD_EFORK (-4) /**< Failed to fork() */ -#define RUNCMD_EINVAL (-5) /**< Invalid parameters */ -#define RUNCMD_EWAIT (-6) /**< Failed to wait() */ - -NAGIOS_BEGIN_DECL - -/** - * Initialize the runcmd library. - * - * Only multi-threaded programs that might launch the first external - * program from multiple threads simultaneously need to bother with - * this. - */ -extern void runcmd_init(void); - -/** - * Return pid of a command with a specific file descriptor - * @param[in] fd stdout filedescriptor of the child to get pid from - * @return pid of the child, or 0 on errors - */ -extern pid_t runcmd_pid(int fd); - -/** - * Return explanation of which system call or operation failed - * @param code Error code returned by a library function - * @return A non-free()'able string explaining where the error occurred - */ -extern const char *runcmd_strerror(int code); - -/** - * Start a command from a command string - * @param[in] cmdstring The command to launch - * @param[out] pfd Child's stdout filedescriptor - * @param[out] pfderr Child's stderr filedescriptor - * @param[in] env Currently ignored for portability - */ -extern int runcmd_open(const char *cmdstring, int *pfd, int *pfderr, char **env) - __attribute__((__nonnull__(1, 2, 3))); - -/** - * Close a command and return its exit status - * @note Don't use this. It's a retarded way to reap children suitable - * only for launching a one-shot program. - * - * @param[in] fd The child's stdout filedescriptor - * @return exit-status of the child, or -1 in case of errors - */ -extern int runcmd_close(int fd); - -/** - * Convert a string to a vector of arguments like a shell would - * @note This might have bugs and is only tested to behave similar - * to how /bin/sh does things. For csh or other non bash-ish shells - * there are no guarantees. - * @note The out_argv array has to be large enough to hold all strings - * found in the command. - * @param[in] str The string to convert to an argument vector - * @param[out] out_argc The number of arguments found - * @param[out] out_argv The argument vector - * @return 0 on (great) success, or a bitmask of failure-codes - * representing f.e. unclosed quotes, job control or output redirection. - * See the RUNCMD_HAS_* and their ilk to find out about the flag. - */ -extern int runcmd_cmd2strv(const char *str, int *out_argc, char **out_argv); - -NAGIOS_END_DECL - -#endif /* INCLUDE_runcmd_h__ */ -/** @} */ diff --git a/devtools/ci/naemon/lib/snprintf.h b/devtools/ci/naemon/lib/snprintf.h deleted file mode 100644 index 2e5d0b0..0000000 --- a/devtools/ci/naemon/lib/snprintf.h +++ /dev/null @@ -1,7 +0,0 @@ -/* lib/snprintf.h. Generated from snprintf.h.in by configure. */ -/* -*- C -*- */ -#ifndef LIBNAGIOS_snprintf_h__ -#define LIBNAGIOS_snprintf_h__ -/* #undef HAVE_SNPRINTF */ -/* #undef NEED_VA_LIST */ -#endif diff --git a/devtools/ci/naemon/lib/t-utils.h b/devtools/ci/naemon/lib/t-utils.h deleted file mode 100644 index 06dcd34..0000000 --- a/devtools/ci/naemon/lib/t-utils.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef INCLUDE_test_utils_h__ -#define INCLUDE_test_utils_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include -#include -#include -#include "lnag-utils.h" - -#ifndef ARRAY_SIZE -# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -#define TEST_PASS 1 -#define TEST_FAIL 0 - -#define CLR_RESET "\033[m" -#define CLR_BOLD "\033[1m" -#define CLR_RED "\033[31m" -#define CLR_GREEN "\033[32m" -#define CLR_BROWN "\033[33m" -#define CLR_YELLOW "\033[33m\033[1m" -#define CLR_BLUE "\033[34m" -#define CLR_MAGENTA "\033[35m" -#define CLR_CYAN "\033[36m" -#define CLR_BG_RED "\033[41m" -#define CLR_BRIGHT_RED "\033[31m\033[1m" -#define CLR_BRIGHT_GREEN "\033[32m\033[1m" -#define CLR_BRIGHT_BLUE "\033[34m\033[1m" -#define CLR_BRIGHT_MAGENTA "\033[35m\033[1m" -#define CLR_BRIGHT_CYAN "\033[36m\033[1m" - -NAGIOS_BEGIN_DECL - -extern const char *red, *green, *yellow, *cyan, *reset; -extern unsigned int passed, failed, t_verbose; - -#define CHECKPOINT() \ - do { \ - fprintf(stderr, "ALIVE @ %s:%s:%d\n", __FILE__, __func__, __LINE__); \ - } while(0) - -#define t_assert(expr) \ - -extern void t_set_colors(int force); -extern void t_start(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); -extern void t_pass(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); -extern void t_fail(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); -extern void t_diag(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); -extern int t_ok(int success, const char *fmt, ...) - __attribute__((__format__(__printf__, 2, 3))); -#define test t_ok -#define t_req(expr) \ - if (!(expr)) \ - crash("No further testing is possible: " #expr " @%s:%d", __FILE__, __LINE__) -extern int ok_int(int a, int b, const char *name); -extern int ok_uint(unsigned int a, unsigned int b, const char *name); -extern int ok_str(const char *a, const char *b, const char *name); -extern int t_end(void); -extern void t_reset(void); -extern void crash(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2), __noreturn__)); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/lib/worker.h b/devtools/ci/naemon/lib/worker.h deleted file mode 100644 index 16eba69..0000000 --- a/devtools/ci/naemon/lib/worker.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef LIBNAEMON_worker_h__ -#define LIBNAEMON_worker_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lnae-utils.h" -#include "kvvec.h" -#include "bufferqueue.h" - -/** - * @file worker.h - * @brief Worker implementation along with various helpers - * - * This code isn't really in the "library" category, but it's tucked - * in here to provide a good resource for writing remote workers and - * as an example on how to use the API's found here. - */ - -NAGIOS_BEGIN_DECL - -#define MSG_DELIM "\1\0\0" /**< message limiter */ -#define MSG_DELIM_LEN (sizeof(MSG_DELIM)) /**< message delimiter length */ -#define PAIR_SEP 0 /**< pair separator for buf2kvvec() and kvvec2buf() */ -#define KV_SEP '=' /**< key/value separator for buf2kvvec() and kvvec2buf() */ - -/** - * Spawn a helper with a specific process name - * The first entry in the argv parameter will be the name of the - * new process, unless the process changes the name itself. - * @param path The path to the executable (can be $PATH relative) - * @param argv Argument vector for the helper to spawn - */ -extern int spawn_named_helper(char *path, char **argv); - -/** - * Spawn any random helper process. Uses spawn_named_helper() - * @param argv The (NULL-sentinel-terminated) argument vector - * @return 0 on success, < 0 on errors - */ -extern int spawn_helper(char **argv); - -/** - * Build a buffer from a key/value vector buffer. - * The resulting kvvec-buffer is suitable for sending between - * worker and master in either direction, as it has all the - * right delimiters in all the right places. - * @param kvv The key/value vector to build the buffer from - * @return NULL on errors, a newly allocated kvvec buffer on success - */ -extern struct kvvec_buf *build_kvvec_buf(struct kvvec *kvv); - -/** - * Grab a worker message from an iocache buffer - * @param[in] ioc The io cache - * @param[out] size Out buffer for buffer length - * @param[in] flags Currently unused - * @return A buffer from the iocache on succes; NULL on errors - */ -extern char *worker_ioc2msg(nm_bufferqueue *ioc, size_t *size, int flags); - -/** - * Set some common socket options - * @param[in] sd The socket to set options for - * @param[in] bufsize Size to set send and receive buffers to - * @return 0 on success. < 0 on errors - */ -extern int worker_set_sockopts(int sd, int bufsize); - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/logging.h b/devtools/ci/naemon/logging.h deleted file mode 100644 index 087e411..0000000 --- a/devtools/ci/naemon/logging.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef INCLUDE_logging_h__ -#define INCLUDE_logging_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lib/lnae-utils.h" - -/******************* LOGGING TYPES ********************/ - -#define NSLOG_RUNTIME_ERROR 1 -#define NSLOG_RUNTIME_WARNING 2 - -#define NSLOG_VERIFICATION_ERROR 4 -#define NSLOG_VERIFICATION_WARNING 8 - -#define NSLOG_CONFIG_ERROR 16 -#define NSLOG_CONFIG_WARNING 32 - -#define NSLOG_PROCESS_INFO 64 -#define NSLOG_EVENT_HANDLER 128 -/*#define NSLOG_NOTIFICATION 256*/ /* NOT USED ANYMORE - CAN BE REUSED */ -#define NSLOG_EXTERNAL_COMMAND 512 - -#define NSLOG_HOST_UP 1024 -#define NSLOG_HOST_DOWN 2048 -#define NSLOG_HOST_UNREACHABLE 4096 - -#define NSLOG_SERVICE_OK 8192 -#define NSLOG_SERVICE_UNKNOWN 16384 -#define NSLOG_SERVICE_WARNING 32768 -#define NSLOG_SERVICE_CRITICAL 65536 - -#define NSLOG_PASSIVE_CHECK 131072 - -#define NSLOG_INFO_MESSAGE 262144 - -#define NSLOG_HOST_NOTIFICATION 524288 -#define NSLOG_SERVICE_NOTIFICATION 1048576 - -/***************** DEBUGGING LEVELS *******************/ - -#define DEBUGL_ALL -1 -#define DEBUGL_NONE 0 -#define DEBUGL_CONFIG 2 -#define DEBUGL_PROCESS 4 -#define DEBUGL_STATUSDATA 4 -#define DEBUGL_RETENTIONDATA 4 -#define DEBUGL_EVENTS 8 -#define DEBUGL_CHECKS 16 -#define DEBUGL_FLAPPING 16 -#define DEBUGL_EVENTHANDLERS 16 -#define DEBUGL_PERFDATA 16 -#define DEBUGL_NOTIFICATIONS 32 -#define DEBUGL_EVENTBROKER 64 -#define DEBUGL_EXTERNALCOMMANDS 128 -#define DEBUGL_COMMANDS 256 -#define DEBUGL_DOWNTIME 512 -#define DEBUGL_COMMENTS 1024 -#define DEBUGL_MACROS 2048 -#define DEBUGL_IPC 4096 -#define DEBUGL_SCHEDULING 8192 - -#define DEBUGV_BASIC 0 -#define DEBUGV_MORE 1 -#define DEBUGV_MOST 2 - - -/******************* STATE LOGGING TYPES **************/ - -#define INITIAL_STATES 1 -#define CURRENT_STATES 2 - - -NAGIOS_BEGIN_DECL - -extern int log_initial_states; -extern int log_current_states; - -/**** Logging Functions ****/ -void nm_log(int, const char *, ...) -__attribute__((__format__(__printf__, 2, 3))); -int log_debug_info(int, int, const char *, ...) -__attribute__((__format__(__printf__, 3, 4))); - -int rotate_log_file(time_t); /* rotates the main log file */ -int write_log_file_info(time_t *); /* records log file/version info */ -int open_debug_log(void); -int close_debug_log(void); -int close_log_file(void); - -/* GLib log handler (GLogFunc*) that maps GLib log messages to their - * corresponding Naemon levels. Only intended for use as a regular handler, - * don't invoke directly through application code*/ -extern guint nm_g_log_handler_id; -void nm_g_log_handler(const gchar *domain, GLogLevelFlags log_level, - const gchar *message, gpointer udata); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/macros.h b/devtools/ci/naemon/macros.h deleted file mode 100644 index a4f8f40..0000000 --- a/devtools/ci/naemon/macros.h +++ /dev/null @@ -1,256 +0,0 @@ -#ifndef _MACROS_H -#define _MACROS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "common.h" -#include "objects_host.h" -#include "objects_hostgroup.h" -#include "objects_contact.h" -#include "objects_contactgroup.h" -#include "objects_service.h" -#include "objects_servicegroup.h" -#include "objects_command.h" - - -/****************** LENGTH LIMITATIONS ****************/ -#define MAX_COMMAND_ARGUMENTS 32 /* max $ARGx$ macros */ - - -/****************** MACRO DEFINITIONS *****************/ -#define MACRO_ENV_VAR_PREFIX "NAGIOS_" -#define MAX_USER_MACROS 256 /* max $USERx$ macros */ -#define MACRO_X_COUNT 156 /* size of macro_x[] array */ - -NAGIOS_BEGIN_DECL - -struct nagios_macros -{ - char *x[MACRO_X_COUNT]; - char *argv[MAX_COMMAND_ARGUMENTS]; - char *contactaddress[MAX_CONTACT_ADDRESSES]; - char *ondemand; - host *host_ptr; - hostgroup *hostgroup_ptr; - service *service_ptr; - servicegroup *servicegroup_ptr; - contact *contact_ptr; - contactgroup *contactgroup_ptr; - customvariablesmember *custom_host_vars; - customvariablesmember *custom_service_vars; - customvariablesmember *custom_contact_vars; -}; -typedef struct nagios_macros nagios_macros; - - -#define MACRO_HOSTNAME 0 -#define MACRO_HOSTALIAS 1 -#define MACRO_HOSTADDRESS 2 -#define MACRO_SERVICEDESC 3 -#define MACRO_SERVICESTATE 4 -#define MACRO_SERVICESTATEID 5 -#define MACRO_SERVICEATTEMPT 6 -#define MACRO_LONGDATETIME 7 -#define MACRO_SHORTDATETIME 8 -#define MACRO_DATE 9 -#define MACRO_TIME 10 -#define MACRO_TIMET 11 -#define MACRO_LASTHOSTCHECK 12 -#define MACRO_LASTSERVICECHECK 13 -#define MACRO_LASTHOSTSTATECHANGE 14 -#define MACRO_LASTSERVICESTATECHANGE 15 -#define MACRO_HOSTOUTPUT 16 -#define MACRO_SERVICEOUTPUT 17 -#define MACRO_HOSTPERFDATA 18 -#define MACRO_SERVICEPERFDATA 19 -#define MACRO_CONTACTNAME 20 -#define MACRO_CONTACTALIAS 21 -#define MACRO_CONTACTEMAIL 22 -#define MACRO_CONTACTPAGER 23 -#define MACRO_ADMINEMAIL 24 -#define MACRO_ADMINPAGER 25 -#define MACRO_HOSTSTATE 26 -#define MACRO_HOSTSTATEID 27 -#define MACRO_HOSTATTEMPT 28 -#define MACRO_NOTIFICATIONTYPE 29 -#define MACRO_NOTIFICATIONNUMBER 30 /* deprecated - see HOSTNOTIFICATIONNUMBER and SERVICENOTIFICATIONNUMBER macros */ -#define MACRO_HOSTEXECUTIONTIME 31 -#define MACRO_SERVICEEXECUTIONTIME 32 -#define MACRO_HOSTLATENCY 33 -#define MACRO_SERVICELATENCY 34 -#define MACRO_HOSTDURATION 35 -#define MACRO_SERVICEDURATION 36 -#define MACRO_HOSTDURATIONSEC 37 -#define MACRO_SERVICEDURATIONSEC 38 -#define MACRO_HOSTDOWNTIME 39 -#define MACRO_SERVICEDOWNTIME 40 -#define MACRO_HOSTSTATETYPE 41 -#define MACRO_SERVICESTATETYPE 42 -#define MACRO_HOSTPERCENTCHANGE 43 -#define MACRO_SERVICEPERCENTCHANGE 44 -#define MACRO_HOSTGROUPNAME 45 -#define MACRO_HOSTGROUPALIAS 46 -#define MACRO_SERVICEGROUPNAME 47 -#define MACRO_SERVICEGROUPALIAS 48 -#define MACRO_HOSTACKAUTHOR 49 -#define MACRO_HOSTACKCOMMENT 50 -#define MACRO_SERVICEACKAUTHOR 51 -#define MACRO_SERVICEACKCOMMENT 52 -#define MACRO_LASTSERVICEOK 53 -#define MACRO_LASTSERVICEWARNING 54 -#define MACRO_LASTSERVICEUNKNOWN 55 -#define MACRO_LASTSERVICECRITICAL 56 -#define MACRO_LASTHOSTUP 57 -#define MACRO_LASTHOSTDOWN 58 -#define MACRO_LASTHOSTUNREACHABLE 59 -#define MACRO_SERVICECHECKCOMMAND 60 -#define MACRO_HOSTCHECKCOMMAND 61 -#define MACRO_MAINCONFIGFILE 62 -#define MACRO_STATUSDATAFILE 63 -#define MACRO_HOSTDISPLAYNAME 64 -#define MACRO_SERVICEDISPLAYNAME 65 -#define MACRO_RETENTIONDATAFILE 66 -#define MACRO_OBJECTCACHEFILE 67 -#define MACRO_TEMPFILE 68 -#define MACRO_LOGFILE 69 -#define MACRO_RESOURCEFILE 70 -#define MACRO_COMMANDFILE 71 -#define MACRO_HOSTPERFDATAFILE 72 -#define MACRO_SERVICEPERFDATAFILE 73 -#define MACRO_HOSTACTIONURL 74 -#define MACRO_HOSTNOTESURL 75 -#define MACRO_HOSTNOTES 76 -#define MACRO_SERVICEACTIONURL 77 -#define MACRO_SERVICENOTESURL 78 -#define MACRO_SERVICENOTES 79 -#define MACRO_TOTALHOSTSUP 80 -#define MACRO_TOTALHOSTSDOWN 81 -#define MACRO_TOTALHOSTSUNREACHABLE 82 -#define MACRO_TOTALHOSTSDOWNUNHANDLED 83 -#define MACRO_TOTALHOSTSUNREACHABLEUNHANDLED 84 -#define MACRO_TOTALHOSTPROBLEMS 85 -#define MACRO_TOTALHOSTPROBLEMSUNHANDLED 86 -#define MACRO_TOTALSERVICESOK 87 -#define MACRO_TOTALSERVICESWARNING 88 -#define MACRO_TOTALSERVICESCRITICAL 89 -#define MACRO_TOTALSERVICESUNKNOWN 90 -#define MACRO_TOTALSERVICESWARNINGUNHANDLED 91 -#define MACRO_TOTALSERVICESCRITICALUNHANDLED 92 -#define MACRO_TOTALSERVICESUNKNOWNUNHANDLED 93 -#define MACRO_TOTALSERVICEPROBLEMS 94 -#define MACRO_TOTALSERVICEPROBLEMSUNHANDLED 95 -#define MACRO_PROCESSSTARTTIME 96 -#define MACRO_HOSTCHECKTYPE 97 -#define MACRO_SERVICECHECKTYPE 98 -#define MACRO_LONGHOSTOUTPUT 99 -#define MACRO_LONGSERVICEOUTPUT 100 -#define MACRO_TEMPPATH 101 -#define MACRO_HOSTNOTIFICATIONNUMBER 102 -#define MACRO_SERVICENOTIFICATIONNUMBER 103 -#define MACRO_HOSTNOTIFICATIONID 104 -#define MACRO_SERVICENOTIFICATIONID 105 -#define MACRO_HOSTEVENTID 106 -#define MACRO_LASTHOSTEVENTID 107 -#define MACRO_SERVICEEVENTID 108 -#define MACRO_LASTSERVICEEVENTID 109 -#define MACRO_HOSTGROUPNAMES 110 -#define MACRO_SERVICEGROUPNAMES 111 -#define MACRO_HOSTACKAUTHORNAME 112 -#define MACRO_HOSTACKAUTHORALIAS 113 -#define MACRO_SERVICEACKAUTHORNAME 114 -#define MACRO_SERVICEACKAUTHORALIAS 115 -#define MACRO_MAXHOSTATTEMPTS 116 -#define MACRO_MAXSERVICEATTEMPTS 117 -#define MACRO_SERVICEISVOLATILE 118 -#define MACRO_TOTALHOSTSERVICES 119 -#define MACRO_TOTALHOSTSERVICESOK 120 -#define MACRO_TOTALHOSTSERVICESWARNING 121 -#define MACRO_TOTALHOSTSERVICESUNKNOWN 122 -#define MACRO_TOTALHOSTSERVICESCRITICAL 123 -#define MACRO_HOSTGROUPNOTES 124 -#define MACRO_HOSTGROUPNOTESURL 125 -#define MACRO_HOSTGROUPACTIONURL 126 -#define MACRO_SERVICEGROUPNOTES 127 -#define MACRO_SERVICEGROUPNOTESURL 128 -#define MACRO_SERVICEGROUPACTIONURL 129 -#define MACRO_HOSTGROUPMEMBERS 130 -#define MACRO_SERVICEGROUPMEMBERS 131 -#define MACRO_CONTACTGROUPNAME 132 -#define MACRO_CONTACTGROUPALIAS 133 -#define MACRO_CONTACTGROUPMEMBERS 134 -#define MACRO_CONTACTGROUPNAMES 135 -#define MACRO_NOTIFICATIONRECIPIENTS 136 -#define MACRO_NOTIFICATIONISESCALATED 137 -#define MACRO_NOTIFICATIONAUTHOR 138 -#define MACRO_NOTIFICATIONAUTHORNAME 139 -#define MACRO_NOTIFICATIONAUTHORALIAS 140 -#define MACRO_NOTIFICATIONCOMMENT 141 -#define MACRO_EVENTSTARTTIME 142 -#define MACRO_HOSTPROBLEMID 143 -#define MACRO_LASTHOSTPROBLEMID 144 -#define MACRO_SERVICEPROBLEMID 145 -#define MACRO_LASTSERVICEPROBLEMID 146 -#define MACRO_ISVALIDTIME 147 -#define MACRO_NEXTVALIDTIME 148 -#define MACRO_LASTHOSTSTATE 149 -#define MACRO_LASTHOSTSTATEID 150 -#define MACRO_LASTSERVICESTATE 151 -#define MACRO_LASTSERVICESTATEID 152 -#define MACRO_HOSTVALUE 153 -#define MACRO_SERVICEVALUE 154 -#define MACRO_PROBLEMVALUE 155 - - -/************* MACRO CLEANING OPTIONS *****************/ -#define STRIP_ILLEGAL_MACRO_CHARS 1 -#define ESCAPE_MACRO_CHARS 2 -#define URL_ENCODE_MACRO_CHARS 4 - - -/****************** MACRO FUNCTIONS ******************/ -nagios_macros *get_global_macros(void); - -/* - * Replace macros with their actual values - * This function modifies the global_macros struct and is thus - * not thread-safe. It's not used in-core, and its use in - * modules is discouraged. - */ -int process_macros(char *, char **, int); - -/* thread-safe version of the above */ -int process_macros_r(nagios_macros *mac, char *, char **, int); - -/* given a raw command line, determine the actual command to run */ -int get_raw_command_line_r(nagios_macros *mac, command *, char *, char **, int); - -/* - * These functions updates *mac with the values from - * their respective object type. - */ -int grab_service_macros_r(nagios_macros *mac, service *); -int grab_host_macros_r(nagios_macros *mac, host *); -int grab_servicegroup_macros_r(nagios_macros *mac, servicegroup *); -int grab_hostgroup_macros_r(nagios_macros *mac, hostgroup *); -int grab_contact_macros_r(nagios_macros *mac, contact *); - -/* init/deinit functions */ -int init_macros(void); -int init_macrox_names(void); -int free_macrox_names(void); - -/* clear out memory from *mac */ -int clear_argv_macros_r(nagios_macros *mac); -int clear_volatile_macros_r(nagios_macros *mac); -int clear_host_macros_r(nagios_macros *mac); -int clear_service_macros_r(nagios_macros *mac); -int clear_hostgroup_macros_r(nagios_macros *mac); -int clear_servicegroup_macros_r(nagios_macros *mac); -int clear_contact_macros_r(nagios_macros *mac); -int clear_contactgroup_macros_r(nagios_macros *mac); -int clear_summary_macros_r(nagios_macros *mac); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/naemon.h b/devtools/ci/naemon/naemon.h deleted file mode 100644 index 02410b3..0000000 --- a/devtools/ci/naemon/naemon.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef _NAEMON_H -#define _NAEMON_H - -#if defined (NAEMON_COMPILATION) -#error "Never include naemon/naemon.h within a file in the naemon project - it's for broker modules." -#endif - -#define _NAEMON_H_INSIDE - -#include "lib/libnaemon.h" -#include "broker.h" -#include "checks.h" -#include "checks_service.h" -#include "checks_host.h" -#include "commands.h" -#include "comments.h" -#include "common.h" -#include "configuration.h" -#include "defaults.h" -#include "downtime.h" -#include "events.h" -#include "flapping.h" -#include "globals.h" -#include "logging.h" -#include "macros.h" -#include "naemon.h" -#include "nebcallbacks.h" -#include "neberrors.h" -#include "nebmods.h" -#include "nebmodules.h" -#include "nebstructs.h" -#include "nerd.h" -#include "notifications.h" -#include "objectlist.h" -#include "objects.h" -#include "objects_command.h" -#include "objects_common.h" -#include "objects_contactgroup.h" -#include "objects_contact.h" -#include "objects_hostdependency.h" -#include "objects_hostescalation.h" -#include "objects_hostgroup.h" -#include "objects_host.h" -#include "objects_servicedependency.h" -#include "objects_serviceescalation.h" -#include "objects_servicegroup.h" -#include "objects_service.h" -#include "objects_timeperiod.h" -#include "perfdata.h" -#include "query-handler.h" -#include "sehandlers.h" -#include "shared.h" -#include "sretention.h" -#include "statusdata.h" -#include "utils.h" -#include "workers.h" - -#undef _NAEMON_H_INSIDE - -/* - * Defines below is kept purely of backward compatibility purposes. They aren't - * used within the naemon project itself. - * - * If they should be used within the naemon project, move them to the correct - * header before use. - */ - -/************* MISC LENGTH/SIZE DEFINITIONS ***********/ - -/* - NOTE: Plugin length is artificially capped at 8k to prevent runaway plugins from returning MBs/GBs of data - back to Nagios. If you increase the 8k cap by modifying this value, make sure you also increase the value - of MAX_EXTERNAL_COMMAND_LENGTH in common.h to allow for passive checks results received through the external - command file. EG 10/19/07 - */ -#define MAX_PLUGIN_OUTPUT_LENGTH 8192 /* max length of plugin output (including perf data) */ - -/*********** ROUTE CHECK PROPAGATION TYPES ************/ - -#define PROPAGATE_TO_PARENT_HOSTS 1 -#define PROPAGATE_TO_CHILD_HOSTS 2 - -/************ SCHEDULED DOWNTIME TYPES ****************/ - -#define ACTIVE_DOWNTIME 0 /* active downtime - currently in effect */ -#define PENDING_DOWNTIME 1 /* pending downtime - scheduled for the future */ - -#endif diff --git a/devtools/ci/naemon/naemonstats.h b/devtools/ci/naemon/naemonstats.h deleted file mode 100644 index 6139dbd..0000000 --- a/devtools/ci/naemon/naemonstats.h +++ /dev/null @@ -1 +0,0 @@ -/*FIXME HEADER*/ diff --git a/devtools/ci/naemon/nebcallbacks.h b/devtools/ci/naemon/nebcallbacks.h deleted file mode 100644 index 2b79c5b..0000000 --- a/devtools/ci/naemon/nebcallbacks.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _NEBCALLBACKS_H -#define _NEBCALLBACKS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "nebmodules.h" - - -/***** CALLBACK TYPES *****/ -enum NEBCallbackType { - NEBCALLBACK_PROCESS_DATA = 0, - NEBCALLBACK_TIMED_EVENT_DATA, - NEBCALLBACK_LOG_DATA, - NEBCALLBACK_SYSTEM_COMMAND_DATA, - NEBCALLBACK_EVENT_HANDLER_DATA, - NEBCALLBACK_NOTIFICATION_DATA, - NEBCALLBACK_SERVICE_CHECK_DATA, - NEBCALLBACK_HOST_CHECK_DATA, - NEBCALLBACK_COMMENT_DATA, - NEBCALLBACK_DOWNTIME_DATA, - NEBCALLBACK_FLAPPING_DATA, - NEBCALLBACK_PROGRAM_STATUS_DATA, - NEBCALLBACK_HOST_STATUS_DATA, - NEBCALLBACK_SERVICE_STATUS_DATA, - NEBCALLBACK_ADAPTIVE_PROGRAM_DATA, - NEBCALLBACK_ADAPTIVE_HOST_DATA, - NEBCALLBACK_ADAPTIVE_SERVICE_DATA, - NEBCALLBACK_EXTERNAL_COMMAND_DATA, - NEBCALLBACK_AGGREGATED_STATUS_DATA, - NEBCALLBACK_RETENTION_DATA, - NEBCALLBACK_CONTACT_NOTIFICATION_DATA, - NEBCALLBACK_CONTACT_NOTIFICATION_METHOD_DATA, - NEBCALLBACK_ACKNOWLEDGEMENT_DATA, - NEBCALLBACK_STATE_CHANGE_DATA, - NEBCALLBACK_CONTACT_STATUS_DATA, - NEBCALLBACK_ADAPTIVE_CONTACT_DATA, - NEBCALLBACK_TYPE__COUNT -}; - -enum NEBCallbackAPIVersion { - NEB_API_VERSION_1, - NEB_API_VERSION_2 -}; - -#define NEBCALLBACK_NUMITEMS NEBCALLBACK_TYPE__COUNT /* total number of callback types we have */ -#define nebcallback_flag(x) (1 << (x)) - -/***** CALLBACK FUNCTIONS *****/ -NAGIOS_BEGIN_DECL - -int neb_register_callback(enum NEBCallbackType callback_type, void *mod_handle, int priority, int (*callback_func)(int, void *)); -int neb_register_callback_full(enum NEBCallbackType callback_type, void *mod_handle, int priority, enum NEBCallbackAPIVersion api_version, void *callback_func); -int neb_deregister_callback(enum NEBCallbackType callback_type, void *callback_func); -int neb_deregister_module_callbacks(nebmodule *); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/neberrors.h b/devtools/ci/naemon/neberrors.h deleted file mode 100644 index 8a5e144..0000000 --- a/devtools/ci/naemon/neberrors.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _NEBERRORS_H -#define _NEBERRORS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - - -/***** GENERIC DEFINES *****/ -#define NEB_OK 0 -#define NEB_ERROR -1 - -#define NEB_TRUE 1 -#define NEB_FALSE 0 - - -/***** GENERIC ERRORS *****/ -#define NEBERROR_NOMEM 100 /* memory could not be allocated */ - - -/***** CALLBACK ERRORS *****/ -#define NEBERROR_NOCALLBACKFUNC 200 /* no callback function was specified */ -#define NEBERROR_NOCALLBACKLIST 201 /* callback list not initialized */ -#define NEBERROR_CALLBACKBOUNDS 202 /* No longer used! callback type was out of bounds */ -#define NEBERROR_CALLBACKNOTFOUND 203 /* the callback could not be found */ -#define NEBERROR_NOMODULEHANDLE 204 /* no module handle specified */ -#define NEBERROR_BADMODULEHANDLE 205 /* bad module handle */ -#define NEBERROR_CALLBACKOVERRIDE 206 /* module wants to override default Nagios handling of event */ -#define NEBERROR_CALLBACKCANCEL 207 /* module wants to cancel callbacks to other modules */ - - -/***** MODULE ERRORS *****/ -#define NEBERROR_NOMODULE 300 /* no module was specified */ - - -/***** MODULE INFO ERRORS *****/ -#define NEBERROR_MODINFOBOUNDS 400 /* module info index was out of bounds */ - -#endif diff --git a/devtools/ci/naemon/nebmods.h b/devtools/ci/naemon/nebmods.h deleted file mode 100644 index ccb25ab..0000000 --- a/devtools/ci/naemon/nebmods.h +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef _NEBMODS_H -#define _NEBMODS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "nebcallbacks.h" -#include "nebmodules.h" - -NAGIOS_BEGIN_DECL - -/***** MODULE STRUCTURES *****/ - -/* NEB module callback list struct */ -typedef struct nebcallback_struct { - void *callback_func; - void *module_handle; - int priority; - enum NEBCallbackAPIVersion api_version; - struct nebcallback_struct *next; -} nebcallback; - - -/***** MODULE FUNCTIONS *****/ -int neb_init_modules(void); -int neb_deinit_modules(void); -int neb_load_all_modules(void); -int neb_load_module(nebmodule *); -int neb_free_module_list(void); -int neb_unload_all_modules(int, int); -int neb_unload_module(nebmodule *, int, int); -int neb_add_module(char *, char *, int); -int neb_add_core_module(nebmodule *mod); - - -/***** CALLBACK FUNCTIONS *****/ -typedef struct neb_cb_result neb_cb_result; -typedef struct neb_cb_resultset neb_cb_resultset; - -/* not for public consumption */ -struct neb_cb_resultset_iter_ { - void *private1; - ssize_t private2; -}; - -typedef struct neb_cb_resultset_iter_ neb_cb_resultset_iter; -int neb_init_callback_list(void); -int neb_free_callback_list(void); -/** - * Make callbacks to Event Broker Modules, and get the full result back - * @param callback_type The callback type to invoke - * @param user_data Opaque pointer passed to callback - * @return A neb_cb_resultset containing neb_cb_result pointers, as created by the callbacks. To - * free this result, use \p neb_cb_resultset_destroy(). To iterate over the - * set, use \p neb_cb_resultset_iter. - **/ -neb_cb_resultset * neb_make_callbacks_full(enum NEBCallbackType callback_type, void * user_data); - -/** - * Make callbacks to Event Broker Modules (simplified) - * This is identical to \p neb_make_callbacks_full, with the execption that it - * automatically frees the result and only returns the return code of the last - * callback invoked, in order to provide backwards compatibility. New code - * should probably avoid using this function. - * @param callback_type The callback type to invoke - * @param user_data Opaque pointer passed to callback - * @return The return code of the callback result - */ -int neb_make_callbacks(enum NEBCallbackType callback_type, void * user_data); - -/***** CALLBACK RESULT *****/ -/** - * Create a new \p neb_cb_result with the given \p rc and a description formatted with - * \p format. To free the returned result, use \p neb_cb_result_destroy(). - * @param rc The return code - * @param printf()-style format string - * @param ... arguments to format - * @return a new \p neb_cb_result - */ -neb_cb_result *neb_cb_result_create_full(int rc, const char *format, ...); - -/** - * Create a new \p neb_cb_result with the given \p rc. The description of this result - * is the empty string "", unless explicitly set with - * neb_cb_result_set_description(). That is, calling this function is - * equivalent to calling \p neb_cb_result_create_full(rc, ""). To free the - * returned result, use \p neb_cb_result_destroy(). - * @param rc The return code - * @return a new \p neb_cb_result - */ -neb_cb_result *neb_cb_result_create(int rc); - -/** - * Frees a \p neb_cb_result and associated resources - * @param cb_result a \p neb_cb_result - */ -void neb_cb_result_destroy(neb_cb_result *); - -/** - * @param cb_result a \p neb_cb_result - * @return The module name associated with this \p neb_cb_result - */ -const char * neb_cb_result_module_name(neb_cb_result *cb_result); - -/** - * @param cb_result a \p neb_cb_result - * @return The description associated with this \p neb_cb_result - */ -const char * neb_cb_result_description(neb_cb_result *cb_result); - -/** - * Set the description for the given \p neb_cb_result formatted with \p format. - * Any preexisting description will be freed and overwritten. - * @param cb_result a \p neb_cb_result - * @param printf()-style format string - * @param ... arguments to format - */ -void neb_cb_result_set_description(neb_cb_result *cb_result, const char *format, ...); -/** - * @param cb_result a \p neb_cb_result - * @return The returncode associated with this \p neb_cb_result - */ -int neb_cb_result_returncode(neb_cb_result *cb_result); - -/** - * Frees a \p neb_cb_resultset and associated resources. Note - * that this also frees all the contained \p neb_cb_results contained - * withing the set. - * @param cb_resultset a \p neb_cb_resultset - */ -void neb_cb_resultset_destroy(neb_cb_resultset *); - -/** - * Initializes an iterator and associates it with \p resultset. Modifying the result set - * after calling this function invalidates the returned iterator. - * @param iter an uninitialized \p neb_cb_resultset_iter - * @param resultset a \p neb_cb_resultset - */ -void neb_cb_resultset_iter_init(neb_cb_resultset_iter *iter, neb_cb_resultset *resultset); - -/** - * Advances \p iter and retrieves the result that is now targeted. If NULL is - * returned, \p result is not set and the iterator becomes invalid. - * @param iter an initialized \p neb_cb_resultset_iter - * @param result a location to store the \p neb_cb_result - * @return \p NULL if the end of the \p neb_cb_resultset has been reached. - */ -neb_cb_resultset_iter *neb_cb_resultset_iter_next(neb_cb_resultset_iter *, neb_cb_result **); -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/nebmodules.h b/devtools/ci/naemon/nebmodules.h deleted file mode 100644 index f1d619b..0000000 --- a/devtools/ci/naemon/nebmodules.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _NEBMODULES_H -#define _NEBMODULES_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "common.h" -NAGIOS_BEGIN_DECL - -/***** MODULE VERSION INFORMATION *****/ -#define NEB_API_VERSION(x) int __neb_api_version = x; -#define CURRENT_NEB_API_VERSION 5 - - -/***** MODULE INFORMATION *****/ -#define NEBMODULE_MODINFO_NUMITEMS 6 -#define NEBMODULE_MODINFO_TITLE 0 -#define NEBMODULE_MODINFO_AUTHOR 1 -#define NEBMODULE_MODINFO_COPYRIGHT 2 -#define NEBMODULE_MODINFO_VERSION 3 -#define NEBMODULE_MODINFO_LICENSE 4 -#define NEBMODULE_MODINFO_DESC 5 - - -/***** MODULE LOAD/UNLOAD OPTIONS *****/ -#define NEBMODULE_NORMAL_LOAD 0 /* module is being loaded normally */ -#define NEBMODULE_REQUEST_UNLOAD 0 /* request module to unload (but don't force it) */ -#define NEBMODULE_FORCE_UNLOAD 1 /* force module to unload */ - -/***** MODULES UNLOAD REASONS *****/ -#define NEBMODULE_NEB_SHUTDOWN 1 /* event broker is shutting down */ -#define NEBMODULE_NEB_RESTART 2 /* event broker is restarting */ -#define NEBMODULE_ERROR_NO_INIT 3 /* _module_init() function was not found in module */ -#define NEBMODULE_ERROR_BAD_INIT 4 /* _module_init() function returned a bad code */ -#define NEBMODULE_ERROR_API_VERSION 5 /* module version is incompatible with current api */ - - -/***** MODULE STRUCTURES *****/ -/* NEB module structure */ -typedef struct nebmodule_struct { - char *filename; - char *args; - char *info[NEBMODULE_MODINFO_NUMITEMS]; - int should_be_loaded; - int is_currently_loaded; - int core_module; -#ifdef USE_LTDL - lt_dlhandle module_handle; - lt_ptr init_func; - lt_ptr deinit_func; -#else - void *module_handle; - void *init_func; - void *deinit_func; -#endif - struct nebmodule_struct *next; -} nebmodule; - - -/***** MODULE FUNCTIONS *****/ -int neb_set_module_info(void *, int, char *); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/nebstructs.h b/devtools/ci/naemon/nebstructs.h deleted file mode 100644 index 86e3ac0..0000000 --- a/devtools/ci/naemon/nebstructs.h +++ /dev/null @@ -1,494 +0,0 @@ -#ifndef _NEBSTRUCTS_H -#define _NEBSTRUCTS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "common.h" - -NAGIOS_BEGIN_DECL - -/****** STRUCTURES *************************/ - -/* process data structure */ -typedef struct nebstruct_process_struct { - int type; - int flags; - int attr; - struct timeval timestamp; -} nebstruct_process_data; - - -/* timed event data structure */ -typedef struct nebstruct_timed_event_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int event_type; - int recurring; - time_t run_time; - void *event_data; - void *event_ptr; -} nebstruct_timed_event_data; - - -/* log data structure */ -typedef struct nebstruct_log_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - time_t entry_time; - int data_type; - char *data; -} nebstruct_log_data; - - -/* system command structure */ -typedef struct nebstruct_system_command_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - struct timeval start_time; - struct timeval end_time; - int timeout; - char *command_line; - int early_timeout; - double execution_time; - int return_code; - char *output; -} nebstruct_system_command_data; - - -/* event handler structure */ -typedef struct nebstruct_event_handler_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int eventhandler_type; - char *host_name; - char *service_description; - int state_type; - int state; - int timeout; - char *command_name; - char *command_args; - char *command_line; - struct timeval start_time; - struct timeval end_time; - int early_timeout; - double execution_time; - int return_code; - char *output; - - void *object_ptr; -} nebstruct_event_handler_data; - - -/* host check structure */ -typedef struct nebstruct_host_check_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - char *host_name; - int current_attempt; - int check_type; - int max_attempts; - int state_type; - int state; - int timeout; - char *command_name; - char *command_args; - char *command_line; - struct timeval start_time; - struct timeval end_time; - int early_timeout; - double execution_time; - double latency; - int return_code; - char *output; - char *long_output; - char *perf_data; - check_result *check_result_ptr; - - void *object_ptr; -} nebstruct_host_check_data; - - -/* service check structure */ -typedef struct nebstruct_service_check_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - char *host_name; - char *service_description; - int check_type; - int current_attempt; - int max_attempts; - int state_type; - int state; - int timeout; - char *command_name; - char *command_args; - char *command_line; - struct timeval start_time; - struct timeval end_time; - int early_timeout; - double execution_time; - double latency; - int return_code; - char *output; - char *long_output; - char *perf_data; - check_result *check_result_ptr; - - void *object_ptr; -} nebstruct_service_check_data; - - -/* comment data structure */ -typedef struct nebstruct_comment_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int comment_type; - char *host_name; - char *service_description; - time_t entry_time; - char *author_name; - char *comment_data; - int persistent; - int source; - int entry_type; - int expires; - time_t expire_time; - unsigned long comment_id; - - void *object_ptr; /* not implemented yet */ -} nebstruct_comment_data; - - -/* downtime data structure */ -typedef struct nebstruct_downtime_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int downtime_type; - char *host_name; - char *service_description; - time_t entry_time; - char *author_name; - char *comment_data; - time_t start_time; - time_t end_time; - int fixed; - unsigned long duration; - unsigned long triggered_by; - unsigned long downtime_id; - - void *object_ptr; /* not implemented yet */ -} nebstruct_downtime_data; - - -/* flapping data structure */ -typedef struct nebstruct_flapping_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int flapping_type; - char *host_name; - char *service_description; - double percent_change; - double high_threshold; - double low_threshold; - unsigned long comment_id; - - void *object_ptr; -} nebstruct_flapping_data; - - -/* program status structure */ -typedef struct nebstruct_program_status_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - time_t program_start; - int pid; - int daemon_mode; - time_t last_log_rotation; - int notifications_enabled; - int active_service_checks_enabled; - int passive_service_checks_enabled; - int active_host_checks_enabled; - int passive_host_checks_enabled; - int event_handlers_enabled; - int flap_detection_enabled; - int process_performance_data; - int obsess_over_hosts; - int obsess_over_services; - unsigned long modified_host_attributes; - unsigned long modified_service_attributes; - char *global_host_event_handler; - char *global_service_event_handler; -} nebstruct_program_status_data; - - -/* host status structure */ -typedef struct nebstruct_host_status_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - void *object_ptr; -} nebstruct_host_status_data; - - -/* service status structure */ -typedef struct nebstruct_service_status_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - void *object_ptr; -} nebstruct_service_status_data; - - -/* contact status structure */ -typedef struct nebstruct_contact_status_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - void *object_ptr; -} nebstruct_contact_status_data; - - -/* notification data structure */ -typedef struct nebstruct_notification_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int notification_type; - struct timeval start_time; - struct timeval end_time; - char *host_name; - char *service_description; - int reason_type; - int state; - char *output; - char *ack_author; - char *ack_data; - int escalated; - int contacts_notified; - void *object_ptr; -} nebstruct_notification_data; - - -/* contact notification data structure */ -typedef struct nebstruct_contact_notification_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int notification_type; - struct timeval start_time; - struct timeval end_time; - char *host_name; - char *service_description; - char *contact_name; - int reason_type; - int state; - char *output; - char *ack_author; - char *ack_data; - int escalated; - void *object_ptr; - void *contact_ptr; -} nebstruct_contact_notification_data; - - -/* contact notification method data structure */ -typedef struct nebstruct_contact_notification_method_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int notification_type; - struct timeval start_time; - struct timeval end_time; - char *host_name; - char *service_description; - char *contact_name; - char *command_name; - char *command_args; - int reason_type; - int state; - char *output; - char *ack_author; - char *ack_data; - int escalated; - void *object_ptr; - void *contact_ptr; -} nebstruct_contact_notification_method_data; - - -/* adaptive program data structure */ -typedef struct nebstruct_adaptive_program_data_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int command_type; - unsigned long modified_host_attribute; - unsigned long modified_host_attributes; - unsigned long modified_service_attribute; - unsigned long modified_service_attributes; -} nebstruct_adaptive_program_data; - - -/* adaptive host data structure */ -typedef struct nebstruct_adaptive_host_data_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int command_type; - unsigned long modified_attribute; - unsigned long modified_attributes; - void *object_ptr; -} nebstruct_adaptive_host_data; - - -/* adaptive service data structure */ -typedef struct nebstruct_adaptive_service_data_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int command_type; - unsigned long modified_attribute; - unsigned long modified_attributes; - void *object_ptr; -} nebstruct_adaptive_service_data; - - -/* adaptive contact data structure */ -typedef struct nebstruct_adaptive_contact_data_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int command_type; - unsigned long modified_attribute; - unsigned long modified_attributes; - unsigned long modified_host_attribute; - unsigned long modified_host_attributes; - unsigned long modified_service_attribute; - unsigned long modified_service_attributes; - void *object_ptr; -} nebstruct_adaptive_contact_data; - - -/* external command data structure */ -typedef struct nebstruct_external_command_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int command_type; - time_t entry_time; - char *command_string; - char *command_args; -} nebstruct_external_command_data; - - -/* aggregated status data structure */ -typedef struct nebstruct_aggregated_status_struct { - int type; - int flags; - int attr; - struct timeval timestamp; -} nebstruct_aggregated_status_data; - - -/* retention data structure */ -typedef struct nebstruct_retention_struct { - int type; - int flags; - int attr; - struct timeval timestamp; -} nebstruct_retention_data; - - -/* acknowledgement structure */ -typedef struct nebstruct_acknowledgement_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int acknowledgement_type; - char *host_name; - char *service_description; - int state; - char *author_name; - char *comment_data; - int is_sticky; - int persistent_comment; - int notify_contacts; - void *object_ptr; -} nebstruct_acknowledgement_data; - - -/* state change structure */ -typedef struct nebstruct_statechange_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int statechange_type; - char *host_name; - char *service_description; - int state; - int state_type; - int current_attempt; - int max_attempts; - char *output; - void *object_ptr; -} nebstruct_statechange_data; - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/nerd.h b/devtools/ci/naemon/nerd.h deleted file mode 100644 index e41a2e4..0000000 --- a/devtools/ci/naemon/nerd.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _NERD_H -#define _NERD_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "objectlist.h" - -NAGIOS_BEGIN_DECL - -/** Nerd subscription type */ -struct nerd_subscription { - int sd; - struct nerd_channel *chan; - char *format; /* requested format (macro string) for this subscription */ -}; - -/*** Nagios Event Radio Dispatcher functions ***/ -int nerd_init(void); -int nerd_mkchan(const char *name, const char *description, int (*handler)(int, void *), unsigned int callbacks); -int nerd_cancel_subscriber(int sd); -int nerd_get_channel_id(const char *chan_name); -objectlist *nerd_get_subscriptions(int chan_id); -int nerd_broadcast(unsigned int chan_id, void *buf, unsigned int len); - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/nm_alloc.h b/devtools/ci/naemon/nm_alloc.h deleted file mode 100644 index 7a2d400..0000000 --- a/devtools/ci/naemon/nm_alloc.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _NM_ALLOC_H -#define _NM_ALLOC_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -void *nm_malloc(size_t size); -void *nm_realloc(void *ptr, size_t size); -void *nm_calloc(size_t count, size_t size); -void *nm_strdup(const char *s); -void *nm_strndup(const char *s, size_t size); -void nm_asprintf(char **strp, const char *fmt, ...); -#define nm_free(ptr) do { if(ptr) { free(ptr); ptr = NULL; } } while(0) -#endif diff --git a/devtools/ci/naemon/nm_arith.h b/devtools/ci/naemon/nm_arith.h deleted file mode 100644 index a4051fc..0000000 --- a/devtools/ci/naemon/nm_arith.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef NM_ARITH_H -#define NM_ARITH_H -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include "lib/lnae-utils.h" - -#ifndef NM_SKIP_BUILTIN_OVERFLOW_CHECKS -# if __GNUC__ >= 5 /* gcc >= 5*/ -# define NM_HAVE_BUILTIN_OVERFLOW_CHECKS -/* we need to check explicility for clang before doing __has_builtin(), since - * not doing this causes compilation to fail with 'missing binary operator - * before token "("' on older gcc's (where the above is not true) - */ -# elif __CLANG___ -# if __has_builtin(__builtin_smull_overflow) /* clang >= 3.5 */ -# define NM_HAVE_BUILTIN_OVERFLOW_CHECKS -# endif -# endif -#endif -NAGIOS_BEGIN_DECL - -/** - * These functions perform checked arithmetics on their parameters and return - * the result in the location pointed to by *dest. - * They return true if no overflow was detected during the operation, and false - * otherwise - **/ -#ifdef NM_HAVE_BUILTIN_OVERFLOW_CHECKS -static inline bool nm_arith_smull_overflow(long x, long y, long *dest) -{ - return !__builtin_smull_overflow(x, y, dest); -} - -static inline bool nm_arith_saddl_overflow(long x, long y, long *dest) -{ - return !__builtin_saddl_overflow(x, y, dest); -} - -static inline bool nm_arith_ssubl_overflow(long x, long y, long *dest) -{ - return !__builtin_ssubl_overflow(x, y, dest); -} -#else -static inline bool nm_arith_smull_overflow(long x, long y, long *dest) -{ - if (x > 0) { // x positive - if (y > 0) { - if (x > (LONG_MAX / y)) { - return false; - } - } else { - if (y < (LONG_MIN / x)) { - return false; - } - } - } else { // x negative or zero - if (y > 0) { - if (x < (LONG_MIN / y)) { - return false; - } - } else { - if ((x != 0) && (y < (LONG_MAX / x))) { - return false; - } - } - } - *dest = x * y; - return true; -} - -static inline bool nm_arith_saddl_overflow(long x, long y, long *dest) -{ - if (((y > 0) && (x > (LONG_MAX - y))) || - ((y < 0) && (x < (LONG_MIN - y)))) { - return false; - } - *dest = x + y; - return true; -} - -static inline bool nm_arith_ssubl_overflow(long x, long y, long *dest) -{ - if ((y > 0 && x < LONG_MIN + y) || - (y < 0 && x > LONG_MAX + y)) { - return false; - } - *dest = x - y; - return true; -} -#endif -NAGIOS_END_DECL -#endif /* NM_ARITH_H */ diff --git a/devtools/ci/naemon/notifications.h b/devtools/ci/naemon/notifications.h deleted file mode 100644 index ee15f1d..0000000 --- a/devtools/ci/naemon/notifications.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef _NOTIFICATIONS_H -#define _NOTIFICATIONS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "objects_serviceescalation.h" -#include "objects_hostescalation.h" -#include "macros.h" - -/* - * Enumeration of the type of objects that can influence notification - * suppressions - */ -enum NotificationSuppressionType { - NS_TYPE_HOST = 0, - NS_TYPE_SERVICE, - NS_TYPE_HOST_CONTACT, - NS_TYPE_SERVICE_CONTACT, - /* NOTE: NS_TYPE__COUNT assumes the types are sequential, and start at zero. If you break - * this assumption, you break this member as well and need to fix it - */ - NS_TYPE__COUNT -}; - -/* - * Enumeration of all known valid notification suppression reasons - */ -enum NotificationSuppressionReason { - NSR_OK, - NSR_DISABLED, - NSR_TIMEPERIOD_BLOCKED, - NSR_DISABLED_OBJECT, - NSR_NO_CONTACTS, - NSR_CUSTOM_SCHED_DOWNTIME, - NSR_ACK_OBJECT_OK, - NSR_NO_FLAPPING, - NSR_SCHED_DOWNTIME_FLAPPING, - NSR_NO_DOWNTIME, - NSR_SCHED_DOWNTIME_DOWNTIME, - NSR_SOFT_STATE, - NSR_ACKNOWLEDGED, - NSR_DEPENDENCY_FAILURE, - NSR_STATE_DISABLED, - NSR_NO_RECOVERY, - NSR_RECOVERY_UNNOTIFIED_PROBLEM, - NSR_DELAY, - NSR_IS_FLAPPING, - NSR_IS_SCHEDULED_DOWNTIME, - NSR_RE_NO_MORE, - NSR_RE_NOT_YET, - NSR_NEB_BLOCKED, - NSR_BAD_PARENTS, - NSR_SERVICE_HOST_DOWN_UNREACHABLE, - NSR_SERVICE_HOST_SCHEDULED_DOWNTIME, - NSR_INSUFF_IMPORTANCE, -}; - -/**************** NOTIFICATION TYPES ******************/ - -#define HOST_NOTIFICATION 0 -#define SERVICE_NOTIFICATION 1 - - -/************* NOTIFICATION REASON TYPES ***************/ -enum NotificationReason { - NOTIFICATION_NORMAL, - NOTIFICATION_ACKNOWLEDGEMENT, - NOTIFICATION_FLAPPINGSTART, - NOTIFICATION_FLAPPINGSTOP, - NOTIFICATION_FLAPPINGDISABLED, - NOTIFICATION_DOWNTIMESTART, - NOTIFICATION_DOWNTIMEEND, - NOTIFICATION_DOWNTIMECANCELLED, - NOTIFICATION_CUSTOM -}; - -NAGIOS_BEGIN_DECL - -typedef struct notify_list { - struct contact *contact; - struct notify_list *next; -} notification; - -const char *notification_reason_name(unsigned int reason_type); -int check_service_notification_viability(service *, int, int); /* checks viability of notifying all contacts about a service */ -int is_valid_escalation_for_service_notification(service *, serviceescalation *, int); /* checks if an escalation entry is valid for a particular service notification */ -int should_service_notification_be_escalated(service *); /* checks if a service notification should be escalated */ -int service_notification(service *, int, char *, char *, int); /* notify all contacts about a service (problem or recovery) */ -int check_contact_service_notification_viability(contact *, service *, int, int); /* checks viability of notifying a contact about a service */ -int notify_contact_of_service(nagios_macros *mac, contact *, service *, int, char *, char *, int, int); /* notify a single contact about a service */ -int check_host_notification_viability(host *, int, int); /* checks viability of notifying all contacts about a host */ -int is_valid_escalation_for_host_notification(host *, hostescalation *, int); /* checks if an escalation entry is valid for a particular host notification */ -int should_host_notification_be_escalated(host *); /* checks if a host notification should be escalated */ -int host_notification(host *, int, char *, char *, int); /* notify all contacts about a host (problem or recovery) */ -int check_contact_host_notification_viability(contact *, host *, int, int); /* checks viability of notifying a contact about a host */ -int notify_contact_of_host(nagios_macros *mac, contact *, host *, int, char *, char *, int, int); /* notify a single contact about a host */ -time_t get_next_host_notification_time(host *, time_t); /* calculates next acceptable re-notification time for a host */ -time_t get_next_service_notification_time(service *, time_t); /* calculates next acceptable re-notification time for a service */ - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/objectlist.h b/devtools/ci/naemon/objectlist.h deleted file mode 100644 index 7bd016e..0000000 --- a/devtools/ci/naemon/objectlist.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef _OBJECTLIST_H -#define _OBJECTLIST_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lib/lnae-utils.h" -#include "nm_alloc.h" -#include - -NAGIOS_BEGIN_DECL - -typedef struct objectlist { - void *object_ptr; - struct objectlist *next; -} objectlist; - -#define OBJECTLIST_DUPE 1 -/** - * Append object_ptr to the list. - * This is O(n) - you probably want to use prepend_object_to_objectlist instead. - * This modifies the pointer you send in, so it points at the new head. - * @param list An reference to an objectlist. Note that an empty objectlist is just NULL. - * @param object_ptr The object you want to put in the list. - * @returns OK if successful, ERROR otherwise - */ -int add_object_to_objectlist(struct objectlist **list, void *object_ptr); -/** - * Put the object_ptr at the head of the list. - * This is O(1). - * This modifies the pointer you send in, so it points at the new head. - * @param list An reference to an objectlist. Note that an empty objectlist is just NULL. - * @param object_ptr The object you want to put in the list. - * @returns OK if successful, ERROR otherwise - */ -int prepend_object_to_objectlist(struct objectlist **list, void *object_ptr); -/** - * Put the object_ptr at the head of the list, if it isn't already in it. - * The callback argument will be called for each existing object in the list, - * and is expected to return 0 for any equal elements. - * @param list An reference to an objectlist. Note that an empty objectlist is just NULL. - * @param object_ptr The object you want to put in the list. - * @param comparator Callback which takes two object_ptr objects, and return 0 if equal, or non-0 if not equal. - * @returns OK if successful, OBJECTLIST_DUPE if the element was already in the list, ERROR otherwise. - */ -int prepend_unique_object_to_objectlist(objectlist **list, void *object_ptr, int (*comparator)(const void *a, const void *b)); -/** - * Put the object_ptr at the head of the list, if it isn't already in it. - * This is similar to prepend_unique_object_to_objectlist, except it also takes - * an arbitrary pointer that will be provided as an argument to the comparator - * when it is invoked. - * @param list An reference to an objectlist. Note that an empty objectlist is just NULL. - * @param object_ptr The object you want to put in the list. - * @param comparator Callback which takes two object_ptr objects, and return 0 if equal, or non-0 if not equal. - * @returns OK if successful, OBJECTLIST_DUPE if the element was already in the list, ERROR otherwise. - */ -int prepend_unique_object_to_objectlist_ptr(objectlist **list, void *object_ptr, int (*comparator)(const void *a, const void *b, void *user_data), void *user_data); -/** - * Free all the allocated memory of the objectlist. Note: this will completely - * orphan any allocated memory inside the objectlist. - * @param list An reference to an objectlist. - * @returns OK if successful, ERROR otherwise - */ -int free_objectlist(objectlist **); - - -/** - * A comparator using memcmp for prepend_unique_object_to_objectlist - */ -int compare_objects(const void *a, const void *b, void *user_data); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects.h b/devtools/ci/naemon/objects.h deleted file mode 100644 index 5156a5a..0000000 --- a/devtools/ci/naemon/objects.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _OBJECTS_H -#define _OBJECTS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lib/lnae-utils.h" - -NAGIOS_BEGIN_DECL - -/* increment when changes are made to data structures... */ -/* Nagios 3 starts at 300, Nagios 4 at 400, etc. */ -#define CURRENT_OBJECT_STRUCTURE_VERSION 402 - -int fcache_objects(char *cache_file); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_command.h b/devtools/ci/naemon/objects_command.h deleted file mode 100644 index ebbe4a5..0000000 --- a/devtools/ci/naemon/objects_command.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef INCLUDE_objects_command_h__ -#define INCLUDE_objects_command_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" - -NAGIOS_BEGIN_DECL - -struct command; -typedef struct command command; -struct commandsmember; -typedef struct commandsmember commandsmember; - -extern struct command *command_list; -extern struct command **command_ary; - -struct command { - unsigned int id; - char *name; - char *command_line; - struct command *next; -}; - -struct commandsmember { - char *command; - struct command *command_ptr; - struct commandsmember *next; -}; - -int init_objects_command(int elems); -void destroy_objects_command(void); - -struct command *create_command(const char *, const char *); -int register_command(command *new_command); -void destroy_command(command *this_command); - -struct command *find_bang_command(const char *); -struct command *find_command(const char *); - -void fcache_command(FILE *fp, const struct command *temp_command); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_common.h b/devtools/ci/naemon/objects_common.h deleted file mode 100644 index 8ea3a9d..0000000 --- a/devtools/ci/naemon/objects_common.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef INCLUDE_objects_common_h__ -#define INCLUDE_objects_common_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lib/lnae-utils.h" -#include "common.h" -#include - -NAGIOS_BEGIN_DECL - -extern char *illegal_object_chars; - -#define MAX_STATE_HISTORY_ENTRIES 21 /* max number of old states to keep track of for flap detection */ - -/* - * flags for notification_options, flapping_options and other similar - * flags. They overlap (hosts and services), so we can't use enum's. - */ -#define OPT_NOTHING 0 /* no options selected */ -#define OPT_ALL (~0) /* everything selected, so all bits set */ -#define OPT_DOWN (1 << STATE_DOWN) -#define OPT_UP (1 << STATE_UP) -#define OPT_UNREACHABLE (1 << STATE_UNREACHABLE) -#define OPT_OK (1 << STATE_OK) -#define OPT_WARNING (1 << STATE_WARNING) -#define OPT_CRITICAL (1 << STATE_CRITICAL) -#define OPT_UNKNOWN (1 << STATE_UNKNOWN) -#define OPT_RECOVERY OPT_OK -/* and now the "unreal" states... */ -#define OPT_PENDING (1 << 10) -#define OPT_FLAPPING (1 << 11) -#define OPT_DOWNTIME (1 << 12) -#define OPT_DISABLED (1 << 15) /* will denote disabled checks some day */ - -struct flag_map { - int opt; - int ch; - const char *name; -}; - -/* macros useful with both hosts and services */ -#define flag_set(c, flag) ((c) |= (flag)) -#define flag_get(c, flag) (unsigned int)((c) & (flag)) -#define flag_isset(c, flag) (flag_get((c), (flag)) == (unsigned int)(flag)) -#define flag_unset(c, flag) (c &= ~(flag)) -#define should_stalk(o) flag_isset(o->stalking_options, 1 << o->current_state) -#define should_flap_detect(o) flag_isset(o->flap_detection_options, 1 << o->current_state) -#define should_notify(o) flag_isset(o->notification_options, 1 << o->current_state) -#define add_notified_on(o, f) (o->notified_on |= (1 << f)) - -typedef struct customvariablesmember { - char *variable_name; - char *variable_value; - int has_been_modified; - struct customvariablesmember *next; -} customvariablesmember; - -struct customvariablesmember *add_custom_variable_to_object(customvariablesmember **, char *, char *); /* adds a custom variable to an object */ - -void fcache_customvars(FILE *fp, const struct customvariablesmember *cvlist); - -const char *opts2str(int opts, const struct flag_map *map, char ok_char); - -const char *state_type_name(int state_type); -const char *check_type_name(int check_type); - -int contains_illegal_object_chars(const char *name); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_contact.h b/devtools/ci/naemon/objects_contact.h deleted file mode 100644 index 46af536..0000000 --- a/devtools/ci/naemon/objects_contact.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef INCLUDE_objects_contact_h__ -#define INCLUDE_objects_contact_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" - -NAGIOS_BEGIN_DECL - -#define MAX_CONTACT_ADDRESSES 6 - -struct contact; -typedef struct contact contact; -struct contactsmember; -typedef struct contactsmember contactsmember; - -extern struct contact *contact_list; -extern struct contact **contact_ary; - -struct contact { - unsigned int id; - char *name; - char *alias; - char *email; - char *pager; - char *address[MAX_CONTACT_ADDRESSES]; - struct commandsmember *host_notification_commands; - struct commandsmember *service_notification_commands; - unsigned int host_notification_options; - unsigned int service_notification_options; - unsigned int minimum_value; - char *host_notification_period; - char *service_notification_period; - int host_notifications_enabled; - int service_notifications_enabled; - int can_submit_commands; - int retain_status_information; - int retain_nonstatus_information; - struct customvariablesmember *custom_variables; - time_t last_host_notification; - time_t last_service_notification; - unsigned long modified_attributes; - unsigned long modified_host_attributes; - unsigned long modified_service_attributes; - struct timeperiod *host_notification_period_ptr; - struct timeperiod *service_notification_period_ptr; - struct objectlist *contactgroups_ptr; - struct contact *next; -}; - -struct contactsmember { - char *contact_name; - struct contact *contact_ptr; - struct contactsmember *next; -}; - -int init_objects_contact(int elems); -void destroy_objects_contact(void); - -struct contact *create_contact(const char *name); -int setup_contact_variables(contact *new_contact, const char *alias, const char *email, const char *pager, char * const *addresses, const char *svc_notification_period, const char *host_notification_period, int service_notification_options, int host_notification_options, int service_notifications_enabled, int host_notifications_enabled, int can_submit_commands, int retain_status_information, int retain_nonstatus_information, unsigned int minimum_value); -int register_contact(contact *new_contact); -void destroy_contact(contact *this_contact); -struct commandsmember *add_service_notification_command_to_contact(contact *, char *); -struct commandsmember *add_host_notification_command_to_contact(contact *, char *); -struct customvariablesmember *add_custom_variable_to_contact(contact *, char *, char *); -struct contactsmember *add_contact_to_object(contactsmember **, char *); - -struct contact *find_contact(const char *); - -void fcache_contactlist(FILE *fp, const char *prefix, const struct contactsmember *list); -void fcache_contact(FILE *fp, const struct contact *temp_contact); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_contactgroup.h b/devtools/ci/naemon/objects_contactgroup.h deleted file mode 100644 index 03216de..0000000 --- a/devtools/ci/naemon/objects_contactgroup.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef INCLUDE_objects_contactgroup_h__ -#define INCLUDE_objects_contactgroup_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lib/lnae-utils.h" -#include "objects_contact.h" - -NAGIOS_BEGIN_DECL -struct contactgroup; -typedef struct contactgroup contactgroup; -struct contactgroupsmember; -typedef struct contactgroupsmember contactgroupsmember; - -extern struct contactgroup *contactgroup_list; -extern struct contactgroup **contactgroup_ary; - -struct contactgroup { - unsigned int id; - char *group_name; - char *alias; - struct contactsmember *members; - struct contactgroup *next; -}; - -struct contactgroupsmember { - char *group_name; - struct contactgroup *group_ptr; - struct contactgroupsmember *next; -}; - -int init_objects_contactgroup(int elems); -void destroy_objects_contactgroup(void); - -struct contactgroup *create_contactgroup(const char *, const char *); -int register_contactgroup(contactgroup *new_contactgroup); -void destroy_contactgroup(contactgroup *this_contactgroup); -contactgroupsmember *add_contactgroup_to_object(contactgroupsmember **cg_list, const char *group_name); -struct contactsmember *add_contact_to_contactgroup(contactgroup *, char *); - -struct contactgroup *find_contactgroup(const char *); -int is_contact_member_of_contactgroup(struct contactgroup *, struct contact *); /* tests whether or not a contact is a member of a specific contact group */ - -void fcache_contactgrouplist(FILE *fp, const char *prefix, const struct contactgroupsmember *list); -void fcache_contactgroup(FILE *fp, const struct contactgroup *temp_contactgroup); -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_host.h b/devtools/ci/naemon/objects_host.h deleted file mode 100644 index 780a77f..0000000 --- a/devtools/ci/naemon/objects_host.h +++ /dev/null @@ -1,184 +0,0 @@ -#ifndef INCLUDE_objects_host_h__ -#define INCLUDE_objects_host_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" -#include "objects_contact.h" - -NAGIOS_BEGIN_DECL - -struct host; -typedef struct host host; -struct servicesmember; - -extern struct host **host_ary; -extern struct host *host_list; - -struct host { - unsigned int id; - char *name; - char *display_name; - char *alias; - char *address; - GTree *parent_hosts; /* char * => struct host * */ - GTree *child_hosts; /* char * => struct host * */ - struct servicesmember *services; - char *check_command; - int initial_state; - double check_interval; - double retry_interval; - int max_attempts; - char *event_handler; - struct contactgroupsmember *contact_groups; - struct contactsmember *contacts; - double notification_interval; - double first_notification_delay; - unsigned int notification_options; - unsigned int hourly_value; - char *notification_period; - char *check_period; - int flap_detection_enabled; - double low_flap_threshold; - double high_flap_threshold; - int flap_detection_options; - unsigned int stalking_options; - int check_freshness; - int freshness_threshold; - int process_performance_data; - int checks_enabled; - const char *check_source; - int accept_passive_checks; - int event_handler_enabled; - int retain_status_information; - int retain_nonstatus_information; - int obsess; - char *notes; - char *notes_url; - char *action_url; - char *icon_image; - char *icon_image_alt; - char *statusmap_image; /* used by lots of graphing tools */ - char *vrml_image; - int have_2d_coords; - int x_2d; - int y_2d; - int have_3d_coords; - double x_3d; - double y_3d; - double z_3d; - customvariablesmember *custom_variables; - int problem_has_been_acknowledged; - int acknowledgement_type; - int check_type; - int current_state; - int last_state; - int last_hard_state; - char *plugin_output; - char *long_plugin_output; - char *perf_data; - int state_type; - int current_attempt; - unsigned long current_event_id; - unsigned long last_event_id; - unsigned long current_problem_id; - unsigned long last_problem_id; - double latency; - double execution_time; - int is_executing; - int check_options; - int notifications_enabled; - time_t last_notification; - time_t next_notification; - time_t next_check; - time_t last_check; - time_t last_state_change; - time_t last_hard_state_change; - time_t last_time_up; - time_t last_time_down; - time_t last_time_unreachable; - int has_been_checked; - int is_being_freshened; - int notified_on; - int current_notification_number; - int no_more_notifications; - unsigned long current_notification_id; - int check_flapping_recovery_notification; - int scheduled_downtime_depth; - int pending_flex_downtime; /* UNUSED */ - int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */ - int state_history_index; - time_t last_state_history_update; - int is_flapping; - unsigned long flapping_comment_id; - double percent_state_change; - int total_services; - unsigned long modified_attributes; - struct command *event_handler_ptr; - struct command *check_command_ptr; - struct timeperiod *check_period_ptr; - struct timeperiod *notification_period_ptr; - struct objectlist *hostgroups_ptr; - /* objects we depend upon */ - struct objectlist *exec_deps, *notify_deps; - struct objectlist *escalation_list; - time_t last_update /* timestamp when object has been updated the last time */; - struct host *next; - struct timed_event *next_check_event; -}; - -static const struct flag_map host_flag_map[] = { - { OPT_DOWN, 'd', "down" }, - { OPT_UNREACHABLE, 'u', "unreachable" }, - { OPT_FLAPPING, 'f', "flapping" }, - { OPT_RECOVERY, 'r', "recovery" }, - { OPT_DOWNTIME, 's', "downtime" }, - { OPT_PENDING, 'p', "pending" }, - { 0, 0, NULL }, -}; - -int init_objects_host(int elems); -void destroy_objects_host(void); - -host *create_host(const char *name); -/** This is an evil legacy function which you should never, ever use */ -int setup_host_variables(host *new_host, const char *display_name, const char *alias, const char *address, const char *check_period, int initial_state, double check_interval, double retry_interval, int max_attempts, int notification_options, double notification_interval, double first_notification_delay, const char *notification_period, int notifications_enabled, const char *check_command, int checks_enabled, int accept_passive_checks, const char *event_handler, int event_handler_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, const char *vrml_image, const char *statusmap_image, int x_2d, int y_2d, int have_2d_coords, double x_3d, double y_3d, double z_3d, int have_3d_coords, int retain_status_information, int retain_nonstatus_information, int obsess_over_host, unsigned int hourly_value); -int register_host(host *new_host); -void destroy_host(host *this_host); - -int add_parent_to_host(host *, host *); -int remove_parent_from_host(host *hst, host *parent); -struct contactgroupsmember *add_contactgroup_to_host(host *, char *); -struct contactsmember *add_contact_to_host(host *, char *); -struct customvariablesmember *add_custom_variable_to_host(host *, char *, char *); - -int compare_host(const void *_host1, const void *_host2); -struct host *find_host(const char *); -int is_contact_for_host(struct host *, struct contact *); -int is_escalated_contact_for_host(struct host *, struct contact *); -int number_of_immediate_child_hosts(struct host *); -int number_of_total_child_hosts(struct host *); -int number_of_immediate_parent_hosts(struct host *); - - -const char *host_state_name(int state); -int get_host_count(void); -time_t get_host_check_interval_s(const host *hst); -time_t get_host_retry_interval_s(const host *hst); -unsigned int host_services_value(struct host *h); - -char * implode_hosttree(GTree *tree, char *delimiter); -void fcache_host(FILE *fp, const struct host *temp_host); - -int log_host_event(host *); -int log_host_states(int, time_t *); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_hostdependency.h b/devtools/ci/naemon/objects_hostdependency.h deleted file mode 100644 index b24e075..0000000 --- a/devtools/ci/naemon/objects_hostdependency.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef INCLUDE_objects_hostdependency_h__ -#define INCLUDE_objects_hostdependency_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" -#include "objects_host.h" - -NAGIOS_BEGIN_DECL - -struct hostdependency; -typedef struct hostdependency hostdependency; - -struct hostdependency { - unsigned int id; - int dependency_type; - char *dependent_host_name; - char *host_name; - char *dependency_period; - int inherits_parent; - int failure_options; - struct host *master_host_ptr; - struct host *dependent_host_ptr; - struct timeperiod *dependency_period_ptr; -}; - -struct hostdependency *add_host_dependency(char *dependent_host_name, char *host_name, int dependency_type, int inherits_parent, int failure_options, char *dependency_period); -void destroy_hostdependency(hostdependency *this_hostdependency); - -void fcache_hostdependency(FILE *fp, const struct hostdependency *temp_hostdependency); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_hostescalation.h b/devtools/ci/naemon/objects_hostescalation.h deleted file mode 100644 index 5ad5060..0000000 --- a/devtools/ci/naemon/objects_hostescalation.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef INCLUDE_objects_hostescalation_h__ -#define INCLUDE_objects_hostescalation_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" -#include "objects_host.h" - -NAGIOS_BEGIN_DECL - -struct hostescalation; -typedef struct hostescalation hostescalation; - -struct hostescalation { - unsigned int id; - char *host_name; - int first_notification; - int last_notification; - double notification_interval; - char *escalation_period; - int escalation_options; - struct contactgroupsmember *contact_groups; - struct contactsmember *contacts; - struct host *host_ptr; - struct timeperiod *escalation_period_ptr; -}; - -struct hostescalation *add_hostescalation(char *host_name, int first_notification, int last_notification, double notification_interval, char *escalation_period, int escalation_options); -void destroy_hostescalation(hostescalation *this_hostescalation); -struct contactsmember *add_contact_to_hostescalation(hostescalation *, char *); /* adds a contact to a host escalation definition */ -struct contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *, char *); /* adds a contact group to a host escalation definition */ - -void fcache_hostescalation(FILE *fp, const struct hostescalation *temp_hostescalation); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_hostgroup.h b/devtools/ci/naemon/objects_hostgroup.h deleted file mode 100644 index e1389e5..0000000 --- a/devtools/ci/naemon/objects_hostgroup.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef INCLUDE_objects_hostgroup_h__ -#define INCLUDE_objects_hostgroup_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" -#include "objects_host.h" - -NAGIOS_BEGIN_DECL - -struct hostgroup; -typedef struct hostgroup hostgroup; - -extern struct hostgroup *hostgroup_list; -extern struct hostgroup **hostgroup_ary; - -struct hostgroup { - unsigned int id; - char *group_name; - char *alias; - GTree *members; - char *notes; - char *notes_url; - char *action_url; - struct hostgroup *next; -}; - -int init_objects_hostgroup(int elems); -void destroy_objects_hostgroup(void); - -hostgroup *create_hostgroup(const char *name, const char *alias, const char *notes, const char *notes_url, const char *action_url); -int register_hostgroup(hostgroup *new_hostgroup); -void destroy_hostgroup(hostgroup *this_hostgroup); -int add_host_to_hostgroup(hostgroup *, host *); -int remove_host_from_hostgroup(hostgroup *temp_hostgroup, host *h); - -struct hostgroup *find_hostgroup(const char *); -int is_host_member_of_hostgroup(struct hostgroup *, struct host *); /* tests whether or not a host is a member of a specific hostgroup */ - -void fcache_hostgroup(FILE *fp, const struct hostgroup *temp_hostgroup); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_service.h b/devtools/ci/naemon/objects_service.h deleted file mode 100644 index 7756565..0000000 --- a/devtools/ci/naemon/objects_service.h +++ /dev/null @@ -1,181 +0,0 @@ -#ifndef INCLUDE_objects_service_h__ -#define INCLUDE_objects_service_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" -#include "objects_contact.h" -#include "objects_host.h" - -NAGIOS_BEGIN_DECL - -struct service; -typedef struct service service; -struct servicemember; -typedef struct servicesmember servicesmember; - -extern struct service *service_list; -extern struct service **service_ary; - -struct service { - unsigned int id; - char *host_name; - char *description; - char *display_name; - struct servicesmember *parents; - struct servicesmember *children; - char *check_command; - char *event_handler; - int initial_state; - double check_interval; - double retry_interval; - int max_attempts; - struct contactgroupsmember *contact_groups; - struct contactsmember *contacts; - double notification_interval; - double first_notification_delay; - unsigned int notification_options; - unsigned int stalking_options; - unsigned int hourly_value; - int is_volatile; - char *notification_period; - char *check_period; - int flap_detection_enabled; - double low_flap_threshold; - double high_flap_threshold; - unsigned int flap_detection_options; - int process_performance_data; - int check_freshness; - int freshness_threshold; - int accept_passive_checks; - int event_handler_enabled; - int checks_enabled; - const char *check_source; - int retain_status_information; - int retain_nonstatus_information; - int notifications_enabled; - int obsess; - char *notes; - char *notes_url; - char *action_url; - char *icon_image; - char *icon_image_alt; - struct customvariablesmember *custom_variables; - int problem_has_been_acknowledged; - int acknowledgement_type; - int host_problem_at_last_check; - int check_type; - int current_state; - int last_state; - int last_hard_state; - char *plugin_output; - char *long_plugin_output; - char *perf_data; - int state_type; - time_t next_check; - time_t last_check; - int current_attempt; - unsigned long current_event_id; - unsigned long last_event_id; - unsigned long current_problem_id; - unsigned long last_problem_id; - time_t last_notification; - time_t next_notification; - int no_more_notifications; - int check_flapping_recovery_notification; - time_t last_state_change; - time_t last_hard_state_change; - time_t last_time_ok; - time_t last_time_warning; - time_t last_time_unknown; - time_t last_time_critical; - int has_been_checked; - int is_being_freshened; - unsigned int notified_on; - int current_notification_number; - unsigned long current_notification_id; - double latency; - double execution_time; - int is_executing; - int check_options; - int scheduled_downtime_depth; - int pending_flex_downtime; /* UNUSED */ - int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */ - int state_history_index; - int is_flapping; - unsigned long flapping_comment_id; - double percent_state_change; - unsigned long modified_attributes; - struct host *host_ptr; - struct command *event_handler_ptr; - char *event_handler_args; - struct command *check_command_ptr; - struct timeperiod *check_period_ptr; - struct timeperiod *notification_period_ptr; - struct objectlist *servicegroups_ptr; - struct objectlist *exec_deps, *notify_deps; - struct objectlist *escalation_list; - time_t last_update /* timestamp when object has been updated the last time */; - struct service *next; - struct timed_event *next_check_event; -}; - -struct servicesmember { - char *host_name; - char *service_description; - struct service *service_ptr; - struct servicesmember *next; -}; - -static const struct flag_map service_flag_map[] = { - { OPT_WARNING, 'w', "warning" }, - { OPT_UNKNOWN, 'u', "unknown" }, - { OPT_CRITICAL, 'c', "critical" }, - { OPT_FLAPPING, 'f', "flapping" }, - { OPT_DOWNTIME, 's', "downtime" }, - { OPT_OK, 'o', "ok" }, - { OPT_RECOVERY, 'r', "recovery" }, - { OPT_PENDING, 'p', "pending" }, - { 0, 0, NULL }, -}; - -int init_objects_service(int elems); -void destroy_objects_service(void); - -service *create_service(host *hst, const char *description); -int setup_service_variables(service *svc, const char *display_name, const char *check_period, const char *check_command, int initial_state, int max_attempts, int accept_passive_checks, double check_interval, double retry_interval, double notification_interval, double first_notification_delay, char *notification_period, int notification_options, int notifications_enabled, int is_volatile, const char *event_handler, int event_handler_enabled, int checks_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, int retain_status_information, int retain_nonstatus_information, int obsess, unsigned int hourly_value); -int register_service(service *new_service); -void destroy_service(service *svc); - -struct contactgroupsmember *add_contactgroup_to_service(service *, char *); /* adds a contact group to a service definition */ -struct contactsmember *add_contact_to_service(service *, char *); /* adds a contact to a host definition */ -struct servicesmember *add_parent_to_service(service *svc, service *parent); -struct customvariablesmember *add_custom_variable_to_service(service *, char *, char *); /* adds a custom variable to a service definition */ - -struct service *find_service(const char *, const char *); -int is_contact_for_service(struct service *, struct contact *); /* tests whether or not a contact is a contact member for a specific service */ -int is_escalated_contact_for_service(struct service *, struct contact *); /* checks whether or not a contact is an escalated contact for a specific service */ -int get_service_count(void); - -/** - * Get the check interval for this service, in seconds - */ -time_t get_service_check_interval_s(const service *svc); -/** - * Get the retry interval for this service, in seconds - */ -time_t get_service_retry_interval_s(const service *svc); - -const char *service_state_name(int state); - -int log_service_event(service *); -int log_service_states(int, time_t *); -void fcache_service(FILE *fp, const struct service *temp_service); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_servicedependency.h b/devtools/ci/naemon/objects_servicedependency.h deleted file mode 100644 index f9662a9..0000000 --- a/devtools/ci/naemon/objects_servicedependency.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef INCLUDE_objects_servicedependency_h__ -#define INCLUDE_objects_servicedependency_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" -#include "objects_service.h" - -NAGIOS_BEGIN_DECL - -struct servicedependency; -typedef struct servicedependency servicedependency; - -struct servicedependency { - unsigned int id; - int dependency_type; - char *dependent_host_name; - char *dependent_service_description; - char *host_name; - char *service_description; - char *dependency_period; - int inherits_parent; - int failure_options; - struct service *master_service_ptr; - struct service *dependent_service_ptr; - struct timeperiod *dependency_period_ptr; -}; - -struct servicedependency *add_service_dependency(char *dependent_host_name, char *dependent_service_description, char *host_name, char *service_description, int dependency_type, int inherits_parent, int failure_options, char *dependency_period); -void destroy_servicedependency(servicedependency *this_servicedependency); - -void fcache_servicedependency(FILE *fp, const struct servicedependency *temp_servicedependency); -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_serviceescalation.h b/devtools/ci/naemon/objects_serviceescalation.h deleted file mode 100644 index 05d7826..0000000 --- a/devtools/ci/naemon/objects_serviceescalation.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef INCLUDE_objects_serviceescalation_h__ -#define INCLUDE_objects_serviceescalation_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" -#include "objects_service.h" - -NAGIOS_BEGIN_DECL - -struct serviceescalation; -typedef struct serviceescalation serviceescalation; - -struct serviceescalation { - unsigned int id; - char *host_name; - char *description; - int first_notification; - int last_notification; - double notification_interval; - char *escalation_period; - int escalation_options; - struct contactgroupsmember *contact_groups; - struct contactsmember *contacts; - struct service *service_ptr; - struct timeperiod *escalation_period_ptr; -}; - -struct serviceescalation *add_serviceescalation(char *host_name, char *description, int first_notification, int last_notification, double notification_interval, char *escalation_period, int escalation_options); -void destroy_serviceescalation(serviceescalation *this_serviceescalation); -struct contactgroupsmember *add_contactgroup_to_serviceescalation(serviceescalation *, char *); /* adds a contact group to a service escalation definition */ -struct contactsmember *add_contact_to_serviceescalation(serviceescalation *, char *); /* adds a contact to a service escalation definition */ - -void fcache_serviceescalation(FILE *fp, const struct serviceescalation *temp_serviceescalation); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_servicegroup.h b/devtools/ci/naemon/objects_servicegroup.h deleted file mode 100644 index 6113f7d..0000000 --- a/devtools/ci/naemon/objects_servicegroup.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef INCLUDE_objects_servicegroup_h__ -#define INCLUDE_objects_servicegroup_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" -#include "objects_service.h" - -NAGIOS_BEGIN_DECL - -struct servicegroup; -typedef struct servicegroup servicegroup; - -extern struct servicegroup *servicegroup_list; -extern struct servicegroup **servicegroup_ary; - -struct servicegroup { - unsigned int id; - char *group_name; - char *alias; - struct servicesmember *members; - char *notes; - char *notes_url; - char *action_url; - struct servicegroup *next; -}; - -int init_objects_servicegroup(int elems); -void destroy_objects_servicegroup(void); - -servicegroup *create_servicegroup(const char *name, const char *alias, const char *notes, const char *notes_url, const char *action_url); -int register_servicegroup(servicegroup *this_servicegroup); -void destroy_servicegroup(servicegroup *this_servicegroup); -struct servicesmember *add_service_to_servicegroup(servicegroup *, service *); -void remove_service_from_servicegroup(servicegroup *temp_servicegroup, service *svc); - -struct servicegroup *find_servicegroup(const char *); -int is_host_member_of_servicegroup(struct servicegroup *, struct host *); /* tests whether or not a service is a member of a specific servicegroup */ -int is_service_member_of_servicegroup(struct servicegroup *, struct service *); /* tests whether or not a service is a member of a specific servicegroup */ - -void fcache_servicegroup(FILE *fp, const struct servicegroup *temp_servicegroup); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/objects_timeperiod.h b/devtools/ci/naemon/objects_timeperiod.h deleted file mode 100644 index b0c380a..0000000 --- a/devtools/ci/naemon/objects_timeperiod.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef INCLUDE_objects_timeperiod_h__ -#define INCLUDE_objects_timeperiod_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lib/lnae-utils.h" -#include "defaults.h" -#include "objects_common.h" - -NAGIOS_BEGIN_DECL - -#define DATERANGE_CALENDAR_DATE 0 /* 2008-12-25 */ -#define DATERANGE_MONTH_DATE 1 /* july 4 (specific month) */ -#define DATERANGE_MONTH_DAY 2 /* day 21 (generic month) */ -#define DATERANGE_MONTH_WEEK_DAY 3 /* 3rd thursday (specific month) */ -#define DATERANGE_WEEK_DAY 4 /* 3rd thursday (generic month) */ -#define DATERANGE_TYPES 5 - -struct timeperiod; -typedef struct timeperiod timeperiod; -struct timerange; -typedef struct timerange timerange; -struct daterange; -typedef struct daterange daterange; -struct timeperiodexclusion; -typedef struct timeperiodexclusion timeperiodexclusion; - -extern struct timeperiod *timeperiod_list; -extern struct timeperiod **timeperiod_ary; - -struct timeperiod { - unsigned int id; - char *name; - char *alias; - struct timerange *days[7]; - struct daterange *exceptions[DATERANGE_TYPES]; - struct timeperiodexclusion *exclusions; - struct timeperiod *next; -}; - -struct timerange { - unsigned long range_start; - unsigned long range_end; - struct timerange *next; -}; - - -struct daterange { - int type; - int syear; /* start year */ - int smon; /* start month */ - int smday; /* start day of month (may 3rd, last day in feb) */ - int swday; /* start day of week (thursday) */ - int swday_offset; /* start weekday offset (3rd thursday, last monday in jan) */ - int eyear; - int emon; - int emday; - int ewday; - int ewday_offset; - int skip_interval; - struct timerange *times; - struct daterange *next; -}; - -struct timeperiodexclusion { - char *timeperiod_name; - struct timeperiod *timeperiod_ptr; - struct timeperiodexclusion *next; -}; - -int init_objects_timeperiod(int elems); -void destroy_objects_timeperiod(void); - -struct timeperiod *create_timeperiod(const char *, const char *); -int register_timeperiod(timeperiod *new_timeperiod); -void destroy_timeperiod(timeperiod *period); - -struct timeperiodexclusion *add_exclusion_to_timeperiod(timeperiod *, char *); -struct timerange *add_timerange_to_timeperiod(timeperiod *, int, unsigned long, unsigned long); -struct daterange *add_exception_to_timeperiod(timeperiod *, int, int, int, int, int, int, int, int, int, int, int, int); -struct timerange *add_timerange_to_daterange(daterange *, unsigned long, unsigned long); - -struct timeperiod *find_timeperiod(const char *); - -void fcache_timeperiod(FILE *fp, const struct timeperiod *temp_timeperiod); - -int check_time_against_period(time_t, const timeperiod *); /* check to see if a specific time is covered by a time period */ -void get_next_valid_time(time_t, time_t *, timeperiod *); /* get the next valid time in a time period */ - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/perfdata.h b/devtools/ci/naemon/perfdata.h deleted file mode 100644 index 24dab46..0000000 --- a/devtools/ci/naemon/perfdata.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _PERFDATA_H -#define _PERFDATA_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "objects_host.h" -#include "objects_service.h" - -NAGIOS_BEGIN_DECL - -extern int perfdata_timeout; -extern char *host_perfdata_command; -extern char *service_perfdata_command; -extern char *host_perfdata_file_template; -extern char *service_perfdata_file_template; -extern char *host_perfdata_file; -extern char *service_perfdata_file; -extern int host_perfdata_file_append; -extern int service_perfdata_file_append; -extern int host_perfdata_file_pipe; -extern int service_perfdata_file_pipe; -extern unsigned long host_perfdata_file_processing_interval; -extern unsigned long service_perfdata_file_processing_interval; -extern char *host_perfdata_file_processing_command; -extern char *service_perfdata_file_processing_command; -extern int host_perfdata_process_empty_results; -extern int service_perfdata_process_empty_results; - -int initialize_performance_data(const char *); /* initializes performance data */ -int cleanup_performance_data(void); /* cleans up performance data */ - -int update_host_performance_data(host *); /* updates host performance data */ -int update_service_performance_data(service *); /* updates service performance data */ - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/query-handler.h b/devtools/ci/naemon/query-handler.h deleted file mode 100644 index e599ff9..0000000 --- a/devtools/ci/naemon/query-handler.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _QUERY_HANDLER_H -#define _QUERY_HANDLER_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -/* return codes for query_handlers() */ -#define QH_OK 0 /* keep listening */ -#define QH_CLOSE 1 /* we should close the socket */ -#define QH_INVALID 2 /* invalid query. Log and close */ -#define QH_TAKEOVER 3 /* handler will take full control. de-register but don't close */ - -NAGIOS_BEGIN_DECL - -/*** Query Handler functions, types and macros*/ -typedef int (*qh_handler)(int, char *, unsigned int); - -int qh_init(const char *path); -void qh_deinit(const char *path); -int qh_register_handler(const char *name, const char *description, unsigned int options, qh_handler handler); -const char *qh_strerror(int code); - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/sehandlers.h b/devtools/ci/naemon/sehandlers.h deleted file mode 100644 index 11d6cde..0000000 --- a/devtools/ci/naemon/sehandlers.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _SEHANDLERS_H -#define _SEHANDLERS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "objects_host.h" -#include "objects_service.h" -#include "macros.h" - -/**************** EVENT HANDLER TYPES *****************/ - -#define HOST_EVENTHANDLER 0 -#define SERVICE_EVENTHANDLER 1 -#define GLOBAL_HOST_EVENTHANDLER 2 -#define GLOBAL_SERVICE_EVENTHANDLER 3 - -/***************** STATE CHANGE TYPES *****************/ - -#define HOST_STATECHANGE 0 -#define SERVICE_STATECHANGE 1 - -NAGIOS_BEGIN_DECL - -int obsessive_compulsive_service_check_processor(service *); /* distributed monitoring craziness... */ -int obsessive_compulsive_host_check_processor(host *); /* distributed monitoring craziness... */ -int handle_service_event(service *); /* top level service event logic */ -int handle_host_event(host *); /* top level host event logic */ - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/shared.h b/devtools/ci/naemon/shared.h deleted file mode 100644 index 8db0ead..0000000 --- a/devtools/ci/naemon/shared.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef INCLUDE__shared_h__ -#define INCLUDE__shared_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "lib/libnaemon.h" -#include - -NAGIOS_BEGIN_DECL - -/* mmapfile structure - used for reading files via mmap() */ -typedef struct mmapfile_struct { - char *path; - int mode; - int fd; - unsigned long file_size; - unsigned long current_position; - unsigned long current_line; - void *mmap_buf; -} mmapfile; - -/* official count of first-class objects */ -struct object_count { - unsigned int commands; - unsigned int timeperiods; - unsigned int hosts; - unsigned int hostescalations; - unsigned int hostdependencies; - unsigned int services; - unsigned int serviceescalations; - unsigned int servicedependencies; - unsigned int contacts; - unsigned int contactgroups; - unsigned int hostgroups; - unsigned int servicegroups; -}; - -extern struct object_count num_objects; - -void timing_point(const char *fmt, ...); /* print a message and the time since the first message */ -char *my_strtok(char *buffer, const char *tokens); -char *my_strsep(char **stringp, const char *delim); -mmapfile *mmap_fopen(const char *filename); -int mmap_fclose(mmapfile *temp_mmapfile); -char *mmap_fgets(mmapfile *temp_mmapfile); -char *mmap_fgets_multiline(mmapfile * temp_mmapfile); -void strip(char *buffer); -int hashfunc(const char *name1, const char *name2, int hashslots); -void get_datetime_string(time_t *raw_time, char *buffer, - int buffer_length, int type); -void get_time_breakdown(unsigned long raw_time, int *days, int *hours, - int *minutes, int *seconds); -gint my_strsorter(gconstpointer a, gconstpointer b, gpointer data); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/sretention.h b/devtools/ci/naemon/sretention.h deleted file mode 100644 index ae75b1a..0000000 --- a/devtools/ci/naemon/sretention.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _SRETENTION_H -#define _SRETENTION_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "common.h" -NAGIOS_BEGIN_DECL - -int initialize_retention_data(void); -int cleanup_retention_data(void); -int save_state_information(int); /* saves all host and state information */ -int read_initial_state_information(void); /* reads in initial host and state information */ -int pre_modify_contact_attribute(struct contact *s, int attr); -int pre_modify_service_attribute(struct service *s, int attr); -int pre_modify_host_attribute(struct host *h, int attr); -struct contact *get_premod_contact(unsigned int id); -struct host *get_premod_host(unsigned int id); -struct service *get_premod_service(unsigned int id); -void deinit_retention_data(void); -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/statusdata.h b/devtools/ci/naemon/statusdata.h deleted file mode 100644 index 4230fb2..0000000 --- a/devtools/ci/naemon/statusdata.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _STATUSDATA_H -#define _STATUSDATA_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "common.h" -#include "objects_host.h" -#include "objects_service.h" -#include "objects_contact.h" - -NAGIOS_BEGIN_DECL -/* Convert the (historically ordered) host states into a notion of "urgency". - This is defined as, in ascending order: - SD_HOST_UP (business as usual) - HOST_PENDING (waiting for - supposedly first - check result) - SD_HOST_UNREACHABLE (a problem, but likely not its cause) - SD_HOST_DOWN (look here!!) - The exact values are irrelevant, so I try to make the conversion as - CPU-efficient as possible: */ -#define HOST_URGENCY(hs) ((hs)|(((hs)&0x5)<<1)) - -int initialize_status_data(const char *); /* initializes status data at program start */ -int update_all_status_data(void); /* updates all status data */ -int cleanup_status_data(int); /* cleans up status data at program termination */ -int update_program_status(int); /* updates program status data */ -int update_host_status(host *, int); /* updates host status data */ -int update_service_status(service *, int); /* updates service status data */ -int update_contact_status(contact *, int); /* updates contact status data */ - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/naemon/utils.h b/devtools/ci/naemon/utils.h deleted file mode 100644 index f7106a8..0000000 --- a/devtools/ci/naemon/utils.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _UTILS_H -#define _UTILS_H - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include "checks.h" -#include "objects_timeperiod.h" -#include "objects_command.h" -#include "macros.h" -#include "lib/lnae-utils.h" - -NAGIOS_BEGIN_DECL - -#define CHECK_STATS_BUCKETS 15 -#define PIPE_READ 0 -#define PIPE_WRITE 1 - -/* used for tracking host and service check statistics */ -typedef struct check_stats { - int current_bucket; - int bucket[CHECK_STATS_BUCKETS]; - int overflow_bucket; - int minute_stats[3]; - time_t last_update; -} check_stats; - -extern struct check_stats check_statistics[MAX_CHECK_STATS_TYPES]; - -const char *check_result_source(check_result *cr); - -void setup_sighandler(void); /* trap signals */ -void reset_sighandler(void); /* reset signals to default action */ -void signal_react(void); /* General signal reaction routines */ -void handle_sigxfsz(void); /* handle SIGXFSZ */ -int signal_parent(int); /* signal parent when daemonizing */ -int daemon_init(void); /* switches to daemon mode */ - -int init_check_stats(void); -int update_check_stats(int, time_t); -int generate_check_stats(void); - -void free_memory(nagios_macros *mac); /* free memory allocated to all linked lists in memory */ -int reset_variables(void); /* reset all global variables */ - -void sighandler(int); /* handles signals */ -int my_rename(char *, char *); /* renames a file */ - -time_t get_next_log_rotation_time(void); /* determine the next time to schedule a log rotation */ -int set_environment_var(char *, char *, int); /* sets/clears and environment variable */ - -const char *get_program_version(void); - -void cleanup(void); /* cleanup after ourselves (before quitting or restarting) */ - -char *escape_plugin_output(const char *); -char *unescape_plugin_output(const char *); - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/worker.h b/devtools/ci/naemon/worker.h deleted file mode 100644 index 6c04095..0000000 --- a/devtools/ci/naemon/worker.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef INCLUDE_worker_h__ -#define INCLUDE_worker_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include -#include -#include -#include -#include -#include "lib/libnaemon.h" - -/** - * @file worker.h - * @brief Naemon core worker implementation - * - * The default core worker accepts shell commands, executes them - * and returns a lot of details about the execution of that - * command. You can use worker.c as a template for writing a - * custom worker, but using functions from it in a custom worker - * will probably not be very useful (apart from wlog()). - */ - -#ifndef ETIME -#define ETIME ETIMEDOUT -#endif - -NAGIOS_BEGIN_DECL - -typedef struct iobuf { - int fd; - nm_bufferqueue *buf; -} iobuf; - -typedef struct execution_information execution_information; - -typedef struct child_process { - unsigned int id, timeout; - char *cmd; - int ret; - struct kvvec *request; - iobuf outstd; - iobuf outerr; - execution_information *ei; -} child_process; - -/** - * Core worker entry point - * @param path The path to the query socket this worker should connect to - * @return EXIT_SUCCESS or EXIT_FAILURE - */ -extern int nm_core_worker(const char *path); - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/naemon/workers.h b/devtools/ci/naemon/workers.h deleted file mode 100644 index 07fcbe5..0000000 --- a/devtools/ci/naemon/workers.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef INCLUDE_workers_h__ -#define INCLUDE_workers_h__ - -#if !defined (_NAEMON_H_INSIDE) && !defined (NAEMON_COMPILATION) -#error "Only can be included directly." -#endif - -#include "lib/libnaemon.h" -#include "macros.h" - -#include - -#define WPROC_FORCE (1 << 0) - -NAGIOS_BEGIN_DECL; - -typedef struct wproc_result { - unsigned int job_id; - time_t timeout; - struct timeval start; - struct timeval stop; - struct timeval runtime; - char *command; - char *outstd; - char *outerr; - char *error_msg; - char *source; - int wait_status; - int error_code; - int exited_ok; - int early_timeout; - struct kvvec *response; - struct rusage rusage; -} wproc_result; - -extern unsigned int wproc_num_workers_spawned; -extern unsigned int wproc_num_workers_online; -extern unsigned int wproc_num_workers_desired; - -struct load_control; /* TODO: load_control is ugly */ - -void free_worker_memory(int flags); -int workers_alive(void); -int init_workers(int desired_workers); - -int wproc_run_callback(char *cmt, int timeout, void (*cb)(struct wproc_result *, void *, int), void *data, nagios_macros *mac); - -NAGIOS_END_DECL; -#endif diff --git a/devtools/ci/nagios/archivejson.h b/devtools/ci/nagios/archivejson.h deleted file mode 100644 index f2711c4..0000000 --- a/devtools/ci/nagios/archivejson.h +++ /dev/null @@ -1,153 +0,0 @@ -/************************************************************************** - * - * ARCHIVEJSON.H - Nagios CGI for returning JSON-formatted archive data - * - * Copyright (c) 2013 Nagios Enterprises, LLC - * Last Modified: 04-13-2013 - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - *************************************************************************/ - -#ifndef ARCHIVEJSON_H_INCLUDED -#define ARCHIVEJSON_H_INCLUDED - -/* Structure containing CGI query string options and values */ -typedef struct archive_json_cgi_data_struct { - /* Format options for JSON output */ - unsigned format_options; - /* Query being requested */ - int query; - /* Index of starting object returned for list requests */ - int start; - /* Number of objects returned for list requests */ - int count; - /* Type(s) of object to be queried (host and/or service) */ - unsigned object_types; - /* Type of object to be queried (host and/or service) */ - int object_type; - /* State types to include in query results */ - unsigned state_types; - /* Host states to include in query results */ - unsigned host_states; - /* Service states to include in query results */ - unsigned service_states; - /* Host notification types to include in query results */ - unsigned host_notification_types; - /* Service notification types to include in query results */ - unsigned service_notification_types; - /* strftime format string for time_t values */ - char * strftime_format; - /* Name of host whose children should be returned if parenthost is - specified */ - char * parent_host_name; - /* Use the parent host field or search all hosts*/ - int use_parent_host; - /* Host whose children should be returned if use_parent_host is non-zero */ - host * parent_host; - /* Name of host whose parents should be returned if childhost is - specified */ - char * child_host_name; - /* Use the child host field or search all hosts*/ - int use_child_host; - /* Host whose parents should be returned if use_child_host is non-zero */ - host * child_host; - /* Name of host for which details should be returned */ - char * host_name; - /* Host whose host name is host_name */ - host * host; - /* Name of hostgroup for which details should be returned */ - char * hostgroup_name; - /* Hostgroup whose name is hostgroup_name */ - hostgroup * hostgroup; - /* Name of servicegroup for which details should be returned */ - char * servicegroup_name; - /* Servicegroup whose name is servicegroup_name */ - servicegroup * servicegroup; - /* Name of service for which details should be returned */ - char * service_description; - /* Service whose host name is host_name and whose description is - service_description*/ - service * service; - /* Name of contact for which details should be returned */ - char * contact_name; - /* Contact whose contact name is contact_name */ - contact * contact; - /* Name of contactgroup for which details should be returned */ - char * contactgroup_name; - /* Contactgroup whose name is contactgroup_name */ - contactgroup * contactgroup; - /* Notification method */ - char * notification_method; - /* Report timeperiod name */ - char * timeperiod_name; - /* Timeperiod whose name is timeperiod_name */ - timeperiod *timeperiod; - /* Assumed initial host state */ - int assumed_initial_host_state; - /* Assumed initial service state */ - int assumed_initial_service_state; - /* Assume initial state for host(s) or service(s) */ - int assume_initial_state; - /* Assume states are retained */ - int assume_state_retention; - /* Assume states during Nagios downtime */ - int assume_states_during_nagios_downtime; - /* Start time */ - time_t start_time; - /* End time */ - time_t end_time; - /* Number of backtrack archives to read */ - int backtracked_archives; - } archive_json_cgi_data; - -/* Object Type Information */ -#define ARCHIVE_QUERY_INVALID 0 -#define ARCHIVE_QUERY_HELP 1 -#define ARCHIVE_QUERY_ALERTCOUNT 2 -#define ARCHIVE_QUERY_ALERTLIST 3 -#define ARCHIVE_QUERY_NOTIFICATIONCOUNT 4 -#define ARCHIVE_QUERY_NOTIFICATIONLIST 5 -#define ARCHIVE_QUERY_STATECHANGELIST 6 -#define ARCHIVE_QUERY_AVAILABILITY 7 - -extern json_object *json_archive_alertcount(unsigned, time_t, time_t, int, - char *, char *, int, host *, int, host *, hostgroup *, servicegroup *, - contact *, contactgroup *, unsigned, unsigned, unsigned, au_log *); -extern json_object *json_archive_alertlist(unsigned, int, int, time_t, time_t, - int, char *, char *, int, host *, int, host *, hostgroup *, - servicegroup *, contact *, contactgroup *, unsigned, unsigned, - unsigned, au_log *); -extern void json_archive_alert_details(json_object *, unsigned, time_t, - au_log_alert *); - -extern json_object * json_archive_notificationcount(unsigned, time_t, time_t, - int, char *, char *, int, host *, int, host *, hostgroup *, - servicegroup *, char *, contactgroup *, unsigned, unsigned, char *, - au_log *); -extern json_object * json_archive_notificationlist(unsigned, int, int, time_t, - time_t, int, char *, char *, int, host *, int, host *, hostgroup *, - servicegroup *, char *, contactgroup *, unsigned, unsigned, char *, - au_log *); -extern void json_archive_notification_details(json_object *, unsigned, time_t, - au_log_notification *); - -extern json_object *json_archive_statechangelist(unsigned, int, int, time_t, - time_t, int, char *, char *, int, int, unsigned, au_log *); - -extern json_object *json_archive_availability(unsigned, time_t, time_t, time_t, - int, char *, char *, hostgroup *, servicegroup *, timeperiod *, int, - int, int, int, int, unsigned, au_log *); -#endif diff --git a/devtools/ci/nagios/archiveutils.h b/devtools/ci/nagios/archiveutils.h deleted file mode 100644 index 1bf4ac3..0000000 --- a/devtools/ci/nagios/archiveutils.h +++ /dev/null @@ -1,278 +0,0 @@ -/************************************************************************** - * - * ARCHIVEUTILS.H - Utility information for Nagios CGI that read archives - * - * Copyright (c) 2013 Nagios Enterprises, LLC - * Last Modified: 06-30-2013 - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - *************************************************************************/ - -#ifndef ARCHIVEUTILS_H_INCLUDED -#define ARCHIVEUTILS_H_INCLUDED - -#include "../include/jsonutils.h" - -/* Archive utilities object types */ -#define AU_OBJTYPE_NONE 0 -#define AU_OBJTYPE_HOST (1<<0) -#define AU_OBJTYPE_SERVICE (1<<1) -#define AU_OBJTYPE_HOSTGROUP (1<<2) -#define AU_OBJTYPE_SERVICEGROUP (1<<3) -#define AU_OBJTYPE_ALL (AU_OBJTYPE_HOST | AU_OBJTYPE_SERVICE) - -/* Archive utilities state types */ -#define AU_STATETYPE_HARD (1<<0) -#define AU_STATETYPE_SOFT (1<<1) -#define AU_STATETYPE_NO_DATA (1<<2) -#define AU_STATETYPE_ALL (AU_STATETYPE_HARD | AU_STATETYPE_SOFT) - -/* Archive utilities states */ -#define AU_STATE_NO_DATA 0 -#define AU_STATE_HOST_UP (1<<0) -#define AU_STATE_HOST_DOWN (1<<1) -#define AU_STATE_HOST_UNREACHABLE (1<<2) -#define AU_STATE_SERVICE_OK (1<<3) -#define AU_STATE_SERVICE_WARNING (1<<4) -#define AU_STATE_SERVICE_CRITICAL (1<<5) -#define AU_STATE_SERVICE_UNKNOWN (1<<6) -#define AU_STATE_PROGRAM_START (1<<7) /* Nagios program start */ -#define AU_STATE_PROGRAM_END (1<<8) /* Nagios program end */ -#define AU_STATE_DOWNTIME_START (1<<9) /* Downtime start */ -#define AU_STATE_DOWNTIME_END (1<<10) /* Downtime end */ -#define AU_STATE_CURRENT_STATE (1<<11) /* Host or service current state */ - -#define AU_STATE_HOST_ALL (AU_STATE_HOST_UP | \ - AU_STATE_HOST_DOWN | \ - AU_STATE_HOST_UNREACHABLE) -#define AU_STATE_SERVICE_ALL (AU_STATE_SERVICE_OK | \ - AU_STATE_SERVICE_WARNING | \ - AU_STATE_SERVICE_CRITICAL | \ - AU_STATE_SERVICE_UNKNOWN) -#define AU_STATE_ALL (AU_STATE_HOST_ALL | AU_STATE_SERVICE_ALL) - -/* Archive utilities log types */ -#define AU_LOGTYPE_ALERT (1<<0) -#define AU_LOGTYPE_STATE_INITIAL (1<<1) -#define AU_LOGTYPE_STATE_CURRENT (1<<2) -#define AU_LOGTYPE_NOTIFICATION (1<<3) -#define AU_LOGTYPE_DOWNTIME (1<<4) -#define AU_LOGTYPE_NAGIOS (1<<5) -#define AU_LOGTYPE_STATE (AU_LOGTYPE_STATE_INITIAL | \ - AU_LOGTYPE_STATE_CURRENT) -#define AU_LOGTYPE_ALL (AU_LOGTYPE_ALERT | \ - AU_LOGTYPE_STATE | \ - AU_LOGTYPE_NOTIFICATION | \ - AU_LOGTYPE_DOWNTIME | \ - AU_LOGTYPE_NAGIOS) - -/* Archive utilities notification types */ -#define AU_NOTIFICATION_NO_DATA 0 -#define AU_NOTIFICATION_HOST_DOWN (1<<0) -#define AU_NOTIFICATION_HOST_UNREACHABLE (1<<1) -#define AU_NOTIFICATION_HOST_RECOVERY (1<<2) -#define AU_NOTIFICATION_HOST_CUSTOM (1<<3) -#define AU_NOTIFICATION_HOST_ACK (1<<4) -#define AU_NOTIFICATION_HOST_FLAPPING_START (1<<5) -#define AU_NOTIFICATION_HOST_FLAPPING_STOP (1<<6) -#define AU_NOTIFICATION_SERVICE_CRITICAL (1<<7) -#define AU_NOTIFICATION_SERVICE_WARNING (1<<8) -#define AU_NOTIFICATION_SERVICE_RECOVERY (1<<9) -#define AU_NOTIFICATION_SERVICE_CUSTOM (1<<10) -#define AU_NOTIFICATION_SERVICE_ACK (1<<11) -#define AU_NOTIFICATION_SERVICE_FLAPPING_START (1<<12) -#define AU_NOTIFICATION_SERVICE_FLAPPING_STOP (1<<13) -#define AU_NOTIFICATION_SERVICE_UNKNOWN (1<<14) - -#define AU_NOTIFICATION_HOST_ALL (AU_NOTIFICATION_HOST_DOWN | \ - AU_NOTIFICATION_HOST_UNREACHABLE | \ - AU_NOTIFICATION_HOST_RECOVERY | \ - AU_NOTIFICATION_HOST_CUSTOM | \ - AU_NOTIFICATION_HOST_ACK | \ - AU_NOTIFICATION_HOST_FLAPPING_START | \ - AU_NOTIFICATION_HOST_FLAPPING_STOP) - -#define AU_NOTIFICATION_SERVICE_ALL (AU_NOTIFICATION_SERVICE_CRITICAL | \ - AU_NOTIFICATION_SERVICE_WARNING | \ - AU_NOTIFICATION_SERVICE_RECOVERY | \ - AU_NOTIFICATION_SERVICE_CUSTOM | \ - AU_NOTIFICATION_SERVICE_ACK | \ - AU_NOTIFICATION_SERVICE_FLAPPING_START | \ - AU_NOTIFICATION_SERVICE_FLAPPING_STOP | \ - AU_NOTIFICATION_SERVICE_UNKNOWN) - -#define AU_NOTFICATION_ALL (AU_NOTFICATION_HOST_ALL | \ - AU_NOTIFICATION_SERVICE_ALL) - -typedef struct au_array_struct { - char *label; - int size; - int count; - void **members; - int new; - } au_array; - -typedef struct au_node_struct { - void *data; - struct au_node_struct *next; - } au_node; - -typedef struct au_linked_list_struct { - char *label; - au_node *head; - au_node *last_new; - } au_linked_list; - -struct au_log_entry_struct; - -/* au_availability keeps the availability information for a given host or - service */ -typedef struct au_availability_struct { - unsigned long time_up; - unsigned long time_down; - unsigned long time_unreachable; - unsigned long time_ok; - unsigned long time_warning; - unsigned long time_unknown; - unsigned long time_critical; - - unsigned long scheduled_time_up; - unsigned long scheduled_time_down; - unsigned long scheduled_time_unreachable; - unsigned long scheduled_time_ok; - unsigned long scheduled_time_warning; - unsigned long scheduled_time_unknown; - unsigned long scheduled_time_critical; - unsigned long scheduled_time_indeterminate; - - unsigned long time_indeterminate_nodata; - unsigned long time_indeterminate_notrunning; - } au_availability; - -/* au_host keeps information about a single host and all log entries that - pertain to that host, including global events such as Nagios starts and - stops */ -typedef struct au_host_struct { - char *name; - host *hostp; - au_linked_list *log_entries; - au_availability *availability; - } au_host; - -/* au_service keeps information about a single service and all log entries - that pertain to that service, including global events such as Nagios - starts and stops */ -typedef struct au_service_struct { - char *host_name; - char *description; - service *servicep; - au_linked_list *log_entries; - au_availability *availability; - } au_service; - -typedef struct au_contact_struct { - char *name; - contact *contactp; - } au_contact; - -/* au_log_alert keeps information about alert and state type logs */ -typedef struct au_log_alert_struct { - int obj_type; /* AU_OBJTYPE_HOST or AU_OBJTYPE_SERVICE */ - void *object; /* au_host or au_service */ - int state_type; /* hard, soft, or no data */ - int state; /* any host or service state, or no data */ - char *plugin_output; - } au_log_alert; - -/* au_log_notification keeps information about notification logs */ -typedef struct au_log_notification_struct { - int obj_type; /* AU_OBJTYPE_HOST or AU_OBJTYPE_SERVICE */ - void *object; /* au_host or au_service */ - au_contact *contact; /* notification contact */ - int notification_type; - char *method; - char *message; /* informational method */ - } au_log_notification; - -/* au_log_downtime keeps information about downtime logs */ -typedef struct au_log_downtime_struct { - int obj_type; /* AU_OBJTYPE_HOST or AU_OBJTYPE_SERVICE */ - void *object; /* au_host or au_service */ - int downtime_type; /* AU_STATE_DOWNTIME_START or - AU_STATE_DOWNTIME_END */ - } au_log_downtime; - -/* au_log_nagios keeps information about Nagios starts and stops */ -typedef struct au_log_nagios_struct { - int type; /* AU_STATE_NAGIOS_START or - AU_STATE_NAGIOS_STOP */ - char *description; - } au_log_nagios; - -/* au_log_entry keeps information about each log entry */ -typedef struct au_log_entry_struct { - time_t timestamp; - int entry_type; /* AU_LOGTYPE_* */ - void *entry; /* au_log_alert *, au_log_notification *, - au_log_downtime *, or au_log_nagios * */ - } au_log_entry; - -typedef struct au_log_struct { - au_array *host_subjects; /* hosts to parse when specified - in the query */ - au_array *service_subjects; /* services to parse when specified - in the query */ - au_linked_list *entry_list; /* linked list of log entries */ - au_array *hosts; /* list of hosts and their log entries - discovered during parsing */ - au_array *services; /* list of services and the log - entries discovered during parsing */ - au_array *contacts; /* list of contacts associated with - notification logs */ - } au_log; - -/* External functions */ -extern au_log *au_init_log(void); -extern int read_archived_data(time_t, time_t, int, unsigned, unsigned, - unsigned, au_log *, time_t *); -extern int au_cmp_log_entries(const void *, const void *); -extern void au_free_log(au_log *); - -extern au_node *au_list_add_node(au_linked_list *, void *, - int(*)(const void *, const void *)); - -extern int au_add_alert_or_state_log(au_log *, time_t, int, int, void *, int, - int, char *); -extern au_log_alert *au_create_alert_or_state_log(int, void *, int, int, - char *); -extern void au_free_alert_log(au_log_alert *); - -extern au_host *au_add_host(au_array *, char *); -extern au_host *au_find_host(au_array *, char *); -extern au_service *au_add_service(au_array *, char *, char *); -extern au_service *au_find_service(au_array *, char *, char *); -extern au_array *au_init_array(char *); -extern void au_free_array(au_array *, void(*)(void *)); -extern int au_array_append_member(au_array *, void *); - -/* External variables */ -extern const string_value_mapping svm_au_object_types[]; -extern const string_value_mapping svm_au_state_types[]; -extern const string_value_mapping svm_au_states[]; -extern const string_value_mapping svm_au_log_types[]; -extern const string_value_mapping svm_au_notification_types[]; - -#endif diff --git a/devtools/ci/nagios/broker.h b/devtools/ci/nagios/broker.h deleted file mode 100644 index 22abe07..0000000 --- a/devtools/ci/nagios/broker.h +++ /dev/null @@ -1,214 +0,0 @@ -/***************************************************************************** - * - * BROKER.H - Event broker includes for Nagios - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#ifndef NAGIOS_BROKER_H_INCLUDED -#define NAGIOS_BROKER_H_INCLUDED - -#include "nagios.h" - -/*************** EVENT BROKER OPTIONS *****************/ - -#define BROKER_NOTHING 0 -#define BROKER_EVERYTHING 1048575 - -#define BROKER_PROGRAM_STATE 1 /* DONE */ -#define BROKER_TIMED_EVENTS 2 /* DONE */ -#define BROKER_SERVICE_CHECKS 4 /* DONE */ -#define BROKER_HOST_CHECKS 8 /* DONE */ -#define BROKER_EVENT_HANDLERS 16 /* DONE */ -#define BROKER_LOGGED_DATA 32 /* DONE */ -#define BROKER_NOTIFICATIONS 64 /* DONE */ -#define BROKER_FLAPPING_DATA 128 /* DONE */ -#define BROKER_COMMENT_DATA 256 /* DONE */ -#define BROKER_DOWNTIME_DATA 512 /* DONE */ -#define BROKER_SYSTEM_COMMANDS 1024 /* DONE */ -#define BROKER_OCP_DATA_UNUSED 2048 /* reusable */ -#define BROKER_STATUS_DATA 4096 /* DONE */ -#define BROKER_ADAPTIVE_DATA 8192 /* DONE */ -#define BROKER_EXTERNALCOMMAND_DATA 16384 /* DONE */ -#define BROKER_RETENTION_DATA 32768 /* DONE */ -#define BROKER_ACKNOWLEDGEMENT_DATA 65536 -#define BROKER_STATECHANGE_DATA 131072 -#define BROKER_RESERVED18 262144 -#define BROKER_RESERVED19 524288 - - -/****** EVENT TYPES ************************/ - -#define NEBTYPE_NONE 0 - -#define NEBTYPE_HELLO 1 -#define NEBTYPE_GOODBYE 2 -#define NEBTYPE_INFO 3 - -#define NEBTYPE_PROCESS_START 100 -#define NEBTYPE_PROCESS_DAEMONIZE 101 -#define NEBTYPE_PROCESS_RESTART 102 -#define NEBTYPE_PROCESS_SHUTDOWN 103 -#define NEBTYPE_PROCESS_PRELAUNCH 104 /* before objects are read or verified */ -#define NEBTYPE_PROCESS_EVENTLOOPSTART 105 -#define NEBTYPE_PROCESS_EVENTLOOPEND 106 - -#define NEBTYPE_TIMEDEVENT_ADD 200 -#define NEBTYPE_TIMEDEVENT_REMOVE 201 -#define NEBTYPE_TIMEDEVENT_EXECUTE 202 -#define NEBTYPE_TIMEDEVENT_DELAY 203 /* NOT IMPLEMENTED */ -#define NEBTYPE_TIMEDEVENT_SKIP 204 /* NOT IMPLEMENTED */ -#define NEBTYPE_TIMEDEVENT_SLEEP 205 -#define NEBTYPE_TIMEDEVENT_END 206 - -#define NEBTYPE_LOG_DATA 300 -#define NEBTYPE_LOG_ROTATION 301 - -#define NEBTYPE_SYSTEM_COMMAND_START 400 -#define NEBTYPE_SYSTEM_COMMAND_END 401 - -#define NEBTYPE_EVENTHANDLER_START 500 -#define NEBTYPE_EVENTHANDLER_END 501 - -#define NEBTYPE_NOTIFICATION_START 600 -#define NEBTYPE_NOTIFICATION_END 601 -#define NEBTYPE_CONTACTNOTIFICATION_START 602 -#define NEBTYPE_CONTACTNOTIFICATION_END 603 -#define NEBTYPE_CONTACTNOTIFICATIONMETHOD_START 604 -#define NEBTYPE_CONTACTNOTIFICATIONMETHOD_END 605 - -#define NEBTYPE_SERVICECHECK_INITIATE 700 -#define NEBTYPE_SERVICECHECK_PROCESSED 701 -#define NEBTYPE_SERVICECHECK_RAW_START 702 /* NOT IMPLEMENTED */ -#define NEBTYPE_SERVICECHECK_RAW_END 703 /* NOT IMPLEMENTED */ -#define NEBTYPE_SERVICECHECK_ASYNC_PRECHECK 704 - -#define NEBTYPE_HOSTCHECK_INITIATE 800 /* a check of the route to the host has been initiated */ -#define NEBTYPE_HOSTCHECK_PROCESSED 801 /* the processed/final result of a host check */ -#define NEBTYPE_HOSTCHECK_RAW_START 802 /* the start of a "raw" host check */ -#define NEBTYPE_HOSTCHECK_RAW_END 803 /* a finished "raw" host check */ -#define NEBTYPE_HOSTCHECK_ASYNC_PRECHECK 804 -#define NEBTYPE_HOSTCHECK_SYNC_PRECHECK 805 - -#define NEBTYPE_COMMENT_ADD 900 -#define NEBTYPE_COMMENT_DELETE 901 -#define NEBTYPE_COMMENT_LOAD 902 - -#define NEBTYPE_FLAPPING_START 1000 -#define NEBTYPE_FLAPPING_STOP 1001 - -#define NEBTYPE_DOWNTIME_ADD 1100 -#define NEBTYPE_DOWNTIME_DELETE 1101 -#define NEBTYPE_DOWNTIME_LOAD 1102 -#define NEBTYPE_DOWNTIME_START 1103 -#define NEBTYPE_DOWNTIME_STOP 1104 - -#define NEBTYPE_PROGRAMSTATUS_UPDATE 1200 -#define NEBTYPE_HOSTSTATUS_UPDATE 1201 -#define NEBTYPE_SERVICESTATUS_UPDATE 1202 -#define NEBTYPE_CONTACTSTATUS_UPDATE 1203 - -#define NEBTYPE_ADAPTIVEPROGRAM_UPDATE 1300 -#define NEBTYPE_ADAPTIVEHOST_UPDATE 1301 -#define NEBTYPE_ADAPTIVESERVICE_UPDATE 1302 -#define NEBTYPE_ADAPTIVECONTACT_UPDATE 1303 - -#define NEBTYPE_EXTERNALCOMMAND_START 1400 -#define NEBTYPE_EXTERNALCOMMAND_END 1401 - -#define NEBTYPE_AGGREGATEDSTATUS_STARTDUMP 1500 -#define NEBTYPE_AGGREGATEDSTATUS_ENDDUMP 1501 - -#define NEBTYPE_RETENTIONDATA_STARTLOAD 1600 -#define NEBTYPE_RETENTIONDATA_ENDLOAD 1601 -#define NEBTYPE_RETENTIONDATA_STARTSAVE 1602 -#define NEBTYPE_RETENTIONDATA_ENDSAVE 1603 - -#define NEBTYPE_ACKNOWLEDGEMENT_ADD 1700 -#define NEBTYPE_ACKNOWLEDGEMENT_REMOVE 1701 /* NOT IMPLEMENTED */ -#define NEBTYPE_ACKNOWLEDGEMENT_LOAD 1702 /* NOT IMPLEMENTED */ - -#define NEBTYPE_STATECHANGE_START 1800 /* NOT IMPLEMENTED */ -#define NEBTYPE_STATECHANGE_END 1801 - - - -/****** EVENT FLAGS ************************/ - -#define NEBFLAG_NONE 0 -#define NEBFLAG_PROCESS_INITIATED 1 /* event was initiated by Nagios process */ -#define NEBFLAG_USER_INITIATED 2 /* event was initiated by a user request */ -#define NEBFLAG_MODULE_INITIATED 3 /* event was initiated by an event broker module */ - - - - -/****** EVENT ATTRIBUTES *******************/ - -#define NEBATTR_NONE 0 - -#define NEBATTR_SHUTDOWN_NORMAL 1 -#define NEBATTR_SHUTDOWN_ABNORMAL 2 -#define NEBATTR_RESTART_NORMAL 4 -#define NEBATTR_RESTART_ABNORMAL 8 - -#define NEBATTR_FLAPPING_STOP_NORMAL 1 -#define NEBATTR_FLAPPING_STOP_DISABLED 2 /* flapping stopped because flap detection was disabled */ - -#define NEBATTR_DOWNTIME_STOP_NORMAL 1 -#define NEBATTR_DOWNTIME_STOP_CANCELLED 2 - - - -/****** EVENT BROKER FUNCTIONS *************/ - -#ifdef USE_EVENT_BROKER -NAGIOS_BEGIN_DECL - -struct timeval get_broker_timestamp(struct timeval *); -void broker_program_state(int, int, int, struct timeval *); -void broker_timed_event(int, int, int, timed_event *, struct timeval *); -void broker_log_data(int, int, int, char *, unsigned long, time_t, struct timeval *); -int broker_event_handler(int, int, int, int, void *, int, int, struct timeval, struct timeval, double, int, int, int, char *, char *, char *, struct timeval *); -void broker_system_command(int, int, int, struct timeval, struct timeval, double, int, int, int, char *, char *, struct timeval *); -int broker_host_check(int, int, int, host *, int, int, int, struct timeval, struct timeval, char *, double, double, int, int, int, char *, char *, char *, char *, struct timeval *, check_result *); -int broker_service_check(int, int, int, service *, int, struct timeval, struct timeval, char *, double, double, int, int, int, char *, struct timeval *, check_result *); -void broker_comment_data(int, int, int, int, int, char *, char *, time_t, char *, char *, int, int, int, time_t, unsigned long, struct timeval *); -void broker_downtime_data(int, int, int, int, char *, char *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long, unsigned long, struct timeval *); -void broker_flapping_data(int, int, int, int, void *, double, double, double, struct timeval *); -void broker_program_status(int, int, int, struct timeval *); -void broker_host_status(int, int, int, host *, struct timeval *); -void broker_service_status(int, int, int, service *, struct timeval *); -void broker_contact_status(int, int, int, contact *, struct timeval *); -int broker_notification_data(int, int, int, int, int, struct timeval, struct timeval, void *, char *, char *, int, int, struct timeval *); -int broker_contact_notification_data(int, int, int, int, int, struct timeval, struct timeval, void *, contact *, char *, char *, int, struct timeval *); -int broker_contact_notification_method_data(int, int, int, int, int, struct timeval, struct timeval, void *, contact *, char *, char *, char *, int, struct timeval *); -void broker_adaptive_program_data(int, int, int, int, unsigned long, unsigned long, unsigned long, unsigned long, struct timeval *); -void broker_adaptive_host_data(int, int, int, host *, int, unsigned long, unsigned long, struct timeval *); -void broker_adaptive_service_data(int, int, int, service *, int, unsigned long, unsigned long, struct timeval *); -void broker_adaptive_contact_data(int, int, int, contact *, int, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, struct timeval *); -void broker_external_command(int, int, int, int, time_t, char *, char *, struct timeval *); -void broker_aggregated_status_data(int, int, int, struct timeval *); -void broker_retention_data(int, int, int, struct timeval *); -void broker_acknowledgement_data(int, int, int, int, void *, char *, char *, int, int, int, struct timeval *); -void broker_statechange_data(int, int, int, int, void *, int, int, int, int, struct timeval *); - -NAGIOS_END_DECL -#endif - -#endif diff --git a/devtools/ci/nagios/cgiauth.h b/devtools/ci/nagios/cgiauth.h deleted file mode 100644 index 3216e44..0000000 --- a/devtools/ci/nagios/cgiauth.h +++ /dev/null @@ -1,70 +0,0 @@ -/***************************************************************************** - * - * CGIAUTH.H - Authorization utilities header file - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#ifndef NAGIOS_CGIAUTH_H_INCLUDED -#define NAGIOS_CGIAUTH_H_INCLUDED -#include "common.h" -#include "objects.h" - -NAGIOS_BEGIN_DECL - -typedef struct authdata_struct { - char *username; - int authorized_for_all_hosts; - int authorized_for_all_host_commands; - int authorized_for_all_services; - int authorized_for_all_service_commands; - int authorized_for_system_information; - int authorized_for_system_commands; - int authorized_for_configuration_information; - int authorized_for_read_only; - int authenticated; - } authdata; - - - -int get_authentication_information(authdata *); /* gets current authentication information */ - -int is_authorized_for_host(host *, authdata *); -int is_authorized_for_service(service *, authdata *); - -int is_authorized_for_all_hosts(authdata *); -int is_authorized_for_all_services(authdata *); - -int is_authorized_for_system_information(authdata *); -int is_authorized_for_system_commands(authdata *); -int is_authorized_for_host_commands(host *, authdata *); -int is_authorized_for_service_commands(service *, authdata *); - -int is_authorized_for_hostgroup(hostgroup *, authdata *); -int is_authorized_for_servicegroup(servicegroup *, authdata *); - -int is_authorized_for_hostgroup_commands(hostgroup *, authdata *); -int is_authorized_for_servicegroup_commands(servicegroup *, authdata *); - -int is_authorized_for_configuration_information(authdata *); - -int is_authorized_for_read_only(authdata *); - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/nagios/cgiutils.h b/devtools/ci/nagios/cgiutils.h deleted file mode 100644 index c0b0d2b..0000000 --- a/devtools/ci/nagios/cgiutils.h +++ /dev/null @@ -1,511 +0,0 @@ -/************************************************************************ - * - * CGIUTILS.H - Header file for common CGI functions - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - ************************************************************************/ - -#ifndef NAGIOS_CGIUTILS_H_INCLUDED -#define NAGIOS_CGIUTILS_H_INCLUDED -#include "lib/libnagios.h" -#include "logging.h" -#include "objects.h" -#include "cgiauth.h" - -NAGIOS_BEGIN_DECL - - /**************************** CGI REFRESH RATE ******************************/ - -#define DEFAULT_REFRESH_RATE 60 /* 60 second refresh rate for CGIs */ - - - /******************************* CGI NAMES **********************************/ - -#define STATUS_CGI "status.cgi" -#ifdef LEGACY_GRAPHICAL_CGIS -#define STATUSMAP_CGI "statusmap.cgi" -#else -#define STATUSMAP_CGI "../map.php" -#define LEGACY_STATUSMAP_CGI "statusmap.cgi" -#endif -#define STATUSWORLD_CGI "statuswrl.cgi" -#define COMMAND_CGI "cmd.cgi" -#define EXTINFO_CGI "extinfo.cgi" -#define SHOWLOG_CGI "showlog.cgi" -#define NOTIFICATIONS_CGI "notifications.cgi" -#define HISTORY_CGI "history.cgi" -#define CONFIG_CGI "config.cgi" -#define OUTAGES_CGI "outages.cgi" -#ifdef LEGACY_GRAPHICAL_CGIS -#define TRENDS_CGI "trends.cgi" -#else -#define TRENDS_CGI "../trends.html" -#define LEGACY_TRENDS_CGI "trends.cgi" -#endif -#define AVAIL_CGI "avail.cgi" -#define TAC_CGI "tac.cgi" -#define STATUSWML_CGI "statuswml.cgi" -#define TRACEROUTE_CGI "traceroute.cgi" -#ifdef LEGACY_GRAPHICAL_CGIS -#define HISTOGRAM_CGI "histogram.cgi" -#else -#define HISTOGRAM_CGI "../histogram.html" -#define LEGACY_HISTOGRAM_CGI "histogram.cgi" -#endif -#define CHECKSANITY_CGI "checksanity.cgi" -#define MINISTATUS_CGI "ministatus.cgi" -#define SUMMARY_CGI "summary.cgi" - - - /**************************** STYLE SHEET NAMES ******************************/ - -#define COMMON_CSS "common.css" - -#define SHOWLOG_CSS "showlog.css" -#define STATUS_CSS "status.css" -#define STATUSMAP_CSS "statusmap.css" -#define COMMAND_CSS "cmd.css" -#define EXTINFO_CSS "extinfo.css" -#define NOTIFICATIONS_CSS "notifications.css" -#define HISTORY_CSS "history.css" -#define CONFIG_CSS "config.css" -#define OUTAGES_CSS "outages.css" -#define TRENDS_CSS "trends.css" -#define AVAIL_CSS "avail.css" -#define TAC_CSS "tac.css" -#define HISTOGRAM_CSS "histogram.css" -#define CHECKSANITY_CSS "checksanity.css" -#define MINISTATUS_CSS "ministatus.css" -#define SUMMARY_CSS "summary.css" -#define NAGFUNCS_CSS "nag_funcs.css" - - /********************************* JAVASCRIPT INCLUDES **********************/ -#define JQUERY_JS "jquery-1.12.4.min.js" -#define NAGFUNCS_JS "nag_funcs.js" - - /********************************* ICONS ************************************/ - -#define STATUS_ICON_WIDTH 20 -#define STATUS_ICON_HEIGHT 20 - -#define INFO_ICON "info.png" -#define INFO_ICON_ALT "Informational Message" -#define START_ICON "start.gif" -#define START_ICON_ALT "Program Start" -#define STOP_ICON "stop.gif" -#define STOP_ICON_ALT "Program End" -#define RESTART_ICON "restart.gif" -#define RESTART_ICON_ALT "Program Restart" -#define OK_ICON "recovery.png" -#define OK_ICON_ALT "Service Ok" -#define CRITICAL_ICON "critical.png" -#define CRITICAL_ICON_ALT "Service Critical" -#define WARNING_ICON "warning.png" -#define WARNING_ICON_ALT "Service Warning" -#define UNKNOWN_ICON "unknown.png" -#define UNKNOWN_ICON_ALT "Service Unknown" -#define NOTIFICATION_ICON "notify.gif" -#define NOTIFICATION_ICON_ALT "Service Notification" -#define LOG_ROTATION_ICON "logrotate.png" -#define LOG_ROTATION_ICON_ALT "Log Rotation" -#define EXTERNAL_COMMAND_ICON "command.png" -#define EXTERNAL_COMMAND_ICON_ALT "External Command" - -#define STATUS_DETAIL_ICON "status2.gif" -#define STATUS_OVERVIEW_ICON "status.gif" -#define STATUSMAP_ICON "status3.gif" -#define STATUSWORLD_ICON "status4.gif" -#define EXTINFO_ICON "extinfo.gif" -#define HISTORY_ICON "history.gif" -#define CONTACTGROUP_ICON "contactgroup.gif" -#define TRENDS_ICON "trends.gif" - -#define DISABLED_ICON "disabled.gif" -#define ENABLED_ICON "enabled.gif" -#define PASSIVE_ONLY_ICON "passiveonly.gif" -#define NOTIFICATIONS_DISABLED_ICON "ndisabled.gif" -#define ACKNOWLEDGEMENT_ICON "ack.gif" -#define REMOVE_ACKNOWLEDGEMENT_ICON "noack.gif" -#define COMMENT_ICON "comment.gif" -#define DELETE_ICON "delete.gif" -#define DELAY_ICON "delay.gif" -#define DOWNTIME_ICON "downtime.gif" -#define PASSIVE_ICON "passiveonly.gif" -#define RIGHT_ARROW_ICON "right.gif" -#define LEFT_ARROW_ICON "left.gif" -#define UP_ARROW_ICON "up.gif" -#define DOWN_ARROW_ICON "down.gif" -#define FLAPPING_ICON "flapping.gif" -#define SCHEDULED_DOWNTIME_ICON "downtime.gif" -#define EMPTY_ICON "empty.gif" - -#define ACTIVE_ICON "active.gif" -#define ACTIVE_ICON_ALT "Active Mode" -#define STANDBY_ICON "standby.gif" -#define STANDBY_ICON_ALT "Standby Mode" - -#define HOST_DOWN_ICON "critical.png" -#define HOST_DOWN_ICON_ALT "Host Down" -#define HOST_UNREACHABLE_ICON "critical.png" -#define HOST_UNREACHABLE_ICON_ALT "Host Unreachable" -#define HOST_UP_ICON "recovery.png" -#define HOST_UP_ICON_ALT "Host Up" -#define HOST_NOTIFICATION_ICON "notify.gif" -#define HOST_NOTIFICATION_ICON_ALT "Host Notification" - -#define SERVICE_EVENT_ICON "serviceevent.gif" -#define SERVICE_EVENT_ICON_ALT "Service Event Handler" -#define HOST_EVENT_ICON "hostevent.gif" -#define HOST_EVENT_ICON_ALT "Host Event Handler" - -#define THERM_OK_IMAGE "thermok.png" -#define THERM_WARNING_IMAGE "thermwarn.png" -#define THERM_CRITICAL_IMAGE "thermcrit.png" - -#define CONFIGURATION_ICON "config.gif" -#define NOTES_ICON "notes.gif" -#define ACTION_ICON "action.gif" -#define DETAIL_ICON "detail.gif" - -#define PARENT_TRAVERSAL_ICON "parentup.gif" - -#define TAC_DISABLED_ICON "tacdisabled.png" -#define TAC_ENABLED_ICON "tacenabled.png" - -#define ZOOM1_ICON "zoom1.gif" -#define ZOOM2_ICON "zoom2.gif" - -#define CONTEXT_HELP_ICON1 "contexthelp1.gif" -#define CONTEXT_HELP_ICON2 "contexthelp2.gif" - -#define SPLUNK_SMALL_WHITE_ICON "splunk1.gif" -#define SPLUNK_SMALL_BLACK_ICON "splunk2.gif" - -#define FIRST_PAGE_ICON "b_first2.png" -#define LAST_PAGE_ICON "b_last2.png" -#define NEXT_PAGE_ICON "b_next2.png" -#define PREVIOUS_PAGE_ICON "b_prev2.png" - - - /********************* EXTENDED INFO CGI DISPLAY TYPES *********************/ - -#define DISPLAY_PROCESS_INFO 0 -#define DISPLAY_HOST_INFO 1 -#define DISPLAY_SERVICE_INFO 2 -#define DISPLAY_COMMENTS 3 -#define DISPLAY_PERFORMANCE 4 -#define DISPLAY_HOSTGROUP_INFO 5 -#define DISPLAY_DOWNTIME 6 -#define DISPLAY_SCHEDULING_QUEUE 7 -#define DISPLAY_SERVICEGROUP_INFO 8 - - - /************************ COMMAND CGI COMMAND MODES *************************/ - -#define CMDMODE_NONE 0 -#define CMDMODE_REQUEST 1 -#define CMDMODE_COMMIT 2 - - - - /******************** HOST AND SERVICE NOTIFICATION TYPES ******************/ - -#define NOTIFICATION_ALL 0 /* all service and host notifications */ -#define NOTIFICATION_SERVICE_ALL 1 /* all types of service notifications */ -#define NOTIFICATION_HOST_ALL 2 /* all types of host notifications */ -#define NOTIFICATION_SERVICE_WARNING 4 -#define NOTIFICATION_SERVICE_UNKNOWN 8 -#define NOTIFICATION_SERVICE_CRITICAL 16 -#define NOTIFICATION_SERVICE_RECOVERY 32 -#define NOTIFICATION_HOST_DOWN 64 -#define NOTIFICATION_HOST_UNREACHABLE 128 -#define NOTIFICATION_HOST_RECOVERY 256 -#define NOTIFICATION_SERVICE_ACK 512 -#define NOTIFICATION_HOST_ACK 1024 -#define NOTIFICATION_SERVICE_FLAP 2048 -#define NOTIFICATION_HOST_FLAP 4096 -#define NOTIFICATION_SERVICE_CUSTOM 8192 -#define NOTIFICATION_HOST_CUSTOM 16384 -#define NOTIFICATION_SERVICE_DOWNTIME 32768 -#define NOTIFICATION_HOST_DOWNTIME 65536 - - - /********************** HOST AND SERVICE ALERT TYPES **********************/ - -#define HISTORY_ALL 0 /* all service and host alert */ -#define HISTORY_SERVICE_ALL 1 /* all types of service alerts */ -#define HISTORY_HOST_ALL 2 /* all types of host alerts */ -#define HISTORY_SERVICE_WARNING 4 -#define HISTORY_SERVICE_UNKNOWN 8 -#define HISTORY_SERVICE_CRITICAL 16 -#define HISTORY_SERVICE_RECOVERY 32 -#define HISTORY_HOST_DOWN 64 -#define HISTORY_HOST_UNREACHABLE 128 -#define HISTORY_HOST_RECOVERY 256 - - - /****************************** SORT TYPES *******************************/ - -#define SORT_NONE 0 -#define SORT_ASCENDING 1 -#define SORT_DESCENDING 2 - - - /***************************** SORT OPTIONS ******************************/ - -#define SORT_NOTHING 0 -#define SORT_HOSTNAME 1 -#define SORT_SERVICENAME 2 -#define SORT_SERVICESTATUS 3 -#define SORT_LASTCHECKTIME 4 -#define SORT_CURRENTATTEMPT 5 -#define SORT_STATEDURATION 6 -#define SORT_NEXTCHECKTIME 7 -#define SORT_HOSTSTATUS 8 -#define SORT_HOSTURGENCY 9 - - - /****************** HOST AND SERVICE FILTER PROPERTIES *******************/ - -#define HOST_SCHEDULED_DOWNTIME 1 -#define HOST_NO_SCHEDULED_DOWNTIME 2 -#define HOST_STATE_ACKNOWLEDGED 4 -#define HOST_STATE_UNACKNOWLEDGED 8 -#define HOST_CHECKS_DISABLED 16 -#define HOST_CHECKS_ENABLED 32 -#define HOST_EVENT_HANDLER_DISABLED 64 -#define HOST_EVENT_HANDLER_ENABLED 128 -#define HOST_FLAP_DETECTION_DISABLED 256 -#define HOST_FLAP_DETECTION_ENABLED 512 -#define HOST_IS_FLAPPING 1024 -#define HOST_IS_NOT_FLAPPING 2048 -#define HOST_NOTIFICATIONS_DISABLED 4096 -#define HOST_NOTIFICATIONS_ENABLED 8192 -#define HOST_PASSIVE_CHECKS_DISABLED 16384 -#define HOST_PASSIVE_CHECKS_ENABLED 32768 -#define HOST_PASSIVE_CHECK 65536 -#define HOST_ACTIVE_CHECK 131072 -#define HOST_HARD_STATE 262144 -#define HOST_SOFT_STATE 524288 - - -#define SERVICE_SCHEDULED_DOWNTIME 1 -#define SERVICE_NO_SCHEDULED_DOWNTIME 2 -#define SERVICE_STATE_ACKNOWLEDGED 4 -#define SERVICE_STATE_UNACKNOWLEDGED 8 -#define SERVICE_CHECKS_DISABLED 16 -#define SERVICE_CHECKS_ENABLED 32 -#define SERVICE_EVENT_HANDLER_DISABLED 64 -#define SERVICE_EVENT_HANDLER_ENABLED 128 -#define SERVICE_FLAP_DETECTION_ENABLED 256 -#define SERVICE_FLAP_DETECTION_DISABLED 512 -#define SERVICE_IS_FLAPPING 1024 -#define SERVICE_IS_NOT_FLAPPING 2048 -#define SERVICE_NOTIFICATIONS_DISABLED 4096 -#define SERVICE_NOTIFICATIONS_ENABLED 8192 -#define SERVICE_PASSIVE_CHECKS_DISABLED 16384 -#define SERVICE_PASSIVE_CHECKS_ENABLED 32768 -#define SERVICE_PASSIVE_CHECK 65536 -#define SERVICE_ACTIVE_CHECK 131072 -#define SERVICE_HARD_STATE 262144 -#define SERVICE_SOFT_STATE 524288 - - - /****************************** SSI TYPES ********************************/ - -#define SSI_HEADER 0 -#define SSI_FOOTER 1 - - - - /************************ CONTEXT-SENSITIVE HELP *************************/ - -#define CONTEXTHELP_STATUS_DETAIL "A1" -#define CONTEXTHELP_STATUS_HGOVERVIEW "A2" -#define CONTEXTHELP_STATUS_HGSUMMARY "A3" -#define CONTEXTHELP_STATUS_HGGRID "A4" -#define CONTEXTHELP_STATUS_SVCPROBLEMS "A5" -#define CONTEXTHELP_STATUS_HOST_DETAIL "A6" -#define CONTEXTHELP_STATUS_HOSTPROBLEMS "A7" -#define CONTEXTHELP_STATUS_SGOVERVIEW "A8" -#define CONTEXTHELP_STATUS_SGSUMMARY "A9" -#define CONTEXTHELP_STATUS_SGGRID "A10" - -#define CONTEXTHELP_TAC "B1" - -#define CONTEXTHELP_MAP "C1" - -#define CONTEXTHELP_LOG "D1" - -#define CONTEXTHELP_HISTORY "E1" - -#define CONTEXTHELP_NOTIFICATIONS "F1" - -#define CONTEXTHELP_TRENDS_MENU1 "G1" -#define CONTEXTHELP_TRENDS_MENU2 "G2" -#define CONTEXTHELP_TRENDS_MENU3 "G3" -#define CONTEXTHELP_TRENDS_MENU4 "G4" -#define CONTEXTHELP_TRENDS_HOST "G5" -#define CONTEXTHELP_TRENDS_SERVICE "G6" - -#define CONTEXTHELP_AVAIL_MENU1 "H1" -#define CONTEXTHELP_AVAIL_MENU2 "H2" -#define CONTEXTHELP_AVAIL_MENU3 "H3" -#define CONTEXTHELP_AVAIL_MENU4 "H4" -#define CONTEXTHELP_AVAIL_MENU5 "H5" -#define CONTEXTHELP_AVAIL_HOSTGROUP "H6" -#define CONTEXTHELP_AVAIL_HOST "H7" -#define CONTEXTHELP_AVAIL_SERVICE "H8" -#define CONTEXTHELP_AVAIL_SERVICEGROUP "H9" - -#define CONTEXTHELP_EXT_HOST "I1" -#define CONTEXTHELP_EXT_SERVICE "I2" -#define CONTEXTHELP_EXT_HOSTGROUP "I3" -#define CONTEXTHELP_EXT_PROCESS "I4" -#define CONTEXTHELP_EXT_PERFORMANCE "I5" -#define CONTEXTHELP_EXT_COMMENTS "I6" -#define CONTEXTHELP_EXT_DOWNTIME "I7" -#define CONTEXTHELP_EXT_QUEUE "I8" -#define CONTEXTHELP_EXT_SERVICEGROUP "I9" - -#define CONTEXTHELP_CMD_INPUT "J1" -#define CONTEXTHELP_CMD_COMMIT "J2" - -#define CONTEXTHELP_OUTAGES "K1" - -#define CONTEXTHELP_CONFIG_MENU "L1" -#define CONTEXTHELP_CONFIG_HOSTS "L2" -#define CONTEXTHELP_CONFIG_HOSTDEPENDENCIES "L3" -#define CONTEXTHELP_CONFIG_HOSTESCALATIONS "L4" -#define CONTEXTHELP_CONFIG_HOSTGROUPS "L5" -#define CONTEXTHELP_CONFIG_HOSTGROUPESCALATIONS "L6" -#define CONTEXTHELP_CONFIG_SERVICES "L7" -#define CONTEXTHELP_CONFIG_SERVICEDEPENDENCIES "L8" -#define CONTEXTHELP_CONFIG_SERVICEESCALATIONS "L9" -#define CONTEXTHELP_CONFIG_CONTACTS "L10" -#define CONTEXTHELP_CONFIG_CONTACTGROUPS "L11" -#define CONTEXTHELP_CONFIG_TIMEPERIODS "L12" -#define CONTEXTHELP_CONFIG_COMMANDS "L13" -#define CONTEXTHELP_CONFIG_HOSTEXTINFO "L14" -#define CONTEXTHELP_CONFIG_SERVICEEXTINFO "L15" -#define CONTEXTHELP_CONFIG_SERVICEGROUPS "L16" - -#define CONTEXTHELP_HISTOGRAM_MENU1 "M1" -#define CONTEXTHELP_HISTOGRAM_MENU2 "M2" -#define CONTEXTHELP_HISTOGRAM_MENU3 "M3" -#define CONTEXTHELP_HISTOGRAM_MENU4 "M4" -#define CONTEXTHELP_HISTOGRAM_HOST "M5" -#define CONTEXTHELP_HISTOGRAM_SERVICE "M6" - -#define CONTEXTHELP_SUMMARY_MENU "N1" -#define CONTEXTHELP_SUMMARY_RECENT_ALERTS "N2" -#define CONTEXTHELP_SUMMARY_ALERT_TOTALS "N3" -#define CONTEXTHELP_SUMMARY_HOSTGROUP_ALERT_TOTALS "N4" -#define CONTEXTHELP_SUMMARY_HOST_ALERT_TOTALS "N5" -#define CONTEXTHELP_SUMMARY_SERVICE_ALERT_TOTALS "N6" -#define CONTEXTHELP_SUMMARY_ALERT_PRODUCERS "N7" -#define CONTEXTHELP_SUMMARY_SERVICEGROUP_ALERT_TOTALS "N8" - - - /************************** LIFO RETURN CODES ****************************/ - -#define LIFO_OK 0 -#define LIFO_ERROR_MEMORY 1 -#define LIFO_ERROR_FILE 2 -#define LIFO_ERROR_DATA 3 - - - - - -/*************************** DATA STRUCTURES *****************************/ - -/* LIFO data structure */ -typedef struct lifo_struct { - char *data; - struct lifo_struct *next; - } lifo; - -struct nagios_extcmd { - const char *name; - int id; - int cmt_opt; /* 0 = not allowed, 1 = optional, 2 = required */ - char *default_comment; - }; - -/******************************** FUNCTIONS *******************************/ - -typedef void (*read_config_callback)(const char*, const char*); - -void reset_cgi_vars(void); -void cgi_init(void (*doc_header)(int), void (*doc_footer)(void), int object_options, int status_options); -void free_memory(void); - -const char *get_cgi_config_location(void); /* gets location of the CGI config file to read */ -const char *get_cmd_file_location(void); /* gets location of external command file to write to */ - -int read_cgi_config_file(const char *, read_config_callback); -int read_main_config_file(const char *); -int read_all_object_configuration_data(const char *, int); -int read_all_status_data(const char *, int); - -char *unescape_newlines(char *); -void sanitize_plugin_output(char *); /* strips HTML and bad characters from plugin output */ -void strip_html_brackets(char *); /* strips > and < from string */ - -void get_time_string(time_t *, char *, int, int); /* gets a date/time string */ -void get_interval_time_string(double, char *, int); /* gets a time string for an interval of time */ - -const char *url_encode(const char *); /* encodes a string in proper URL format */ -char *html_encode(char *, int); /* encodes a string in HTML format (for what the user sees) */ -char *escape_string(const char *); /* escape string for html form usage */ - -void get_log_archive_to_use(int, char *, int); /* determines the name of the log archive to use */ -void determine_log_rotation_times(int); -int determine_archive_to_use_from_time(time_t); - -void print_extra_hostgroup_url(char *, char *); -void print_extra_servicegroup_url(char *, char *); - -void display_info_table(const char *, int, authdata *); -void display_nav_table(char *, int); - -void display_splunk_host_url(host *); -void display_splunk_service_url(service *); -void display_splunk_generic_url(char *, int); -void strip_splunk_query_terms(char *); - -void include_ssi_files(const char *, int); /* include user-defined SSI footers/headers */ -void include_ssi_file(const char *); /* include user-defined SSI footer/header */ - -void cgi_config_file_error(const char *); -void main_config_file_error(const char *); -void object_data_error(void); -void status_data_error(void); - -void display_context_help(const char *); /* displays context-sensitive help window */ - -int read_file_into_lifo(char *); /* LIFO functions */ -void free_lifo_memory(void); -int push_lifo(char *); -char *pop_lifo(void); - -struct nagios_extcmd* extcmd_get_command_id(int); -struct nagios_extcmd* extcmd_get_command_name(const char *); -const char *extcmd_get_name(int); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/comments.h b/devtools/ci/nagios/comments.h deleted file mode 100644 index bb46841..0000000 --- a/devtools/ci/nagios/comments.h +++ /dev/null @@ -1,118 +0,0 @@ -/***************************************************************************** - * - * COMMENTS.H - Header file for comment functions - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - - -#ifndef NAGIOS_COMMENTS_H_INCLUDED -#define NAGIOS_COMMENTS_H_INCLUDED -#include "common.h" -#include "objects.h" - - -/**************************** COMMENT SOURCES ******************************/ - -#define COMMENTSOURCE_INTERNAL 0 -#define COMMENTSOURCE_EXTERNAL 1 - - - -/***************************** COMMENT TYPES *******************************/ - -#define HOST_COMMENT 1 -#define SERVICE_COMMENT 2 - - -/****************************** ENTRY TYPES ********************************/ - -#define USER_COMMENT 1 -#define DOWNTIME_COMMENT 2 -#define FLAPPING_COMMENT 3 -#define ACKNOWLEDGEMENT_COMMENT 4 - - -/*************************** CHAINED HASH LIMITS ***************************/ - -#define COMMENT_HASHSLOTS 1024 - - -/**************************** DATA STRUCTURES ******************************/ - -NAGIOS_BEGIN_DECL - -/* COMMENT structure */ -typedef struct nagios_comment { - int comment_type; - int entry_type; - unsigned long comment_id; - int source; - int persistent; - time_t entry_time; - int expires; - time_t expire_time; - char *host_name; - char *service_description; - char *author; - char *comment_data; - struct nagios_comment *next; - struct nagios_comment *nexthash; - } nagios_comment; - -extern struct nagios_comment *comment_list; - -#ifndef NSCGI -int initialize_comment_data(void); /* initializes comment data */ -int add_new_comment(int, int, char *, char *, time_t, char *, char *, int, int, int, time_t, unsigned long *); /* adds a new host or service comment */ -int add_new_host_comment(int, char *, time_t, char *, char *, int, int, int, time_t, unsigned long *); /* adds a new host comment */ -int add_new_service_comment(int, char *, char *, time_t, char *, char *, int, int, int, time_t, unsigned long *); /* adds a new service comment */ -int delete_comment(int, unsigned long); /* deletes a host or service comment */ -int delete_host_comment(unsigned long); /* deletes a host comment */ -int delete_service_comment(unsigned long); /* deletes a service comment */ -int delete_all_comments(int, char *, char *); /* deletes all comments for a particular host or service */ -int delete_all_host_comments(char *); /* deletes all comments for a specific host */ -int delete_host_acknowledgement_comments(struct host *); /* deletes all non-persistent ack comments for a specific host */ -int delete_all_service_comments(char *, char *); /* deletes all comments for a specific service */ -int delete_service_acknowledgement_comments(struct service *); /* deletes all non-persistent ack comments for a specific service */ - -int check_for_expired_comment(unsigned long); /* expires a comment */ -#endif - -struct nagios_comment *find_comment(unsigned long, int); /* finds a specific comment */ -struct nagios_comment *find_service_comment(unsigned long); /* finds a specific service comment */ -struct nagios_comment *find_host_comment(unsigned long); /* finds a specific host comment */ - -struct nagios_comment *get_first_comment_by_host(char *); -struct nagios_comment *get_next_comment_by_host(char *, struct nagios_comment *); - -int number_of_host_comments(char *); /* returns the number of comments associated with a particular host */ -int number_of_service_comments(char *, char *); /* returns the number of comments associated with a particular service */ - -int add_comment(int, int, char *, char *, time_t, char *, char *, unsigned long, int, int, time_t, int); /* adds a comment (host or service) */ -int sort_comments(void); -int add_host_comment(int, char *, time_t, char *, char *, unsigned long, int, int, time_t, int); /* adds a host comment */ -int add_service_comment(int, char *, char *, time_t, char *, char *, unsigned long, int, int, time_t, int); /* adds a service comment */ - -int add_comment_to_hashlist(struct nagios_comment *); - -void free_comment_data(void); /* frees memory allocated to the comment list */ - -NAGIOS_END_DECL - -#endif diff --git a/devtools/ci/nagios/common.h b/devtools/ci/nagios/common.h deleted file mode 100644 index 821b9c1..0000000 --- a/devtools/ci/nagios/common.h +++ /dev/null @@ -1,536 +0,0 @@ -/************************************************************************ - * - * Nagios Common Header File - * Written By: Ethan Galstad (egalstad@nagios.org) - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - ************************************************************************/ - -#ifndef NAGIOS_COMMON_H_INCLUDED -#define NAGIOS_COMMON_H_INCLUDED - -#include "shared.h" - -#define PROGRAM_VERSION "4.4.5" -#define PROGRAM_MODIFICATION_DATE "2019-08-20" - -NAGIOS_BEGIN_DECL - -/*************************************************************/ -/************** SHARED GLOBAL VARIABLES **********************/ -/*************************************************************/ -extern int date_format; -extern int interval_length; -extern char *illegal_output_chars; -extern char illegal_output_char_map[256]; - -extern int log_rotation_method; -extern int check_external_commands; -/* set this if you're going to add a ton of comments at once */ -extern int defer_comment_sorting; -extern unsigned long next_downtime_id; - -extern char *object_cache_file; -extern char *status_file; - -extern time_t program_start; -extern int nagios_pid; -extern int daemon_mode; - -extern time_t last_log_rotation; - -extern int process_performance_data; -extern int enable_flap_detection; -extern int enable_notifications; -extern int execute_service_checks; -extern int accept_passive_service_checks; -extern int execute_host_checks; -extern int accept_passive_host_checks; -extern int enable_event_handlers; -extern int obsess_over_services; -extern int obsess_over_hosts; - -extern int enable_timing_point; - -extern char *config_file_dir; -extern char *website_url; - -#ifdef HAVE_TZNAME -#ifdef CYGWIN -extern char *_tzname[2] __declspec(dllimport); -#else -extern char *tzname[2]; -#endif -#endif - - -NAGIOS_END_DECL - - -/* Experimental performance tweaks - use with caution */ -#undef USE_MEMORY_PERFORMANCE_TWEAKS - - -/****************** OBJECT STATES ********************/ -#define STATE_OK 0 -#define STATE_WARNING 1 -#define STATE_CRITICAL 2 -#define STATE_UNKNOWN 3 -#define STATE_UP 0 -#define STATE_DOWN 1 -#define STATE_UNREACHABLE 2 -/* for legacy reasons */ -#define HOST_UP STATE_UP -#define HOST_DOWN STATE_DOWN -#define HOST_UNREACHABLE STATE_UNREACHABLE - -/***************************** COMMANDS *********************************/ - -#define CMD_NONE 0 - -#define CMD_ADD_HOST_COMMENT 1 -#define CMD_DEL_HOST_COMMENT 2 - -#define CMD_ADD_SVC_COMMENT 3 -#define CMD_DEL_SVC_COMMENT 4 - -#define CMD_ENABLE_SVC_CHECK 5 -#define CMD_DISABLE_SVC_CHECK 6 - -#define CMD_SCHEDULE_SVC_CHECK 7 - -#define CMD_DELAY_SVC_NOTIFICATION 9 - -#define CMD_DELAY_HOST_NOTIFICATION 10 - -#define CMD_DISABLE_NOTIFICATIONS 11 -#define CMD_ENABLE_NOTIFICATIONS 12 - -#define CMD_RESTART_PROCESS 13 -#define CMD_SHUTDOWN_PROCESS 14 - -#define CMD_ENABLE_HOST_SVC_CHECKS 15 -#define CMD_DISABLE_HOST_SVC_CHECKS 16 - -#define CMD_SCHEDULE_HOST_SVC_CHECKS 17 - -#define CMD_DELAY_HOST_SVC_NOTIFICATIONS 19 /* currently unimplemented */ - -#define CMD_DEL_ALL_HOST_COMMENTS 20 -#define CMD_DEL_ALL_SVC_COMMENTS 21 - -#define CMD_ENABLE_SVC_NOTIFICATIONS 22 -#define CMD_DISABLE_SVC_NOTIFICATIONS 23 -#define CMD_ENABLE_HOST_NOTIFICATIONS 24 -#define CMD_DISABLE_HOST_NOTIFICATIONS 25 -#define CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST 26 -#define CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST 27 -#define CMD_ENABLE_HOST_SVC_NOTIFICATIONS 28 -#define CMD_DISABLE_HOST_SVC_NOTIFICATIONS 29 - -#define CMD_PROCESS_SERVICE_CHECK_RESULT 30 - -#define CMD_SAVE_STATE_INFORMATION 31 -#define CMD_READ_STATE_INFORMATION 32 - -#define CMD_ACKNOWLEDGE_HOST_PROBLEM 33 -#define CMD_ACKNOWLEDGE_SVC_PROBLEM 34 - -#define CMD_START_EXECUTING_SVC_CHECKS 35 -#define CMD_STOP_EXECUTING_SVC_CHECKS 36 - -#define CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS 37 -#define CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS 38 - -#define CMD_ENABLE_PASSIVE_SVC_CHECKS 39 -#define CMD_DISABLE_PASSIVE_SVC_CHECKS 40 - -#define CMD_ENABLE_EVENT_HANDLERS 41 -#define CMD_DISABLE_EVENT_HANDLERS 42 - -#define CMD_ENABLE_HOST_EVENT_HANDLER 43 -#define CMD_DISABLE_HOST_EVENT_HANDLER 44 - -#define CMD_ENABLE_SVC_EVENT_HANDLER 45 -#define CMD_DISABLE_SVC_EVENT_HANDLER 46 - -#define CMD_ENABLE_HOST_CHECK 47 -#define CMD_DISABLE_HOST_CHECK 48 - -#define CMD_START_OBSESSING_OVER_SVC_CHECKS 49 -#define CMD_STOP_OBSESSING_OVER_SVC_CHECKS 50 - -#define CMD_REMOVE_HOST_ACKNOWLEDGEMENT 51 -#define CMD_REMOVE_SVC_ACKNOWLEDGEMENT 52 - -#define CMD_SCHEDULE_FORCED_HOST_SVC_CHECKS 53 -#define CMD_SCHEDULE_FORCED_SVC_CHECK 54 - -#define CMD_SCHEDULE_HOST_DOWNTIME 55 -#define CMD_SCHEDULE_SVC_DOWNTIME 56 - -#define CMD_ENABLE_HOST_FLAP_DETECTION 57 -#define CMD_DISABLE_HOST_FLAP_DETECTION 58 - -#define CMD_ENABLE_SVC_FLAP_DETECTION 59 -#define CMD_DISABLE_SVC_FLAP_DETECTION 60 - -#define CMD_ENABLE_FLAP_DETECTION 61 -#define CMD_DISABLE_FLAP_DETECTION 62 - -#define CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS 63 -#define CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS 64 - -#define CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS 65 -#define CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS 66 - -#define CMD_ENABLE_HOSTGROUP_SVC_CHECKS 67 -#define CMD_DISABLE_HOSTGROUP_SVC_CHECKS 68 - -/* commands 69-77 are unimplemented */ -#define CMD_UNIMPLEMENTED_69 69 -#define CMD_UNIMPLEMENTED_70 70 -#define CMD_UNIMPLEMENTED_71 71 -#define CMD_UNIMPLEMENTED_72 72 -#define CMD_UNIMPLEMENTED_73 73 -#define CMD_UNIMPLEMENTED_74 74 -#define CMD_UNIMPLEMENTED_75 75 -#define CMD_UNIMPLEMENTED_76 76 -#define CMD_UNIMPLEMENTED_77 77 - -#define CMD_DEL_HOST_DOWNTIME 78 -#define CMD_DEL_SVC_DOWNTIME 79 - -#define CMD_ENABLE_PERFORMANCE_DATA 82 -#define CMD_DISABLE_PERFORMANCE_DATA 83 - -#define CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME 84 -#define CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME 85 -#define CMD_SCHEDULE_HOST_SVC_DOWNTIME 86 - -/* new commands in Nagios 2.x found below... */ -#define CMD_PROCESS_HOST_CHECK_RESULT 87 - -#define CMD_START_EXECUTING_HOST_CHECKS 88 -#define CMD_STOP_EXECUTING_HOST_CHECKS 89 - -#define CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS 90 -#define CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS 91 - -#define CMD_ENABLE_PASSIVE_HOST_CHECKS 92 -#define CMD_DISABLE_PASSIVE_HOST_CHECKS 93 - -#define CMD_START_OBSESSING_OVER_HOST_CHECKS 94 -#define CMD_STOP_OBSESSING_OVER_HOST_CHECKS 95 - -#define CMD_SCHEDULE_HOST_CHECK 96 -#define CMD_SCHEDULE_FORCED_HOST_CHECK 98 - -#define CMD_START_OBSESSING_OVER_SVC 99 -#define CMD_STOP_OBSESSING_OVER_SVC 100 - -#define CMD_START_OBSESSING_OVER_HOST 101 -#define CMD_STOP_OBSESSING_OVER_HOST 102 - -#define CMD_ENABLE_HOSTGROUP_HOST_CHECKS 103 -#define CMD_DISABLE_HOSTGROUP_HOST_CHECKS 104 - -#define CMD_ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS 105 -#define CMD_DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS 106 - -#define CMD_ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS 107 -#define CMD_DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS 108 - -#define CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS 109 -#define CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS 110 - -#define CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS 111 -#define CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS 112 - -#define CMD_ENABLE_SERVICEGROUP_SVC_CHECKS 113 -#define CMD_DISABLE_SERVICEGROUP_SVC_CHECKS 114 - -#define CMD_ENABLE_SERVICEGROUP_HOST_CHECKS 115 -#define CMD_DISABLE_SERVICEGROUP_HOST_CHECKS 116 - -#define CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS 117 -#define CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS 118 - -#define CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS 119 -#define CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS 120 - -#define CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME 121 -#define CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME 122 - -#define CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER 123 -#define CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER 124 - -#define CMD_CHANGE_HOST_EVENT_HANDLER 125 -#define CMD_CHANGE_SVC_EVENT_HANDLER 126 - -#define CMD_CHANGE_HOST_CHECK_COMMAND 127 -#define CMD_CHANGE_SVC_CHECK_COMMAND 128 - -#define CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL 129 -#define CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL 130 -#define CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL 131 - -#define CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS 132 -#define CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS 133 - -#define CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME 134 - -#define CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS 135 -#define CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS 136 - -#define CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME 137 - -#define CMD_ENABLE_SERVICE_FRESHNESS_CHECKS 138 -#define CMD_DISABLE_SERVICE_FRESHNESS_CHECKS 139 - -#define CMD_ENABLE_HOST_FRESHNESS_CHECKS 140 -#define CMD_DISABLE_HOST_FRESHNESS_CHECKS 141 - -#define CMD_SET_HOST_NOTIFICATION_NUMBER 142 -#define CMD_SET_SVC_NOTIFICATION_NUMBER 143 - -/* new commands in Nagios 3.x found below... */ -#define CMD_CHANGE_HOST_CHECK_TIMEPERIOD 144 -#define CMD_CHANGE_SVC_CHECK_TIMEPERIOD 145 - -#define CMD_PROCESS_FILE 146 - -#define CMD_CHANGE_CUSTOM_HOST_VAR 147 -#define CMD_CHANGE_CUSTOM_SVC_VAR 148 -#define CMD_CHANGE_CUSTOM_CONTACT_VAR 149 - -#define CMD_ENABLE_CONTACT_HOST_NOTIFICATIONS 150 -#define CMD_DISABLE_CONTACT_HOST_NOTIFICATIONS 151 -#define CMD_ENABLE_CONTACT_SVC_NOTIFICATIONS 152 -#define CMD_DISABLE_CONTACT_SVC_NOTIFICATIONS 153 - -#define CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS 154 -#define CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS 155 -#define CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS 156 -#define CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS 157 - -#define CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL 158 - -#define CMD_SEND_CUSTOM_HOST_NOTIFICATION 159 -#define CMD_SEND_CUSTOM_SVC_NOTIFICATION 160 - -#define CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD 161 -#define CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD 162 -#define CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD 163 -#define CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD 164 - -#define CMD_CHANGE_HOST_MODATTR 165 -#define CMD_CHANGE_SVC_MODATTR 166 -#define CMD_CHANGE_CONTACT_MODATTR 167 -#define CMD_CHANGE_CONTACT_MODHATTR 168 -#define CMD_CHANGE_CONTACT_MODSATTR 169 - -#define CMD_DEL_DOWNTIME_BY_HOST_NAME 170 -#define CMD_DEL_DOWNTIME_BY_HOSTGROUP_NAME 171 -#define CMD_DEL_DOWNTIME_BY_START_TIME_COMMENT 172 - -/* new commands in Nagios 4.x found below... */ -#define CMD_CLEAR_HOST_FLAPPING_STATE 173 -#define CMD_CLEAR_SVC_FLAPPING_STATE 174 - -/* custom command introduced in Nagios 3.x */ -#define CMD_CUSTOM_COMMAND 999 - -/**************************** COMMAND ERRORS *****************************/ -#define CMD_ERROR_OK 0 /* No errors encountered */ -#define CMD_ERROR_UNKNOWN_COMMAND 1 /* Unknown/unsupported command */ -#define CMD_ERROR_MALFORMED_COMMAND 2 /* Command malformed/missing timestamp? */ -#define CMD_ERROR_INTERNAL_ERROR 3 /* Internal error */ -#define CMD_ERROR_FAILURE 4 /* Command routine failed */ - -extern const char *cmd_error_strerror(int error_code); - -/**************************** CHECK TYPES ********************************/ - -#define CHECK_TYPE_ACTIVE 0 -#define CHECK_TYPE_PASSIVE 1 -#define CHECK_TYPE_PARENT 2 /* (active) check for the benefit of dependent objects */ -#define CHECK_TYPE_FILE 3 /* from spool files (yuck) */ -#define CHECK_TYPE_OTHER 4 /* for modules to use */ - - -/************* LEGACY (deprecated) CHECK TYPES ***************************/ - -#define SERVICE_CHECK_ACTIVE CHECK_TYPE_ACTIVE -#define SERVICE_CHECK_PASSIVE CHECK_TYPE_PASSIVE -#define HOST_CHECK_ACTIVE CHECK_TYPE_ACTIVE -#define HOST_CHECK_PASSIVE CHECK_TYPE_PASSIVE - - -/************************ SERVICE STATE TYPES ****************************/ - -#define SOFT_STATE 0 -#define HARD_STATE 1 - - -/************************* SCHEDULED DOWNTIME TYPES **********************/ - -#define SERVICE_DOWNTIME 1 /* service downtime */ -#define HOST_DOWNTIME 2 /* host downtime */ -#define ANY_DOWNTIME 3 /* host or service downtime */ - - -/************************** NOTIFICATION OPTIONS *************************/ - -#define NOTIFICATION_OPTION_NONE 0 -#define NOTIFICATION_OPTION_BROADCAST 1 -#define NOTIFICATION_OPTION_FORCED 2 -#define NOTIFICATION_OPTION_INCREMENT 4 - - -/************************** ACKNOWLEDGEMENT TYPES ************************/ - -#define HOST_ACKNOWLEDGEMENT 0 -#define SERVICE_ACKNOWLEDGEMENT 1 - -#define ACKNOWLEDGEMENT_NONE 0 -#define ACKNOWLEDGEMENT_NORMAL 1 -#define ACKNOWLEDGEMENT_STICKY 2 - - -/**************************** DEPENDENCY TYPES ***************************/ - -#define NOTIFICATION_DEPENDENCY 1 -#define EXECUTION_DEPENDENCY 2 - - - -/********************** HOST/SERVICE CHECK OPTIONS ***********************/ - -#define CHECK_OPTION_NONE 0 /* no check options */ -#define CHECK_OPTION_FORCE_EXECUTION 1 /* force execution of a check (ignores disabled services/hosts, invalid timeperiods) */ -#define CHECK_OPTION_FRESHNESS_CHECK 2 /* this is a freshness check */ -#define CHECK_OPTION_ORPHAN_CHECK 4 /* this is an orphan check */ -#define CHECK_OPTION_DEPENDENCY_CHECK 8 /* dependency check. different scheduling rules apply */ - - -/**************************** PROGRAM MODES ******************************/ - -#define STANDBY_MODE 0 -#define ACTIVE_MODE 1 - - -/************************** LOG ROTATION MODES ***************************/ - -#define LOG_ROTATION_NONE 0 -#define LOG_ROTATION_HOURLY 1 -#define LOG_ROTATION_DAILY 2 -#define LOG_ROTATION_WEEKLY 3 -#define LOG_ROTATION_MONTHLY 4 - - -/***************************** LOG VERSIONS ******************************/ - -#define LOG_VERSION_1 "1.0" -#define LOG_VERSION_2 "2.0" - - - -/*************************** CHECK STATISTICS ****************************/ - -#define ACTIVE_SCHEDULED_SERVICE_CHECK_STATS 0 -#define ACTIVE_ONDEMAND_SERVICE_CHECK_STATS 1 -#define PASSIVE_SERVICE_CHECK_STATS 2 -#define ACTIVE_SCHEDULED_HOST_CHECK_STATS 3 -#define ACTIVE_ONDEMAND_HOST_CHECK_STATS 4 -#define PASSIVE_HOST_CHECK_STATS 5 -#define ACTIVE_CACHED_HOST_CHECK_STATS 6 -#define ACTIVE_CACHED_SERVICE_CHECK_STATS 7 -#define EXTERNAL_COMMAND_STATS 8 -#define PARALLEL_HOST_CHECK_STATS 9 -#define SERIAL_HOST_CHECK_STATS 10 -#define MAX_CHECK_STATS_TYPES 11 - - -/****************** HOST CONFIG FILE READING OPTIONS ********************/ - -#define READ_HOSTS 1 -#define READ_HOSTGROUPS 2 -#define READ_CONTACTS 4 -#define READ_CONTACTGROUPS 8 -#define READ_SERVICES 16 -#define READ_COMMANDS 32 -#define READ_TIMEPERIODS 64 -#define READ_SERVICEESCALATIONS 128 -#define READ_HOSTGROUPESCALATIONS 256 /* no longer implemented */ -#define READ_SERVICEDEPENDENCIES 512 -#define READ_HOSTDEPENDENCIES 1024 -#define READ_HOSTESCALATIONS 2048 -#define READ_HOSTEXTINFO 4096 -#define READ_SERVICEEXTINFO 8192 -#define READ_SERVICEGROUPS 16384 - -#define READ_ALL_OBJECT_DATA READ_HOSTS | READ_HOSTGROUPS | READ_CONTACTS | READ_CONTACTGROUPS | READ_SERVICES | READ_COMMANDS | READ_TIMEPERIODS | READ_SERVICEESCALATIONS | READ_SERVICEDEPENDENCIES | READ_HOSTDEPENDENCIES | READ_HOSTESCALATIONS | READ_HOSTEXTINFO | READ_SERVICEEXTINFO | READ_SERVICEGROUPS - - -/************************** DATE/TIME TYPES *****************************/ - -#define LONG_DATE_TIME 0 -#define SHORT_DATE_TIME 1 -#define SHORT_DATE 2 -#define SHORT_TIME 3 -#define HTTP_DATE_TIME 4 /* time formatted for use in HTTP headers */ - - -/**************************** DATE FORMATS ******************************/ - -#define DATE_FORMAT_US 0 /* U.S. (MM-DD-YYYY HH:MM:SS) */ -#define DATE_FORMAT_EURO 1 /* European (DD-MM-YYYY HH:MM:SS) */ -#define DATE_FORMAT_ISO8601 2 /* ISO8601 (YYYY-MM-DD HH:MM:SS) */ -#define DATE_FORMAT_STRICT_ISO8601 3 /* ISO8601 (YYYY-MM-DDTHH:MM:SS) */ - - -/************************** MISC DEFINITIONS ****************************/ - -#define MAX_FILENAME_LENGTH 256 /* max length of path/filename that Nagios will process */ -#define MAX_INPUT_BUFFER 1024 /* size in bytes of max. input buffer (for reading files, misc stuff) */ -#define MAX_COMMAND_BUFFER 8192 /* max length of raw or processed command line */ -#define MAX_EXTERNAL_COMMAND_LENGTH 8192 /* max length of an external command */ - -#define MAX_DATETIME_LENGTH 48 - - -/************************* MODIFIED ATTRIBUTES **************************/ - -#define MODATTR_NONE 0 -#define MODATTR_NOTIFICATIONS_ENABLED 1 -#define MODATTR_ACTIVE_CHECKS_ENABLED 2 -#define MODATTR_PASSIVE_CHECKS_ENABLED 4 -#define MODATTR_EVENT_HANDLER_ENABLED 8 -#define MODATTR_FLAP_DETECTION_ENABLED 16 -#define MODATTR_FAILURE_PREDICTION_ENABLED 32 -#define MODATTR_PERFORMANCE_DATA_ENABLED 64 -#define MODATTR_OBSESSIVE_HANDLER_ENABLED 128 -#define MODATTR_EVENT_HANDLER_COMMAND 256 -#define MODATTR_CHECK_COMMAND 512 -#define MODATTR_NORMAL_CHECK_INTERVAL 1024 -#define MODATTR_RETRY_CHECK_INTERVAL 2048 -#define MODATTR_MAX_CHECK_ATTEMPTS 4096 -#define MODATTR_FRESHNESS_CHECKS_ENABLED 8192 -#define MODATTR_CHECK_TIMEPERIOD 16384 -#define MODATTR_CUSTOM_VARIABLE 32768 -#define MODATTR_NOTIFICATION_TIMEPERIOD 65536 -#endif /* NAGIOS_COMMON_H_INCLUDED */ diff --git a/devtools/ci/nagios/defaults.h b/devtools/ci/nagios/defaults.h deleted file mode 100644 index a2e05b3..0000000 --- a/devtools/ci/nagios/defaults.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef NAGIOS_DEFAULTS_H_INCLUDED -#define NAGIOS_DEFAULTS_H_INCLUDED - -/******************* DEFAULT VALUES *******************/ - -#define DEFAULT_LOG_LEVEL 1 /* log all events to main log file */ -#define DEFAULT_USE_SYSLOG 1 /* log events to syslog? 1=yes, 0=no */ -#define DEFAULT_SYSLOG_LEVEL 2 /* log only severe events to syslog */ - -#define DEFAULT_NOTIFICATION_LOGGING 1 /* log notification events? 1=yes, 0=no */ - -#define DEFAULT_INTER_CHECK_DELAY 5.0 /* seconds between initial service check scheduling */ -#define DEFAULT_INTERLEAVE_FACTOR 1 /* default interleave to use when scheduling checks */ -#define DEFAULT_RETRY_INTERVAL 30 /* services are retried in 30 seconds if they're not OK */ -#define DEFAULT_CHECK_REAPER_INTERVAL 10 /* interval in seconds to reap host and service check results */ -#define DEFAULT_MAX_REAPER_TIME 30 /* maximum number of seconds to spend reaping service checks before we break out for a while */ -#define DEFAULT_MAX_CHECK_RESULT_AGE 3600 /* maximum number of seconds that a check result file is considered to be valid */ -#define DEFAULT_MAX_PARALLEL_SERVICE_CHECKS 0 /* maximum number of service checks we can have running at any given time (0=unlimited) */ -#define DEFAULT_RETENTION_UPDATE_INTERVAL 60 /* minutes between auto-save of retention data */ -#define DEFAULT_RETENTION_SCHEDULING_HORIZON 900 /* max seconds between program restarts that we will preserve scheduling information */ -#define DEFAULT_STATUS_UPDATE_INTERVAL 60 /* seconds between aggregated status data updates */ -#define DEFAULT_FRESHNESS_CHECK_INTERVAL 60 /* seconds between service result freshness checks */ -#define DEFAULT_AUTO_RESCHEDULING_INTERVAL 30 /* seconds between host and service check rescheduling events */ -#define DEFAULT_AUTO_RESCHEDULING_WINDOW 180 /* window of time (in seconds) for which we should reschedule host and service checks */ -#define DEFAULT_ORPHAN_CHECK_INTERVAL 60 /* seconds between checks for orphaned hosts and services */ - -#define DEFAULT_INTERVAL_LENGTH 60 /* seconds per interval unit for check scheduling */ - -#define DEFAULT_NOTIFICATION_TIMEOUT 30 /* max time in seconds to wait for notification commands to complete */ -#define DEFAULT_EVENT_HANDLER_TIMEOUT 30 /* max time in seconds to wait for event handler commands to complete */ -#define DEFAULT_HOST_CHECK_TIMEOUT 30 /* max time in seconds to wait for host check commands to complete */ -#define DEFAULT_SERVICE_CHECK_TIMEOUT 60 /* max time in seconds to wait for service check commands to complete */ -#define DEFAULT_OCSP_TIMEOUT 15 /* max time in seconds to wait for obsessive compulsive processing commands to complete */ -#define DEFAULT_OCHP_TIMEOUT 15 /* max time in seconds to wait for obsessive compulsive processing commands to complete */ -#define DEFAULT_PERFDATA_TIMEOUT 5 /* max time in seconds to wait for performance data commands to complete */ -#define DEFAULT_TIME_CHANGE_THRESHOLD 900 /* compensate for time changes of more than 15 minutes */ - -#define DEFAULT_LOG_HOST_RETRIES 0 /* don't log host retries */ -#define DEFAULT_LOG_SERVICE_RETRIES 0 /* don't log service retries */ -#define DEFAULT_LOG_EVENT_HANDLERS 1 /* log event handlers */ -#define DEFAULT_LOG_INITIAL_STATES 0 /* don't log initial service and host states */ -#define DEFAULT_LOG_CURRENT_STATES 1 /* log current service and host states after rotating log */ -#define DEFAULT_LOG_EXTERNAL_COMMANDS 1 /* log external commands */ -#define DEFAULT_LOG_PASSIVE_CHECKS 1 /* log passive service checks */ - -#define DEFAULT_DEBUG_LEVEL 0 /* don't log any debugging information */ -#define DEFAULT_DEBUG_VERBOSITY 1 -#define DEFAULT_MAX_DEBUG_FILE_SIZE 1000000 /* max size of debug log */ - -#define DEFAULT_AGGRESSIVE_HOST_CHECKING 0 /* don't use "aggressive" host checking */ -#define DEFAULT_CHECK_EXTERNAL_COMMANDS 1 /* check for external commands */ -#define DEFAULT_CHECK_ORPHANED_SERVICES 1 /* check for orphaned services */ -#define DEFAULT_CHECK_ORPHANED_HOSTS 1 /* check for orphaned hosts */ -#define DEFAULT_ENABLE_FLAP_DETECTION 0 /* don't enable flap detection */ -#define DEFAULT_PROCESS_PERFORMANCE_DATA 0 /* don't process performance data */ -#define DEFAULT_CHECK_SERVICE_FRESHNESS 1 /* check service result freshness */ -#define DEFAULT_CHECK_HOST_FRESHNESS 0 /* don't check host result freshness */ -#define DEFAULT_AUTO_RESCHEDULE_CHECKS 0 /* don't auto-reschedule host and service checks */ -#define DEFAULT_TRANSLATE_PASSIVE_HOST_CHECKS 0 /* should we translate DOWN/UNREACHABLE passive host checks? */ -#define DEFAULT_PASSIVE_HOST_CHECKS_SOFT 0 /* passive host checks are treated as HARD by default */ - -#define DEFAULT_LOW_SERVICE_FLAP_THRESHOLD 20.0 /* low threshold for detection of service flapping */ -#define DEFAULT_HIGH_SERVICE_FLAP_THRESHOLD 30.0 /* high threshold for detection of service flapping */ -#define DEFAULT_LOW_HOST_FLAP_THRESHOLD 20.0 /* low threshold for detection of host flapping */ -#define DEFAULT_HIGH_HOST_FLAP_THRESHOLD 30.0 /* high threshold for detection of host flapping */ - -#define DEFAULT_HOST_CHECK_SPREAD 30 /* max minutes to schedule all initial host checks */ -#define DEFAULT_SERVICE_CHECK_SPREAD 30 /* max minutes to schedule all initial service checks */ - -#define DEFAULT_CACHED_HOST_CHECK_HORIZON 15 /* max age in seconds that cached host checks can be used */ -#define DEFAULT_CACHED_SERVICE_CHECK_HORIZON 15 /* max age in seconds that cached service checks can be used */ -#define DEFAULT_ENABLE_PREDICTIVE_HOST_DEPENDENCY_CHECKS 1 /* should we use predictive host dependency checks? */ -#define DEFAULT_ENABLE_PREDICTIVE_SERVICE_DEPENDENCY_CHECKS 1 /* should we use predictive service dependency checks? */ - -#define DEFAULT_USE_LARGE_INSTALLATION_TWEAKS 0 /* don't use tweaks for large Nagios installations */ - -#define DEFAULT_ADDITIONAL_FRESHNESS_LATENCY 15 /* seconds to be added to freshness thresholds when automatically calculated by Nagios */ - -#define DEFAULT_CHECK_FOR_UPDATES 1 /* should we check for new Nagios releases? */ -#define DEFAULT_BARE_UPDATE_CHECK 0 /* report current version and new installs */ -#define MINIMUM_UPDATE_CHECK_INTERVAL 60*60*22 /* 22 hours minimum between checks - please be kind to our servers! */ -#define BASE_UPDATE_CHECK_INTERVAL 60*60*22 /* 22 hours base interval */ -#define UPDATE_CHECK_INTERVAL_WOBBLE 60*60*4 /* 4 hour wobble on top of base interval */ -#define BASE_UPDATE_CHECK_RETRY_INTERVAL 60*60*1 /* 1 hour base retry interval */ -#define UPDATE_CHECK_RETRY_INTERVAL_WOBBLE 60*60*3 /* 3 hour wobble on top of base retry interval */ - -#define DEFAULT_ALLOW_EMPTY_HOSTGROUP_ASSIGNMENT 2 /* Allow assigning to empty hostgroups by default, but warn about it */ - -#define DEFAULT_HOST_PERFDATA_FILE_TEMPLATE "[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$" -#define DEFAULT_SERVICE_PERFDATA_FILE_TEMPLATE "[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$" -#define DEFAULT_HOST_PERFDATA_PROCESS_EMPTY_RESULTS 1 -#define DEFAULT_SERVICE_PERFDATA_PROCESS_EMPTY_RESULTS 1 - -#endif /* NAGIOS_DEFAULTS_H_INCLUDED */ diff --git a/devtools/ci/nagios/downtime.h b/devtools/ci/nagios/downtime.h deleted file mode 100644 index 4bee3d2..0000000 --- a/devtools/ci/nagios/downtime.h +++ /dev/null @@ -1,114 +0,0 @@ -/***************************************************************************** - * - * DOWNTIME.H - Header file for scheduled downtime functions - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - - -#ifndef NAGIOS_DOWNTIME_H_INCLUDED -#define NAGIOS_DOWNTIME_H_INCLUDED - -#include "common.h" -#include "objects.h" -#ifndef NSCGI -#include "nagios.h" -#endif - -NAGIOS_BEGIN_DECL - -/* SCHEDULED_DOWNTIME_ENTRY structure */ -typedef struct scheduled_downtime { - int type; - char *host_name; - char *service_description; - time_t entry_time; - time_t start_time; - time_t flex_downtime_start; /* Time the flexible downtime started */ - time_t end_time; - int fixed; - unsigned long triggered_by; - unsigned long duration; - unsigned long downtime_id; - int is_in_effect; - int start_notification_sent; - char *author; - char *comment; - unsigned long comment_id; -#ifndef NSCGI - int start_flex_downtime; - int incremented_pending_downtime; -#endif - struct scheduled_downtime *next; -#ifndef NSCGI - struct timed_event *start_event, *stop_event; -#endif - struct scheduled_downtime *prev; - } scheduled_downtime; - -extern struct scheduled_downtime *scheduled_downtime_list; - - -int initialize_downtime_data(void); /* initializes scheduled downtime data */ -int cleanup_downtime_data(void); /* cleans up scheduled downtime data */ - -#ifndef NSCGI -int add_new_downtime(int, char *, char *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long, unsigned long *, int, int); -int add_new_host_downtime(char *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long, unsigned long *, int, int); -int add_new_service_downtime(char *, char *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long, unsigned long *, int, int); - -int delete_host_downtime(unsigned long); -int delete_service_downtime(unsigned long); -int delete_downtime(int, unsigned long); - -int schedule_downtime(int, char *, char *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long, unsigned long *); -int unschedule_downtime(int, unsigned long); - -int register_downtime(int, unsigned long); -int handle_scheduled_downtime(struct scheduled_downtime *); -int handle_scheduled_downtime_by_id(unsigned long); - -int check_pending_flex_host_downtime(struct host *); -int check_pending_flex_service_downtime(struct service *); -int is_host_in_pending_flex_downtime(struct host *); -int is_service_in_pending_flex_downtime(struct service *); - -int check_for_expired_downtime(void); -#endif - -int add_host_downtime(char *, time_t, char *, char *, time_t, time_t, time_t, int, unsigned long, unsigned long, unsigned long, int, int); -int add_service_downtime(char *, char *, time_t, char *, char *, time_t, time_t, time_t, int, unsigned long, unsigned long, unsigned long, int, int); - -/* If you are going to be adding a lot of downtime in sequence, set - defer_downtime_sorting to 1 before you start and then call - sort_downtime afterwards. Things will go MUCH faster. */ - -extern int defer_downtime_sorting; -int add_downtime(int, char *, char *, time_t, char *, char *, time_t, time_t, time_t, int, unsigned long, unsigned long, unsigned long, int, int); -int sort_downtime(void); - -struct scheduled_downtime *find_downtime(int, unsigned long); -struct scheduled_downtime *find_host_downtime(unsigned long); -struct scheduled_downtime *find_service_downtime(unsigned long); - -void free_downtime_data(void); /* frees memory allocated to scheduled downtime list */ - -int delete_downtime_by_hostname_service_description_start_time_comment(char *, char *, time_t, char *); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/getcgi.h b/devtools/ci/nagios/getcgi.h deleted file mode 100644 index 76d8014..0000000 --- a/devtools/ci/nagios/getcgi.h +++ /dev/null @@ -1,39 +0,0 @@ -/****************************************************** - * - * GETCGI.H - Nagios CGI Input Routine Include File - * - * - *****************************************************/ - -#include "lib/lnag-utils.h" -NAGIOS_BEGIN_DECL - -#define ACCEPT_LANGUAGE_Q_DELIMITER ";q=" - -/* information for a single language in the variable HTTP_ACCEPT_LANGUAGE - sent by the browser */ -typedef struct accept_language_struct { - char * language; - char * locality; - double q; -} accept_language; - -/* information for all languages in the variable HTTP_ACCEPT_LANGUAGE - sent by the browser */ -typedef struct accept_languages_struct { - int count; - accept_language ** languages; -} accept_languages; - -char **getcgivars(void); -void free_cgivars(char **); -void unescape_cgi_input(char *); -void sanitize_cgi_input(char **); -unsigned char hex_to_char(char *); - -void process_language( char *); -accept_languages * parse_accept_languages( char *); -int compare_accept_languages( const void *, const void *); -void free_accept_languages( accept_languages *); - -NAGIOS_END_DECL diff --git a/devtools/ci/nagios/jsonutils.h b/devtools/ci/nagios/jsonutils.h deleted file mode 100644 index b6756a1..0000000 --- a/devtools/ci/nagios/jsonutils.h +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************** - * - * JSONUTILS.H - Utility information for Nagios CGI for that return - * JSON-formatted data - * - * Copyright (c) 2013 Nagios Enterprises, LLC - * Last Modified: 04-13-2013 - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - *************************************************************************/ - -#ifndef NAGIOS_JSONUTILS_H_INCLUDED -#define NAGIOS_JSONUTILS_H_INCLUDED - -/* JSON object definitions */ -#define JSON_TYPE_INVALID 0 -#define JSON_TYPE_OBJECT 1 -#define JSON_TYPE_ARRAY 2 -#define JSON_TYPE_INTEGER 3 -#define JSON_TYPE_REAL 4 -#define JSON_TYPE_TIME_T 5 -#define JSON_TYPE_STRING 6 -#define JSON_TYPE_BOOLEAN 7 -#define JSON_TYPE_DURATION 8 - -struct json_object_struct; - -typedef struct json_object_member_struct { - char *key; - unsigned type; - union { - long long integer; - unsigned long long unsigned_integer; - time_t time; - double real; - char * string; - unsigned boolean; - struct json_object_struct *object; - } value; - } json_object_member; - -typedef struct json_object_struct { - unsigned member_count; - json_object_member **members; - } json_object; - -typedef json_object json_array; - -/* Mapping from CGI query string option to value */ -typedef struct string_value_mapping_struct { - char *string; /* String to map from */ - unsigned value; /* Value to map to */ - char *description; /* Description of the meaning of the - string/value */ - } string_value_mapping; - -typedef struct option_help_struct { - const char * name; /* name used in query */ - const char * label; /* short label for name */ - const char * type; /* option type */ - /* If the type is of the form nagios:/, value values - for this option will be obtained by sending the query - 'http:///.cgi?objecttype=' */ - const char * required[25]; /* optiontypes required - for */ - const char * optional[25]; /* optiontypes optional - for */ - const char * depends_on; /* valid values dependent on - other option */ - const char * description; /* longer description */ - const string_value_mapping * valid_values; /* list of valid values */ - } option_help; - -/* String escaping structures */ -typedef struct json_escape_pair_struct { - const wchar_t *from; - const wchar_t *to; -} json_escape_pair; - -typedef struct json_escape_struct { - const int count; - const json_escape_pair *pairs; -} json_escape; - -/* Output Format Version */ -#define OUTPUT_FORMAT_VERSION 0 - -/* Result Types */ -#define RESULT_SUCCESS 0 -#define RESULT_MEMORY_ALLOCATION_ERROR 1 -#define RESULT_FILE_OPEN_READ_ERROR 2 -#define RESULT_OPTION_INVALID 3 -#define RESULT_OPTION_MISSING 4 -#define RESULT_OPTION_VALUE_MISSING 5 -#define RESULT_OPTION_VALUE_INVALID 6 -#define RESULT_OPTION_IGNORED 7 - -/* Boolean Values - Used when selecting true, false, or both */ -#define BOOLEAN_TRUE 1 -#define BOOLEAN_FALSE 2 -#define BOOLEAN_EITHER (BOOLEAN_TRUE | BOOLEAN_FALSE) - -/* Formatting Options */ -#define JSON_FORMAT_WHITESPACE (1<<0) -#define JSON_FORMAT_ENUMERATE (1<<1) -#define JSON_FORMAT_BITMASK (1<<2) -#define JSON_FORMAT_DURATION (1<<3) -#if 0 -#define JSON_FORMAT_DATETIME (1<<3) -#define JSON_FORMAT_DATE (1<<4) -#define JSON_FORMAT_TIME (1<<5) -#endif - -/* Possible Query Statuses */ -#define QUERY_STATUS_ALPHA 0 -#define QUERY_STATUS_BETA 1 -#define QUERY_STATUS_RELEASED 2 -#define QUERY_STATUS_DEPRECATED 3 - -extern const string_value_mapping svm_format_options[]; -extern const string_value_mapping svm_host_statuses[]; -extern const string_value_mapping svm_host_states[]; -extern const string_value_mapping svm_service_statuses[]; -extern const string_value_mapping svm_service_states[]; -extern const string_value_mapping svm_check_options[]; -extern const string_value_mapping svm_host_check_types[]; -extern const string_value_mapping svm_service_check_types[]; -extern const string_value_mapping svm_state_types[]; -extern const string_value_mapping svm_acknowledgement_types[]; -extern const string_value_mapping svm_comment_types[]; -extern const string_value_mapping svm_comment_entry_types[]; -extern const string_value_mapping svm_downtime_types[]; -extern const string_value_mapping parent_host_extras[]; -extern const string_value_mapping child_host_extras[]; -extern const string_value_mapping parent_service_extras[]; -extern const string_value_mapping child_service_extras[]; -#ifdef JSON_NAGIOS_4X -extern const string_value_mapping svm_option_types[]; -#endif - -extern const char *dayofweek[]; -extern const char *month[]; - -extern json_object *json_new_object(void); -extern void json_free_object(json_object *, int); -extern json_array *json_new_array(void); -extern void json_free_member(json_object_member *, int); -extern void json_object_append_object(json_object *, char *, json_object *); -extern void json_object_append_array(json_object *, char *, json_array *); -extern void json_object_append_integer(json_object *, char *, int); -extern void json_object_append_real(json_object *, char *, double); -extern void json_object_append_time(json_object *, char *, unsigned long); -extern void json_object_append_time_t(json_object *, char *, time_t); -extern void json_set_time_t(json_object_member *, time_t); -extern void json_object_append_string(json_object *, char *, - const json_escape *, char *, ...); -extern void json_object_append_boolean(json_object *, char *, int); -extern void json_array_append_object(json_array *, json_object *); -extern void json_array_append_array(json_array *, json_array *); -extern void json_array_append_integer(json_array *, int); -extern void json_array_append_real(json_array *, double); -extern void json_array_append_time(json_array *, unsigned long); -extern void json_array_append_time_t(json_array *, time_t); -extern void json_array_append_string(json_array *, const json_escape *, - char *, ...); -extern void json_array_append_boolean(json_array *, int); -extern void json_object_append_duration(json_object *, char *, unsigned long); -extern void json_array_append_duration(json_object *, unsigned long); -extern json_object_member *json_get_object_member(json_object *, char *); -extern json_object_member *json_get_array_member(json_object *, char *); -extern void json_object_print(json_object *, int, int, char *, unsigned); -extern void json_array_print(json_array *, int, int, char *, unsigned); -extern void json_member_print(json_object_member *, int, int, char *, unsigned); - -extern json_object *json_result(time_t, char *, char *, int, time_t, authdata *, - int, char *, ...); -extern json_object *json_help(option_help *); -extern int passes_start_and_count_limits(int, int, int, int); -extern void indentf(int, int, char *, ...); -extern void json_string(int, int, char *, char *); -extern void json_boolean(int, int, char *, int); -extern void json_int(int, int, char *, int); -extern void json_unsigned(int, int, char *, unsigned long long); -extern void json_float(int, int, char *, double); -extern void json_time(int, int, char *, unsigned long); -extern void json_time_t(int, int, char *, time_t, char *); -extern void json_duration(int, int, char *, unsigned long, int); - -extern void json_enumeration(json_object *, unsigned, char *, int, - const string_value_mapping *); -extern void json_bitmask(json_object *, unsigned, char *, int, - const string_value_mapping *); - -extern int parse_bitmask_cgivar(char *, char *, int, json_object *, time_t, - authdata *, char *, char *, const string_value_mapping *, unsigned *); -extern int parse_enumeration_cgivar(char *, char *, int, json_object *, - time_t, authdata *, char *, char *, const string_value_mapping *, - int *); -extern int parse_string_cgivar(char *, char *, int, json_object *, time_t, - authdata *, char *, char *, char **); -extern int parse_time_cgivar(char *, char *, int, json_object *, time_t, - authdata *, char *, char *, time_t *); -extern int parse_boolean_cgivar(char *, char *, int, json_object *, time_t, - authdata *, char *, char *, int *); -extern int parse_int_cgivar(char *, char *, int, json_object *, time_t, - authdata *, char *, char *, int *); - -extern int get_query_status(const int[][2], int); -extern char *svm_get_string_from_value(int, const string_value_mapping *); -extern char *svm_get_description_from_value(int, const string_value_mapping *); - -extern time_t compile_time(const char *, const char *); -extern char *json_escape_string(const char *, const json_escape *); -#endif diff --git a/devtools/ci/nagios/lib/bitmap.h b/devtools/ci/nagios/lib/bitmap.h deleted file mode 100644 index b729628..0000000 --- a/devtools/ci/nagios/lib/bitmap.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef LIBNAGIOS_bitmap_h__ -#define LIBNAGIOS_bitmap_h__ - -/** - * @file bitmap.h - * @brief Bit map API - * - * The bitmap api is useful for running set operations on objects - * indexed by unsigned integers. - * @{ - */ -struct bitmap; -typedef struct bitmap bitmap; - -/** - * Resize a bitmap - * If the bitmap is made smaller, data will silently be lost. - * - * @param bm The bitmap to resize - * @param size The new desired size of the bitmap - * @return 0 on success, -1 on errors. - */ -extern int bitmap_resize(bitmap *bm, unsigned long size); - -/** - * Create a bitmaptor of size 'size' - * @param size Desired storage capacity - * @return A bitmap pointer on success, NULL on errors - */ -extern bitmap *bitmap_create(unsigned long size); - -/** - * Destroy a bitmaptor by freeing all the memory it uses - * @param bm The bitmaptor to destroy - */ -extern void bitmap_destroy(bitmap *bm); - -/** - * Copy a bitmaptor - * @param bm The bitmaptor to copy - * @return Pointer to an identical bitmap on success, NULL on errors - */ -extern bitmap *bitmap_copy(const bitmap *bm); - -/** - * Set a bit in the map - * @param bm The bitmaptor to operate on - * @param pos Position of the bit to set - * @return 0 on success, -1 on errors - */ -extern int bitmap_set(bitmap *bm, unsigned long pos); - -/** - * Check if a particular bit is set in the map - * @param bm The bitmaptor to check - * @param pos Position of the bit to check - * @return 1 if set, otherwise 0 - */ -extern int bitmap_isset(const bitmap *bm, unsigned long pos); - -/** - * Unset a particular bit in the map - * @param bm The bitmaptor to operate on - * @param pos Position of the bit to unset - */ -extern int bitmap_unset(bitmap *bm, unsigned long pos); - -/** - * Obtain cardinality (max number of elements) of the bitmaptor - * @param bm The bitmaptor to check - * @return The cardinality of the bitmaptor - */ -extern unsigned long bitmap_cardinality(const bitmap *bm); -#define bitmap_size bitmap_cardinality - -/** - * Count set bits in map. Completed in O(n/8) time. - * @param bm The bitmaptor to count bits in - * @return The number of set bits - */ -extern unsigned long bitmap_count_set_bits(const bitmap *bm); - -/** - * Count unset bits in map. Completed in O(n/8) time. - * @param bm The bitmaptor to count bits in - * @return The number of set bits - */ -extern unsigned long bitmap_count_unset_bits(const bitmap *bm); - -/** - * Unset all bits in a bitmap - * @param bm The bitmap to clear - */ -extern void bitmap_clear(bitmap *bm); - -/** - * Calculate intersection of two bitmaps - * The intersection is defined as all bits that are members of - * both A and B. It's equivalent to bitwise AND. - * This function completes in O(n/sizeof(long)) operations. - * @param a The first bitmaptor - * @param b The second bitmaptor - * @return NULL on errors; A newly created bitmaptor on success. - */ -extern bitmap *bitmap_intersect(const bitmap *a, const bitmap *b); - -/** - * Calculate union of two bitmaps - * The union is defined as all bits that are members of - * A or B or both A and B. It's equivalent to bitwise OR. - * This function completes in O(n/sizeof(long)) operations. - * @param a The first bitmaptor - * @param b The second bitmaptor - * @return NULL on errors; A newly created bitmaptor on success. - */ -extern bitmap *bitmap_union(const bitmap *a, const bitmap *b); - -/** - * Calculate union of two bitmaps and store result in one of them - * @param res The first bitmap - * @param addme The bitmap to unite to the first bitmap - * @return NULL on errors, res on success - */ -extern bitmap *bitmap_unite(bitmap *res, const bitmap *addme); - -/** - * Calculate set difference between two bitmaps - * The set difference of A / B is defined as all members of A - * that isn't members of B. Note that parameter ordering matters - * for this function. - * This function completes in O(n/sizeof(long)) operations. - * @param a The first bitmaptor (numerator) - * @param b The first bitmaptor (denominator) - * @return NULL on errors; A newly created bitmaptor on success. - */ -extern bitmap *bitmap_diff(const bitmap *a, const bitmap *b); - -/** - * Calculate symmetric difference between two bitmaps - * The symmetric difference between A and B is the set that - * contains all elements in either set but not in both. - * This function completes in O(n/sizeof(long)) operations. - * @param a The first bitmaptor - * @param b The second bitmaptor - */ -extern bitmap *bitmap_symdiff(const bitmap *a, const bitmap *b); - -/** - * Compare two bitmaps for equality - * @param a The first bitmaptor - * @param b The other bitmaptor - * @return Similar to memcmp(), with tiebreaks determined by cardinality - */ -extern int bitmap_cmp(const bitmap *a, const bitmap *b); -/** @} */ -#endif /* LIBNAGIOS_bitmap_h__ */ diff --git a/devtools/ci/nagios/lib/dkhash.h b/devtools/ci/nagios/lib/dkhash.h deleted file mode 100644 index b2e1ff3..0000000 --- a/devtools/ci/nagios/lib/dkhash.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef LIBNAGIOS_DKHASH_H_INCLUDED -#define LIBNAGIOS_DKHASH_H_INCLUDED -#include - -/** - * @file dkhash.h - * @brief Dual-key hash functions for Nagios - * - * Having a dual-key hash function is pretty unusual, but since so - * much data in Nagios pertains to services (which are uniquely - * identified based on both host_name and service_description), it - * makes sense here. - * - * @{ - */ - -/** return flags usable from the callback function of dkhash_walk_data() */ -#define DKHASH_WALK_REMOVE 1 /**< Remove the most recently visited object */ -#define DKHASH_WALK_STOP 2 /**< Cause walking to stop */ - -/** return values for dkhash_insert() */ -#define DKHASH_OK 0 /**< Success */ -#define DKHASH_EDUPE (-EPERM) /**< duplicate insert attempted */ -#define DKHASH_EPERM (-EPERM) /**< duplicate insert attempted */ -#define DKHASH_EINVAL (-EINVAL) /**< Invalid parameters passed */ -#define DKHASH_ENOMEM (-ENOMEM) /**< Memory allocation failed */ - -struct dkhash_table; -/** opaque type */ -typedef struct dkhash_table dkhash_table; - -/** - * Create a dual-keyed hash-table of the given size - * Note that it's generally useful to make the table 25-30% larger - * than the number of items you intend to store, and also note that - * the 'size' arguments gets rounded up to the nearest power of 2. - * @param size The desired size of the hash-table. - */ -extern dkhash_table *dkhash_create(unsigned int size); - -/** - * Destroy a dual-keyed hash table - * @param t The table to destroy - * @return 0 on success, -1 on errors - */ -extern int dkhash_destroy(dkhash_table *t); - -/** - * Fetch the data associated with a particular key - * @param t The table to get the data from - * @param k1 The first key - * @param k2 The second key - * @return The data on success, NULL on errors or if data isn't found - */ -extern void *dkhash_get(dkhash_table *t, const char *k1, const char *k2); - -/** - * Insert a new entry into the hash table - * @param t The hash table - * @param k1 The first key - * @param k2 The second key (may be null) - * @param data The data to insert - * @return 0 on success, < 0 on errors - */ -extern int dkhash_insert(dkhash_table *t, const char *k1, const char *k2, void *data); - -/** - * Remove data from the hash table - * Note that this does not free() the pointer to the data stored in the - * table. It just destroys containers for that data in the hash table. - * @param t The hash table - * @param k1 The first key - * @param k2 The second key - * @return The removed data on success, or NULL on errors - */ -extern void *dkhash_remove(dkhash_table *t, const char *k1, const char *k2); - -/** - * Call a function once for each item in the hash-table - * The callback function can return DKHASH_WALK_{REMOVE,STOP} or any - * OR'ed combination thereof to control the walking procedure, and - * should return 0 on the normal case. - * @param t The hash table - * @param walker The callback function to send the data to - */ -extern void dkhash_walk_data(dkhash_table *t, int (*walker)(void *data)); - - -/** - * Get number of collisions in hash table - * Many collisions is a sign of a too small hash table or - * poor hash-function. - * @param t The hash table to report on - * @return The total number of collisions (not duplicates) from inserts - */ -extern unsigned int dkhash_collisions(dkhash_table *t); - -/** - * Get number of items in the hash table - * @param t The hash table - * @return Number of items currently in the hash-table - */ -extern unsigned int dkhash_num_entries(dkhash_table *t); - -/** - * Get max number of items stored in the hash table - * @param t The hash table - * @return Max number of items stored in hash-table - */ -extern unsigned int dkhash_num_entries_max(dkhash_table *t); - -/** - * Get number of entries added to hash table - * Note that some of them may have been removed. - * @param t The hash table - * @return The number of items added to the table - */ -extern unsigned int dkhash_num_entries_added(dkhash_table *t); - -/** - * Get number of removed items from hash table - * @param t The hash table - * @return Number of items removed from hash table - */ -extern unsigned int dkhash_num_entries_removed(dkhash_table *t); - -/** - * Get actual table size (in number of buckets) - * @param t The hash table - * @return Number of bucket-slots in hash table - */ -extern unsigned int dkhash_table_size(dkhash_table *t); -/** @} */ -#endif /* LIBNAGIOS_DKHASH_H_INCLUDED */ diff --git a/devtools/ci/nagios/lib/fanout.h b/devtools/ci/nagios/lib/fanout.h deleted file mode 100644 index d1164dd..0000000 --- a/devtools/ci/nagios/lib/fanout.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef LIBNAGIOS_FANOUT_H_INCLUDED -#define LIBNAGIOS_FANOUT_H_INCLUDED -#include "lnag-utils.h" - -/** - * @file fanout.h - * @brief Simple fanout table implementation - * - * Fanouts are useful to hold short-lived integer-indexed data where - * the keyspan between smallest and largest key can be too large and - * change too often for it to be practical to maintain a growing array. - * If you think of it as a hash-table optimized for unsigned longs you've - * got the right idea. - * - * @{ - */ - -NAGIOS_BEGIN_DECL - -/** Primary (opaque) type for this api */ -typedef struct fanout_table fanout_table; - -/** - * Create a fanout table - * @param[in] size The size of the table. Preferably a power of 2 - * @return Pointer to a newly created table - */ -extern fanout_table *fanout_create(unsigned long size); - -/** - * Destroy a fanout table, with optional destructor. - * This function will iterate over all the entries in the fanout - * table and remove them, one by one. If 'destructor' is not NULL, - * it will be called on each and every object in the table. Note that - * 'free' is a valid destructor. - * - * @param[in] t The fanout table to destroy - * @param[in] destructor Function to call on data pointers in table - */ -extern void fanout_destroy(fanout_table *t, void (*destructor)(void *)); - -/** - * Return a pointer from the fanout table t - * - * @param[in] t table to fetch from - * @param[in] key key to fetch - * @return NULL on errors; Pointer to data on success - */ -extern void *fanout_get(fanout_table *t, unsigned long key); - -/** - * Add an entry to the fanout table. - * Note that we don't check if the key is unique. If it isn't, - * fanout_remove() will remove the latest added first. - * - * @param[in] t fanout table to add to - * @param[in] key Key for this entry - * @param[in] data Data to add. Must not be NULL - * @return 0 on success, -1 on errors - */ -extern int fanout_add(fanout_table *t, unsigned long key, void *data); - -/** - * Remove an entry from the fanout table and return its data. - * - * @param[in] t fanout table to look in - * @param[in] key The key whose data we should locate - * @return Pointer to the data stored on success; NULL on errors - */ -extern void *fanout_remove(fanout_table *t, unsigned long key); -NAGIOS_END_DECL -/** @} */ -#endif diff --git a/devtools/ci/nagios/lib/iobroker.h b/devtools/ci/nagios/lib/iobroker.h deleted file mode 100644 index d19495e..0000000 --- a/devtools/ci/nagios/lib/iobroker.h +++ /dev/null @@ -1,175 +0,0 @@ -/* lib/iobroker.h. Generated from iobroker.h.in by configure. */ -#ifndef LIBNAGIOS_iobroker_h__ -#define LIBNAGIOS_iobroker_h__ - -/** - * @file iobroker.h - * @brief I/O broker library function declarations - * - * The I/O broker library handles multiplexing between hundreds or - * thousands of sockets with a few simple calls. It's designed to - * be as lightweight as possible so as to not cause memory bloat, - * and is therefore highly suitable for use by processes that are - * fork()-intensive. - * - * @{ - */ - -#define IOBROKER_USES_EPOLL 1 -/* #undef IOBROKER_USES_POLL */ -/* #undef IOBROKER_USES_SELECT */ - -#if (_POSIX_C_SOURCE - 0) >= 200112L -#include -# define IOBROKER_POLLIN POLLIN -# define IOBROKER_POLLPRI POLLPRI -# define IOBROKER_POLLOUT POLLOUT - -# define IOBROKER_POLLERR POLLERR -# define IOBROKER_POLLHUP POLLHUP -# define IOBROKER_POLLNVAL POLLNVAL -#else -# define IOBROKER_POLLIN 0x001 /* there is data to read */ -# define IOBROKER_POLLPRI 0x002 /* there is urgent data to read */ -# define IOBROKER_POLLOUT 0x004 /* writing now will not block */ - -# define IOBROKER_POLLERR 0x008 /* error condition */ -# define IOBROKER_POLLHUP 0x010 /* hung up */ -# define IOBROKER_POLLNVAL 0x020 /* invalid polling request */ -#endif - -/** return codes */ -#define IOBROKER_SUCCESS 0 -#define IOBROKER_ENOSET (-1) -#define IOBROKER_ENOINIT (-2) -#define IOBROKER_ELIB (-3) -#define IOBROKER_EALREADY (-EALREADY) -#define IOBROKER_EINVAL (-EINVAL) - - -/** Flags for iobroker_destroy() */ -#define IOBROKER_CLOSE_SOCKETS 1 - -/* Opaque type. Callers needn't worry about this */ -struct iobroker_set; -typedef struct iobroker_set iobroker_set; - -/** - * Get a string describing the error in the last iobroker call. - * The returned string must not be free()'d. - * @param error The error code - * @return A string describing the meaning of the error code - */ -extern const char *iobroker_strerror(int error); - -/** - * Create a new socket set - * @return An iobroker_set on success. NULL on errors. - */ -extern iobroker_set *iobroker_create(void); - -/** - * Published utility function used to determine the max number of - * file descriptors this process can keep open at any one time. - * @return Max number of filedescriptors we can keep open - */ -extern int iobroker_max_usable_fds(void); - -/** - * Register a socket for input polling with the broker. - * - * @param iobs The socket set to add the socket to. - * @param sd The socket descriptor to add - * @param arg Argument passed to input handler on available input - * @param handler The callback function to call when input is available - * - * @return 0 on success. < 0 on errors. - */ -extern int iobroker_register(iobroker_set *iobs, int sd, void *arg, int (*handler)(int, int, void *)); - - -/** - * Register a socket for output polling with the broker - * @note There's no guarantee that *ALL* data is writable just - * because the socket won't block you completely. - * - * @param iobs The socket set to add the socket to. - * @param sd The socket descriptor to add - * @param arg Argument passed to output handler on ready-to-write - * @param handler The function to call when output won't block - * - * @return 0 on success. < 0 on errors - */ -extern int iobroker_register_out(iobroker_set *iobs, int sd, void *arg, int (*handler)(int, int, void *)); - -/** - * Check if a particular filedescriptor is registered with the iobroker set - * @param[in] iobs The iobroker set the filedescriptor should be member of - * @param[in] fd The filedescriptor to check for - * @return 1 if the filedescriptor is registered and 0 otherwise - */ -extern int iobroker_is_registered(iobroker_set *iobs, int fd); - -/** - * Getter function for number of file descriptors registered in - * the set specified. - * @param iobs The io broker set to query - * @return Number of file descriptors registered in the set - */ -extern int iobroker_get_num_fds(iobroker_set *iobs); - -/** - * Getter function for the maximum amount of file descriptors this - * set can handle. - * @param iobs The io broker set to query - * @return Max file descriptor capacity for the set - */ -extern int iobroker_get_max_fds(iobroker_set *iobs); - -/** - * Unregister a socket for input polling with the broker. - * - * @param iobs The socket set to remove the socket from - * @param sd The socket descriptor to remove - * @return 0 on success. < 0 on errors. - */ -extern int iobroker_unregister(iobroker_set *iobs, int sd); - -/** - * Deregister a socket for input polling with the broker - * (this is identical to iobroker_unregister()) - * @param iobs The socket set to remove the socket from - * @param sd The socket descriptor to remove - * @return 0 on success. < 0 on errors. - */ -extern int iobroker_deregister(iobroker_set *iobs, int sd); - -/** - * Unregister and close(2) a socket registered for input with the - * broker. This is a convenience function which exists only to avoid - * doing multiple calls when read() returns 0, as closed sockets must - * always be removed from the socket set to avoid consuming tons of - * cpu power from iterating "too fast" over the file descriptors. - * - * @param iobs The socket set to remove the socket from - * @param sd The socket descriptor to remove and close - * @return 0 on success. < 0 on errors - */ -extern int iobroker_close(iobroker_set *iobs, int sd); - -/** - * Destroy a socket set as created by iobroker_create - * @param iobs The socket set to destroy - * @param flags If set, close(2) all registered sockets - */ -extern void iobroker_destroy(iobroker_set *iobs, int flags); - -/** - * Wait for input on any of the registered sockets. - * @param iobs The socket set to wait for. - * @param timeout Timeout in milliseconds. -1 is "wait indefinitely" - * @return -1 on errors, or number of filedescriptors with input - */ -extern int iobroker_poll(iobroker_set *iobs, int timeout); -#endif /* INCLUDE_iobroker_h__ */ -/** @} */ diff --git a/devtools/ci/nagios/lib/iocache.h b/devtools/ci/nagios/lib/iocache.h deleted file mode 100644 index 70e75a3..0000000 --- a/devtools/ci/nagios/lib/iocache.h +++ /dev/null @@ -1,181 +0,0 @@ -#ifndef LIBNAGIOS_IOCACHE_H_INCLUDED -#define LIBNAGIOS_IOCACHE_H_INCLUDED -#include -#include -#include - -/** - * @file iocache.h - * @brief I/O cache function declarations - * - * The I/O cache library is useful for reading large chunks of data - * from sockets and utilizing parts of that data based on either - * size or a magic delimiter. - * - * @{ - */ - -/** opaque type for iocache operations */ -struct iocache; -typedef struct iocache iocache; - -/** - * Destroys an iocache object, freeing all memory allocated to it. - * @param ioc The iocache object to destroy - */ -extern void iocache_destroy(iocache *ioc); - -/** - * Resets an iocache struct, discarding all data in it without free()'ing - * any memory. - * - * @param[in] ioc The iocache struct to reset - */ -extern void iocache_reset(iocache *ioc); - -/** - * Resizes the buffer in an io cache - * @param ioc The io cache to resize - * @param new_size The new size of the io cache - * @return 0 on success, -1 on errors - */ -extern int iocache_resize(iocache *ioc, unsigned long new_size); - -/** - * Grows an iocache object - * This uses iocache_resize() internally - * @param[in] ioc The iocache to grow - * @param[in] increment How much to increase it - * @return 0 on success, -1 on errors - */ -extern int iocache_grow(iocache *ioc, unsigned long increment); - -/** - * Returns the total size of the io cache - * @param[in] ioc The iocache to inspect - * @return The size of the io cache. If ioc is null, 0 is returned - */ -extern unsigned long iocache_size(iocache *ioc); - -/** - * Returns remaining read capacity of the io cache - * @param ioc The io cache to operate on - * @return The number of bytes available to read, or -1 if ioc is null, -2 if the buffer is null, or -2 if the buffer size is <= 0 - */ -extern unsigned long iocache_capacity(iocache *ioc); - -/** - * Return the amount of unread but stored data in the io cache - * @param ioc The io cache to operate on - * @return Number of bytes available to read - */ -extern unsigned long iocache_available(iocache *ioc); - -/** - * Use a chunk of data from iocache based on size. The caller - * must take care not to write beyond the end of the requested - * buffer, or Bad Things(tm) will happen. - * - * @param ioc The io cache we should use data from - * @param size The size of the data we want returned - * @return NULL on errors (insufficient data, fe). pointer on success - */ -extern char *iocache_use_size(iocache *ioc, unsigned long size); - -/** - * Use a chunk of data from iocache based on delimiter. The - * caller must take care not to write beyond the end of the - * requested buffer, if any is returned, or Bad Things(tm) will - * happen. - * - * @param ioc The io cache to use data from - * @param delim The delimiter - * @param delim_len Length of the delimiter - * @param size Length of the returned buffer - * @return NULL on errors (delimiter not found, insufficient data). pointer on success - */ -extern char *iocache_use_delim(iocache *ioc, const char *delim, size_t delim_len, unsigned long *size); - -/** - * Forget that a specified number of bytes have been used. - * @param ioc The io cache that you want to un-use data in - * @param size The number of bytes you want to forget you've seen - * @return -1 if there was an error, 0 otherwise. - */ -extern int iocache_unuse_size(iocache *ioc, unsigned long size); - -/** - * Creates the iocache object, initializing it with the given size - * @param size Initial size of the iocache buffer - * @return Pointer to a valid iocache object - */ -extern iocache *iocache_create(unsigned long size); - -/** - * Read data into the iocache buffer - * @param ioc The io cache we should read into - * @param fd The filedescriptor we should read from - * @return The number of bytes read on success. < 0 on errors - */ -extern int iocache_read(iocache *ioc, int fd); - -/** - * Add data to the iocache buffer - * The data is copied, so it can safely be taken from the stack in a - * function that returns before the data is used. - * If the io cache is too small to hold the data, -1 will be returned. - * - * @param[in] ioc The io cache to add to - * @param[in] buf Pointer to the data we should add - * @param[in] len Length (in bytes) of data pointed to by buf - * @return iocache_available(ioc) on success, -1 on errors - */ -extern int iocache_add(iocache *ioc, char *buf, unsigned int len); - -/** - * Like sendto(), but sends all cached data prior to the requested - * - * @param[in] ioc The iocache to send, or cache data in - * @param[in] fd The file descriptor to send to - * @param[in] buf Pointer to the data to send - * @param[in] len Length (in bytes) of data to send - * @param[in] flags Flags passed to sendto(2) - * @param[in] dest_addr Destination address - * @param[in] addrlen size (in bytes) of dest_addr - * @return bytes sent on success, -ERRNO on errors - */ -extern int iocache_sendto(iocache *ioc, int fd, char *buf, unsigned int len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); - -/** - * Like send(2), but sends all cached data prior to the requested - * This function uses iocache_sendto() internally, but can only be - * used on connected sockets or open()'ed files. - * - * @param[in] ioc The iocache to send, or cache data in - * @param[in] fd The file descriptor to send to - * @param[in] buf Pointer to the data to send - * @param[in] len Length (in bytes) of data to send - * @param[in] flags Flags passed to sendto(2) - * @return bytes sent on success, -ERRNO on errors - */ -static inline int iocache_send(iocache *ioc, int fd, char *buf, unsigned int len, int flags) -{ - return iocache_sendto(ioc, fd, buf, len, flags, NULL, 0); -} - -/** - * Like write(2), but sends all cached data prior to the requested - * This function uses iocache_send() internally. - * - * @param[in] ioc The iocache to send, or cache data in - * @param[in] fd The file descriptor to send to - * @param[in] buf Pointer to the data to send - * @param[in] len Length (in bytes) of data to send - * @return bytes sent on success, -ERRNO on errors - */ -static inline int iocache_write(iocache *ioc, int fd, char *buf, unsigned int len) -{ - return iocache_send(ioc, fd, buf, len, 0); -} -#endif /* INCLUDE_iocache_h__ */ -/** @} */ diff --git a/devtools/ci/nagios/lib/kvvec.h b/devtools/ci/nagios/lib/kvvec.h deleted file mode 100644 index 49be959..0000000 --- a/devtools/ci/nagios/lib/kvvec.h +++ /dev/null @@ -1,207 +0,0 @@ -#ifndef LIBNAGIOS_KVVEC_H_INCLUDED -#define LIBNAGIOS_KVVEC_H_INCLUDED - -/** - * @file kvvec.h - * @brief Key/value vector library function and type declarations - * - * The kvvec library is nifty as either a configuration meta-format - * or for IPC purposes. Take a look at the buf2kvvec() and kvvec2buf() - * pair of functions for the latter. - * @{ - */ - -/** - * key/value pair - * One of the two major components of the kvvec api - */ -struct key_value { - char *key; /**< The key */ - char *value; /**< The value */ - int key_len; /**< Length of key */ - int value_len; /**< Length of value */ -}; - -/** - * key/value vector buffer. Actually just a buffer, but one that gets - * used as return value and internal tracker for kvvec2buf() - */ -struct kvvec_buf { - char *buf; /**< The buffer */ - unsigned long buflen; /**< Length of buffer */ - unsigned long bufsize; /**< Size of buffer (includes overalloc) */ -}; - -/** - * key/value vector struct - * This is the main component of the kvvec library - * @note This should be made opaque, with a kvvec_foreach() using a - * callback to iterate over key/value pairs. - */ -struct kvvec { - struct key_value *kv; /**< The key/value array */ - int kv_alloc; /**< Allocated size of key/value array */ - int kv_pairs; /**< Number of key/value pairs */ - int kvv_sorted; /**< Determines if this kvvec has been sorted */ -}; - -/** Portable initializer for stack-allocated key/value vectors */ -#define KVVEC_INITIALIZER { NULL, 0, 0, 0 } - -/** Parameters for kvvec_destroy() */ -#define KVVEC_FREE_KEYS 1 /**< Free keys when destroying a kv vector */ -#define KVVEC_FREE_VALUES 2 /**< Free values when destroying a kv vector */ -/** Free both keys and values when destroying a kv vector */ -#define KVVEC_FREE_ALL (KVVEC_FREE_KEYS | KVVEC_FREE_VALUES) - -#define KVVEC_ASSIGN 0 /**< Assign from buf in buf2kvvec_prealloc() */ -#define KVVEC_COPY 1 /**< Copy from buf in buf2kvvec_prealloc() */ -#define KVVEC_APPEND 2 /**< Don't reset kvvec in buf2kvvec_prealloc() */ - -/** - * Initialize a previously allocated key/value vector - * - * @param kvv The key/value vector to initialize - * @param hint Number of key/value pairs we expect to store - * @return Pointer to a struct kvvec, properly initialized - */ -extern struct kvvec *kvvec_init(struct kvvec *kvv, int hint); - -/** - * Create a key/value vector - * - * @param hint Number of key/value pairs we expect to store - * @return Pointer to a struct kvvec, properly initialized - */ -extern struct kvvec *kvvec_create(int hint); - -/** - * Resize a key/value vector - * Used by kvvec_grow(). If size is smaller than the current number of - * used key/value slots, -1 is returned. - * - * @param[in] kvv The key/value vector to resize - * @param[in] size The size to grow to - * @return 0 on success, < 0 on errors - */ -extern int kvvec_resize(struct kvvec *kvv, int size); - -/** - * Grow a key/value vector. - * Used internally as needed by the kvvec api. If 'hint' is zero, the - * key/value capacity is increased by a third of the current capacity - * plus a small constant number. This uses kvvec_resize() internally. - * - * @param kvv The key/value vector to grow - * @param hint The amount of key/value slots we should grow by - * @return 0 on success, < 0 on errors - */ -extern int kvvec_grow(struct kvvec *kvv, int hint); - -/** - * Return remaining storage capacity of key/value vector - * @param[in] kvv The key/value vector to check - * @return Number of key/value pairs that can be stored without growing - */ -extern unsigned int kvvec_capacity(struct kvvec *kvv); - -/** - * Sort a key/value vector alphabetically by key name - * @param kvv The key/value vector to sort - * @return 0 - */ -extern int kvvec_sort(struct kvvec *kvv); - -/** - * Add a key/value pair to an existing key/value vector, with - * lengths of strings already calculated - * @param kvv The key/value vector to add this key/value pair to - * @param key The key - * @param keylen Length of the key - * @param value The value - * @param valuelen Length of the value - * @return 0 on success, < 0 on errors - */ -extern int kvvec_addkv_wlen(struct kvvec *kvv, const char *key, int keylen, const char *value, int valuelen); - -/** - * Shortcut to kvvec_addkv_wlen() when lengths aren't known - * @param kvv The key/value vector to add this key/value pair to - * @param key The key - * @param value The value - * @return 0 on success, < 0 on errors - */ -#define kvvec_addkv(kvv, key, value) kvvec_addkv_wlen(kvv, key, 0, value, 0) - -/** - * Walk each key/value pair in a key/value vector, sending them - * as arguments to a callback function. The callback function has - * no control over the iteration process and must not delete or - * modify the key/value vector it's operating on. - * @param kvv The key/value vector to walk - * @param arg Extra argument to the callback function - * @param callback Callback function - * @return 0 on success, < 0 on errors - */ -extern int kvvec_foreach(struct kvvec *kvv, void *arg, int (*callback)(struct key_value *, void *)); - -/** - * Destroy a key/value vector - * @param kvv The key/value vector to destroy - * @param flags or'ed combination of KVVEC_FREE_{KEYS,VALUES}, or KVVEC_FREE_ALL - * @return 0 on success, < 0 on errors - */ -extern int kvvec_destroy(struct kvvec *kvv, int flags); - -/** - * Free key/value pairs associated with a key/value vector - * @param kvv The key/value vector to operate on - * @param flags flags or'ed combination of KVVEC_FREE_{KEYS,VALUES}, or KVVEC_FREE_ALL - */ -void kvvec_free_kvpairs(struct kvvec *kvv, int flags); - -/** - * Create a linear buffer of all the key/value pairs and - * return it as a kvvec_buf. The caller must free() all - * pointers in the returned kvvec_buf - * (FIXME: add kvvec_buf_destroy(), or move this and its counterpart - * out of the kvvec api into a separate one) - * - * @param kvv The key/value vector to convert - * @param kv_sep Character separating keys and their values - * @param pair_sep Character separating key/value pairs - * @param overalloc Integer determining how much extra data we should - * allocate. The overallocated memory is filled with - * nul bytes. - * @return A pointer to a newly created kvvec_buf structure - */ -extern struct kvvec_buf *kvvec2buf(struct kvvec *kvv, char kv_sep, char pair_sep, int overalloc); - -/** - * Create a key/value vector from a pre-parsed buffer. Immensely - * useful for ipc in combination with kvvec2buf(). - * - * @param str The buffer to convert to a key/value vector - * @param len Length of buffer to convert - * @param kvsep Character separating key and value - * @param pair_sep Character separating key/value pairs - * @param flags bitmask. See KVVEC_{ASSIGN,COPY,APPEND} for values - * @return The created key/value vector - */ -extern struct kvvec *buf2kvvec(char *str, unsigned int len, const char kvsep, const char pair_sep, int flags); - -/** - * Parse a buffer into the pre-allocated key/value vector. Immensely - * useful for ipc in combination with kvvec2buf(). - * - * @param kvv A pre-allocated key/value vector to populate - * @param str The buffer to convert to a key/value vector - * @param len Length of buffer to convert - * @param kvsep Character separating key and value - * @param pair_sep Character separating key/value pairs - * @param flags bitmask. See KVVEC_{ASSIGN,COPY,APPEND} for values - * @return The number of pairs in the created key/value vector - */ -extern int buf2kvvec_prealloc(struct kvvec *kvv, char *str, unsigned int len, const char kvsep, const char pair_sep, int flags); -/** @} */ -#endif /* INCLUDE_kvvec_h__ */ diff --git a/devtools/ci/nagios/lib/libnagios.h b/devtools/ci/nagios/lib/libnagios.h deleted file mode 100644 index 1c78f05..0000000 --- a/devtools/ci/nagios/lib/libnagios.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef LIBNAGIOS_LIBNAGIOS_H_INCLUDED -#define LIBNAGIOS_LIBNAGIOS_H_INCLUDED -/** - * @file libnagios.h - * - * @brief Include this for all public parts of libnagios to be accessible - */ - -#include "lnag-utils.h" -#include "fanout.h" -#include "nsutils.h" -#include "pqueue.h" -#include "squeue.h" -#include "kvvec.h" -#include "iobroker.h" -#include "iocache.h" -#include "runcmd.h" -#include "bitmap.h" -#include "dkhash.h" -#include "worker.h" -#include "skiplist.h" -#include "nsock.h" -#include "nspath.h" -#include "snprintf.h" -#include "nwrite.h" -#endif /* LIB_libnagios_h__ */ diff --git a/devtools/ci/nagios/lib/lnag-utils.h b/devtools/ci/nagios/lib/lnag-utils.h deleted file mode 100644 index 443025e..0000000 --- a/devtools/ci/nagios/lib/lnag-utils.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef LIBNAGIOS_LNAG_UTILS_H_INCLUDED -#define LIBNAGIOS_LNAG_UTILS_H_INCLUDED - -#include /* for sysconf() */ -#include /* for rand() */ - -/** - * @file lnag-utils.h - * @brief libnagios helper and compatibility macros that lack a "real" home. - * - * This is the home of random macros that must be present for compilation - * to succeed but are missing on some platforms. - * - * @{ - */ - -#define NAGIOS_MKVERSION(a, b, c) \ - (((a) * 10000) + ((b) * 100) + (c)) - -#ifdef __cplusplus -/** C++ compatibility macro that avoids confusing indentation programs */ -# define NAGIOS_BEGIN_DECL extern "C" { -/** - * Use at end of header file declarations to obtain C++ compatibility - * ... without confusing indentation programs - */ -# define NAGIOS_END_DECL } -#else -/** C++ compatibility macro that avoids confusing indentation programs */ -# define NAGIOS_BEGIN_DECL /* nothing */ -/** C++ compatibility macro that avoid confusing indentation programs */ -# define NAGIOS_END_DECL /* more of nothing */ -#endif - -#ifndef NODOXY /* doxy comments are useless here */ -# ifndef __GNUC__ -# define GCC_VERSION 0 -# define __attribute__(x) /* nothing */ -# else -# ifdef __GNUC_PATCHLEVEL__ -# define GCC_VERSION NAGIOS_MKVERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -# else -# define GCC_VERSION NAGIOS_MKVERSION(__GNUC__, __GNUC_MINOR__, 0) -# endif /* __GNUC_PATCHLEVEL__ */ -# endif /* __GNUC__ */ -#endif /* NODOXY */ - -#if GCC_VERSION >= NAGIOS_MKVERSION(4, 5, 0) -# define NAGIOS_DEPRECATED(version, hint) \ - __attribute__((deprecated("This function will be removed in Nagios v" #version ". Please use " #hint " instead"))) -#else -/** Macro for alerting module authors to function deprecation */ -# define NAGIOS_DEPRECATED(version, hint) \ - __attribute__((deprecated)) -#endif - -/* - * These macros are widely used throughout Nagios - */ -#define OK 0 /**< Indicates successful function call in Nagios */ -#define ERROR -2 /**< Non-successful function call in Nagios */ - -#ifdef FALSE -#undef FALSE -#endif -#define FALSE 0 /**< Not true */ - -#ifdef TRUE -#undef TRUE -#endif -#define TRUE (!FALSE) /**< Not false */ - -/** Useful macro to safely avoid double-free memory corruption */ -#define my_free(ptr) do { if(ptr) { free(ptr); ptr = NULL; } } while(0) - -#ifndef ARRAY_SIZE -/** Useful for iterating over all elements in a static array */ -# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif -#ifndef veclen -/** useful for iterating over all elements in a static array */ -# define veclen ARRAY_SIZE -#endif - -#ifndef offsetof -/** standard offsetof macro */ -# define offsetof(t, f) ((unsigned long)&((t *)0)->f) -#endif - -/** character map initialization for .bss-allocated char maps */ -#define CHAR_MAP_INIT(k) { \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, k, \ - } - -/** @} */ -#endif diff --git a/devtools/ci/nagios/lib/nsock.h b/devtools/ci/nagios/lib/nsock.h deleted file mode 100644 index c2e52c7..0000000 --- a/devtools/ci/nagios/lib/nsock.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef LIBNAGIOS_NSOCK_H_INCLUDED -#define LIBNAGIOS_NSOCK_H_INCLUDED -#include - -/** - * @file nsock.h - * @brief Nagios socket helper library - * - * This is a pretty stupid library, but since so many addons and - * now Nagios core itself makes use of sockets, we might as well - * have some simple wrappers for it that handle the most common - * cases. - * - * @{ - */ - -#define NSOCK_EBIND (-1) /**< failed to bind() */ -#define NSOCK_ELISTEN (-2) /**< failed to listen() */ -#define NSOCK_ESOCKET (-3) /**< failed to socket() */ -#define NSOCK_EUNLINK (-4) /**< failed to unlink() */ -#define NSOCK_ECONNECT (-5) /**< failed to connect() */ -#define NSOCK_EFCNTL (-6) /**< failed to fcntl() */ -#define NSOCK_EINVAL (-EINVAL) /**< -22, normally */ - -/* flags for the various create calls */ -#define NSOCK_TCP (1 << 0) /**< use tcp mode */ -#define NSOCK_UDP (1 << 1) /**< use udp mode */ -#define NSOCK_UNLINK (1 << 2) /**< unlink existing path (only nsock_unix) */ -#define NSOCK_REUSE (1 << 2) /**< reuse existing address */ -#define NSOCK_CONNECT (1 << 3) /**< connect rather than create */ -#define NSOCK_BLOCK (1 << 4) /**< socket should be in blocking mode */ - -/** - * Grab an error string relating to nsock_unix() - * @param code The error code return by the nsock library - * @return An error string describing the error - */ -extern const char *nsock_strerror(int code); - -/** - * Create or connect to a unix socket - * To control permissions on sockets when NSOCK_LISTEN is specified, - * callers will have to modify their umask() before (and possibly - * after) the nsock_unix() call. - * - * @param path The path to connect to or create - * @param flags Various options controlling the mode of the socket - * @return An NSOCK_E macro on errors, the created socket on success - */ -extern int nsock_unix(const char *path, unsigned int flags); - -/** - * Write a nul-terminated message to the socket pointed to by sd. - * This isn't quite the same as dprintf(), which doesn't include - * the terminating nul byte. - * @note This function may block, so poll(2) for writability - * @param sd The socket to write to - * @param fmt The format string - * @return Whatever write() returns - */ -extern int nsock_printf_nul(int sd, const char *fmt, ...) - __attribute__((__format__(__printf__, 2, 3))); - -/** - * Write a printf()-formatted string to the socket pointed to by sd. - * This is identical to dprintf(), which is unfortunately GNU only. - * @note This function may block, so poll(2) for writability - * @param sd The socket to write to - * @param fmt The format string - * @return Whatever write() returns - */ -extern int nsock_printf(int sd, const char *fmt, ...) - __attribute__((__format__(__printf__, 2, 3))); - -/** @} */ -#endif /* LIBNAGIOS_NSOCK_H_INCLUDED */ diff --git a/devtools/ci/nagios/lib/nspath.h b/devtools/ci/nagios/lib/nspath.h deleted file mode 100644 index f0788e4..0000000 --- a/devtools/ci/nagios/lib/nspath.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef LIBNAGIOS_NSPATH_H_INCLUDED -#define LIBNAGIOS_NSPATH_H_INCLUDED -#ifndef _GNU_SOURCE -# ifndef NODOXY -# define _GNU_SOURCE 1 -# endif -#endif -#include -#include -#include "snprintf.h" - -/** - * @file nspath.h - * @brief path handling functions - * - * This library handles path normalization and resolution. It's nifty - * if you want to turn relative paths into absolute ones, or if you - * want to make insane ones sane, but without chdir()'ing your way - * around the filesystem. - * - * @{ - */ - -/** - * Normalize a path - * By "normalize", we mean that we convert dot-slash and dot-dot-slash - * embedded components into a legible continuous string of characters. - * Leading and trailing slashes are kept exactly as they are in input, - * but with sequences of slashes reduced to a single one. - * - * "foo/bar/.././lala.txt" becomes "foo/lala.txt" - * "../../../../bar/../foo/" becomes "/foo/" - * "////foo////././bar" becomes "/foo/bar" - * @param orig_path The path to normalize - * @return A newly allocated string containing the normalized path - */ -extern char *nspath_normalize(const char *orig_path); - -/** - * Make the "base"-relative path "rel_path" absolute. - * Turns the relative path "rel_path" into an absolute path and - * resolves it as if we were currently in "base". If "base" is - * NULL, the current working directory is used. If "base" is not - * null, it should be an absolute path for the result to make - * sense. - * - * @param rel_path The relative path to convert - * @param base The base directory (if NULL, we use current working dir) - * @return A newly allocated string containing the absolute path - */ -extern char *nspath_absolute(const char *rel_path, const char *base); - -/** - * Canonicalize the "base"-relative path "rel_path". - * errno gets properly set in case of errors. - * @param rel_path The path to transform - * @param base The base we should operate relative to - * @return Newly allocated canonical path on success, NULL on errors - */ -extern char *nspath_real(const char *rel_path, const char *base); - -/** - * Get absolute dirname of "path", relative to "base" - * @param path Full path to target object (file or subdir) - * @param base The base directory (if NULL, we use current working dir) - * @return NULL on errors, allocated absolute directory name on success - */ -extern char *nspath_absolute_dirname(const char *path, const char *base); - - -/** - * Recursively create a directory, just like mkdir_p would. - * @note This function *will* taint errno with ENOENT if any path - * component has to be created. - * @note If "path" has a trailing slash, NSPATH_MKDIR_SKIP_LAST - * won't have any effect. That's considered a feature, since the - * option is designed so one can send a file-path to the function - * and have it create the directory structure for it. - * @param path Path to create, in normalized form - * @param mode Filemode (same as mkdir() takes) - * @param options Options flag. See NSPATH_MKDIR_* for or-able options - * @return 0 on success, -1 on errors and errno will hold error code - * from either stat() or mkdir(). - */ -extern int nspath_mkdir_p(const char *path, mode_t mode, int options); - -/** Don't mkdir() last element of path when calling nspath_mkdir_p() */ -#define NSPATH_MKDIR_SKIP_LAST (1 << 0) - -/** @} */ -#endif diff --git a/devtools/ci/nagios/lib/nsutils.h b/devtools/ci/nagios/lib/nsutils.h deleted file mode 100644 index a003535..0000000 --- a/devtools/ci/nagios/lib/nsutils.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef LIBNAGIOS_NSUTILS_H_INCLUDED -#define LIBNAGIOS_NSUTILS_H_INCLUDED -#include -#include - -/** - * @file nsutils.h - * @brief Non-Standard (or Nagios) utility functions and macros. - * - * This is where we house all helpers and macros that fall outside - * the "standard-ish" norm. The prefixes "nsu_" and NSU_ are - * reserved for this purpose, so we avoid clashing with other - * applications that may have similarly-acting functions with - * identical names. - * - * The functions already here lack the nsu_ prefix for backwards - * compatibility reasons. It's possible we'll have to fix that - * some day, but let's leave that for later. - * - * @{ - */ - -/** Macro for dynamically increasing vector lengths */ -#define alloc_nr(x) (((x)+16)*3/2) - -/** - * Check if a number is a power of 2 - * @param x The number to check - * @return 1 if the number is a power of 2, 0 if it's not - */ -static inline int nsu_ispow2(unsigned int x) -{ - return x > 1 ? !(x & (x - 1)) : 0; -} - -/** - * Round up to a power of 2 - * Yes, this is the most cryptic function name in all of Nagios, but I - * like it, so shush. - * @param r The number to round up - * @return r, rounded up to the nearest power of 2. - */ -static inline unsigned int rup2pof2(unsigned int r) -{ - r--; - if (!r) - return 2; - r |= r >> 1; - r |= r >> 2; - r |= r >> 4; - r |= r >> 8; - r |= r >> 16; - - return r + 1; -} - -/** - * Grab a random unsigned int in the range between low and high. - * Note that the PRNG has to be seeded prior to calling this. - * @param low The lower bound, inclusive - * @param high The higher bound, inclusive - * @return An unsigned integer in the mathematical range [low, high] - */ -static inline unsigned int ranged_urand(unsigned int low, unsigned int high) -{ - return low + (rand() * (1.0 / (RAND_MAX + 1.0)) * (high - low)); -} - -/** - * Get number of online cpus - * @return Active cpu cores detected on success. 0 on failure. - */ -extern int real_online_cpus(void); - -/** - * Wrapper for real_online_cpus(), returning 1 in case we can't - * detect any active cpus. - * @return Number of active cpu cores on success. 1 on failure. - */ -extern int online_cpus(void); - -/** - * Create a short-lived string in stack-allocated memory - * The number and size of strings is limited (currently to 256 strings of - * 32 bytes each), so beware and use this sensibly. Intended for - * number-to-string conversion and other short strings. - * @note The returned string must *not* be free()'d! - * @param[in] fmt The format string - * @return A pointer to the formatted string on success. Undefined on errors - */ -extern const char *mkstr(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); - -/** - * Calculate the millisecond delta between two timeval structs - * @param[in] start The start time - * @param[in] stop The stop time - * @return The millisecond delta between the two structs - */ -extern int tv_delta_msec(const struct timeval *start, const struct timeval *stop); - - -/** - * Get timeval delta as seconds - * @param start The start time - * @param stop The stop time - * @return time difference in fractions of seconds - */ -extern float tv_delta_f(const struct timeval *start, const struct timeval *stop); - -/** @} */ -#endif /* LIBNAGIOS_NSUTILS_H_INCLUDED */ diff --git a/devtools/ci/nagios/lib/nwrite.h b/devtools/ci/nagios/lib/nwrite.h deleted file mode 100644 index 73a9418..0000000 --- a/devtools/ci/nagios/lib/nwrite.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef LIBNAGIOS_NWRITE_H_INCLUDED -#define LIBNAGIOS_NWRITE_H_INCLUDED - -/** - * @file nwrite.h - * @brief Functions that properly handle incomplete write()'s - * - * Some functions simply use write() to send data through a socket. - * These calls are sometimes interrupted, especially in the case of - * an overly large buffer. Even though the write() _could_ finish, - * the incomplete write is treated as an error. The functions here - * properly handle those cases. - * - * @{ - */ - -/** - * Send data through a socket - * This function will send data through a socket and return - * the number of bytes written. - * @param sock The socket to write to - * @param data The data to write - * @param lth The length of the data - * @param sent The number of bytes written (can be NULL) - * @return The number of bytes written or -1 if error - */ -static inline ssize_t nwrite(int fd, const void *buf, size_t count, ssize_t *written) -{ - /* - * Given the API we have to assume (unsigned) size_t 'count' fits into - * a (signed) ssize_t because we can't return a larger value. - * https://stackoverflow.com/questions/29722999/will-write2-always-write-less-than-or-equal-to-ssize-max - */ - ssize_t out, tot = 0; - - if (!buf || count == 0) - return 0; - - while ((size_t) tot < count) { - out = write(fd, (const char *) buf + tot, count - tot); - if (out > 0) - tot += out; - else if(errno == EAGAIN || errno == EINTR) - continue; - else { - if (written) - *written = tot; - return out; - } - } - if (written) - *written = tot; - return tot; -} - -/** @} */ -#endif /* LIBNAGIOS_NWRITE_H_INCLUDED */ diff --git a/devtools/ci/nagios/lib/pqueue.h b/devtools/ci/nagios/lib/pqueue.h deleted file mode 100644 index 9f0059e..0000000 --- a/devtools/ci/nagios/lib/pqueue.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2010 Volkan Yazıcı - * Copyright 2006-2010 The Apache Software Foundation - * - * 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. - */ -#ifndef LIBNAGIOS_PQUEUE_H_INCLUDED -#define LIBNAGIOS_PQUEUE_H_INCLUDED -#include - -/** - * @file pqueue.h - * @brief Priority Queue function declarations - * - * This priority queue library was originally written by Volkan Yazici - * . It was lated adapted for Nagios by - * Andreas Ericsson . Changes compared to the original - * version are pretty much limited to changing pqueue_pri_t to be - * an unsigned long long instead of a double, since ULL comparisons - * are 107 times faster on my 64-bit laptop. - * - * @{ - */ - - -/** priority data type (used to be double, but ull is 107 times faster) */ -typedef unsigned long long pqueue_pri_t; - -/** callback functions to get/set/compare the priority of an element */ -typedef pqueue_pri_t (*pqueue_get_pri_f)(void *a); -typedef void (*pqueue_set_pri_f)(void *a, pqueue_pri_t pri); -typedef int (*pqueue_cmp_pri_f)(pqueue_pri_t next, pqueue_pri_t curr); - - -/** callback functions to get/set the position of an element */ -typedef unsigned int (*pqueue_get_pos_f)(void *a); -typedef void (*pqueue_set_pos_f)(void *a, unsigned int pos); - - -/** debug callback function to print a entry */ -typedef void (*pqueue_print_entry_f)(FILE *out, void *a); - - -/** the priority queue handle */ -typedef struct pqueue_t -{ - unsigned int size; /**< number of elements in this queue */ - unsigned int avail; /**< slots available in this queue */ - unsigned int step; /**< growth stepping setting */ - pqueue_cmp_pri_f cmppri; /**< callback to compare nodes */ - pqueue_get_pri_f getpri; /**< callback to get priority of a node */ - pqueue_set_pri_f setpri; /**< callback to set priority of a node */ - pqueue_get_pos_f getpos; /**< callback to get position of a node */ - pqueue_set_pos_f setpos; /**< callback to set position of a node */ - void **d; /**< The actual queue in binary heap form */ -} pqueue_t; - - -/** - * initialize the queue - * - * @param n the initial estimate of the number of queue items for which memory - * should be preallocated - * @param cmppri The callback function to run to compare two elements - * This callback should return 0 for 'lower' and non-zero - * for 'higher', or vice versa if reverse priority is desired - * @param setpri the callback function to run to assign a score to an element - * @param getpri the callback function to run to set a score to an element - * @param getpos the callback function to get the current element's position - * @param setpos the callback function to set the current element's position - * - * @return the handle or NULL for insufficient memory - */ -pqueue_t * -pqueue_init(unsigned int n, - pqueue_cmp_pri_f cmppri, - pqueue_get_pri_f getpri, - pqueue_set_pri_f setpri, - pqueue_get_pos_f getpos, - pqueue_set_pos_f setpos); - - -/** - * free all memory used by the queue - * @param q the queue - */ -void pqueue_free(pqueue_t *q); - - -/** - * return the size of the queue. - * @param q the queue - */ -unsigned int pqueue_size(pqueue_t *q); - - -/** - * insert an item into the queue. - * @param q the queue - * @param d the item - * @return 0 on success - */ -int pqueue_insert(pqueue_t *q, void *d); - - -/** - * move an existing entry to a different priority - * @param q the queue - * @param new_pri the new priority - * @param d the entry - */ -void -pqueue_change_priority(pqueue_t *q, - pqueue_pri_t new_pri, - void *d); - - -/** - * pop the highest-ranking item from the queue. - * @param q the queue - * @return NULL on error, otherwise the entry - */ -void *pqueue_pop(pqueue_t *q); - - -/** - * remove an item from the queue. - * @param q the queue - * @param d the entry - * @return 0 on success - */ -int pqueue_remove(pqueue_t *q, void *d); - - -/** - * access highest-ranking item without removing it. - * @param q the queue - * @return NULL on error, otherwise the entry - */ -void *pqueue_peek(pqueue_t *q); - - -/** - * print the queue - * @internal - * DEBUG function only - * @param q the queue - * @param out the output handle - * @param the callback function to print the entry - */ -void -pqueue_print(pqueue_t *q, FILE *out, pqueue_print_entry_f print); - - -/** - * dump the queue and it's internal structure - * @internal - * debug function only - * @param q the queue - * @param out the output handle - * @param the callback function to print the entry - */ -void pqueue_dump(pqueue_t *q, FILE *out, pqueue_print_entry_f print); - - -/** - * checks that the pq is in the right order, etc - * @internal - * debug function only - * @param q the queue - */ -int pqueue_is_valid(pqueue_t *q); - -#endif -/** @} */ diff --git a/devtools/ci/nagios/lib/runcmd.h b/devtools/ci/nagios/lib/runcmd.h deleted file mode 100644 index ab9d0c5..0000000 --- a/devtools/ci/nagios/lib/runcmd.h +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef NDO_LIBNAGIOS_RUNCMD_H_INCLUDED -#define NDO_LIBNAGIOS_RUNCMD_H_INCLUDED -#include - -/** - * @file runcmd.h - * @brief runcmd library function declarations - * - * A simple interface to executing programs from other programs, using an - * optimized and safer popen()-like implementation. It is considered safer in - * that no shell needs to be spawned for simple commands, and the environment - * passed to the execve()'d program is essentially empty. - * - * This code is based on popen.c, which in turn was taken from - * "Advanced Programming in the UNIX Environment" by W. Richard Stevens. - * - * Care has been taken to make sure the functions are async-safe. The exception - * is runcmd_init() which multithreaded applications or plugins must call in a - * non-reentrant manner before calling any other runcmd function. - * - * @note This is inherited from the nagiosplugins project, although - * it might need refactoring for performance later. - * @{ - */ - -/** Return code bitflags for runcmd_cmd2strv() */ -#define RUNCMD_HAS_REDIR (1 << 0) /**< I/O redirection */ -#define RUNCMD_HAS_SUBCOMMAND (1 << 1) /**< subcommands present */ -#define RUNCMD_HAS_PAREN (1 << 2) /**< parentheses present in command */ -#define RUNCMD_HAS_JOBCONTROL (1 << 3) /**< job control stuff present */ -#define RUNCMD_HAS_UBSQ (1 << 4) /**< unbalanced single quotes */ -#define RUNCMD_HAS_UBDQ (1 << 5) /**< unbalanced double quotes */ -#define RUNCMD_HAS_WILDCARD (1 << 6) /**< wildcards present */ -#define RUNCMD_HAS_SHVAR (1 << 7) /**< shell variables present */ - - -#define RUNCMD_EFD (-1) /**< Failed to pipe() or open() */ -#define RUNCMD_EALLOC (-2) /**< Failed to alloc */ -#define RUNCMD_ECMD (-3) /**< Bad command */ -#define RUNCMD_EFORK (-4) /**< Failed to fork() */ -#define RUNCMD_EINVAL (-5) /**< Invalid parameters */ -#define RUNCMD_EWAIT (-6) /**< Failed to wait() */ - -/** - * Initialize the runcmd library. - * - * Only multi-threaded programs that might launch the first external - * program from multiple threads simultaneously need to bother with - * this, and they must ensure this is called at least once in a non-reentrant - * manner before calling any other runcmd function. - */ -extern void runcmd_init(void); - -/** - * Return pid of a command with a specific file descriptor - * @param[in] fd stdout filedescriptor of the child to get pid from - * @return pid of the child, or 0 on errors - */ -extern pid_t runcmd_pid(int fd); - -/** - * Return explanation of which system call or operation failed - * @param code Error code returned by a library function - * @return A non-free()'able string explaining where the error occurred - */ -extern const char *runcmd_strerror(int code); - -/** - * Start a command from a command string - * @param[in] cmd The command to launch - * @param[out] pfd Child's stdout filedescriptor - * @param[out] pfderr Child's stderr filedescriptor - * @param[in] env Currently ignored for portability - * @param[in] iobreg The callback function to register the iobrokers for the read ends of the pipe - * @param[in] iobregarg The "arg" value to pass to iobroker_register() - */ -extern int runcmd_open(const char *cmd, int *pfd, int *pfderr, char **env, - void (*iobreg)(int, int, void *), void *iobregarg); - -/** - * Close a command and return its exit status - * @note Don't use this. It's a retarded way to reap children suitable - * only for launching a one-shot program. - * - * @param[in] fd The child's stdout filedescriptor - * @return exit-status of the child, or -1 in case of errors - */ -extern int runcmd_close(int fd); - -/** - * Convert a string to a vector of arguments like a shell would - * @note This might have bugs and is only tested to behave similar - * to how /bin/sh does things. For csh or other non bash-ish shells - * there are no guarantees. - * @note The out_argv array has to be large enough to hold all strings - * found in the command. - * @param[in] str The string to convert to an argument vector - * @param[out] out_argc The number of arguments found - * @param[out] out_argv The argument vector - * @return 0 on (great) success, or a bitmask of failure-codes - * representing f.e. unclosed quotes, job control or output redirection. - * See the RUNCMD_HAS_* and their ilk to find out about the flag. - */ -extern int runcmd_cmd2strv(const char *str, int *out_argc, char **out_argv); - -/** - * If you're using libnagios to execute a remote command, the - * static pid_t pids is not freed after runcmd_open - * You can call this function when you're sure pids is no longer - * in use, to keep down memory leaks - */ -extern void runcmd_free_pids(void); - -/** @} */ -/* INCLUDE_runcmd_h__ */ -#endif diff --git a/devtools/ci/nagios/lib/skiplist.h b/devtools/ci/nagios/lib/skiplist.h deleted file mode 100644 index 17d49e7..0000000 --- a/devtools/ci/nagios/lib/skiplist.h +++ /dev/null @@ -1,162 +0,0 @@ -/************************************************************************ - * - * SKIPLIST.H - Skiplist data structures and functions - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - ************************************************************************/ - -#ifndef LIBNAGIOS_SKIPLIST_H_INCLUDED -#define LIBNAGIOS_SKIPLIST_H_INCLUDED -#include "lnag-utils.h" - -/** - * @file skiplist.h - * @brief Skiplist library functions - * - * http://en.wikipedia.org/wiki/Skiplist - * - * @{ - */ - -#define SKIPLIST_OK 0 /**< A ok */ -#define SKIPLIST_ERROR_ARGS 1 /**< Bad arguments */ -#define SKIPLIST_ERROR_MEMORY 2 /**< Memory error */ -#define SKIPLIST_ERROR_DUPLICATE 3 /**< Trying to insert non-unique item */ - -NAGIOS_BEGIN_DECL - -struct skiplist_struct; -typedef struct skiplist_struct skiplist; - -/** - * Return number of items currently in the skiplist - * @param list The list to investigate - * @return number of items in list - */ -unsigned long skiplist_num_items(skiplist *list); - -/** - * Create a new skiplist - * @param max_levels Number of "ups" we have. - * This Should be kept close to lg2 of the number of items to store. - * @param level_probability Ignored - * @param allow_duplicates Allow duplicates in this list - * @param append_duplicates Append rather than prepend duplicates - * @param compare_function Comparison function for data entries - * @return pointer to a new skiplist on success, NULL on errors - */ -skiplist *skiplist_new(int max_levels, float level_probability, int allow_duplicates, int append_duplicates, int (*compare_function)(void *, void *)); - -/** - * Insert an item into a skiplist - * @param list The list to insert to - * @param data The data to insert - * @return SKIPLIST_OK on success, or an error code - */ -int skiplist_insert(skiplist *list, void *data); - -/** - * Empty the skiplist of all data - * @param list The list to empty - * @return ERROR on failures. OK on success - */ -int skiplist_empty(skiplist *list); - -/** - * Free all nodes (but not all data) in a skiplist - * This is similar to skiplist_empty(), but also free()'s the head node - * @param list The list to free - * @return OK on success, ERROR on failures - */ -int skiplist_free(skiplist **list); - -/** - * Get the first item in the skiplist - * @param list The list to peek into - * @return The first item, or NULL if there is none - */ -void *skiplist_peek(skiplist *list); - -/** - * Pop the first item from the skiplist - * @param list The list to pop from - */ -void *skiplist_pop(skiplist *list); - -/** - * Get first node of skiplist - * @param list The list to search - * @param[out] node_ptr State variable for skiplist_get_next() - * @return The data-item of the first node on success, NULL on errors - */ -void *skiplist_get_first(skiplist *list, void **node_ptr); - -/** - * Get next item from node_ptr - * @param[out] node_ptr State variable primed from an earlier call to - * skiplist_get_first() or skiplist_get_next() - * @return The next data-item matching node_ptr on success, NULL on errors - */ -void *skiplist_get_next(void **node_ptr); - -/** - * Find first entry in skiplist matching data - * @param list The list to search - * @param data Comparison object used to search - * @param[out] node_ptr State variable for future lookups with - * skiplist_find_next() - * @return The first found data-item, of NULL if none could be found - */ -void *skiplist_find_first(skiplist *list, void *data, void **node_ptr); - -/** - * Find next entry in skiplist matching data - * @param list The list to search - * @param data The data to compare against - * @param[out] node_ptr State var primed from earlier call to - * skiplist_find_next() or skiplist_find_first() - * @return The next found data-item, or NULL if none could be found - */ -void *skiplist_find_next(skiplist *list, void *data, void **node_ptr); - -/** - * Delete all items matching 'data' from skiplist - * @param list The list to delete from - * @param data Comparison object used to find the real node - * @return OK on success, ERROR on errors - */ -int skiplist_delete(skiplist *list, void *data); - -/** - * Delete first item matching 'data' from skiplist - * @param list The list to delete from - * @param data Comparison object used to search the list - * @return OK on success, ERROR on errors. - */ -int skiplist_delete_first(skiplist *list, void *data); - -/** - * Delete a particular node from the skiplist - * @param list The list to search - * @param node_ptr The node to delete - * @return OK on success, ERROR on errors. - */ -int skiplist_delete_node(skiplist *list, void *node_ptr); - -NAGIOS_END_DECL -/* @} */ -#endif diff --git a/devtools/ci/nagios/lib/snprintf.h b/devtools/ci/nagios/lib/snprintf.h deleted file mode 100644 index 2e5d0b0..0000000 --- a/devtools/ci/nagios/lib/snprintf.h +++ /dev/null @@ -1,7 +0,0 @@ -/* lib/snprintf.h. Generated from snprintf.h.in by configure. */ -/* -*- C -*- */ -#ifndef LIBNAGIOS_snprintf_h__ -#define LIBNAGIOS_snprintf_h__ -/* #undef HAVE_SNPRINTF */ -/* #undef NEED_VA_LIST */ -#endif diff --git a/devtools/ci/nagios/lib/squeue.h b/devtools/ci/nagios/lib/squeue.h deleted file mode 100644 index 9819c03..0000000 --- a/devtools/ci/nagios/lib/squeue.h +++ /dev/null @@ -1,170 +0,0 @@ -#ifndef LIBNAGIOS_SQUEUE_H_INCLUDED -#define LIBNAGIOS_SQUEUE_H_INCLUDED -#include -#include -#include "pqueue.h" -/** - * @file squeue.h - * @brief Scheduling queue function declarations - * - * This library is based on the pqueue api, which implements a - * priority queue based on a binary heap, providing O(lg n) times - * for insert() and remove(), and O(1) time for peek(). - * @note There is no "find". Callers must maintain pointers to their - * scheduled events if they wish to be able to remove them. - * - * @{ - */ - -/* - * All opaque types here. - * The pqueue library can be useful on its own though, so we - * don't block that from user view. - */ -typedef pqueue_t squeue_t; -struct squeue_event; -typedef struct squeue_event squeue_event; - -/** - * Options for squeue_destroy()'s flag parameter - */ -#define SQUEUE_FREE_DATA (1 << 0) /** Call free() on all data pointers */ - -/** - * Get the scheduled runtime of this event - * @param[in] evt The event to get runtime of - * @return struct timeval on success, NULL on errors - */ -extern const struct timeval *squeue_event_runtime(squeue_event *evt); - -/** - * Get data of an squeue_event struct - * @param[in] evt The event to operate on - * @return The data object pointed to by the event - */ -extern void *squeue_event_data(squeue_event *evt); - -/** - * Creates a scheduling queue optimized for handling events within - * the given timeframe. Callers should take care to create a queue - * of a decent but not overly large size, as too small or too large - * a queue will impact performance negatively. A queue can hold any - * number of events. A good value for "horizon" would be the max - * seconds into the future one expects to schedule things, although - * with few scheduled items in that timeframe you'd be better off - * using a more narrow horizon. - * - * @param size Hint about how large this queue will get - * @return A pointer to a scheduling queue - */ -extern squeue_t *squeue_create(unsigned int size); - -/** - * Destroys a scheduling queue completely - * @param[in] q The doomed queue - * @param[in] flags Flags determining the the level of destruction - */ -extern void squeue_destroy(squeue_t *q, int flags); - -/** - * Enqueue an event with microsecond precision. - * It's up to the caller to keep the event pointer in case he/she - * wants to remove the event from the queue later. - * - * @param q The scheduling queue to add to - * @param tv When this event should occur - * @param data Pointer to any kind of data - * @return The complete scheduled event - */ -extern squeue_event *squeue_add_tv(squeue_t *q, struct timeval *tv, void *data); - -/** - * Adds an event to the scheduling queue. - * See notes for squeue_add_tv() for details - * - * @param q The scheduling queue to add to - * @param when The unix timestamp when this event is to occur - * @param data Pointer to any kind of data - * @return The complete scheduled event - */ -extern squeue_event *squeue_add(squeue_t *q, time_t when, void *data); - -/** - * Adds an event to the scheduling queue with millisecond precision - * See notes on squeue_add_tv() for details - * - * @param[in] q The scheduling queue to add to - * @param[in] when Unix timestamp when this event should occur - * @param[in] usec Millisecond of above this event should occur - * @param[in] data Pointer to any kind of data - * @return NULL on errors. squeue_event pointer on success - */ -extern squeue_event *squeue_add_usec(squeue_t *q, time_t when, time_t usec, void *data); - -/** - * Adds an event to the scheduling queue with millisecond precision - * See notes on squeue_add_tv() for details - * - * @param[in] q The scheduling queue to add to - * @param[in] when Unix timestamp when this event should occur - * @param[in] msec Millisecond of above this event should occur - * @param[in] data Pointer to any kind of data - * @return NULL on errors. squeue_event pointer on success - */ -extern squeue_event *squeue_add_msec(squeue_t *q, time_t when, time_t msec, void *data); - -/** - * Change an event's priority to a new time. - * - * @param q The scheduling queue holding the event. - * @param evt The event to reschedule. - * @param tv When the event should be rescheduled to. - */ -extern void squeue_change_priority_tv(squeue_t *q, squeue_event *evt, struct timeval *tv); - -/** - * Returns the data of the next scheduled event from the scheduling - * queue without removing it from the queue. - * - * @param q The scheduling queue to peek into - */ -extern void *squeue_peek(squeue_t *q); - -/** - * Pops the next scheduled event from the scheduling queue and - * returns the data for it. - * This is equivalent to squeue_peek() + squeue_pop() - * @note This causes the squeue_event to be free()'d. - * - * @param q The scheduling queue to pop from - */ -extern void *squeue_pop(squeue_t *q); - -/** - * Removes the given event from the scheduling queue - * @note This causes the associated squeue_event() to be free()'d. - * @param[in] q The scheduling queue to remove from - * @param[in] evt The event to remove - */ -extern int squeue_remove(squeue_t *q, squeue_event *evt); - -/** - * Returns the number of events in the scheduling queue. This - * function never fails. - * - * @param[in] q The scheduling queue to inspect - * @return number of events in the inspected queue - */ -extern unsigned int squeue_size(squeue_t *q); - - -/** - * Returns true if passed timeval is after the time for the event - * - * @param[in] evt The queue event to inspect - * @param[in] reftime The reference time to compare to the queue event time - * @return 1 if reftime > event time, 0 otherwise - */ -extern int squeue_evt_when_is_after(squeue_event *evt, struct timeval *reftime); -#endif -/** @} */ diff --git a/devtools/ci/nagios/lib/t-utils.h b/devtools/ci/nagios/lib/t-utils.h deleted file mode 100644 index 1fa25de..0000000 --- a/devtools/ci/nagios/lib/t-utils.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef NAGIOS_T_UTILS_H_INCLUDED -#define NAGIOS_T_UTILS_H_INCLUDED -#include -#include -#include -#include -#include - -#ifndef ARRAY_SIZE -# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -#define TEST_PASS 1 -#define TEST_FAIL 0 - -#define CLR_RESET "\033[m" -#define CLR_BOLD "\033[1m" -#define CLR_RED "\033[31m" -#define CLR_GREEN "\033[32m" -#define CLR_BROWN "\033[33m" -#define CLR_YELLOW "\033[33m\033[1m" -#define CLR_BLUE "\033[34m" -#define CLR_MAGENTA "\033[35m" -#define CLR_CYAN "\033[36m" -#define CLR_BG_RED "\033[41m" -#define CLR_BRIGHT_RED "\033[31m\033[1m" -#define CLR_BRIGHT_GREEN "\033[32m\033[1m" -#define CLR_BRIGHT_BLUE "\033[34m\033[1m" -#define CLR_BRIGHT_MAGENTA "\033[35m\033[1m" -#define CLR_BRIGHT_CYAN "\033[36m\033[1m" - -extern const char *red, *green, *yellow, *cyan, *reset; -extern unsigned int passed, failed, t_verbose; - -#define CHECKPOINT() \ - do { \ - fprintf(stderr, "ALIVE @ %s:%s:%d\n", __FILE__, __func__, __LINE__); \ - } while(0) - -#define t_assert(expr) \ - -extern void t_set_colors(int force); -extern void t_start(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); -extern void t_pass(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); -extern void t_fail(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); -extern void t_diag(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2))); -extern int t_ok(int success, const char *fmt, ...) - __attribute__((__format__(__printf__, 2, 3))); -#define test t_ok -#define t_req(expr) \ - if (!(expr)) \ - crash("No further testing is possible: " #expr " @%s:%d", __FILE__, __LINE__) -extern int ok_int(int a, int b, const char *name); -extern int ok_uint(unsigned int a, unsigned int b, const char *name); -extern int ok_str(const char *a, const char *b, const char *name); -extern int t_end(void); -extern void t_reset(void); -extern void crash(const char *fmt, ...) - __attribute__((__format__(__printf__, 1, 2), __noreturn__)); -#endif diff --git a/devtools/ci/nagios/lib/worker.h b/devtools/ci/nagios/lib/worker.h deleted file mode 100644 index 51b1332..0000000 --- a/devtools/ci/nagios/lib/worker.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef LIBNAGIOS_WORKER_H_INCLUDED -#define LIBNAGIOS_WORKER_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include "libnagios.h" - -/** - * @file worker.h - * @brief Worker implementation along with various helpers - * - * This code isn't really in the "library" category, but it's tucked - * in here to provide a good resource for writing remote workers and - * as an example on how to use the API's found here. - */ - -#ifndef ETIME -#define ETIME ETIMEDOUT -#endif - -typedef struct iobuf { - int fd; - unsigned int len; - char *buf; -} iobuf; - -typedef struct execution_information execution_information; - -typedef struct child_process { - unsigned int id, timeout; - char *cmd; - struct kvvec *env; - int ret; - struct kvvec *request; - iobuf outstd; - iobuf outerr; - execution_information *ei; -} child_process; - -/** - * Callback for enter_worker that simply runs a command - */ -extern int start_cmd(child_process *cp); - -/** - * Spawn a helper with a specific process name - * The first entry in the argv parameter will be the name of the - * new process, unless the process changes the name itself. - * @param path The path to the executable (can be $PATH relative) - * @param argv Argument vector for the helper to spawn - */ -extern int spawn_named_helper(char *path, char **argv); - -/** - * Spawn any random helper process. Uses spawn_named_helper() - * @param argv The (NULL-sentinel-terminated) argument vector - * @return 0 on success, < 0 on errors - */ -extern int spawn_helper(char **argv); - -/** - * To be called when a child_process has completed to ship the result to nagios - * @param cp The child_process that describes the job - * @param reason 0 if everything was OK, 1 if the job was unable to run - * @return 0 on success, non-zero otherwise - */ -extern int finish_job(child_process *cp, int reason); - -/** - * Start to poll the socket and call the callback when there are new tasks - * @param sd A socket descriptor to poll - * @param cb The callback to call upon completion - */ -extern void enter_worker(int sd, int (*cb)(child_process*)); - -/** - * Build a buffer from a key/value vector buffer. - * The resulting kvvec-buffer is suitable for sending between - * worker and master in either direction, as it has all the - * right delimiters in all the right places. - * @param kvv The key/value vector to build the buffer from - * @return NULL on errors, a newly allocated kvvec buffer on success - */ -extern struct kvvec_buf *build_kvvec_buf(struct kvvec *kvv); - -/** - * Send a key/value vector as a bytestream through a socket - * @param[in] sd The socket descriptor to send to - * @param kvv The key/value vector to send - * @return The number of bytes sent, or -1 on errors - */ -extern int worker_send_kvvec(int sd, struct kvvec *kvv); - -/** @deprecated Use worker_send_kvvec() instead */ -extern int send_kvvec(int sd, struct kvvec *kvv) - NAGIOS_DEPRECATED(4.1.0, "worker_send_kvvec()"); - -/** - * Grab a worker message from an iocache buffer - * @param[in] ioc The io cache - * @param[out] size Out buffer for buffer length - * @param[in] flags Currently unused - * @return A buffer from the iocache on success; NULL on errors - */ -extern char *worker_ioc2msg(iocache *ioc, unsigned long *size, int flags); - -/** - * Parse a worker message to a preallocated key/value vector - * - * @param[in] kvv Key/value vector to fill - * @param[in] buf The buffer to parse - * @param[in] len Length of 'buf' - * @param[in] kvv_flags Flags for buf2kvvec() - * @return 0 on success, < 0 on errors - */ -extern int worker_buf2kvvec_prealloc(struct kvvec *kvv, char *buf, unsigned long len, int kvv_flags); - -/** - * Set some common socket options - * @param[in] sd The socket to set options for - * @param[in] bufsize Size to set send and receive buffers to - * @return 0 on success. < 0 on errors - */ -extern int worker_set_sockopts(int sd, int bufsize); - -/** @deprecated Use worker_set_sockopts() instead */ -extern int set_socket_options(int sd, int bufsize) - NAGIOS_DEPRECATED(4.1.0, "worker_set_sockopts()"); -#endif /* INCLUDE_worker_h__ */ diff --git a/devtools/ci/nagios/locations.h b/devtools/ci/nagios/locations.h deleted file mode 100644 index 9094dd7..0000000 --- a/devtools/ci/nagios/locations.h +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************ - * - * Nagios Locations Header File - * Written By: Ethan Galstad (egalstad@nagios.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - ************************************************************************/ - -#define DEFAULT_TEMP_FILE "/opt/nagios/var/tempfile" -#define DEFAULT_TEMP_PATH "/tmp" -#define DEFAULT_CHECK_RESULT_PATH "/opt/nagios/var/spool/checkresults" -#define DEFAULT_STATUS_FILE "/opt/nagios/var/status.dat" -#define DEFAULT_LOG_FILE "/opt/nagios/var/nagios.log" -#define DEFAULT_LOG_ARCHIVE_PATH "/opt/nagios/var/archives/" -#define DEFAULT_DEBUG_FILE "/opt/nagios/var/nagios.debug" -#define DEFAULT_COMMENT_FILE "/opt/nagios/var/comments.dat" -#define DEFAULT_DOWNTIME_FILE "/opt/nagios/var/downtime.dat" -#define DEFAULT_RETENTION_FILE "/opt/nagios/var/retention.dat" -#define DEFAULT_COMMAND_FILE "/opt/nagios/var/rw/nagios.cmd" -#define DEFAULT_QUERY_SOCKET "/opt/nagios/var/rw/nagios.qh" -#define DEFAULT_CONFIG_FILE "/opt/nagios/etc/nagios.cfg" -#define DEFAULT_PHYSICAL_HTML_PATH "/opt/nagios/share" -#define DEFAULT_URL_HTML_PATH "/nagios" -#define DEFAULT_PHYSICAL_CGIBIN_PATH "/opt/nagios/sbin" -#define DEFAULT_URL_CGIBIN_PATH "/nagios/cgi-bin" -#define DEFAULT_CGI_CONFIG_FILE "/opt/nagios/etc/cgi.cfg" -#define DEFAULT_LOCK_FILE "/run/nagios.lock" -#define DEFAULT_OBJECT_CACHE_FILE "/opt/nagios/var/objects.cache" -#define DEFAULT_PRECACHED_OBJECT_FILE "/opt/nagios/var/objects.precache" -#define DEFAULT_EVENT_BROKER_FILE "/opt/nagios/var/broker.socket" diff --git a/devtools/ci/nagios/logging.h b/devtools/ci/nagios/logging.h deleted file mode 100644 index ed98648..0000000 --- a/devtools/ci/nagios/logging.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef NAGIOS_LOGGING_H_INCLUDED -#define NAGIOS_LOGGING_H_INCLUDED - -#include "objects.h" - -/******************* LOGGING TYPES ********************/ - -#define NSLOG_RUNTIME_ERROR 1 -#define NSLOG_RUNTIME_WARNING 2 - -#define NSLOG_VERIFICATION_ERROR 4 -#define NSLOG_VERIFICATION_WARNING 8 - -#define NSLOG_CONFIG_ERROR 16 -#define NSLOG_CONFIG_WARNING 32 - -#define NSLOG_PROCESS_INFO 64 -#define NSLOG_EVENT_HANDLER 128 -/*#define NSLOG_NOTIFICATION 256*/ /* NOT USED ANYMORE - CAN BE REUSED */ -#define NSLOG_EXTERNAL_COMMAND 512 - -#define NSLOG_HOST_UP 1024 -#define NSLOG_HOST_DOWN 2048 -#define NSLOG_HOST_UNREACHABLE 4096 - -#define NSLOG_SERVICE_OK 8192 -#define NSLOG_SERVICE_UNKNOWN 16384 -#define NSLOG_SERVICE_WARNING 32768 -#define NSLOG_SERVICE_CRITICAL 65536 - -#define NSLOG_PASSIVE_CHECK 131072 - -#define NSLOG_INFO_MESSAGE 262144 - -#define NSLOG_HOST_NOTIFICATION 524288 -#define NSLOG_SERVICE_NOTIFICATION 1048576 - -/***************** DEBUGGING LEVELS *******************/ - -#define DEBUGL_ALL -1 -#define DEBUGL_NONE 0 -#define DEBUGL_FUNCTIONS 1 -#define DEBUGL_CONFIG 2 -#define DEBUGL_PROCESS 4 -#define DEBUGL_STATUSDATA 4 -#define DEBUGL_RETENTIONDATA 4 -#define DEBUGL_EVENTS 8 -#define DEBUGL_CHECKS 16 -#define DEBUGL_FLAPPING 16 -#define DEBUGL_EVENTHANDLERS 16 -#define DEBUGL_PERFDATA 16 -#define DEBUGL_NOTIFICATIONS 32 -#define DEBUGL_EVENTBROKER 64 -#define DEBUGL_EXTERNALCOMMANDS 128 -#define DEBUGL_COMMANDS 256 -#define DEBUGL_DOWNTIME 512 -#define DEBUGL_COMMENTS 1024 -#define DEBUGL_MACROS 2048 -#define DEBUGL_IPC 4096 -#define DEBUGL_SCHEDULING 8192 -#define DEBUGL_WORKERS 16384 - -#define DEBUGV_BASIC 0 -#define DEBUGV_MORE 1 -#define DEBUGV_MOST 2 - -NAGIOS_BEGIN_DECL -/**** Logging Functions ****/ -void logit(int, int, const char *, ...) -__attribute__((__format__(__printf__, 3, 4))); -int log_debug_info(int, int, const char *, ...) -__attribute__((__format__(__printf__, 3, 4))); - -#ifndef NSCGI -int write_to_all_logs(char *, unsigned long); /* writes a string to main log file and syslog facility */ -int write_to_log(char *, unsigned long, time_t *); /* write a string to the main log file */ -int write_to_syslog(char *, unsigned long); /* write a string to the syslog facility */ -int log_service_event(service *); /* logs a service event */ -int log_host_event(host *); /* logs a host event */ -int log_host_states(int, time_t *); /* logs initial/current host states */ -int log_service_states(int, time_t *); /* logs initial/current service states */ -int rotate_log_file(time_t); /* rotates the main log file */ -int write_log_file_info(time_t *); /* records log file/version info */ -int open_debug_log(void); -int close_debug_log(void); -int close_log_file(void); -int fix_log_file_owner(uid_t uid, gid_t gid); -#endif /* !NSCGI */ - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/macros.h b/devtools/ci/nagios/macros.h deleted file mode 100644 index 927e6f0..0000000 --- a/devtools/ci/nagios/macros.h +++ /dev/null @@ -1,349 +0,0 @@ -/************************************************************************ - * - * MACROS.H - Common macro functions - * Written By: Ethan Galstad (egalstad@nagios.org) - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - ************************************************************************/ - -#ifndef NAGIOS_MACROS_H_INCLUDED -#define NAGIOS_MACROS_H_INCLUDED - -#include "common.h" -#include "objects.h" - - - -/****************** LENGTH LIMITATIONS ****************/ - -#define MAX_COMMAND_ARGUMENTS 32 /* maximum number of $ARGx$ macros */ - - -/****************** MACRO DEFINITIONS *****************/ - -#define MACRO_ENV_VAR_PREFIX "NAGIOS_" - -#define MAX_USER_MACROS 256 /* maximum number of $USERx$ macros */ - -#define MACRO_X_COUNT 163 /* size of macro_x[] array */ - -NAGIOS_BEGIN_DECL - -struct nagios_macros { - char *x[MACRO_X_COUNT]; - char *argv[MAX_COMMAND_ARGUMENTS]; - char *contactaddress[MAX_CONTACT_ADDRESSES]; - char *ondemand; - host *host_ptr; - hostgroup *hostgroup_ptr; - service *service_ptr; - servicegroup *servicegroup_ptr; - contact *contact_ptr; - contactgroup *contactgroup_ptr; - customvariablesmember *custom_host_vars; - customvariablesmember *custom_service_vars; - customvariablesmember *custom_contact_vars; - }; -typedef struct nagios_macros nagios_macros; - - - -#define MACRO_HOSTNAME 0 -#define MACRO_HOSTALIAS 1 -#define MACRO_HOSTADDRESS 2 -#define MACRO_SERVICEDESC 3 -#define MACRO_SERVICESTATE 4 -#define MACRO_SERVICESTATEID 5 -#define MACRO_SERVICEATTEMPT 6 -#define MACRO_LONGDATETIME 7 -#define MACRO_SHORTDATETIME 8 -#define MACRO_DATE 9 -#define MACRO_TIME 10 -#define MACRO_TIMET 11 -#define MACRO_LASTHOSTCHECK 12 -#define MACRO_LASTSERVICECHECK 13 -#define MACRO_LASTHOSTSTATECHANGE 14 -#define MACRO_LASTSERVICESTATECHANGE 15 -#define MACRO_HOSTOUTPUT 16 -#define MACRO_SERVICEOUTPUT 17 -#define MACRO_HOSTPERFDATA 18 -#define MACRO_SERVICEPERFDATA 19 -#define MACRO_CONTACTNAME 20 -#define MACRO_CONTACTALIAS 21 -#define MACRO_CONTACTEMAIL 22 -#define MACRO_CONTACTPAGER 23 -#define MACRO_ADMINEMAIL 24 -#define MACRO_ADMINPAGER 25 -#define MACRO_HOSTSTATE 26 -#define MACRO_HOSTSTATEID 27 -#define MACRO_HOSTATTEMPT 28 -#define MACRO_NOTIFICATIONTYPE 29 -#define MACRO_NOTIFICATIONNUMBER 30 /* deprecated - see HOSTNOTIFICATIONNUMBER and SERVICENOTIFICATIONNUMBER macros */ -#define MACRO_HOSTEXECUTIONTIME 31 -#define MACRO_SERVICEEXECUTIONTIME 32 -#define MACRO_HOSTLATENCY 33 -#define MACRO_SERVICELATENCY 34 -#define MACRO_HOSTDURATION 35 -#define MACRO_SERVICEDURATION 36 -#define MACRO_HOSTDURATIONSEC 37 -#define MACRO_SERVICEDURATIONSEC 38 -#define MACRO_HOSTDOWNTIME 39 -#define MACRO_SERVICEDOWNTIME 40 -#define MACRO_HOSTSTATETYPE 41 -#define MACRO_SERVICESTATETYPE 42 -#define MACRO_HOSTPERCENTCHANGE 43 -#define MACRO_SERVICEPERCENTCHANGE 44 -#define MACRO_HOSTGROUPNAME 45 -#define MACRO_HOSTGROUPALIAS 46 -#define MACRO_SERVICEGROUPNAME 47 -#define MACRO_SERVICEGROUPALIAS 48 -#define MACRO_HOSTACKAUTHOR 49 -#define MACRO_HOSTACKCOMMENT 50 -#define MACRO_SERVICEACKAUTHOR 51 -#define MACRO_SERVICEACKCOMMENT 52 -#define MACRO_LASTSERVICEOK 53 -#define MACRO_LASTSERVICEWARNING 54 -#define MACRO_LASTSERVICEUNKNOWN 55 -#define MACRO_LASTSERVICECRITICAL 56 -#define MACRO_LASTHOSTUP 57 -#define MACRO_LASTHOSTDOWN 58 -#define MACRO_LASTHOSTUNREACHABLE 59 -#define MACRO_SERVICECHECKCOMMAND 60 -#define MACRO_HOSTCHECKCOMMAND 61 -#define MACRO_MAINCONFIGFILE 62 -#define MACRO_STATUSDATAFILE 63 -#define MACRO_HOSTDISPLAYNAME 64 -#define MACRO_SERVICEDISPLAYNAME 65 -#define MACRO_RETENTIONDATAFILE 66 -#define MACRO_OBJECTCACHEFILE 67 -#define MACRO_TEMPFILE 68 -#define MACRO_LOGFILE 69 -#define MACRO_RESOURCEFILE 70 -#define MACRO_COMMANDFILE 71 -#define MACRO_HOSTPERFDATAFILE 72 -#define MACRO_SERVICEPERFDATAFILE 73 -#define MACRO_HOSTACTIONURL 74 -#define MACRO_HOSTNOTESURL 75 -#define MACRO_HOSTNOTES 76 -#define MACRO_SERVICEACTIONURL 77 -#define MACRO_SERVICENOTESURL 78 -#define MACRO_SERVICENOTES 79 -#define MACRO_TOTALHOSTSUP 80 -#define MACRO_TOTALHOSTSDOWN 81 -#define MACRO_TOTALHOSTSUNREACHABLE 82 -#define MACRO_TOTALHOSTSDOWNUNHANDLED 83 -#define MACRO_TOTALHOSTSUNREACHABLEUNHANDLED 84 -#define MACRO_TOTALHOSTPROBLEMS 85 -#define MACRO_TOTALHOSTPROBLEMSUNHANDLED 86 -#define MACRO_TOTALSERVICESOK 87 -#define MACRO_TOTALSERVICESWARNING 88 -#define MACRO_TOTALSERVICESCRITICAL 89 -#define MACRO_TOTALSERVICESUNKNOWN 90 -#define MACRO_TOTALSERVICESWARNINGUNHANDLED 91 -#define MACRO_TOTALSERVICESCRITICALUNHANDLED 92 -#define MACRO_TOTALSERVICESUNKNOWNUNHANDLED 93 -#define MACRO_TOTALSERVICEPROBLEMS 94 -#define MACRO_TOTALSERVICEPROBLEMSUNHANDLED 95 -#define MACRO_PROCESSSTARTTIME 96 -#define MACRO_HOSTCHECKTYPE 97 -#define MACRO_SERVICECHECKTYPE 98 -#define MACRO_LONGHOSTOUTPUT 99 -#define MACRO_LONGSERVICEOUTPUT 100 -#define MACRO_TEMPPATH 101 -#define MACRO_HOSTNOTIFICATIONNUMBER 102 -#define MACRO_SERVICENOTIFICATIONNUMBER 103 -#define MACRO_HOSTNOTIFICATIONID 104 -#define MACRO_SERVICENOTIFICATIONID 105 -#define MACRO_HOSTEVENTID 106 -#define MACRO_LASTHOSTEVENTID 107 -#define MACRO_SERVICEEVENTID 108 -#define MACRO_LASTSERVICEEVENTID 109 -#define MACRO_HOSTGROUPNAMES 110 -#define MACRO_SERVICEGROUPNAMES 111 -#define MACRO_HOSTACKAUTHORNAME 112 -#define MACRO_HOSTACKAUTHORALIAS 113 -#define MACRO_SERVICEACKAUTHORNAME 114 -#define MACRO_SERVICEACKAUTHORALIAS 115 -#define MACRO_MAXHOSTATTEMPTS 116 -#define MACRO_MAXSERVICEATTEMPTS 117 -#define MACRO_SERVICEISVOLATILE 118 -#define MACRO_TOTALHOSTSERVICES 119 -#define MACRO_TOTALHOSTSERVICESOK 120 -#define MACRO_TOTALHOSTSERVICESWARNING 121 -#define MACRO_TOTALHOSTSERVICESUNKNOWN 122 -#define MACRO_TOTALHOSTSERVICESCRITICAL 123 -#define MACRO_HOSTGROUPNOTES 124 -#define MACRO_HOSTGROUPNOTESURL 125 -#define MACRO_HOSTGROUPACTIONURL 126 -#define MACRO_SERVICEGROUPNOTES 127 -#define MACRO_SERVICEGROUPNOTESURL 128 -#define MACRO_SERVICEGROUPACTIONURL 129 -#define MACRO_HOSTGROUPMEMBERS 130 -#define MACRO_SERVICEGROUPMEMBERS 131 -#define MACRO_CONTACTGROUPNAME 132 -#define MACRO_CONTACTGROUPALIAS 133 -#define MACRO_CONTACTGROUPMEMBERS 134 -#define MACRO_CONTACTGROUPNAMES 135 -#define MACRO_NOTIFICATIONRECIPIENTS 136 -#define MACRO_NOTIFICATIONISESCALATED 137 -#define MACRO_NOTIFICATIONAUTHOR 138 -#define MACRO_NOTIFICATIONAUTHORNAME 139 -#define MACRO_NOTIFICATIONAUTHORALIAS 140 -#define MACRO_NOTIFICATIONCOMMENT 141 -#define MACRO_EVENTSTARTTIME 142 -#define MACRO_HOSTPROBLEMID 143 -#define MACRO_LASTHOSTPROBLEMID 144 -#define MACRO_SERVICEPROBLEMID 145 -#define MACRO_LASTSERVICEPROBLEMID 146 -#define MACRO_ISVALIDTIME 147 -#define MACRO_NEXTVALIDTIME 148 -#define MACRO_LASTHOSTSTATE 149 -#define MACRO_LASTHOSTSTATEID 150 -#define MACRO_LASTSERVICESTATE 151 -#define MACRO_LASTSERVICESTATEID 152 -#define MACRO_HOSTIMPORTANCE 153 -#define MACRO_SERVICEIMPORTANCE 154 -#define MACRO_HOSTANDSERVICESIMPORTANCE 155 -#define MACRO_HOSTGROUPMEMBERADDRESSES 156 -#define MACRO_HOSTINFOURL 157 -#define MACRO_SERVICEINFOURL 158 -#define MACRO_HOSTNOTIFICATIONENABLED 159 -#define MACRO_SERVICENOTIFICATIONENABLED 160 -#define MACRO_HOSTNOTIFICATIONPERIOD 161 -#define MACRO_SERVICENOTIFICATIONPERIOD 162 - - -/************* MACRO CLEANING OPTIONS *****************/ - -#define STRIP_ILLEGAL_MACRO_CHARS 1 -#define ESCAPE_MACRO_CHARS 2 -#define URL_ENCODE_MACRO_CHARS 4 - - - -/****************** MACRO FUNCTIONS ******************/ - -nagios_macros *get_global_macros(void); - -/* - * Replace macros with their actual values - * This function modifies the global_macros struct and is thus - * not thread-safe. - */ -int process_macros(char *, char **, int); - -/* thread-safe version of the above */ -int process_macros_r(nagios_macros *mac, char *, char **, int); - -/* cleans macros characters before insertion into output string */ -char *clean_macro_chars(char *, int); - -/* - * These functions updates **macros with the values from - * their respective object type. - */ - -int grab_service_macros(service *); -int grab_host_macros(host *); -int grab_servicegroup_macros(servicegroup *); -int grab_hostgroup_macros(hostgroup *); -int grab_contact_macros(contact *); - -int grab_macro_value(char *, char **, int *, int *); -int grab_macrox_value(int, char *, char *, char **, int *); -int grab_custom_macro_value(char *, char *, char *, char **); -int grab_datetime_macro(int, char *, char *, char **); -int grab_standard_host_macro(int, host *, char **, int *); -int grab_standard_hostgroup_macro(int, hostgroup *, char **); -int grab_standard_service_macro(int, service *, char **, int *); -int grab_standard_servicegroup_macro(int, servicegroup *, char **); -int grab_standard_contact_macro(int, contact *, char **); -int grab_contact_address_macro(int, contact *, char **); -int grab_standard_contactgroup_macro(int, contactgroup *, char **); -int grab_custom_object_macro(char *, customvariablesmember *, char **); - -/* thread-safe version of the above */ -int grab_service_macros_r(nagios_macros *mac, service *); -int grab_host_macros_r(nagios_macros *mac, host *); -int grab_servicegroup_macros_r(nagios_macros *mac, servicegroup *); -int grab_hostgroup_macros_r(nagios_macros *mac, hostgroup *); -int grab_contact_macros_r(nagios_macros *mac, contact *); - -int grab_argv_macros_r(nagios_macros *mac, char *check_command); - -int grab_macro_value_r(nagios_macros *mac, char *, char **, int *, int *); -int grab_macrox_value_r(nagios_macros *mac, int, char *, char *, char **, int *); -int grab_custom_macro_value_r(nagios_macros *mac, char *, char *, char *, char **); -int grab_datetime_macro_r(nagios_macros *mac, int, char *, char *, char **); -int grab_standard_host_macro_r(nagios_macros *mac, int, host *, char **, int *); -int grab_standard_hostgroup_macro_r(nagios_macros *mac, int, hostgroup *, char **); -int grab_standard_service_macro_r(nagios_macros *mac, int, service *, char **, int *); -int grab_standard_servicegroup_macro_r(nagios_macros *mac, int, servicegroup *, char **); -int grab_standard_contact_macro_r(nagios_macros *mac, int, contact *, char **); -int grab_custom_object_macro_r(nagios_macros *mac, char *, customvariablesmember *, char **); - - -char *get_url_encoded_string(char *); /* URL encode a string */ - -int init_macros(void); -int init_macrox_names(void); -int free_macrox_names(void); - -extern void copy_constant_macros(char **dest); - -/* clear macros */ -int clear_argv_macros(void); -int clear_volatile_macros(void); -int clear_host_macros(void); -int clear_service_macros(void); -int clear_hostgroup_macros(void); -int clear_servicegroup_macros(void); -int clear_contact_macros(void); -int clear_contactgroup_macros(void); -int clear_summary_macros(void); - -/* thread-safe version of the above */ -int clear_argv_macros_r(nagios_macros *mac); -int clear_volatile_macros_r(nagios_macros *mac); -int clear_host_macros_r(nagios_macros *mac); -int clear_service_macros_r(nagios_macros *mac); -int clear_hostgroup_macros_r(nagios_macros *mac); -int clear_servicegroup_macros_r(nagios_macros *mac); -int clear_contact_macros_r(nagios_macros *mac); -int clear_contactgroup_macros_r(nagios_macros *mac); -int clear_summary_macros_r(nagios_macros *mac); -int clear_datetime_macros_r(nagios_macros *mac); - - -#ifndef NSCGI -int set_all_macro_environment_vars(int); -int set_macrox_environment_vars(int); -int set_argv_macro_environment_vars(int); -int set_custom_macro_environment_vars(int); -int set_contact_address_environment_vars(int); -int set_macro_environment_var(char *, char *, int); - -/* thread-safe version of the above */ -int set_all_macro_environment_vars_r(nagios_macros *mac, int); -int set_macrox_environment_vars_r(nagios_macros *mac, int); -int set_argv_macro_environment_vars_r(nagios_macros *mac, int); -int set_custom_macro_environment_vars_r(nagios_macros *mac, int); -int set_contact_address_environment_vars_r(nagios_macros *mac, int); - -#endif - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/nagios.h b/devtools/ci/nagios/nagios.h deleted file mode 100644 index e1e5595..0000000 --- a/devtools/ci/nagios/nagios.h +++ /dev/null @@ -1,789 +0,0 @@ -/************************************************************************ - * - * Nagios Main Header File - * Written By: Ethan Galstad (egalstad@nagios.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - ************************************************************************/ - -#ifndef NAGIOS_NAGIOS_H_INCLUDED -#define NAGIOS_NAGIOS_H_INCLUDED - -#ifndef NSCORE -# define NSCORE -#endif - -#include "defaults.h" -#include "common.h" -#include "logging.h" -#include "locations.h" -#include "objects.h" -#include "macros.h" - -/* - * global variables only used in the core. Reducing this list would be - * a Good Thing(tm). - */ -extern char *nagios_binary_path; -extern char *config_file; -extern char *command_file; -extern char *temp_file; -extern char *temp_path; -extern char *check_result_path; -extern char *lock_file; -extern char *object_precache_file; - -extern unsigned int nofile_limit, nproc_limit, max_apps; - -extern int num_check_workers; -extern char *qh_socket_path; - -extern char *nagios_user; -extern char *nagios_group; - -extern char *macro_user[MAX_USER_MACROS]; - -extern char *ocsp_command; -extern char *ochp_command; -extern command *ocsp_command_ptr; -extern command *ochp_command_ptr; -extern int ocsp_timeout; -extern int ochp_timeout; - -extern char *global_host_event_handler; -extern char *global_service_event_handler; -extern command *global_host_event_handler_ptr; -extern command *global_service_event_handler_ptr; - -extern char *illegal_object_chars; - -extern int use_regexp_matches; -extern int use_true_regexp_matching; - -extern int use_syslog; -extern char *log_file; -extern char *log_archive_path; -extern int log_notifications; -extern int log_service_retries; -extern int log_host_retries; -extern int log_event_handlers; -extern int log_external_commands; -extern int log_passive_checks; -extern unsigned long logging_options; -extern unsigned long syslog_options; - -extern int service_check_timeout; -extern int service_check_timeout_state; -extern int host_check_timeout; -extern int event_handler_timeout; -extern int notification_timeout; - -extern int log_initial_states; -extern int log_current_states; - -extern int daemon_dumps_core; -extern int sig_id; -extern int caught_signal; - - -extern int verify_config; -extern int test_scheduling; -extern int precache_objects; -extern int use_precached_objects; - -extern int service_inter_check_delay_method; -extern int host_inter_check_delay_method; -extern int service_interleave_factor_method; -extern int max_host_check_spread; -extern int max_service_check_spread; - -extern sched_info scheduling_info; - -extern int max_parallel_service_checks; - -extern int check_reaper_interval; -extern int max_check_reaper_time; -extern int service_freshness_check_interval; -extern int host_freshness_check_interval; -extern int auto_rescheduling_interval; -extern int auto_rescheduling_window; - -extern int enable_soft_host_recovery; -extern int enable_soft_service_recovery; - -extern int check_orphaned_services; -extern int check_orphaned_hosts; -extern int check_service_freshness; -extern int check_host_freshness; -extern int auto_reschedule_checks; - -extern int additional_freshness_latency; - -extern int check_for_updates; -extern int bare_update_check; -extern time_t last_update_check; -extern unsigned long update_uid; -extern int update_available; -extern char *last_program_version; -extern char *new_program_version; - -extern int use_aggressive_host_checking; -extern time_t cached_host_check_horizon; -extern time_t cached_service_check_horizon; -extern int enable_predictive_host_dependency_checks; -extern int enable_predictive_service_dependency_checks; - -extern int soft_state_dependencies; - -extern int retain_state_information; -extern int retention_update_interval; -extern int use_retained_program_state; -extern int use_retained_scheduling_info; -extern int retention_scheduling_horizon; -extern char *retention_file; -extern unsigned long retained_host_attribute_mask; -extern unsigned long retained_service_attribute_mask; -extern unsigned long retained_contact_host_attribute_mask; -extern unsigned long retained_contact_service_attribute_mask; -extern unsigned long retained_process_host_attribute_mask; -extern unsigned long retained_process_service_attribute_mask; - -extern int translate_passive_host_checks; -extern int passive_host_checks_are_soft; - -extern int status_update_interval; -extern char *retention_file; - -extern int time_change_threshold; - -extern unsigned long event_broker_options; - -extern double low_service_flap_threshold; -extern double high_service_flap_threshold; -extern double low_host_flap_threshold; -extern double high_host_flap_threshold; - -extern int use_large_installation_tweaks; -extern int enable_environment_macros; -extern int free_child_process_memory; -extern int child_processes_fork_twice; - -extern char *use_timezone; - -extern time_t max_check_result_file_age; - -extern char *debug_file; -extern int debug_level; -extern int debug_verbosity; -extern unsigned long max_debug_file_size; - -extern int allow_empty_hostgroup_assignment; - -extern int host_down_disable_service_checks; -extern int service_skip_check_dependency_status; -extern int service_skip_check_parent_status; -extern int service_skip_check_host_down_status; -extern int host_skip_check_dependency_status; - -extern time_t last_program_stop; -extern time_t event_start; - -extern int sigshutdown, sigrestart; -extern int currently_running_service_checks; -extern int currently_running_host_checks; - -extern unsigned long next_event_id; -extern unsigned long next_problem_id; -extern unsigned long next_comment_id; -extern unsigned long next_notification_id; - -extern unsigned long modified_process_attributes; -extern unsigned long modified_host_process_attributes; -extern unsigned long modified_service_process_attributes; - -extern squeue_t *nagios_squeue; -extern iobroker_set *nagios_iobs; - -extern struct check_stats check_statistics[MAX_CHECK_STATS_TYPES]; - -/*** perfdata variables ***/ -extern int perfdata_timeout; -extern char *host_perfdata_command; -extern char *service_perfdata_command; -extern char *host_perfdata_file_template; -extern char *service_perfdata_file_template; -extern char *host_perfdata_file; -extern char *service_perfdata_file; -extern int host_perfdata_file_append; -extern int service_perfdata_file_append; -extern int host_perfdata_file_pipe; -extern int service_perfdata_file_pipe; -extern unsigned long host_perfdata_file_processing_interval; -extern unsigned long service_perfdata_file_processing_interval; -extern char *host_perfdata_file_processing_command; -extern char *service_perfdata_file_processing_command; -extern int host_perfdata_process_empty_results; -extern int service_perfdata_process_empty_results; -/*** end perfdata variables */ - -extern struct notify_list *notification_list; - -extern struct check_engine nagios_check_engine; - -/* - * Everything we need to keep system load in check. - * Don't use this from modules. - */ -struct load_control { - time_t last_check; /* last time we checked the real load */ - time_t last_change; /* last time we changed settings */ - time_t check_interval; /* seconds between load checks */ - double load[3]; /* system load, as reported by getloadavg() */ - float backoff_limit; /* limit we must reach before we back off */ - float rampup_limit; /* limit we must reach before we ramp back up */ - unsigned int backoff_change; /* backoff by this much */ - unsigned int rampup_change; /* ramp up by this much */ - unsigned int changes; /* number of times we've changed settings */ - unsigned int jobs_max; /* upper setting for jobs_limit */ - unsigned int jobs_limit; /* current limit */ - unsigned int jobs_min; /* lower setting for jobs_limit */ - unsigned int jobs_running; /* jobs currently running */ - unsigned int nproc_limit; /* rlimit for user processes */ - unsigned int nofile_limit; /* rlimit for open files */ - unsigned int options; /* various option flags */ -}; -extern struct load_control loadctl; - -/* options for load control */ -#define LOADCTL_ENABLED (1 << 0) - - - /************* MISC LENGTH/SIZE DEFINITIONS ***********/ - - /* - NOTE: Plugin length is artificially capped at 8k to prevent runaway plugins from returning MBs/GBs of data - back to Nagios. If you increase the 8k cap by modifying this value, make sure you also increase the value - of MAX_EXTERNAL_COMMAND_LENGTH in common.h to allow for passive checks results received through the external - command file. EG 10/19/07 - */ -#define MAX_PLUGIN_OUTPUT_LENGTH 8192 /* max length of plugin output (including perf data) */ - - - /******************* STATE LOGGING TYPES **************/ - -#define INITIAL_STATES 1 -#define CURRENT_STATES 2 - - - - /************ SERVICE DEPENDENCY VALUES ***************/ - -#define DEPENDENCIES_OK 0 -#define DEPENDENCIES_FAILED 1 - - - - /*********** ROUTE CHECK PROPAGATION TYPES ************/ - -#define PROPAGATE_TO_PARENT_HOSTS 1 -#define PROPAGATE_TO_CHILD_HOSTS 2 - - - - /****************** FLAPPING TYPES ********************/ - -#define HOST_FLAPPING 0 -#define SERVICE_FLAPPING 1 - - - - /**************** NOTIFICATION TYPES ******************/ - -#define HOST_NOTIFICATION 0 -#define SERVICE_NOTIFICATION 1 - - - - /************* NOTIFICATION REASON TYPES ***************/ - -#define NOTIFICATION_NORMAL 0 -#define NOTIFICATION_ACKNOWLEDGEMENT 1 -#define NOTIFICATION_FLAPPINGSTART 2 -#define NOTIFICATION_FLAPPINGSTOP 3 -#define NOTIFICATION_FLAPPINGDISABLED 4 -#define NOTIFICATION_DOWNTIMESTART 5 -#define NOTIFICATION_DOWNTIMEEND 6 -#define NOTIFICATION_DOWNTIMECANCELLED 7 -#define NOTIFICATION_CUSTOM 8 - - - - /**************** EVENT HANDLER TYPES *****************/ - -#define HOST_EVENTHANDLER 0 -#define SERVICE_EVENTHANDLER 1 -#define GLOBAL_HOST_EVENTHANDLER 2 -#define GLOBAL_SERVICE_EVENTHANDLER 3 - - - - /***************** STATE CHANGE TYPES *****************/ - -#define HOST_STATECHANGE 0 -#define SERVICE_STATECHANGE 1 - - - - /***************** OBJECT CHECK TYPES *****************/ -#define SERVICE_CHECK 0 -#define HOST_CHECK 1 - - - - /******************* EVENT TYPES **********************/ - -#define EVENT_SERVICE_CHECK 0 /* active service check */ -#define EVENT_COMMAND_CHECK 1 /* external command check */ -#define EVENT_LOG_ROTATION 2 /* log file rotation */ -#define EVENT_PROGRAM_SHUTDOWN 3 /* program shutdown */ -#define EVENT_PROGRAM_RESTART 4 /* program restart */ -#define EVENT_CHECK_REAPER 5 /* reaps results from host and service checks */ -#define EVENT_ORPHAN_CHECK 6 /* checks for orphaned hosts and services */ -#define EVENT_RETENTION_SAVE 7 /* save (dump) retention data */ -#define EVENT_STATUS_SAVE 8 /* save (dump) status data */ -#define EVENT_SCHEDULED_DOWNTIME 9 /* scheduled host or service downtime */ -#define EVENT_SFRESHNESS_CHECK 10 /* checks service result "freshness" */ -#define EVENT_EXPIRE_DOWNTIME 11 /* checks for (and removes) expired scheduled downtime */ -#define EVENT_HOST_CHECK 12 /* active host check */ -#define EVENT_HFRESHNESS_CHECK 13 /* checks host result "freshness" */ -#define EVENT_RESCHEDULE_CHECKS 14 /* adjust scheduling of host and service checks */ -#define EVENT_EXPIRE_COMMENT 15 /* removes expired comments */ -#define EVENT_CHECK_PROGRAM_UPDATE 16 /* checks for new version of Nagios */ -#define EVENT_SLEEP 98 /* asynchronous sleep event that occurs when event queues are empty */ -#define EVENT_USER_FUNCTION 99 /* USER-defined function (modules) */ - -/* - * VERSIONFIX: Make EVENT_SLEEP and EVENT_USER_FUNCTION appear - * linearly in order. - */ - -#define EVENT_TYPE_STR(type) ( \ - type == EVENT_SERVICE_CHECK ? "SERVICE_CHECK" : \ - type == EVENT_COMMAND_CHECK ? "COMMAND_CHECK" : \ - type == EVENT_LOG_ROTATION ? "LOG_ROTATION" : \ - type == EVENT_PROGRAM_SHUTDOWN ? "PROGRAM_SHUTDOWN" : \ - type == EVENT_PROGRAM_RESTART ? "PROGRAM_RESTART" : \ - type == EVENT_CHECK_REAPER ? "CHECK_REAPER" : \ - type == EVENT_ORPHAN_CHECK ? "ORPHAN_CHECK" : \ - type == EVENT_RETENTION_SAVE ? "RETENTION_SAVE" : \ - type == EVENT_STATUS_SAVE ? "STATUS_SAVE" : \ - type == EVENT_SCHEDULED_DOWNTIME ? "SCHEDULED_DOWNTIME" : \ - type == EVENT_SFRESHNESS_CHECK ? "SFRESHNESS_CHECK" : \ - type == EVENT_EXPIRE_DOWNTIME ? "EXPIRE_DOWNTIME" : \ - type == EVENT_HOST_CHECK ? "HOST_CHECK" : \ - type == EVENT_HFRESHNESS_CHECK ? "HFRESHNESS_CHECK" : \ - type == EVENT_RESCHEDULE_CHECKS ? "RESCHEDULE_CHECKS" : \ - type == EVENT_EXPIRE_COMMENT ? "EXPIRE_COMMENT" : \ - type == EVENT_CHECK_PROGRAM_UPDATE ? "CHECK_PROGRAM_UPDATE" : \ - type == EVENT_SLEEP ? "SLEEP" : \ - type == EVENT_USER_FUNCTION ? "USER_FUNCTION" : \ - "UNKNOWN" \ -) - - - - /******* INTER-CHECK DELAY CALCULATION TYPES **********/ - -#define ICD_NONE 0 /* no inter-check delay */ -#define ICD_DUMB 1 /* dumb delay of 1 second */ -#define ICD_SMART 2 /* smart delay */ -#define ICD_USER 3 /* user-specified delay */ - - - - /******* INTERLEAVE FACTOR CALCULATION TYPES **********/ - -#define ILF_USER 0 /* user-specified interleave factor */ -#define ILF_SMART 1 /* smart interleave */ - - - - /************ SCHEDULED DOWNTIME TYPES ****************/ - -#define ACTIVE_DOWNTIME 0 /* active downtime - currently in effect */ -#define PENDING_DOWNTIME 1 /* pending downtime - scheduled for the future */ - - -NAGIOS_BEGIN_DECL - -/* useful for hosts and services to determine time 'til next check */ -#define normal_check_window(o) ((time_t)(o->check_interval * interval_length)) -#define retry_check_window(o) ((time_t)(o->retry_interval * interval_length)) -#define check_window(o) \ - ((o->current_state && o->state_type == SOFT_STATE) ? \ - retry_check_window(o) : \ - normal_check_window(o)) - -/******************** FUNCTIONS **********************/ -extern int set_loadctl_options(char *opts, unsigned int len); - -/* silly helpers useful pretty much all over the place */ -extern const char *service_state_name(int state); -extern const char *host_state_name(int state); -extern const char *state_type_name(int state_type); -extern const char *check_type_name(int check_type); -extern const char *check_result_source(check_result *cr); - -#ifdef ENABLE_NERD - -/** Nerd subscription type */ -struct nerd_subscription { - int sd; - struct nerd_channel *chan; - char *format; /* requested format (macro string) for this subscription */ -}; - -/*** Nagios Event Radio Dispatcher functions ***/ -extern int nerd_init(void); -extern int nerd_mkchan(const char *name, const char *description, int (*handler)(int, void *), unsigned int callbacks); -extern int nerd_cancel_subscriber(int sd); -extern int nerd_get_channel_id(const char *chan_name); -extern objectlist *nerd_get_subscriptions(int chan_id); -extern int nerd_broadcast(unsigned int chan_id, void *buf, unsigned int len); - -#endif - -/*** Query Handler functions, types and macros*/ -typedef int (*qh_handler)(int, char *, unsigned int); -extern int dump_event_stats(int sd); - -/* return codes for query_handlers() */ -#define QH_OK 0 /* keep listening */ -#define QH_CLOSE 1 /* we should close the socket */ -#define QH_INVALID 2 /* invalid query. Log and close */ -#define QH_TAKEOVER 3 /* handler will take full control. de-register but don't close */ -extern int qh_init(const char *path); -extern void qh_deinit(const char *path); -extern int qh_register_handler(const char *name, const char *description, unsigned int options, qh_handler handler); -extern const char *qh_strerror(int code); - -/**** Configuration Functions ****/ -int read_main_config_file(char *); /* reads the main config file (nagios.cfg) */ -int read_resource_file(char *); /* processes macros in resource file */ -int read_all_object_data(char *); /* reads all object config data */ - - -/**** Setup Functions ****/ -int pre_flight_check(void); /* try and verify the configuration data */ -int pre_flight_object_check(int *, int *); /* verify object relationships and settings */ -int pre_flight_circular_check(int *, int *); /* detects circular dependencies and paths */ -void init_timing_loop(void); /* setup the initial scheduling queue */ -void setup_sighandler(void); /* trap signals */ -void reset_sighandler(void); /* reset signals to default action */ -extern void handle_sigxfsz(int); /* handle SIGXFSZ */ - -int daemon_init(void); /* switches to daemon mode */ -int drop_privileges(char *, char *); /* drops privileges before startup */ -void display_scheduling_info(void); /* displays service check scheduling information */ -void init_main_cfg_vars(int); /* Initialize the non-shared main configuration variables */ - - -/**** Event Queue Functions ****/ -int init_event_queue(void); /* creates the queue nagios_squeue */ -timed_event *schedule_new_event(int, int, time_t, int, unsigned long, void *, int, void *, void *, int); /* schedules a new timed event */ -void reschedule_event(squeue_t *sq, timed_event *event); /* reschedules an event */ -void add_event(squeue_t *sq, timed_event *event); /* adds an event to the execution queue */ -void remove_event(squeue_t *sq, timed_event *event); /* remove an event from the execution queue */ -int event_execution_loop(void); /* main monitoring/event handler loop */ -int handle_timed_event(timed_event *); /* top level handler for timed events */ -void adjust_check_scheduling(void); /* auto-adjusts scheduling of host and service checks */ -void compensate_for_system_time_change(unsigned long, unsigned long); /* attempts to compensate for a change in the system time */ -void adjust_timestamp_for_time_change(time_t, time_t, unsigned long, time_t *); /* adjusts a timestamp variable for a system time change */ - - -/**** IPC Functions ****/ -int process_check_result_queue(char *); -int process_check_result_file(char *); -int process_check_result(check_result *); -int delete_check_result_file(char *); -int init_check_result(check_result *); -int free_check_result(check_result *); /* frees memory associated with a host/service check result */ -int parse_check_output(char *, char **, char **, char **, int, int); -int open_command_file(void); /* creates the external command file as a named pipe (FIFO) and opens it for reading */ -int close_command_file(void); /* closes and deletes the external command file (FIFO) */ - - -/**** Monitoring/Event Handler Functions ****/ -int check_service_parents(service *svc); /* checks service parents */ -int check_service_dependencies(service *, int); /* checks service dependencies */ -int check_host_dependencies(host *, int); /* checks host dependencies */ -void check_for_orphaned_services(void); /* checks for orphaned services */ -void check_for_orphaned_hosts(void); /* checks for orphaned hosts */ -void check_service_result_freshness(void); /* checks the "freshness" of service check results */ -int is_service_result_fresh(service *, time_t, int); /* determines if a service's check results are fresh */ -void check_host_result_freshness(void); /* checks the "freshness" of host check results */ -int is_host_result_fresh(host *, time_t, int); /* determines if a host's check results are fresh */ -int my_system(char *, int, int *, double *, char **, int); /* executes a command via popen(), but also protects against timeouts */ -int my_system_r(nagios_macros *mac, char *, int, int *, double *, char **, int); /* thread-safe version of the above */ - - -/**** Flap Detection Functions ****/ -void check_for_service_flapping(service *, int, int); /* determines whether or not a service is "flapping" between states */ -void check_for_host_flapping(host *, int, int, int); /* determines whether or not a host is "flapping" between states */ -void set_service_flap(service *, double, double, double, int); /* handles a service that is flapping */ -void clear_service_flap(service *, double, double, double, int); /* handles a service that has stopped flapping */ -void set_host_flap(host *, double, double, double, int); /* handles a host that is flapping */ -void clear_host_flap(host *, double, double, double, int); /* handles a host that has stopped flapping */ -void enable_flap_detection_routines(void); /* enables flap detection on a program-wide basis */ -void disable_flap_detection_routines(void); /* disables flap detection on a program-wide basis */ -void enable_host_flap_detection(host *); /* enables flap detection for a particular host */ -void disable_host_flap_detection(host *); /* disables flap detection for a particular host */ -void enable_service_flap_detection(service *); /* enables flap detection for a particular service */ -void disable_service_flap_detection(service *); /* disables flap detection for a particular service */ -void handle_host_flap_detection_disabled(host *); /* handles the details when flap detection is disabled globally or on a per-host basis */ -void handle_service_flap_detection_disabled(service *); /* handles the details when flap detection is disabled globally or on a per-service basis */ - - -/**** Route/Host Check Functions ****/ -int check_host_check_viability(host *, int, int *, time_t *); -int adjust_host_check_attempt(host *, int); -int determine_host_reachability(host *); -int perform_on_demand_host_check(host *, int *, int, int, unsigned long); -int execute_sync_host_check(host *); -int run_scheduled_host_check(host *, int, double); -int run_async_host_check(host *, int, double, int, int, int *, time_t *); -int handle_async_host_check_result(host *, check_result *); - - -/**** Service Check Functions ****/ -int check_service_check_viability(service *, int, int *, time_t *); -int run_scheduled_service_check(service *, int, double); -int run_async_service_check(service *, int, double, int, int, int *, time_t *); -int handle_async_service_check_result(service *, check_result *); - - -/**** Event Handler Functions ****/ -int handle_host_state(host *); /* top level host state handler */ - - -/**** Common Check Functions *****/ -int reap_check_results(void); - - -/**** Check Statistics Functions ****/ -int init_check_stats(void); -int update_check_stats(int, time_t); -int generate_check_stats(void); - - -/**** Event Handler Functions ****/ -int obsessive_compulsive_service_check_processor(service *); /* distributed monitoring craziness... */ -int obsessive_compulsive_host_check_processor(host *); /* distributed monitoring craziness... */ -int handle_service_event(service *); /* top level service event logic */ -int run_service_event_handler(nagios_macros *mac, service *); /* runs the event handler for a specific service */ -int run_global_service_event_handler(nagios_macros *mac, service *); /* runs the global service event handler */ -int handle_host_event(host *); /* top level host event logic */ -int run_host_event_handler(nagios_macros *mac, host *); /* runs the event handler for a specific host */ -int run_global_host_event_handler(nagios_macros *mac, host *); /* runs the global host event handler */ - - -/**** Notification Functions ****/ -const char *notification_reason_name(unsigned int reason_type); -int check_service_notification_viability(service *, int, int); /* checks viability of notifying all contacts about a service */ -int is_valid_escalation_for_service_notification(service *, serviceescalation *, int); /* checks if an escalation entry is valid for a particular service notification */ -int should_service_notification_be_escalated(service *); /* checks if a service notification should be escalated */ -int service_notification(service *, int, char *, char *, int); /* notify all contacts about a service (problem or recovery) */ -int check_contact_service_notification_viability(contact *, service *, int, int); /* checks viability of notifying a contact about a service */ -int notify_contact_of_service(nagios_macros *mac, contact *, service *, int, char *, char *, int, int); /* notify a single contact about a service */ -int check_host_notification_viability(host *, int, int); /* checks viability of notifying all contacts about a host */ -int is_valid_escalation_for_host_notification(host *, hostescalation *, int); /* checks if an escalation entry is valid for a particular host notification */ -int should_host_notification_be_escalated(host *); /* checks if a host notification should be escalated */ -int host_notification(host *, int, char *, char *, int); /* notify all contacts about a host (problem or recovery) */ -int check_contact_host_notification_viability(contact *, host *, int, int); /* checks viability of notifying a contact about a host */ -int notify_contact_of_host(nagios_macros *mac, contact *, host *, int, char *, char *, int, int); /* notify a single contact about a host */ -int create_notification_list_from_host(nagios_macros *mac, host *,int,int *,int); /* given a host, create list of contacts to be notified (remove duplicates) */ -int create_notification_list_from_service(nagios_macros *mac, service *,int,int *,int); /* given a service, create list of contacts to be notified (remove duplicates) */ -int add_notification(nagios_macros *mac, contact *); /* adds a notification instance */ -notification *find_notification(contact *); /* finds a notification object */ -time_t get_next_host_notification_time(host *, time_t); /* calculates nex acceptable re-notification time for a host */ -time_t get_next_service_notification_time(service *, time_t); /* calculates nex acceptable re-notification time for a service */ - - -/**** Cleanup Functions ****/ -void cleanup(void); /* cleanup after ourselves (before quitting or restarting) */ -void free_memory(nagios_macros *mac); /* free memory allocated to all linked lists in memory */ -int reset_variables(void); /* reset all global variables */ -void free_notification_list(void); /* frees all memory allocated to the notification list */ - - -/**** Miscellaneous Functions ****/ -void sighandler(int); /* handles signals */ -void my_system_sighandler(int); /* handles timeouts when executing commands via my_system() */ -char *get_next_string_from_buf(char *buf, int *start_index, int bufsize); -int compare_strings(char *, char *); /* compares two strings for equality */ -char *escape_newlines(char *); -#ifdef DETECT_RLIMIT_PROBLEM -void rlimit_problem_detection(int); -#endif -/** - * Unescapes newlines and backslashes in a check result output string read from - * a source that uses newlines as a delimiter (e.g., files in the checkresults - * spool dir, or the command pipe). - * @note: There is an unescape_newlines() in cgi/cgiutils.c that unescapes more - * than '\\' and '\n' in place. Since this function is specifically intended - * for processing escaped plugin output, we'll use a more specific name to - * avoid confusion and conflicts. - * @param rawbuf Input string tp unescape. - * @return An unescaped copy of rawbuf in a newly allocated string, or NULL if - * rawbuf is NULL or no memory could be allocated for the new string. - */ -char *unescape_check_result_output(const char *rawbuf); - -int contains_illegal_object_chars(char *); /* tests whether or not an object name (host, service, etc.) contains illegal characters */ -int my_rename(char *, char *); /* renames a file - works across filesystems */ -int my_fcopy(char *, char *); /* copies a file - works across filesystems */ -int my_fdcopy(char *, char *, int); /* copies a named source to an already opened destination file */ - -/* thread-safe version of get_raw_command_line_r() */ -extern int get_raw_command_line_r(nagios_macros *mac, command *, char *, char **, int); - -/* - * given a raw command line, determine the actual command to run - * Manipulates global_macros.argv and is thus not threadsafe - */ -extern int get_raw_command_line(command *, char *, char **, int); - -int check_time_against_period(time_t, timeperiod *); /* check to see if a specific time is covered by a time period */ -int is_daterange_single_day(daterange *); -time_t calculate_time_from_weekday_of_month(int, int, int, int); /* calculates midnight time of specific (3rd, last, etc.) weekday of a particular month */ -time_t calculate_time_from_day_of_month(int, int, int); /* calculates midnight time of specific (1st, last, etc.) day of a particular month */ -void get_next_valid_time(time_t, time_t *, timeperiod *); /* get the next valid time in a time period */ -time_t reschedule_within_timeperiod(time_t, timeperiod*, time_t); -time_t get_next_log_rotation_time(void); /* determine the next time to schedule a log rotation */ -int dbuf_init(dbuf *, int); -int dbuf_free(dbuf *); -int dbuf_strcat(dbuf *, const char *); -int set_environment_var(char *, char *, int); /* sets/clears and environment variable */ -int check_for_nagios_updates(int, int); /* checks to see if new version of Nagios are available */ -int query_update_api(void); /* checks to see if new version of Nagios are available */ - - -/**** External Command Functions ****/ -int process_external_command1(char *); /* top-level external command processor */ -int process_external_command2(int, time_t, char *); /* process an external command */ -int process_external_commands_from_file(char *, int); /* process external commands in a file */ -int process_host_command(int, time_t, char *); /* process an external host command */ -int process_hostgroup_command(int, time_t, char *); /* process an external hostgroup command */ -int process_service_command(int, time_t, char *); /* process an external service command */ -int process_servicegroup_command(int, time_t, char *); /* process an external servicegroup command */ -int process_contact_command(int, time_t, char *); /* process an external contact command */ -int process_contactgroup_command(int, time_t, char *); /* process an external contactgroup command */ - - -/**** External Command Implementations ****/ -int cmd_add_comment(int, time_t, char *); /* add a service or host comment */ -int cmd_delete_comment(int, char *); /* delete a service or host comment */ -int cmd_delete_all_comments(int, char *); /* delete all comments associated with a host or service */ -int cmd_delay_notification(int, char *); /* delay a service or host notification */ -int cmd_schedule_check(int, char *); /* schedule an immediate or delayed host check */ -int cmd_schedule_host_service_checks(int, char *, int); /* schedule an immediate or delayed checks of all services on a host */ -int cmd_signal_process(int, char *); /* schedules a program shutdown or restart */ -int cmd_process_service_check_result(int, time_t, char *); /* processes a passive service check */ -int cmd_process_host_check_result(int, time_t, char *); /* processes a passive host check */ -int cmd_acknowledge_problem(int, char *); /* acknowledges a host or service problem */ -int cmd_remove_acknowledgement(int, char *); /* removes a host or service acknowledgement */ -int cmd_schedule_downtime(int, time_t, char *); /* schedules host or service downtime */ -int cmd_delete_downtime(int, char *); /* cancels active/pending host or service scheduled downtime */ -int cmd_change_object_int_var(int, char *); /* changes host/svc (int) variable */ -int cmd_change_object_char_var(int, char *); /* changes host/svc (char) variable */ -int cmd_change_object_custom_var(int, char *); /* changes host/svc custom variable */ -int cmd_process_external_commands_from_file(int, char *); /* process external commands from a file */ -int cmd_delete_downtime_by_start_time_comment(int, char *); -int cmd_delete_downtime_by_host_name(int, char *); -int cmd_delete_downtime_by_hostgroup_name(int, char *); - -int process_passive_service_check(time_t, char *, char *, int, char *); -int process_passive_host_check(time_t, char *, int, char *); - - -/**** Internal Command Implementations ****/ -void disable_service_checks(service *); /* disables a service check */ -void enable_service_checks(service *); /* enables a service check */ -void schedule_service_check(service *, time_t, int); /* schedules an immediate or delayed service check */ -void schedule_host_check(host *, time_t, int); /* schedules an immediate or delayed host check */ -void enable_all_notifications(void); /* enables notifications on a program-wide basis */ -void disable_all_notifications(void); /* disables notifications on a program-wide basis */ -void enable_service_notifications(service *); /* enables service notifications */ -void disable_service_notifications(service *); /* disables service notifications */ -void enable_host_notifications(host *); /* enables host notifications */ -void disable_host_notifications(host *); /* disables host notifications */ -void enable_and_propagate_notifications(host *, int, int, int, int); /* enables notifications for all hosts and services beyond a given host */ -void disable_and_propagate_notifications(host *, int, int, int, int); /* disables notifications for all hosts and services beyond a given host */ -void schedule_and_propagate_downtime(host *, time_t, char *, char *, time_t, time_t, int, unsigned long, unsigned long); /* schedules downtime for all hosts beyond a given host */ -void acknowledge_host_problem(host *, char *, char *, int, int, int); /* acknowledges a host problem */ -void acknowledge_service_problem(service *, char *, char *, int, int, int); /* acknowledges a service problem */ -void remove_host_acknowledgement(host *); /* removes a host acknowledgement */ -void remove_service_acknowledgement(service *); /* removes a service acknowledgement */ -void start_executing_service_checks(void); /* starts executing service checks */ -void stop_executing_service_checks(void); /* stops executing service checks */ -void start_accepting_passive_service_checks(void); /* starts accepting passive service check results */ -void stop_accepting_passive_service_checks(void); /* stops accepting passive service check results */ -void enable_passive_service_checks(service *); /* enables passive service checks for a particular service */ -void disable_passive_service_checks(service *); /* disables passive service checks for a particular service */ -void start_using_event_handlers(void); /* enables event handlers on a program-wide basis */ -void stop_using_event_handlers(void); /* disables event handlers on a program-wide basis */ -void enable_service_event_handler(service *); /* enables the event handler for a particular service */ -void disable_service_event_handler(service *); /* disables the event handler for a particular service */ -void enable_host_event_handler(host *); /* enables the event handler for a particular host */ -void disable_host_event_handler(host *); /* disables the event handler for a particular host */ -void enable_host_checks(host *); /* enables checks of a particular host */ -void disable_host_checks(host *); /* disables checks of a particular host */ -void start_obsessing_over_service_checks(void); /* start obsessing about service check results */ -void stop_obsessing_over_service_checks(void); /* stop obsessing about service check results */ -void start_obsessing_over_host_checks(void); /* start obsessing about host check results */ -void stop_obsessing_over_host_checks(void); /* stop obsessing about host check results */ -void enable_service_freshness_checks(void); /* enable service freshness checks */ -void disable_service_freshness_checks(void); /* disable service freshness checks */ -void enable_host_freshness_checks(void); /* enable host freshness checks */ -void disable_host_freshness_checks(void); /* disable host freshness checks */ -void enable_performance_data(void); /* enables processing of performance data on a program-wide basis */ -void disable_performance_data(void); /* disables processing of performance data on a program-wide basis */ -void start_executing_host_checks(void); /* starts executing host checks */ -void stop_executing_host_checks(void); /* stops executing host checks */ -void start_accepting_passive_host_checks(void); /* starts accepting passive host check results */ -void stop_accepting_passive_host_checks(void); /* stops accepting passive host check results */ -void enable_passive_host_checks(host *); /* enables passive host checks for a particular host */ -void disable_passive_host_checks(host *); /* disables passive host checks for a particular host */ -void start_obsessing_over_service(service *); /* start obsessing about specific service check results */ -void stop_obsessing_over_service(service *); /* stop obsessing about specific service check results */ -void start_obsessing_over_host(host *); /* start obsessing about specific host check results */ -void stop_obsessing_over_host(host *); /* stop obsessing about specific host check results */ -void set_host_notification_number(host *, int); /* sets current notification number for a specific host */ -void set_service_notification_number(service *, int); /* sets current notification number for a specific service */ -void enable_contact_host_notifications(contact *); /* enables host notifications for a specific contact */ -void disable_contact_host_notifications(contact *); /* disables host notifications for a specific contact */ -void enable_contact_service_notifications(contact *); /* enables service notifications for a specific contact */ -void disable_contact_service_notifications(contact *); /* disables service notifications for a specific contact */ -void clear_host_flapping_state(host *); /* clears the flapping state for a specific host */ -void clear_service_flapping_state(service *); /* clears the flapping state for a specific service */ - -int launch_command_file_worker(void); -int shutdown_command_file_worker(void); - -char *get_program_version(void); -char *get_program_modification_date(void); - -NAGIOS_END_DECL -#endif - diff --git a/devtools/ci/nagios/nebcallbacks.h b/devtools/ci/nagios/nebcallbacks.h deleted file mode 100644 index f67477a..0000000 --- a/devtools/ci/nagios/nebcallbacks.h +++ /dev/null @@ -1,70 +0,0 @@ -/***************************************************************************** - * - * NEBCALLBACKS.H - Include file for event broker modules - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#ifndef NAGIOS_NEBCALLBACKS_H_INCLUDED -#define NAGIOS_NEBCALLBACKS_H_INCLUDED - -#include "nebmodules.h" - - -/***** CALLBACK TYPES *****/ - -#define NEBCALLBACK_NUMITEMS 26 /* total number of callback types we have */ - -#define NEBCALLBACK_PROCESS_DATA 0 -#define NEBCALLBACK_TIMED_EVENT_DATA 1 -#define NEBCALLBACK_LOG_DATA 2 -#define NEBCALLBACK_SYSTEM_COMMAND_DATA 3 -#define NEBCALLBACK_EVENT_HANDLER_DATA 4 -#define NEBCALLBACK_NOTIFICATION_DATA 5 -#define NEBCALLBACK_SERVICE_CHECK_DATA 6 -#define NEBCALLBACK_HOST_CHECK_DATA 7 -#define NEBCALLBACK_COMMENT_DATA 8 -#define NEBCALLBACK_DOWNTIME_DATA 9 -#define NEBCALLBACK_FLAPPING_DATA 10 -#define NEBCALLBACK_PROGRAM_STATUS_DATA 11 -#define NEBCALLBACK_HOST_STATUS_DATA 12 -#define NEBCALLBACK_SERVICE_STATUS_DATA 13 -#define NEBCALLBACK_ADAPTIVE_PROGRAM_DATA 14 -#define NEBCALLBACK_ADAPTIVE_HOST_DATA 15 -#define NEBCALLBACK_ADAPTIVE_SERVICE_DATA 16 -#define NEBCALLBACK_EXTERNAL_COMMAND_DATA 17 -#define NEBCALLBACK_AGGREGATED_STATUS_DATA 18 -#define NEBCALLBACK_RETENTION_DATA 19 -#define NEBCALLBACK_CONTACT_NOTIFICATION_DATA 20 -#define NEBCALLBACK_CONTACT_NOTIFICATION_METHOD_DATA 21 -#define NEBCALLBACK_ACKNOWLEDGEMENT_DATA 22 -#define NEBCALLBACK_STATE_CHANGE_DATA 23 -#define NEBCALLBACK_CONTACT_STATUS_DATA 24 -#define NEBCALLBACK_ADAPTIVE_CONTACT_DATA 25 - -#define nebcallback_flag(x) (1 << (x)) - -/***** CALLBACK FUNCTIONS *****/ -NAGIOS_BEGIN_DECL - -int neb_register_callback(int callback_type, void *mod_handle, int priority, int (*callback_func)(int, void *)); -int neb_deregister_callback(int callback_type, int (*callback_func)(int, void *)); -int neb_deregister_module_callbacks(nebmodule *); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/neberrors.h b/devtools/ci/nagios/neberrors.h deleted file mode 100644 index d4cba36..0000000 --- a/devtools/ci/nagios/neberrors.h +++ /dev/null @@ -1,67 +0,0 @@ -/***************************************************************************** - * - * NEBERRORS.H - Event broker errors - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#ifndef NAGIOS_NEBERRORS_H_INCLUDED -#define NAGIOS_NEBERRORS_H_INCLUDED - - -/***** GENERIC DEFINES *****/ - -#define NEB_OK 0 -#define NEB_ERROR -1 - -#define NEB_TRUE 1 -#define NEB_FALSE 0 - - - -/***** GENERIC ERRORS *****/ - -#define NEBERROR_NOMEM 100 /* memory could not be allocated */ - - - -/***** CALLBACK ERRORS *****/ - -#define NEBERROR_NOCALLBACKFUNC 200 /* no callback function was specified */ -#define NEBERROR_NOCALLBACKLIST 201 /* callback list not initialized */ -#define NEBERROR_CALLBACKBOUNDS 202 /* callback type was out of bounds */ -#define NEBERROR_CALLBACKNOTFOUND 203 /* the callback could not be found */ -#define NEBERROR_NOMODULEHANDLE 204 /* no module handle specified */ -#define NEBERROR_BADMODULEHANDLE 205 /* bad module handle */ -#define NEBERROR_CALLBACKOVERRIDE 206 /* module wants to override default Nagios handling of event */ -#define NEBERROR_CALLBACKCANCEL 207 /* module wants to cancel callbacks to other modules */ - - - -/***** MODULE ERRORS *****/ - -#define NEBERROR_NOMODULE 300 /* no module was specified */ - - - -/***** MODULE INFO ERRORS *****/ - -#define NEBERROR_MODINFOBOUNDS 400 /* module info index was out of bounds */ - - -#endif diff --git a/devtools/ci/nagios/nebmods.h b/devtools/ci/nagios/nebmods.h deleted file mode 100644 index 760ff0b..0000000 --- a/devtools/ci/nagios/nebmods.h +++ /dev/null @@ -1,62 +0,0 @@ -/***************************************************************************** - * - * NEBMODS.H - Include file for event broker modules - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#ifndef NAGIOS_NEBMODS_H_INCLUDED -#define NAGIOS_NEBMODS_H_INCLUDED - -#include "nebcallbacks.h" -#include "nebmodules.h" - -NAGIOS_BEGIN_DECL - -/***** MODULE STRUCTURES *****/ - -/* NEB module callback list struct */ -typedef struct nebcallback_struct { - void *callback_func; - void *module_handle; - int priority; - struct nebcallback_struct *next; - } nebcallback; - - - -/***** MODULE FUNCTIONS *****/ - -int neb_init_modules(void); -int neb_deinit_modules(void); -int neb_load_all_modules(void); -int neb_load_module(nebmodule *); -int neb_free_module_list(void); -int neb_unload_all_modules(int, int); -int neb_unload_module(nebmodule *, int, int); -int neb_add_module(char *, char *, int); -int neb_add_core_module(nebmodule *mod); - - -/***** CALLBACK FUNCTIONS *****/ -int neb_init_callback_list(void); -int neb_free_callback_list(void); -int neb_make_callbacks(int, void *); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/nebmodules.h b/devtools/ci/nagios/nebmodules.h deleted file mode 100644 index 4fc2b2f..0000000 --- a/devtools/ci/nagios/nebmodules.h +++ /dev/null @@ -1,94 +0,0 @@ -/***************************************************************************** - * - * NEBMODULES.H - Include file for event broker modules - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#ifndef NAGIOS_NEBMODULES_H_INCLUDED -#define NAGIOS_NEBMODULES_H_INCLUDED - -#include "common.h" -NAGIOS_BEGIN_DECL - - /***** MODULE VERSION INFORMATION *****/ - -#define NEB_API_VERSION(x) int __neb_api_version = x; -#define CURRENT_NEB_API_VERSION 4 - - - - /***** MODULE INFORMATION *****/ - -#define NEBMODULE_MODINFO_NUMITEMS 6 -#define NEBMODULE_MODINFO_TITLE 0 -#define NEBMODULE_MODINFO_AUTHOR 1 -#define NEBMODULE_MODINFO_COPYRIGHT 2 -#define NEBMODULE_MODINFO_VERSION 3 -#define NEBMODULE_MODINFO_LICENSE 4 -#define NEBMODULE_MODINFO_DESC 5 - - - - /***** MODULE LOAD/UNLOAD OPTIONS *****/ - -#define NEBMODULE_NORMAL_LOAD 0 /* module is being loaded normally */ -#define NEBMODULE_REQUEST_UNLOAD 0 /* request module to unload (but don't force it) */ -#define NEBMODULE_FORCE_UNLOAD 1 /* force module to unload */ - - - - /***** MODULES UNLOAD REASONS *****/ - -#define NEBMODULE_NEB_SHUTDOWN 1 /* event broker is shutting down */ -#define NEBMODULE_NEB_RESTART 2 /* event broker is restarting */ -#define NEBMODULE_ERROR_NO_INIT 3 /* _module_init() function was not found in module */ -#define NEBMODULE_ERROR_BAD_INIT 4 /* _module_init() function returned a bad code */ -#define NEBMODULE_ERROR_API_VERSION 5 /* module version is incompatible with current api */ - - - -/***** MODULE STRUCTURES *****/ - -/* NEB module structure */ -typedef struct nebmodule_struct { - char *filename; - char *dl_file; /* the file we actually loaded */ - char *args; - char *info[NEBMODULE_MODINFO_NUMITEMS]; - int should_be_loaded; - int is_currently_loaded; - int core_module; -#ifdef USE_LTDL - lt_dlhandle module_handle; - lt_ptr init_func; - lt_ptr deinit_func; -#else - void *module_handle; - void *init_func; - void *deinit_func; -#endif - struct nebmodule_struct *next; - } nebmodule; - - -/***** MODULE FUNCTIONS *****/ -int neb_set_module_info(void *, int, char *); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/nebstructs.h b/devtools/ci/nagios/nebstructs.h deleted file mode 100644 index 9862ea9..0000000 --- a/devtools/ci/nagios/nebstructs.h +++ /dev/null @@ -1,525 +0,0 @@ -/***************************************************************************** - * - * NEBSTRUCTS.H - Event broker includes for Nagios - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#ifndef NAGIOS_NEBSTRUCTS_H_INCLUDED -#define NAGIOS_NEBSTRUCTS_H_INCLUDED - -#include "common.h" -#include "objects.h" -#include "nagios.h" - -NAGIOS_BEGIN_DECL - -/****** STRUCTURES *************************/ - -/* process data structure */ -typedef struct nebstruct_process_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - } nebstruct_process_data; - - -/* timed event data structure */ -typedef struct nebstruct_timed_event_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int event_type; - int recurring; - time_t run_time; - void *event_data; - - void *event_ptr; - } nebstruct_timed_event_data; - - -/* log data structure */ -typedef struct nebstruct_log_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - time_t entry_time; - int data_type; - char *data; - } nebstruct_log_data; - - -/* system command structure */ -typedef struct nebstruct_system_command_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - struct timeval start_time; - struct timeval end_time; - int timeout; - char *command_line; - int early_timeout; - double execution_time; - int return_code; - char *output; - } nebstruct_system_command_data; - - -/* event handler structure */ -typedef struct nebstruct_event_handler_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int eventhandler_type; - char *host_name; - char *service_description; - int state_type; - int state; - int timeout; - char *command_name; - char *command_args; - char *command_line; - struct timeval start_time; - struct timeval end_time; - int early_timeout; - double execution_time; - int return_code; - char *output; - - void *object_ptr; - } nebstruct_event_handler_data; - - -/* host check structure */ -typedef struct nebstruct_host_check_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - char *host_name; - int current_attempt; - int check_type; - int max_attempts; - int state_type; - int state; - int timeout; - char *command_name; - char *command_args; - char *command_line; - struct timeval start_time; - struct timeval end_time; - int early_timeout; - double execution_time; - double latency; - int return_code; - char *output; - char *long_output; - char *perf_data; - check_result *check_result_ptr; - - void *object_ptr; - } nebstruct_host_check_data; - - -/* service check structure */ -typedef struct nebstruct_service_check_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - char *host_name; - char *service_description; - int check_type; - int current_attempt; - int max_attempts; - int state_type; - int state; - int timeout; - char *command_name; - char *command_args; - char *command_line; - struct timeval start_time; - struct timeval end_time; - int early_timeout; - double execution_time; - double latency; - int return_code; - char *output; - char *long_output; - char *perf_data; - check_result *check_result_ptr; - - void *object_ptr; - } nebstruct_service_check_data; - - -/* comment data structure */ -typedef struct nebstruct_comment_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int comment_type; - char *host_name; - char *service_description; - time_t entry_time; - char *author_name; - char *comment_data; - int persistent; - int source; - int entry_type; - int expires; - time_t expire_time; - unsigned long comment_id; - - void *object_ptr; /* not implemented yet */ - } nebstruct_comment_data; - - -/* downtime data structure */ -typedef struct nebstruct_downtime_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int downtime_type; - char *host_name; - char *service_description; - time_t entry_time; - char *author_name; - char *comment_data; - time_t start_time; - time_t end_time; - int fixed; - unsigned long duration; - unsigned long triggered_by; - unsigned long downtime_id; - - void *object_ptr; /* not implemented yet */ - } nebstruct_downtime_data; - - -/* flapping data structure */ -typedef struct nebstruct_flapping_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int flapping_type; - char *host_name; - char *service_description; - double percent_change; - double high_threshold; - double low_threshold; - unsigned long comment_id; - - void *object_ptr; - } nebstruct_flapping_data; - - -/* program status structure */ -typedef struct nebstruct_program_status_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - time_t program_start; - int pid; - int daemon_mode; - time_t last_log_rotation; - int notifications_enabled; - int active_service_checks_enabled; - int passive_service_checks_enabled; - int active_host_checks_enabled; - int passive_host_checks_enabled; - int event_handlers_enabled; - int flap_detection_enabled; - int process_performance_data; - int obsess_over_hosts; - int obsess_over_services; - unsigned long modified_host_attributes; - unsigned long modified_service_attributes; - char *global_host_event_handler; - char *global_service_event_handler; - } nebstruct_program_status_data; - - -/* host status structure */ -typedef struct nebstruct_host_status_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - void *object_ptr; - } nebstruct_host_status_data; - - -/* service status structure */ -typedef struct nebstruct_service_status_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - void *object_ptr; - } nebstruct_service_status_data; - - -/* contact status structure */ -typedef struct nebstruct_contact_status_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - void *object_ptr; - } nebstruct_contact_status_data; - - -/* notification data structure */ -typedef struct nebstruct_notification_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int notification_type; - struct timeval start_time; - struct timeval end_time; - char *host_name; - char *service_description; - int reason_type; - int state; - char *output; - char *ack_author; - char *ack_data; - int escalated; - int contacts_notified; - - void *object_ptr; - } nebstruct_notification_data; - - -/* contact notification data structure */ -typedef struct nebstruct_contact_notification_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int notification_type; - struct timeval start_time; - struct timeval end_time; - char *host_name; - char *service_description; - char *contact_name; - int reason_type; - int state; - char *output; - char *ack_author; - char *ack_data; - int escalated; - - void *object_ptr; - void *contact_ptr; - } nebstruct_contact_notification_data; - - -/* contact notification method data structure */ -typedef struct nebstruct_contact_notification_method_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int notification_type; - struct timeval start_time; - struct timeval end_time; - char *host_name; - char *service_description; - char *contact_name; - char *command_name; - char *command_args; - int reason_type; - int state; - char *output; - char *ack_author; - char *ack_data; - int escalated; - - void *object_ptr; - void *contact_ptr; - } nebstruct_contact_notification_method_data; - - -/* adaptive program data structure */ -typedef struct nebstruct_adaptive_program_data_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int command_type; - unsigned long modified_host_attribute; - unsigned long modified_host_attributes; - unsigned long modified_service_attribute; - unsigned long modified_service_attributes; - } nebstruct_adaptive_program_data; - - -/* adaptive host data structure */ -typedef struct nebstruct_adaptive_host_data_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int command_type; - unsigned long modified_attribute; - unsigned long modified_attributes; - - void *object_ptr; - } nebstruct_adaptive_host_data; - - -/* adaptive service data structure */ -typedef struct nebstruct_adaptive_service_data_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int command_type; - unsigned long modified_attribute; - unsigned long modified_attributes; - - void *object_ptr; - } nebstruct_adaptive_service_data; - - -/* adaptive contact data structure */ -typedef struct nebstruct_adaptive_contact_data_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int command_type; - unsigned long modified_attribute; - unsigned long modified_attributes; - unsigned long modified_host_attribute; - unsigned long modified_host_attributes; - unsigned long modified_service_attribute; - unsigned long modified_service_attributes; - - void *object_ptr; - } nebstruct_adaptive_contact_data; - - -/* external command data structure */ -typedef struct nebstruct_external_command_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int command_type; - time_t entry_time; - char *command_string; - char *command_args; - } nebstruct_external_command_data; - - -/* aggregated status data structure */ -typedef struct nebstruct_aggregated_status_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - } nebstruct_aggregated_status_data; - - -/* retention data structure */ -typedef struct nebstruct_retention_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - } nebstruct_retention_data; - - -/* acknowledgement structure */ -typedef struct nebstruct_acknowledgement_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int acknowledgement_type; - char *host_name; - char *service_description; - int state; - char *author_name; - char *comment_data; - int is_sticky; - int persistent_comment; - int notify_contacts; - - void *object_ptr; - } nebstruct_acknowledgement_data; - - -/* state change structure */ -typedef struct nebstruct_statechange_struct { - int type; - int flags; - int attr; - struct timeval timestamp; - - int statechange_type; - char *host_name; - char *service_description; - int state; - int state_type; - int current_attempt; - int max_attempts; - char *output; - void *object_ptr; - char *longoutput; - } nebstruct_statechange_data; - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/netutils.h b/devtools/ci/nagios/netutils.h deleted file mode 100644 index 1407e3f..0000000 --- a/devtools/ci/nagios/netutils.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef NAGIOS_NETUGILS_H_INCLUDED -#define NAGIOS_NETUGILS_H_INCLUDED -#include "common.h" -NAGIOS_BEGIN_DECL -int my_tcp_connect(const char *host_name, int port, int *sd, int timeout); -int my_sendall(int s, const char *buf, int *len, int timeout); -int my_recvall(int s, char *buf, int *len, int timeout); -NAGIOS_END_DECL -#endif - diff --git a/devtools/ci/nagios/objectjson.h b/devtools/ci/nagios/objectjson.h deleted file mode 100644 index 5e05e15..0000000 --- a/devtools/ci/nagios/objectjson.h +++ /dev/null @@ -1,298 +0,0 @@ -/************************************************************************** - * - * OBJECTJSON.H - Nagios CGI for returning JSON-formatted object data - * - * Copyright (c) 2013 Nagios Enterprises, LLC - * Last Modified: 04-13-2013 - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - *************************************************************************/ - -#ifndef NAGIOS_OBJECTJSON_H_INCLUDED -#define NAGIOS_OBJECTJSON_H_INCLUDED - -/* Structure containing CGI query string options and values */ -typedef struct object_json_cgi_data_struct { - /* Format options for JSON output */ - unsigned format_options; - /* Query being requested */ - int query; - /* Index of starting object returned for list requests */ - int start; - /* Number of objects returned for list requests */ - int count; - /* Return details for each entity in a list request */ - int details; - /* strftime format string for time_t values */ - char * strftime_format; - /* Name of host whose children should be returned if parenthost is - specified */ - char * parent_host_name; - /* Use the parent host field or search all hosts */ - int use_parent_host; - /* Host whose children should be returned if use_parent_host is non-zero */ - host * parent_host; - /* Name of host whose parents should be returned if childhost is - specified */ - char * child_host_name; - /* Use the child host field or search all hosts */ - int use_child_host; - /* Host whose parents should be returned if use_child_host is non-zero */ - host * child_host; - /* Name of host for which details should be returned */ - char * host_name; - /* Host whose host name is host_name */ - host * host; - /* Name of host whose hostgroup should be returned if hostgroupmember is - specified */ - char * hostgroup_member_name; - /* Host whose hostgroup should be returned if hostgroup_member_name is - specified */ - host * hostgroup_member; - /* Name of hostgroup for which details should be returned */ - char * hostgroup_name; - /* Hostgroup whose name is hostgroup_name */ - hostgroup * hostgroup; - /* Name of servicegroup for which details should be returned */ - char * servicegroup_name; - /* Servicegroup whose name is servicegroup_name */ - servicegroup * servicegroup; - /* Name of service for which details should be returned */ - char * service_description; - /* Service whose host name is host_name and whose description is - service_description*/ - service * service; - /* Name of host for which servicegroup should be returned if - servicegroupmemberhost and servicegroupmemberservice are specified */ - char * servicegroup_member_host_name; - /* Name of service for which servicegroup should be returned if - servicegroupmemberhost and servicegroupmemberservice are specified */ - char * servicegroup_member_service_description; - /* Service whose servicegroup should be returned if - servicegroup_member_host_name and - servicegroup_member_service_description are specified */ - service * servicegroup_member; - /* Name of service whose children should be returned if parentservice is - specified */ - char * parent_service_name; - /* Name of service whose parents should be returned if childservice is - specified */ - char * child_service_name; - /* Name of contactgroup for which details should be returned */ - char * contactgroup_name; - /* Contactgroup whose name is contactgroup_name */ - contactgroup * contactgroup; - /* Name of contact for which details should be returned */ - char * contact_name; - /* Contact whose contact name is contact_name */ - contact * contact; - /* Name of contact whose contactgroup should be returned if - contactgroupmember is specified */ - char * contactgroup_member_name; - /* Contact whose contactgroup should be returned if - contactgroup_member_name is specified */ - contact * contactgroup_member; - /* Name of timeperiod for which details should be returned */ - char * timeperiod_name; - /* Timeperiod whose timeperiod name is timeperiod_name */ - timeperiod *timeperiod; - /* Name of check timeperiod for which details should be returned */ - char * check_timeperiod_name; - /* Timeperiod whose timeperiod name is check_timeperiod_name */ - timeperiod *check_timeperiod; - /* Name of host notification timeperiod for which details should - be returned */ - char * host_notification_timeperiod_name; - /* Timeperiod whose timeperiod name is host_notification_timeperiod_name */ - timeperiod *host_notification_timeperiod; - /* Name of service notification timeperiod for which details should - be returned */ - char * service_notification_timeperiod_name; - /* Timeperiod whose timeperiod name is - service_notification_timeperiod_name */ - timeperiod *service_notification_timeperiod; - /* Name of command for which details should be returned */ - char * command_name; - /* Command whose command name is command_name */ - command * command; - /* Name of check command to be used as a selector */ - char * check_command_name; - /* Command whose command name is check_command_name */ - command * check_command; - /* Name of event handler to be used as a selector */ - char * event_handler_name; - /* Command whose command name is event_handler_name */ - command * event_handler; - /* Name of master host to be used as a selector for dependencies */ - char * master_host_name; - /* Host whose host name is master_host_name */ - host * master_host; - /* Name of master hostgroup to be used as a selector for dependencies */ - char * master_hostgroup_name; - /* Host whose hostgroup name is master_hostgroup_name */ - hostgroup * master_hostgroup; - /* Name of master service to be used as a selector for dependencies */ - char * master_service_description; - /* Service whose service name is master_service_description */ - service * master_service; - /* Name of master servicegroup to be used as a selector for dependencies */ - char * master_servicegroup_name; - /* Service whose servicegroup name is master_servicegroup_name */ - servicegroup * master_servicegroup; - /* Name of dependent host to be used as a selector for dependencies */ - char * dependent_host_name; - /* Host whose host name is dependent_host_name */ - host * dependent_host; - /* Name of dependent hostgroup to be used as a selector for dependencies */ - char * dependent_hostgroup_name; - /* Host whose hostgroup name is dependent_hostgroup_name */ - hostgroup * dependent_hostgroup; - /* Name of dependent service to be used as a selector for dependencies */ - char * dependent_service_description; - /* Service whose service name is dependent_service_description */ - service * dependent_service; - /* Name of dependent servicegroup to be used as a selector for - dependencies */ - char * dependent_servicegroup_name; - /* Service whose servicegroup name is dependent_servicegroup_name */ - servicegroup * dependent_servicegroup; - } object_json_cgi_data; - -/* Object Type Information */ -#define OBJECT_QUERY_INVALID 0 -#define OBJECT_QUERY_HOSTCOUNT 1 -#define OBJECT_QUERY_HOSTLIST 2 -#define OBJECT_QUERY_HOST 3 -#define OBJECT_QUERY_HOSTGROUPCOUNT 4 -#define OBJECT_QUERY_HOSTGROUPLIST 5 -#define OBJECT_QUERY_HOSTGROUP 6 -#define OBJECT_QUERY_SERVICECOUNT 7 -#define OBJECT_QUERY_SERVICELIST 8 -#define OBJECT_QUERY_SERVICE 9 -#define OBJECT_QUERY_SERVICEGROUPCOUNT 10 -#define OBJECT_QUERY_SERVICEGROUPLIST 11 -#define OBJECT_QUERY_SERVICEGROUP 12 -#define OBJECT_QUERY_CONTACTCOUNT 13 -#define OBJECT_QUERY_CONTACTLIST 14 -#define OBJECT_QUERY_CONTACT 15 -#define OBJECT_QUERY_CONTACTGROUPCOUNT 16 -#define OBJECT_QUERY_CONTACTGROUPLIST 17 -#define OBJECT_QUERY_CONTACTGROUP 18 -#define OBJECT_QUERY_TIMEPERIODCOUNT 19 -#define OBJECT_QUERY_TIMEPERIODLIST 20 -#define OBJECT_QUERY_TIMEPERIOD 21 -#define OBJECT_QUERY_COMMANDCOUNT 22 -#define OBJECT_QUERY_COMMANDLIST 23 -#define OBJECT_QUERY_COMMAND 24 -#define OBJECT_QUERY_SERVICEDEPENDENCYCOUNT 25 -#define OBJECT_QUERY_SERVICEDEPENDENCYLIST 26 -#define OBJECT_QUERY_SERVICEESCALATIONCOUNT 27 -#define OBJECT_QUERY_SERVICEESCALATIONLIST 28 -#define OBJECT_QUERY_HOSTDEPENDENCYCOUNT 29 -#define OBJECT_QUERY_HOSTDEPENDENCYLIST 30 -#define OBJECT_QUERY_HOSTESCALATIONCOUNT 31 -#define OBJECT_QUERY_HOSTESCALATIONLIST 32 -#define OBJECT_QUERY_HELP 33 - -extern json_object * json_object_custom_variables(struct customvariablesmember *); - -extern json_object *json_object_hostcount(int, host *, int, host *, hostgroup *, - contact *, contactgroup *, timeperiod *, timeperiod *, command *, - command *); -extern json_object *json_object_hostlist(unsigned, int, int, int, int, host *, - int, host *, hostgroup *, contact *, contactgroup *, timeperiod *, - timeperiod *, command *, command *); -extern json_object *json_object_host(unsigned, host *); -extern void json_object_host_details(json_object *, unsigned, host *); - -extern json_object *json_object_hostgroupcount(unsigned, host *); -extern json_object *json_object_hostgrouplist(unsigned, int, int, int, host *); -extern json_object *json_object_hostgroup(unsigned, hostgroup *); -extern void json_object_hostgroup_details(json_object *, unsigned, hostgroup *); - -extern json_object *json_object_servicecount(host *, int, host *, int, host *, - hostgroup *, servicegroup *, contact *, char *, char *, char *, - contactgroup *, timeperiod *, timeperiod *, command *, command *); -extern json_object *json_object_servicelist(unsigned, int, int, int, host *, - int, host *, int, host *, hostgroup *, servicegroup *, contact *, - char *, char *, char *, contactgroup *, timeperiod *, timeperiod *, - command *, command *); -extern json_object *json_object_service(unsigned, service *); -extern void json_object_service_details(json_object *, unsigned, service *); - -extern json_object *json_object_servicegroupcount(service *); -extern json_object *json_object_servicegrouplist(unsigned, int, int, int, - service *); -extern json_object *json_object_servicegroup(unsigned, servicegroup *); -extern void json_object_servicegroup_details(json_object *, unsigned, - servicegroup *); - -extern json_object *json_object_contactcount(contactgroup *, timeperiod *, - timeperiod *); -extern json_object *json_object_contactlist(unsigned, int, int, int, - contactgroup *, timeperiod *, timeperiod *); -extern json_object *json_object_contact(unsigned, contact *); -extern void json_object_contact_details(json_object *, unsigned, contact *); - -extern json_object *json_object_contactgroupcount(contact *); -extern json_object *json_object_contactgrouplist(unsigned, int, int, int, - contact *); -extern json_object *json_object_contactgroup(unsigned, contactgroup *); -extern void json_object_contactgroup_details(json_object *, unsigned, - contactgroup *); - -extern json_object *json_object_timeperiodcount(void); -extern json_object *json_object_timeperiodlist(unsigned, int, int, int); -extern json_object *json_object_timeperiod(unsigned, timeperiod *); -extern void json_object_timeperiod_details(json_object *, unsigned, timeperiod *); -extern void json_object_timerange(json_array *, unsigned, timerange *); -extern json_object *json_object_daterange(unsigned, daterange *, int); - -extern json_object *json_object_commandcount(void); -extern json_object *json_object_commandlist(unsigned, int, int, int); -extern json_object *json_object_command(unsigned, command *); -extern void json_object_command_details(json_object *, unsigned, command *); - -extern json_object *json_object_servicedependencycount(host *, hostgroup *, - char *, servicegroup *, host *, hostgroup *, char *, servicegroup *); -extern json_object *json_object_servicedependencylist(unsigned, int, int, - host *, hostgroup *, char *, servicegroup *, host *, hostgroup *, - char *, servicegroup *); -extern void json_object_servicedependency_details(json_object *, unsigned, - servicedependency *); - -extern json_object *json_object_serviceescalationcount(host *, char *, - hostgroup *, servicegroup *, contact *, contactgroup *); -extern json_object *json_object_serviceescalationlist(unsigned, int, int, - host *, char *, hostgroup *, servicegroup *, contact *, contactgroup *); -extern void json_object_serviceescalation_details(json_object *, unsigned, - serviceescalation *); - -extern json_object *json_object_hostdependencycount(host *, hostgroup *, - host *, hostgroup *); -extern json_object *json_object_hostdependencylist(unsigned, int, int, host *, - hostgroup *, host *, hostgroup *); -extern void json_object_hostdependency_details(json_object *, unsigned, - hostdependency *); - -extern json_object *json_object_hostescalationcount(host *, hostgroup *, - contact *, contactgroup *); -extern json_object *json_object_hostescalationlist(unsigned, int, int, host *, - hostgroup *, contact *, contactgroup *); -extern void json_object_hostescalation_details(json_object *, unsigned, - hostescalation *); - -#endif diff --git a/devtools/ci/nagios/objects.h b/devtools/ci/nagios/objects.h deleted file mode 100644 index dd7f767..0000000 --- a/devtools/ci/nagios/objects.h +++ /dev/null @@ -1,877 +0,0 @@ -/***************************************************************************** - * - * OBJECTS.H - Header file for object addition/search functions - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - - -#ifndef NAGIOS_OBJECTS_H_INCLUDED -#define NAGIOS_OBJECTS_H_INCLUDED - -#include "common.h" - -NAGIOS_BEGIN_DECL - - -/*************** CURRENT OBJECT REVISION **************/ - -#define CURRENT_OBJECT_STRUCTURE_VERSION 403 /* increment when changes are made to data structures... */ -/* Nagios 3 starts at 300, Nagios 4 at 400, etc. */ - - - -/***************** OBJECT SIZE LIMITS *****************/ - -#define MAX_STATE_HISTORY_ENTRIES 21 /* max number of old states to keep track of for flap detection */ -#define MAX_CONTACT_ADDRESSES 6 /* max number of custom addresses a contact can have */ - - - -/***************** SKIP LISTS ****************/ - -#define NUM_OBJECT_SKIPLISTS 12 -#define NUM_HASHED_OBJECT_TYPES 8 - -#define HOST_SKIPLIST 0 -#define SERVICE_SKIPLIST 1 -#define COMMAND_SKIPLIST 2 -#define TIMEPERIOD_SKIPLIST 3 -#define CONTACT_SKIPLIST 4 -#define CONTACTGROUP_SKIPLIST 5 -#define HOSTGROUP_SKIPLIST 6 -#define SERVICEGROUP_SKIPLIST 7 -#define HOSTDEPENDENCY_SKIPLIST 8 -#define SERVICEDEPENDENCY_SKIPLIST 9 -#define HOSTESCALATION_SKIPLIST 10 -#define SERVICEESCALATION_SKIPLIST 11 - - -/***************** DATE RANGE TYPES *******************/ - -#define DATERANGE_CALENDAR_DATE 0 /* 2008-12-25 */ -#define DATERANGE_MONTH_DATE 1 /* july 4 (specific month) */ -#define DATERANGE_MONTH_DAY 2 /* day 21 (generic month) */ -#define DATERANGE_MONTH_WEEK_DAY 3 /* 3rd thursday (specific month) */ -#define DATERANGE_WEEK_DAY 4 /* 3rd thursday (generic month) */ -#define DATERANGE_TYPES 5 - - -/* - * flags for notification_options, flapping_options and other similar - * flags. They overlap (hosts and services), so we can't use enum's. - */ -#define OPT_NOTHING 0 /* no options selected */ -#define OPT_ALL (~0) /* everything selected, so all bits set */ -#define OPT_DOWN (1 << HOST_DOWN) -#define OPT_UP (1 << HOST_UP) -#define OPT_UNREACHABLE (1 << HOST_UNREACHABLE) -#define OPT_OK (1 << STATE_OK) -#define OPT_WARNING (1 << STATE_WARNING) -#define OPT_CRITICAL (1 << STATE_CRITICAL) -#define OPT_UNKNOWN (1 << STATE_UNKNOWN) -#define OPT_RECOVERY OPT_OK -/* and now the "unreal" states... */ -#define OPT_NOTIFICATIONS (1 << 9) -#define OPT_PENDING (1 << 10) -#define OPT_FLAPPING (1 << 11) -#define OPT_DOWNTIME (1 << 12) -#define OPT_DISABLED (1 << 15) /* will denote disabled checks some day */ - -/* macros useful with both hosts and services */ -#define flag_set(c, flag) ((c) |= (flag)) -#define flag_get(c, flag) (unsigned int)((c) & (flag)) -#define flag_isset(c, flag) (flag_get((c), (flag)) == (unsigned int)(flag)) -#define flag_unset(c, flag) (c &= ~(flag)) -#define should_stalk(o) flag_isset(o->stalking_options, 1 << o->current_state) -#define should_stalk_notifications(o) flag_isset(o->stalking_options, OPT_NOTIFICATIONS) -#define should_flap_detect(o) flag_isset(o->flap_detection_options, 1 << o->current_state) -#define should_notify(o) flag_isset(o->notification_options, 1 << o->current_state) -#define add_notified_on(o, f) (o->notified_on |= (1 << f)) - - -/* Event-related macros */ -#define NUDGE_MIN 5 -#define NUDGE_MAX 17 - -/****************** DATA STRUCTURES *******************/ - -/* @todo Remove typedef's of non-opaque types in Nagios 5 */ -typedef struct host host; -typedef struct service service; -typedef struct contact contact; - -/* TIMED_EVENT structure */ -typedef struct timed_event { - int event_type; - time_t run_time; - int recurring; - unsigned long event_interval; - int compensate_for_time_change; - void *timing_func; - void *event_data; - void *event_args; - int event_options; - unsigned int priority; /* 0 is auto, 1 is highest. n+1 < n */ - struct squeue_event *sq_event; - } timed_event; - - -/* NOTIFY_LIST structure */ -typedef struct notify_list { - struct contact *contact; - struct notify_list *next; - } notification; - - -/* - * *name can be "Nagios Core", "Merlin", "mod_gearman" or "DNX", fe. - * source_name gets passed the 'source' pointer from check_result - * and must return a non-free()'able string useful for printing what - * we need to determine exactly where the check was received from, - * such as "mod_gearman worker@10.11.12.13", or "Nagios Core command - * file worker" (for passive checks submitted locally), which will be - * stashed with hosts and services and used as the "CHECKSOURCE" macro. - */ -struct check_engine { - char *name; /* "Nagios Core", "Merlin", "Mod Gearman" fe */ - const char *(*source_name)( const void *); - void (*clean_result)(void *); -}; - -/* CHECK_RESULT structure */ -typedef struct check_result { - int object_check_type; /* is this a service or a host check? */ - char *host_name; /* host name */ - char *service_description; /* service description */ - int check_type; /* was this an active or passive service check? */ - int check_options; - int scheduled_check; /* was this a scheduled or an on-demand check? */ - int reschedule_check; /* should we reschedule the next check */ - char *output_file; /* what file is the output stored in? */ - FILE *output_file_fp; - double latency; - struct timeval start_time; /* time the service check was initiated */ - struct timeval finish_time; /* time the service check was completed */ - int early_timeout; /* did the service check timeout? */ - int exited_ok; /* did the plugin check return okay? */ - int return_code; /* plugin return code */ - char *output; /* plugin output */ - /* 5DEPR: rusage is deprecated in Nagios, will be removed in 5.0.0 */ - struct rusage rusage; /* resource usage by this check */ - struct check_engine *engine; /* where did we get this check from? */ - const void *source; /* engine handles this */ - } check_result; - - -/* SCHED_INFO structure */ -typedef struct sched_info { - int total_services; - int total_scheduled_services; - int total_hosts; - int total_scheduled_hosts; - double average_services_per_host; - double average_scheduled_services_per_host; - unsigned long service_check_interval_total; - unsigned long host_check_interval_total; - double average_service_execution_time; - double average_service_check_interval; - double average_host_check_interval; - double average_service_inter_check_delay; - double average_host_inter_check_delay; - double service_inter_check_delay; - double host_inter_check_delay; - int service_interleave_factor; - int max_service_check_spread; - int max_host_check_spread; - time_t first_service_check; - time_t last_service_check; - time_t first_host_check; - time_t last_host_check; - } sched_info; - - -/* DBUF structure - dynamic string storage */ -typedef struct dbuf { - char *buf; - unsigned long used_size; - unsigned long allocated_size; - unsigned long chunk_size; - } dbuf; - - -#define CHECK_STATS_BUCKETS 15 - -/* used for tracking host and service check statistics */ -typedef struct check_stats { - int current_bucket; - int bucket[CHECK_STATS_BUCKETS]; - int overflow_bucket; - int minute_stats[3]; - time_t last_update; - } check_stats; - - - -/* OBJECT LIST STRUCTURE */ -typedef struct objectlist { - void *object_ptr; - struct objectlist *next; - } objectlist; - - -/* TIMERANGE structure */ -typedef struct timerange { - unsigned long range_start; - unsigned long range_end; - struct timerange *next; - } timerange; - - -/* DATERANGE structure */ -typedef struct daterange { - int type; - int syear; /* start year */ - int smon; /* start month */ - int smday; /* start day of month (may 3rd, last day in feb) */ - int swday; /* start day of week (thursday) */ - int swday_offset; /* start weekday offset (3rd thursday, last monday in jan) */ - int eyear; - int emon; - int emday; - int ewday; - int ewday_offset; - int skip_interval; - struct timerange *times; - struct daterange *next; - } daterange; - - -/* TIMEPERIODEXCLUSION structure */ -typedef struct timeperiodexclusion { - char *timeperiod_name; - struct timeperiod *timeperiod_ptr; - struct timeperiodexclusion *next; - } timeperiodexclusion; - - -/* TIMEPERIOD structure */ -typedef struct timeperiod { - unsigned int id; - char *name; - char *alias; - struct timerange *days[7]; - struct daterange *exceptions[DATERANGE_TYPES]; - struct timeperiodexclusion *exclusions; - struct timeperiod *next; - } timeperiod; - - -/* CONTACTSMEMBER structure */ -typedef struct contactsmember { - char *contact_name; - struct contact *contact_ptr; - struct contactsmember *next; - } contactsmember; - - -/* CONTACTGROUP structure */ -typedef struct contactgroup { - unsigned int id; - char *group_name; - char *alias; - struct contactsmember *members; - struct contactgroup *next; - } contactgroup; - - -/* CONTACTGROUPSMEMBER structure */ -typedef struct contactgroupsmember { - char *group_name; - struct contactgroup *group_ptr; - struct contactgroupsmember *next; - } contactgroupsmember; - - -/* CUSTOMVARIABLESMEMBER structure */ -typedef struct customvariablesmember { - char *variable_name; - char *variable_value; - int has_been_modified; - struct customvariablesmember *next; - } customvariablesmember; - - -/* COMMAND structure */ -typedef struct command { - unsigned int id; - char *name; - char *command_line; - struct command *next; - } command; - - -/* COMMANDSMEMBER structure */ -typedef struct commandsmember { - char *command; - struct command *command_ptr; - struct commandsmember *next; - } commandsmember; - - -/* CONTACT structure */ -struct contact { - unsigned int id; - char *name; - char *alias; - char *email; - char *pager; - char *address[MAX_CONTACT_ADDRESSES]; - struct commandsmember *host_notification_commands; - struct commandsmember *service_notification_commands; - unsigned int host_notification_options; - unsigned int service_notification_options; - unsigned int minimum_value; - char *host_notification_period; - char *service_notification_period; - int host_notifications_enabled; - int service_notifications_enabled; - int can_submit_commands; - int retain_status_information; - int retain_nonstatus_information; - struct customvariablesmember *custom_variables; -#ifndef NSCGI - time_t last_host_notification; - time_t last_service_notification; - unsigned long modified_attributes; - unsigned long modified_host_attributes; - unsigned long modified_service_attributes; -#endif - - struct timeperiod *host_notification_period_ptr; - struct timeperiod *service_notification_period_ptr; - struct objectlist *contactgroups_ptr; - struct contact *next; - }; - - -/* SERVICESMEMBER structure */ -typedef struct servicesmember { - char *host_name; - char *service_description; - struct service *service_ptr; - struct servicesmember *next; - } servicesmember; - - -/* HOSTSMEMBER structure */ -typedef struct hostsmember { - char *host_name; - struct host *host_ptr; - struct hostsmember *next; - } hostsmember; - - -/* HOSTGROUP structure */ -typedef struct hostgroup { - unsigned int id; - char *group_name; - char *alias; - struct hostsmember *members; - char *notes; - char *notes_url; - char *action_url; - struct hostgroup *next; - } hostgroup; - - -/* HOST structure */ -struct host { - unsigned int id; - char *name; - char *display_name; - char *alias; - char *address; - struct hostsmember *parent_hosts; - struct hostsmember *child_hosts; - struct servicesmember *services; - char *check_command; - int initial_state; - double check_interval; - double retry_interval; - int max_attempts; - char *event_handler; - struct contactgroupsmember *contact_groups; - struct contactsmember *contacts; - double notification_interval; - double first_notification_delay; - unsigned int notification_options; - unsigned int hourly_value; - char *notification_period; - char *check_period; - int flap_detection_enabled; - double low_flap_threshold; - double high_flap_threshold; - int flap_detection_options; - unsigned int stalking_options; - int check_freshness; - int freshness_threshold; - int process_performance_data; - int checks_enabled; - const char *check_source; - int accept_passive_checks; - int event_handler_enabled; - int retain_status_information; - int retain_nonstatus_information; - int obsess; - char *notes; - char *notes_url; - char *action_url; - char *icon_image; - char *icon_image_alt; - char *statusmap_image; /* used by lots of graphing tools */ -/* #ifdef NSCGI */ - /* - * these are kept in ancillary storage for the daemon and - * thrown out as soon as we've created the object cache. - * The CGI's still attach them though, since they are the - * only users of this utter crap. - */ - char *vrml_image; - int have_2d_coords; - int x_2d; - int y_2d; - int have_3d_coords; - double x_3d; - double y_3d; - double z_3d; - int should_be_drawn; -/* #endif */ - customvariablesmember *custom_variables; -#ifndef NSCGI - int problem_has_been_acknowledged; - int acknowledgement_type; - int check_type; - int current_state; - int last_state; - int last_hard_state; - char *plugin_output; - char *long_plugin_output; - char *perf_data; - int state_type; - int current_attempt; - unsigned long current_event_id; - unsigned long last_event_id; - unsigned long current_problem_id; - unsigned long last_problem_id; - double latency; - double execution_time; - int is_executing; - int check_options; - int notifications_enabled; - time_t last_notification; - time_t next_notification; - time_t next_check; - int should_be_scheduled; - time_t last_check; - time_t last_state_change; - time_t last_hard_state_change; - time_t last_time_up; - time_t last_time_down; - time_t last_time_unreachable; - int has_been_checked; - int is_being_freshened; - int notified_on; - int current_notification_number; - int no_more_notifications; - unsigned long current_notification_id; - int check_flapping_recovery_notification; - int scheduled_downtime_depth; - int pending_flex_downtime; - int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */ - int state_history_index; - time_t last_state_history_update; - int is_flapping; - unsigned long flapping_comment_id; - double percent_state_change; - int total_services; - unsigned long total_service_check_interval; - unsigned long modified_attributes; -#endif - - struct command *event_handler_ptr; - struct command *check_command_ptr; - struct timeperiod *check_period_ptr; - struct timeperiod *notification_period_ptr; - struct objectlist *hostgroups_ptr; - /* objects we depend upon */ - struct objectlist *exec_deps, *notify_deps; - struct objectlist *escalation_list; - struct host *next; - struct timed_event *next_check_event; - }; - - -/* SERVICEGROUP structure */ -typedef struct servicegroup { - unsigned int id; - char *group_name; - char *alias; - struct servicesmember *members; - char *notes; - char *notes_url; - char *action_url; - struct servicegroup *next; - } servicegroup; - - -/* SERVICE structure */ -struct service { - unsigned int id; - char *host_name; - char *description; - char *display_name; - struct servicesmember *parents; - struct servicesmember *children; - char *check_command; - char *event_handler; - int initial_state; - double check_interval; - double retry_interval; - int max_attempts; - int parallelize; - struct contactgroupsmember *contact_groups; - struct contactsmember *contacts; - double notification_interval; - double first_notification_delay; - unsigned int notification_options; - unsigned int stalking_options; - unsigned int hourly_value; - int is_volatile; - char *notification_period; - char *check_period; - int flap_detection_enabled; - double low_flap_threshold; - double high_flap_threshold; - unsigned int flap_detection_options; - int process_performance_data; - int check_freshness; - int freshness_threshold; - int accept_passive_checks; - int event_handler_enabled; - int checks_enabled; - const char *check_source; - int retain_status_information; - int retain_nonstatus_information; - int notifications_enabled; - int obsess; - char *notes; - char *notes_url; - char *action_url; - char *icon_image; - char *icon_image_alt; - struct customvariablesmember *custom_variables; -#ifndef NSCGI - int problem_has_been_acknowledged; - int acknowledgement_type; - int host_problem_at_last_check; - int check_type; - int current_state; - int last_state; - int last_hard_state; - char *plugin_output; - char *long_plugin_output; - char *perf_data; - int state_type; - time_t next_check; - int should_be_scheduled; - time_t last_check; - int current_attempt; - unsigned long current_event_id; - unsigned long last_event_id; - unsigned long current_problem_id; - unsigned long last_problem_id; - time_t last_notification; - time_t next_notification; - int no_more_notifications; - int check_flapping_recovery_notification; - time_t last_state_change; - time_t last_hard_state_change; - time_t last_time_ok; - time_t last_time_warning; - time_t last_time_unknown; - time_t last_time_critical; - int has_been_checked; - int is_being_freshened; - unsigned int notified_on; - int current_notification_number; - unsigned long current_notification_id; - double latency; - double execution_time; - int is_executing; - int check_options; - int scheduled_downtime_depth; - int pending_flex_downtime; - int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */ - int state_history_index; - int is_flapping; - unsigned long flapping_comment_id; - double percent_state_change; - unsigned long modified_attributes; -#endif - - struct host *host_ptr; - struct command *event_handler_ptr; - char *event_handler_args; - struct command *check_command_ptr; - char *check_command_args; - struct timeperiod *check_period_ptr; - struct timeperiod *notification_period_ptr; - struct objectlist *servicegroups_ptr; - struct objectlist *exec_deps, *notify_deps; - struct objectlist *escalation_list; - struct service *next; - struct timed_event *next_check_event; - }; - - -/* SERVICE ESCALATION structure */ -typedef struct serviceescalation { - unsigned int id; - char *host_name; - char *description; - int first_notification; - int last_notification; - double notification_interval; - char *escalation_period; - int escalation_options; - struct contactgroupsmember *contact_groups; - struct contactsmember *contacts; - struct service *service_ptr; - struct timeperiod *escalation_period_ptr; - } serviceescalation; - - -/* SERVICE DEPENDENCY structure */ -typedef struct servicedependency { - unsigned int id; - int dependency_type; - char *dependent_host_name; - char *dependent_service_description; - char *host_name; - char *service_description; - char *dependency_period; - int inherits_parent; - int failure_options; - struct service *master_service_ptr; - struct service *dependent_service_ptr; - struct timeperiod *dependency_period_ptr; - } servicedependency; - - -/* HOST ESCALATION structure */ -typedef struct hostescalation { - unsigned int id; - char *host_name; - int first_notification; - int last_notification; - double notification_interval; - char *escalation_period; - int escalation_options; - struct contactgroupsmember *contact_groups; - struct contactsmember *contacts; - struct host *host_ptr; - struct timeperiod *escalation_period_ptr; - } hostescalation; - - -/* HOST DEPENDENCY structure */ -typedef struct hostdependency { - unsigned int id; - int dependency_type; - char *dependent_host_name; - char *host_name; - char *dependency_period; - int inherits_parent; - int failure_options; - struct host *master_host_ptr; - struct host *dependent_host_ptr; - struct timeperiod *dependency_period_ptr; - } hostdependency; - -extern struct command *command_list; -extern struct timeperiod *timeperiod_list; -extern struct host *host_list; -extern struct service *service_list; -extern struct contact *contact_list; -extern struct hostgroup *hostgroup_list; -extern struct servicegroup *servicegroup_list; -extern struct contactgroup *contactgroup_list; -extern struct hostescalation *hostescalation_list; -extern struct serviceescalation *serviceescalation_list; -extern struct command **command_ary; -extern struct timeperiod **timeperiod_ary; -extern struct host **host_ary; -extern struct service **service_ary; -extern struct contact **contact_ary; -extern struct hostgroup **hostgroup_ary; -extern struct servicegroup **servicegroup_ary; -extern struct contactgroup **contactgroup_ary; -extern struct hostescalation **hostescalation_ary; -extern struct hostdependency **hostdependency_ary; -extern struct serviceescalation **serviceescalation_ary; -extern struct servicedependency **servicedependency_ary; - - -/********************* FUNCTIONS **********************/ - -/**** Top-level input functions ****/ -int read_object_config_data(const char *, int); /* reads all external configuration data of specific types */ - - -/**** Object Creation Functions ****/ -struct contact *add_contact(char *name, char *alias, char *email, char *pager, char **addresses, char *svc_notification_period, char *host_notification_period, int service_notification_options, int host_notification_options, int service_notifications_enabled, int host_notifications_enabled, int can_submit_commands, int retain_status_information, int retain_nonstatus_information, unsigned int minimum_value); -struct commandsmember *add_service_notification_command_to_contact(contact *, char *); /* adds a service notification command to a contact definition */ -struct commandsmember *add_host_notification_command_to_contact(contact *, char *); /* adds a host notification command to a contact definition */ -struct customvariablesmember *add_custom_variable_to_contact(contact *, char *, char *); /* adds a custom variable to a service definition */ -struct host *add_host(char *name, char *display_name, char *alias, char *address, char *check_period, int initial_state, double check_interval, double retry_interval, int max_attempts, int notification_options, double notification_interval, double first_notification_delay, char *notification_period, int notifications_enabled, char *check_command, int checks_enabled, int accept_passive_checks, char *event_handler, int event_handler_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, char *notes, char *notes_url, char *action_url, char *icon_image, char *icon_image_alt, char *vrml_image, char *statusmap_image, int x_2d, int y_2d, int have_2d_coords, double x_3d, double y_3d, double z_3d, int have_3d_coords, int should_be_drawn, int retain_status_information, int retain_nonstatus_information, int obsess_over_host, unsigned int hourly_value); -struct hostsmember *add_parent_host_to_host(host *, char *); /* adds a parent host to a host definition */ -struct servicesmember *add_parent_service_to_service(service *, char *host_name, char *description); -struct hostsmember *add_child_link_to_host(host *, host *); /* adds a child host to a host definition */ -struct servicesmember *add_child_link_to_service(service *, service *); /* adds a child host to a host definition */ -struct contactgroupsmember *add_contactgroup_to_host(host *, char *); /* adds a contactgroup to a host definition */ -struct contactsmember *add_contact_to_host(host *, char *); /* adds a contact to a host definition */ -struct customvariablesmember *add_custom_variable_to_host(host *, char *, char *); /* adds a custom variable to a host definition */ -struct timeperiod *add_timeperiod(char *, char *); /* adds a timeperiod definition */ -struct timeperiodexclusion *add_exclusion_to_timeperiod(timeperiod *, char *); /* adds an exclusion to a timeperiod */ -struct timerange *add_timerange_to_timeperiod(timeperiod *, int, unsigned long, unsigned long); /* adds a timerange to a timeperiod definition */ -struct daterange *add_exception_to_timeperiod(timeperiod *, int, int, int, int, int, int, int, int, int, int, int, int); -struct timerange *add_timerange_to_daterange(daterange *, unsigned long, unsigned long); -struct hostgroup *add_hostgroup(char *, char *, char *, char *, char *); /* adds a hostgroup definition */ -struct hostsmember *add_host_to_hostgroup(hostgroup *, char *); /* adds a host to a hostgroup definition */ -struct servicegroup *add_servicegroup(char *, char *, char *, char *, char *); /* adds a servicegroup definition */ -struct servicesmember *add_service_to_servicegroup(servicegroup *, char *, char *); /* adds a service to a servicegroup definition */ -struct contactgroup *add_contactgroup(char *, char *); /* adds a contactgroup definition */ -struct contactsmember *add_contact_to_contactgroup(contactgroup *, char *); /* adds a contact to a contact group definition */ -struct command *add_command(char *, char *); /* adds a command definition */ -struct service *add_service(char *host_name, char *description, char *display_name, char *check_period, int initial_state, int max_attempts, int parallelize, int accept_passive_checks, double check_interval, double retry_interval, double notification_interval, double first_notification_delay, char *notification_period, int notification_options, int notifications_enabled, int is_volatile, char *event_handler, int event_handler_enabled, char *check_command, int checks_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, char *notes, char *notes_url, char *action_url, char *icon_image, char *icon_image_alt, int retain_status_information, int retain_nonstatus_information, int obsess_over_service, unsigned int hourly_value); -struct contactgroupsmember *add_contactgroup_to_service(service *, char *); /* adds a contact group to a service definition */ -struct contactsmember *add_contact_to_service(service *, char *); /* adds a contact to a host definition */ -struct serviceescalation *add_serviceescalation(char *host_name, char *description, int first_notification, int last_notification, double notification_interval, char *escalation_period, int escalation_options); -struct contactgroupsmember *add_contactgroup_to_serviceescalation(serviceescalation *, char *); /* adds a contact group to a service escalation definition */ -struct contactsmember *add_contact_to_serviceescalation(serviceescalation *, char *); /* adds a contact to a service escalation definition */ -struct customvariablesmember *add_custom_variable_to_service(service *, char *, char *); /* adds a custom variable to a service definition */ -struct servicedependency *add_service_dependency(char *dependent_host_name, char *dependent_service_description, char *host_name, char *service_description, int dependency_type, int inherits_parent, int failure_options, char *dependency_period); -struct hostdependency *add_host_dependency(char *dependent_host_name, char *host_name, int dependency_type, int inherits_parent, int failure_options, char *dependency_period); -struct hostescalation *add_hostescalation(char *host_name, int first_notification, int last_notification, double notification_interval, char *escalation_period, int escalation_options); -struct contactsmember *add_contact_to_hostescalation(hostescalation *, char *); /* adds a contact to a host escalation definition */ -struct contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *, char *); /* adds a contact group to a host escalation definition */ - -struct contactsmember *add_contact_to_object(contactsmember **, char *); /* adds a contact to an object */ -struct customvariablesmember *add_custom_variable_to_object(customvariablesmember **, char *, char *); /* adds a custom variable to an object */ - - -struct servicesmember *add_service_link_to_host(host *, service *); - - -int skiplist_compare_text(const char *val1a, const char *val1b, const char *val2a, const char *val2b); -int get_host_count(void); -int get_service_count(void); - - -int create_object_tables(unsigned int *); - -/**** Object Search Functions ****/ -struct timeperiod *find_timeperiod(const char *); -struct host *find_host(const char *); -struct hostgroup *find_hostgroup(const char *); -struct servicegroup *find_servicegroup(const char *); -struct contact *find_contact(const char *); -struct contactgroup *find_contactgroup(const char *); -struct command *find_command(const char *); -struct service *find_service(const char *, const char *); - - -#define OBJECTLIST_DUPE 1 -int add_object_to_objectlist(struct objectlist **, void *); -int prepend_object_to_objectlist(struct objectlist **, void *); -int prepend_unique_object_to_objectlist(struct objectlist **, void *, size_t size); -int free_objectlist(objectlist **); - - -/**** Object Query Functions ****/ -unsigned int host_services_value(struct host *h); -int is_host_immediate_child_of_host(struct host *, struct host *); /* checks if a host is an immediate child of another host */ -int is_host_primary_immediate_child_of_host(struct host *, struct host *); /* checks if a host is an immediate child (and primary child) of another host */ -int is_host_immediate_parent_of_host(struct host *, struct host *); /* checks if a host is an immediate child of another host */ -int is_host_member_of_hostgroup(struct hostgroup *, struct host *); /* tests whether or not a host is a member of a specific hostgroup */ -int is_host_member_of_servicegroup(struct servicegroup *, struct host *); /* tests whether or not a service is a member of a specific servicegroup */ -int is_service_member_of_servicegroup(struct servicegroup *, struct service *); /* tests whether or not a service is a member of a specific servicegroup */ -int is_contact_member_of_contactgroup(struct contactgroup *, struct contact *); /* tests whether or not a contact is a member of a specific contact group */ -int is_contact_for_host(struct host *, struct contact *); /* tests whether or not a contact is a contact member for a specific host */ -int is_contactgroup_for_host(struct host *, struct contactgroup *); - /* tests whether a contact group is a contract group for a specific host */ -int is_escalated_contact_for_host(struct host *, struct contact *); /* checks whether or not a contact is an escalated contact for a specific host */ -int is_contact_for_host_escalation(hostescalation *, contact *); - /* tests whether a contact is an contact for a particular host escalation */ -int is_contactgroup_for_host_escalation(hostescalation *, contactgroup *); - /* tests whether a contactgroup is a contactgroup for a particular - host escalation */ -int is_contact_for_service(struct service *, struct contact *); /* tests whether or not a contact is a contact member for a specific service */ -int is_contactgroup_for_service(struct service *, struct contactgroup *); - /* tests whether a contact group is a contract group for a specific service */ -int is_escalated_contact_for_host(struct host *, struct contact *); /* checks whether or not a contact is an escalated contact for a specific host */ -int is_escalated_contact_for_service(struct service *, struct contact *); /* checks whether or not a contact is an escalated contact for a specific service */ -int is_contact_for_service_escalation(serviceescalation *, contact *); - /* tests whether a contact is an contact for a particular service - escalation */ -int is_contactgroup_for_service_escalation(serviceescalation *, contactgroup *); -/* tests whether a contactgroup is a contactgroup for a particular - service escalation */ - -int number_of_immediate_child_hosts(struct host *); /* counts the number of immediate child hosts for a particular host */ -int number_of_total_child_hosts(struct host *); /* counts the number of total child hosts for a particular host */ -int number_of_immediate_parent_hosts(struct host *); /* counts the number of immediate parents hosts for a particular host */ - -#ifndef NSCGI -void fcache_contactlist(FILE *fp, const char *prefix, struct contactsmember *list); -void fcache_contactgrouplist(FILE *fp, const char *prefix, struct contactgroupsmember *list); -void fcache_hostlist(FILE *fp, const char *prefix, struct hostsmember *list); -void fcache_customvars(FILE *fp, struct customvariablesmember *cvlist); -void fcache_timeperiod(FILE *fp, struct timeperiod *temp_timeperiod); -void fcache_command(FILE *fp, struct command *temp_command); -void fcache_contactgroup(FILE *fp, struct contactgroup *temp_contactgroup); -void fcache_hostgroup(FILE *fp, struct hostgroup *temp_hostgroup); -void fcache_servicegroup(FILE *fp, struct servicegroup *temp_servicegroup); -void fcache_contact(FILE *fp, struct contact *temp_contact); -void fcache_host(FILE *fp, struct host *temp_host); -void fcache_service(FILE *fp, struct service *temp_service); -void fcache_servicedependency(FILE *fp, struct servicedependency *temp_servicedependency); -void fcache_serviceescalation(FILE *fp, struct serviceescalation *temp_serviceescalation); -void fcache_hostdependency(FILE *fp, struct hostdependency *temp_hostdependency); -void fcache_hostescalation(FILE *fp, struct hostescalation *temp_hostescalation); -int fcache_objects(char *cache_file); -#endif - - -/**** Object Cleanup Functions ****/ -int free_object_data(void); /* frees all allocated memory for the object definitions */ - - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/perfdata.h b/devtools/ci/nagios/perfdata.h deleted file mode 100644 index 97e44bd..0000000 --- a/devtools/ci/nagios/perfdata.h +++ /dev/null @@ -1,38 +0,0 @@ -/***************************************************************************** - * - * PERFDATA.H - Include file for performance data routines - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#ifndef NAGIOS_PERFDATA_H_INCLUDED -#define NAGIOS_PERFDATA_H_INCLUDED - -#include "common.h" -#include "objects.h" - -NAGIOS_BEGIN_DECL - -int initialize_performance_data(const char *); /* initializes performance data */ -int cleanup_performance_data(void); /* cleans up performance data */ - -int update_host_performance_data(host *); /* updates host performance data */ -int update_service_performance_data(service *); /* updates service performance data */ - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/shared.h b/devtools/ci/nagios/shared.h deleted file mode 100644 index 84836c7..0000000 --- a/devtools/ci/nagios/shared.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef NAGIOS_SHARED_H_INCLUDED -#define NAGIOS_SHARED_H_INCLUDED - -#include -#include "lib/libnagios.h" - -NAGIOS_BEGIN_DECL - -/* mmapfile structure - used for reading files via mmap() */ -typedef struct mmapfile_struct { - char *path; - int mode; - int fd; - unsigned long file_size; - unsigned long current_position; - unsigned long current_line; - void *mmap_buf; - } mmapfile; - -/* official count of first-class objects */ -struct object_count { - unsigned int commands; - unsigned int timeperiods; - unsigned int hosts; - unsigned int hostescalations; - unsigned int hostdependencies; - unsigned int services; - unsigned int serviceescalations; - unsigned int servicedependencies; - unsigned int contacts; - unsigned int contactgroups; - unsigned int hostgroups; - unsigned int servicegroups; - }; - -extern struct object_count num_objects; - -extern void init_shared_cfg_vars(int); -extern void timing_point(const char *fmt, ...); /* print a message and the time since the first message */ -extern char *my_strtok(char *buffer, const char *tokens); -extern char *my_strtok_with_free(char *buffer, const char *tokens, int free_orig); -extern char *my_strsep(char **stringp, const char *delim); -extern mmapfile *mmap_fopen(const char *filename); -extern int mmap_fclose(mmapfile *temp_mmapfile); -extern char *mmap_fgets(mmapfile *temp_mmapfile); -extern char *mmap_fgets_multiline(mmapfile * temp_mmapfile); -extern void strip(char *buffer); -extern int hashfunc(const char *name1, const char *name2, int hashslots); -extern int compare_hashdata(const char *val1a, const char *val1b, const char *val2a, - const char *val2b); -extern void get_datetime_string(time_t *raw_time, char *buffer, - int buffer_length, int type); -extern void get_time_breakdown(unsigned long raw_time, int *days, int *hours, - int *minutes, int *seconds); - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/sretention.h b/devtools/ci/nagios/sretention.h deleted file mode 100644 index 5485c24..0000000 --- a/devtools/ci/nagios/sretention.h +++ /dev/null @@ -1,31 +0,0 @@ -/***************************************************************************** - * - * SRETENTION.H - Header for state retention routines - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#include "common.h" -NAGIOS_BEGIN_DECL - -int initialize_retention_data(const char *); -int cleanup_retention_data(void); -int save_state_information(int); /* saves all host and state information */ -int read_initial_state_information(void); /* reads in initial host and state information */ - -NAGIOS_END_DECL diff --git a/devtools/ci/nagios/statusdata.h b/devtools/ci/nagios/statusdata.h deleted file mode 100644 index 3910c3e..0000000 --- a/devtools/ci/nagios/statusdata.h +++ /dev/null @@ -1,199 +0,0 @@ -/***************************************************************************** - * - * STATUSDATA.H - Header for external status data routines - * - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#ifndef NAGIOS_STATUSDATA_H_INCLUDED -#define NAGIOS_STATUSDATA_H_INCLUDED - -#include "common.h" -#include "objects.h" - -#ifdef NSCGI -#define READ_PROGRAM_STATUS 1 -#define READ_HOST_STATUS 2 -#define READ_SERVICE_STATUS 4 -#define READ_CONTACT_STATUS 8 - -#define READ_ALL_STATUS_DATA READ_PROGRAM_STATUS | READ_HOST_STATUS | READ_SERVICE_STATUS | READ_CONTACT_STATUS - - - - /*************************** CHAINED HASH LIMITS ***************************/ - -#define SERVICESTATUS_HASHSLOTS 1024 -#define HOSTSTATUS_HASHSLOTS 1024 - - - /**************************** DATA STRUCTURES ******************************/ - -NAGIOS_BEGIN_DECL - -/* HOST STATUS structure */ -typedef struct hoststatus_struct { - char *host_name; - char *plugin_output; - char *long_plugin_output; - char *perf_data; - int status; - time_t last_update; - int has_been_checked; - int should_be_scheduled; - int current_attempt; - int max_attempts; - time_t last_check; - time_t next_check; - int check_options; - int check_type; - time_t last_state_change; - time_t last_hard_state_change; - int last_hard_state; - time_t last_time_up; - time_t last_time_down; - time_t last_time_unreachable; - int state_type; - time_t last_notification; - time_t next_notification; - int no_more_notifications; - int notifications_enabled; - int problem_has_been_acknowledged; - int acknowledgement_type; - int current_notification_number; - int accept_passive_checks; - int event_handler_enabled; - int checks_enabled; - int flap_detection_enabled; - int is_flapping; - double percent_state_change; - double latency; - double execution_time; - int scheduled_downtime_depth; - int process_performance_data; - int obsess; - struct hoststatus_struct *next; - struct hoststatus_struct *nexthash; - } hoststatus; - - -/* SERVICE STATUS structure */ -typedef struct servicestatus_struct { - char *host_name; - char *description; - char *plugin_output; - char *long_plugin_output; - char *perf_data; - int max_attempts; - int current_attempt; - int status; - time_t last_update; - int has_been_checked; - int should_be_scheduled; - time_t last_check; - time_t next_check; - int check_options; - int check_type; - int checks_enabled; - time_t last_state_change; - time_t last_hard_state_change; - int last_hard_state; - time_t last_time_ok; - time_t last_time_warning; - time_t last_time_unknown; - time_t last_time_critical; - int state_type; - time_t last_notification; - time_t next_notification; - int no_more_notifications; - int notifications_enabled; - int problem_has_been_acknowledged; - int acknowledgement_type; - int current_notification_number; - int accept_passive_checks; - int event_handler_enabled; - int flap_detection_enabled; - int is_flapping; - double percent_state_change; - double latency; - double execution_time; - int scheduled_downtime_depth; - int process_performance_data; - int obsess; - struct servicestatus_struct *next; - struct servicestatus_struct *nexthash; - } servicestatus; - - -/*************************** SERVICE STATES ***************************/ - -#define SERVICE_PENDING 1 -#define SERVICE_OK 2 -#define SERVICE_WARNING 4 -#define SERVICE_UNKNOWN 8 -#define SERVICE_CRITICAL 16 - - - -/**************************** HOST STATES ****************************/ - -#define HOST_PENDING 1 -#define SD_HOST_UP 2 -#define SD_HOST_DOWN 4 -#define SD_HOST_UNREACHABLE 8 - -/* Convert the (historically ordered) host states into a notion of "urgency". - This is defined as, in ascending order: - SD_HOST_UP (business as usual) - HOST_PENDING (waiting for - supposedly first - check result) - SD_HOST_UNREACHABLE (a problem, but likely not its cause) - SD_HOST_DOWN (look here!!) - The exact values are irrelevant, so I try to make the conversion as - CPU-efficient as possible: */ -#define HOST_URGENCY(hs) ((hs)|(((hs)&0x5)<<1)) - - - -/**************************** FUNCTIONS ******************************/ - -int read_status_data(const char *, int); /* reads all status data */ -int add_host_status(hoststatus *); /* adds a host status entry to the list in memory */ -int add_service_status(servicestatus *); /* adds a service status entry to the list in memory */ - -int add_hoststatus_to_hashlist(hoststatus *); -int add_servicestatus_to_hashlist(servicestatus *); - -servicestatus *find_servicestatus(char *, char *); /* finds status information for a specific service */ -hoststatus *find_hoststatus(char *); /* finds status information for a specific host */ -int get_servicestatus_count(char *, int); /* gets total number of services of a certain type for a specific host */ - -void free_status_data(void); /* free all memory allocated to status data */ -#endif - -#ifndef NSCGI -int initialize_status_data(const char *); /* initializes status data at program start */ -int update_all_status_data(void); /* updates all status data */ -int cleanup_status_data(int); /* cleans up status data at program termination */ -int update_program_status(int); /* updates program status data */ -int update_host_status(host *, int); /* updates host status data */ -int update_service_status(service *, int); /* updates service status data */ -int update_contact_status(contact *, int); /* updates contact status data */ -#endif - -NAGIOS_END_DECL -#endif diff --git a/devtools/ci/nagios/statusjson.h b/devtools/ci/nagios/statusjson.h deleted file mode 100644 index 63e0ea8..0000000 --- a/devtools/ci/nagios/statusjson.h +++ /dev/null @@ -1,280 +0,0 @@ -/************************************************************************** - * - * STATUSJSON.H - Nagios CGI for returning JSON-formatted status data - * - * Copyright (c) 2013 Nagios Enterprises, LLC - * Last Modified: 04-13-2013 - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - *************************************************************************/ - -#ifndef NAGIOS_STATUSJSON_H_INCLUDED -#define NAGIOS_STATUSJSON_H_INCLUDED - -/* Structure containing CGI query string options and values */ -typedef struct status_json_cgi_data_struct { - /* Format options for JSON output */ - unsigned format_options; - /* Query being requested */ - int query; - /* Index of starting object returned for list requests */ - int start; - /* Number of objects returned for list requests */ - int count; - /* Return details for each entity in a list request */ - int details; - /* strftime format string for time_t values */ - char * strftime_format; - /* Name of host whose children should be returned if parenthost is - specified */ - char * parent_host_name; - /* Use the parent host field or search all hosts*/ - int use_parent_host; - /* Host whose children should be returned if use_parent_host is non-zero */ - host * parent_host; - /* Name of host whose parents should be returned if childhost is - specified */ - char * child_host_name; - /* Use the child host field or search all hosts*/ - int use_child_host; - /* Host whose parents should be returned if use_child_host is non-zero */ - host * child_host; - /* Name of host for which details should be returned */ - char * host_name; - /* Host whose host name is host_name */ - host * host; - /* The host status selector values */ - unsigned host_statuses; - /* Name of hostgroup for which details should be returned */ - char * hostgroup_name; - /* Hostgroup whose name is hostgroup_name */ - hostgroup * hostgroup; - /* Name of servicegroup for which details should be returned */ - char * servicegroup_name; - /* Servicegroup whose name is servicegroup_name */ - servicegroup * servicegroup; - /* Name of service for which details should be returned */ - char * service_description; - /* Service whose host name is host_name and whose description is - service_description*/ - service * service; - /* The service status selector values */ - unsigned service_statuses; - /* Name of service whose children should be returned if parentservice is - specified */ - char * parent_service_name; - /* Name of service whose parents should be returned if childservice is - specified */ - char * child_service_name; - /* Name of contactgroup for which details should be returned */ - char * contactgroup_name; - /* Contactgroup whose name is contactgroup_name */ - contactgroup * contactgroup; - /* Name of contact for which details should be returned */ - char * contact_name; - /* Contact whose contact name is contact_name */ - contact * contact; - /* Name of check timeperiod for which details should be returned */ - char * check_timeperiod_name; - /* Timeperiod whose timeperiod name is check_timeperiod_name */ - timeperiod *check_timeperiod; - /* Name of host notification timeperiod for which details should - be returned */ - char * host_notification_timeperiod_name; - /* Timeperiod whose timeperiod name is host_notification_timeperiod_name */ - timeperiod *host_notification_timeperiod; - /* Name of service notification timeperiod for which details should - be returned */ - char * service_notification_timeperiod_name; - /* Timeperiod whose timeperiod name is - service_notification_timeperiod_name */ - timeperiod *service_notification_timeperiod; - /* Name of check command to be used as a selector */ - char * check_command_name; - /* Command whose command name is check_command_name */ - command * check_command; - /* Name of event handle to be used as a selector */ - char * event_handler_name; - /* Command whose command name is event_handler_name */ - command * event_handler; - /* Type(s) of comments to include in comment count and list results */ - unsigned comment_types; - /* Entry type(s) of comments to include in comment count and list results */ - unsigned entry_types; - /* Persistence(s) of comments to include in comment count and list - results */ - unsigned persistence; - /* Whether comments that are expiring, non-expiring, or both are included - in comment count and list results */ - unsigned expiring; - /* ID of comment for which details should be returned */ - int comment_id; - /* Comment whose id is comment_id */ - nagios_comment *comment; - /* ID of downtime for which details should be returned */ - int downtime_id; - /* Downtime whose id is downtime_id */ - scheduled_downtime * downtime; - /* Start time for time-based queries */ - time_t start_time; - /* End time for time-based queries */ - time_t end_time; - /* Field on which to base time for hostcount and hostlist queries */ - int host_time_field; - /* Field on which to base time for servicecount and servicelist queries */ - int service_time_field; - /* Field on which to base time for commentcount and commentlist queries */ - int comment_time_field; - /* Field on which to base time for downtimecount and downtimelist queries */ - int downtime_time_field; - /* Object type to use for downtimecount and downtimelist queries */ - unsigned downtime_object_types; - /* Downtime type to use for downtimecount and downtimelist queries */ - unsigned downtime_types; - /* Whether downtimes that are triggered, non-triggered, or both are - included in downtime count and list results */ - unsigned triggered; - /* ID of a triggering downtime */ - int triggered_by; - /* Whether downtimes that are or are not in effect or both are included - in downtime count and list results */ - unsigned in_effect; - } status_json_cgi_data; - -/* Status Type Information */ -#define STATUS_QUERY_INVALID 0 -#define STATUS_QUERY_HOSTCOUNT 1 -#define STATUS_QUERY_HOSTLIST 2 -#define STATUS_QUERY_HOST 3 -#define STATUS_QUERY_SERVICECOUNT 4 -#define STATUS_QUERY_SERVICELIST 5 -#define STATUS_QUERY_SERVICE 6 -#if 0 -#define STATUS_QUERY_CONTACTCOUNT 7 -#define STATUS_QUERY_CONTACTLIST 8 -#define STATUS_QUERY_CONTACT 9 -#endif -#define STATUS_QUERY_COMMENTCOUNT 10 -#define STATUS_QUERY_COMMENTLIST 11 -#define STATUS_QUERY_COMMENT 12 -#define STATUS_QUERY_DOWNTIMECOUNT 13 -#define STATUS_QUERY_DOWNTIMELIST 14 -#define STATUS_QUERY_DOWNTIME 16 -#define STATUS_QUERY_PROGRAMSTATUS 17 -#define STATUS_QUERY_PERFORMANCEDATA 18 -#define STATUS_QUERY_HELP 19 - -/* Status Time Fields */ -#define STATUS_TIME_INVALID 0 -#define STATUS_TIME_LAST_UPDATE 1 /* host, service */ -#define STATUS_TIME_LAST_CHECK 2 /* host, service */ -#define STATUS_TIME_NEXT_CHECK 3 /* host, service */ -#define STATUS_TIME_LAST_STATE_CHANGE 4 /* host, service */ -#define STATUS_TIME_LAST_HARD_STATE_CHANGE 5 /* host, service */ -#define STATUS_TIME_LAST_TIME_UP 6 /* host */ -#define STATUS_TIME_LAST_TIME_DOWN 7 /* host */ -#define STATUS_TIME_LAST_TIME_UNREACHABLE 8 /* host */ -#define STATUS_TIME_LAST_TIME_OK 9 /* service */ -#define STATUS_TIME_LAST_TIME_WARNING 10 /* service */ -#define STATUS_TIME_LAST_TIME_CRITICAL 11 /* service */ -#define STATUS_TIME_LAST_TIME_UNKNOWN 12 /* service */ -#define STATUS_TIME_LAST_NOTIFICATION 13 /* host, service */ -#define STATUS_TIME_NEXT_NOTIFICATION 14 /* host, service */ -#define STATUS_TIME_ENTRY_TIME 15 /* comment, downtime */ -#define STATUS_TIME_EXPIRE_TIME 16 /* comment */ -#define STATUS_TIME_START_TIME 17 /* downtime */ -#define STATUS_TIME_FLEX_DOWNTIME_START 18 /* downtime */ -#define STATUS_TIME_END_TIME 19 /* downtime */ - -/* Comment Types */ -#define COMMENT_TYPE_HOST 1 -#define COMMENT_TYPE_SERVICE 2 -#define COMMENT_TYPE_ALL (COMMENT_TYPE_HOST | COMMENT_TYPE_SERVICE) - -/* Comment Entry Types */ -#define COMMENT_ENTRY_USER 1 -#define COMMENT_ENTRY_DOWNTIME 2 -#define COMMENT_ENTRY_FLAPPING 4 -#define COMMENT_ENTRY_ACKNOWLEDGEMENT 8 -#define COMMENT_ENTRY_ALL (COMMENT_ENTRY_USER |\ - COMMENT_ENTRY_DOWNTIME |\ - COMMENT_ENTRY_FLAPPING |\ - COMMENT_ENTRY_ACKNOWLEDGEMENT) - -/* Downtime Object Types */ -#define DOWNTIME_OBJECT_TYPE_HOST 1 -#define DOWNTIME_OBJECT_TYPE_SERVICE 2 -#define DOWNTIME_OBJECT_TYPE_ALL (DOWNTIME_OBJECT_TYPE_HOST |\ - DOWNTIME_OBJECT_TYPE_SERVICE) - -/* Downtime Types */ -#define DOWNTIME_TYPE_FIXED 1 -#define DOWNTIME_TYPE_FLEXIBLE 2 -#define DOWNTIME_TYPE_ALL (DOWNTIME_TYPE_FIXED | DOWNTIME_TYPE_FLEXIBLE) - -extern json_object *json_status_hostcount(unsigned, int, host *, int, host *, - hostgroup *, int, contact *, int, time_t, time_t, contactgroup *, - timeperiod *, timeperiod *, command *, command *); -extern json_object *json_status_hostlist(unsigned, int, int, int, int, host *, - int, host *, hostgroup *, int, contact *, int, time_t, time_t, - contactgroup *, timeperiod *, timeperiod *, command *, command *); -extern json_object *json_status_host(unsigned, host *, hoststatus *); -extern void json_status_host_details(json_object *, unsigned, host *, - hoststatus *); - -extern json_object *json_status_servicecount(unsigned, host *, int, host *, - int, host *, hostgroup *, servicegroup *, int, int, contact *, int, - time_t, time_t, char *, char *, char *, contactgroup *, timeperiod *, - timeperiod *, command *, command *); -extern json_object *json_status_servicelist(unsigned, int, int, int, host *, - int, host *, int, host *, hostgroup *, servicegroup *, int, int, - contact *, int, time_t, time_t, char *, char *, char *, contactgroup *, - timeperiod *, timeperiod *, command *, command *); -extern json_object *json_status_service(unsigned, service *, servicestatus *); -extern void json_status_service_details(json_object *, unsigned, service *, - servicestatus *); - -#if 0 -extern void json_status_contactlist(unsigned, unsigned, unsigned, unsigned, - unsigned, contactgroup *); -extern void json_status_contactlist(unsigned, unsigned, unsigned, unsigned, - unsigned, contactgroup *); -extern void json_status_contact(unsigned, unsigned, contact *); -extern void json_status_contact_details(unsigned, unsigned, contact *); -#endif - -extern json_object *json_status_commentcount(unsigned, int, time_t, time_t, - unsigned, unsigned, unsigned, unsigned, char *, char *); -extern json_object *json_status_commentlist(unsigned, int, int, int, int, - time_t, time_t, unsigned, unsigned, unsigned, unsigned, char *, char *); -extern json_object *json_status_comment(unsigned, nagios_comment *); -extern void json_status_comment_details(json_object *, unsigned, - nagios_comment *); - -extern json_object *json_status_downtimecount(unsigned, int, time_t, time_t, - unsigned, unsigned, unsigned, int, unsigned, char *, char *); -extern json_object *json_status_downtimelist(unsigned, int, int, int, int, - time_t, time_t, unsigned, unsigned, unsigned, int, unsigned, char *, - char *); -extern json_object *json_status_downtime(unsigned, scheduled_downtime *); -extern void json_status_downtime_details(json_object *, unsigned, - scheduled_downtime *); - -extern json_object *json_status_program(unsigned); - -extern json_object *json_status_performance(void); - -#endif diff --git a/devtools/ci/nagios/workers.h b/devtools/ci/nagios/workers.h deleted file mode 100644 index 8fd759a..0000000 --- a/devtools/ci/nagios/workers.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef INCLUDE_WORKERS_H_INCLUDED -#define INCLUDE_WORKERS_H_INCLUDED -#include "lib/libnagios.h" -#include "lib/worker.h" -#include "nagios.h" /* for check_result definition */ - -/* different jobtypes. We add more as needed */ -#define WPJOB_CHECK 0 -#define WPJOB_NOTIFY 1 -#define WPJOB_OCSP 2 -#define WPJOB_OCHP 3 -#define WPJOB_GLOBAL_SVC_EVTHANDLER 4 -#define WPJOB_SVC_EVTHANDLER 5 -#define WPJOB_GLOBAL_HOST_EVTHANDLER 6 -#define WPJOB_HOST_EVTHANDLER 7 -#define WPJOB_CALLBACK 8 -#define WPJOB_HOST_PERFDATA 9 -#define WPJOB_SVC_PERFDATA 10 - -#define WPROC_FORCE (1 << 0) - -NAGIOS_BEGIN_DECL - -typedef struct wproc_result { - unsigned int job_id; - unsigned int type; - time_t timeout; - struct timeval start; - struct timeval stop; - struct timeval runtime; - char *command; - char *outstd; - char *outerr; - char *error_msg; - int wait_status; - int error_code; - int exited_ok; - int early_timeout; - struct kvvec *response; - /* 5DEPR: rusage is deprecated for Nagios, will be removed in 5.0.0 */ - struct rusage rusage; -} wproc_result; - -extern unsigned int wproc_num_workers_spawned; -extern unsigned int wproc_num_workers_online; -extern unsigned int wproc_num_workers_desired; - -extern void wproc_reap(int jobs, int msecs); -extern int wproc_can_spawn(struct load_control *lc); -extern void free_worker_memory(int flags); -extern int workers_alive(void); -extern int get_desired_workers(int desired_workers); -extern int init_workers(int desired_workers); -extern int wproc_run_check(check_result *cr, char *cmd, nagios_macros *mac); -extern int wproc_notify(char *cname, char *hname, char *sdesc, char *cmd, nagios_macros *mac); -extern int wproc_run(int job_type, char *cmd, int timeout, nagios_macros *mac); -extern int wproc_run_service_job(int jtype, int timeout, service *svc, char *cmd, nagios_macros *mac); -extern int wproc_run_host_job(int jtype, int timeout, host *hst, char *cmd, nagios_macros *mac); -extern int wproc_run_callback(char *cmt, int timeout, void (*cb)(struct wproc_result *, void *, int), void *data, nagios_macros *mac); - -NAGIOS_END_DECL -#endif diff --git a/devtools/gearmand/Dockerfile b/devtools/gearmand/Dockerfile index 2595942..a42d2df 100644 --- a/devtools/gearmand/Dockerfile +++ b/devtools/gearmand/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:bionic +FROM ubuntu:focal RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y gearman-job-server gearman-tools && apt-get clean diff --git a/export_headers.sh b/export_headers.sh new file mode 100755 index 0000000..2f2e1b3 --- /dev/null +++ b/export_headers.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +docker-compose build naemon + +CONTAINER_ID=$(docker create ${PWD##*/}_naemon:latest) +rm -rf devtools/naemon +mkdir -p devtools/include/naemon/ +docker cp $CONTAINER_ID:/opt/naemon/include/naemon/ devtools/include/naemon/ +docker rm -v $CONTAINER_ID diff --git a/meson.build b/meson.build deleted file mode 100644 index b0f1c06..0000000 --- a/meson.build +++ /dev/null @@ -1,21 +0,0 @@ -project('statusengine-broker', 'cpp', - version: '4.2.0', - default_options: ['warning_level=3', 'cpp_std=c++11'], - license: 'GPLv2+') - -uchardet_dep = dependency('uchardet') -gearmand_dep = dependency('gearmand', required: get_option('gearman')) -librabbitmq_dep = dependency('librabbitmq', required: get_option('rabbitmq')) -jsonc_dep = dependency('json-c') - -if get_option('nagios') - nagios_dep = declare_dependency(include_directories: include_directories(get_option('nagios_include_dir'))).as_system('system') -else - glib_dep = dependency('glib-2.0') - naemon_full_dep = dependency('naemon') - # We don't want to link against libnaemon - naemon_dep = declare_dependency(include_directories: include_directories(naemon_full_dep.get_pkgconfig_variable('includedir'))).as_system('system') -endif -toml_dep = declare_dependency(include_directories: include_directories('vendor')).as_system('system') - -subdir('src') diff --git a/meson_options.txt b/meson_options.txt deleted file mode 100644 index 3cf9fe9..0000000 --- a/meson_options.txt +++ /dev/null @@ -1,5 +0,0 @@ -# feature is not available on bionic -option('gearman', type: 'boolean', value: true) -option('rabbitmq', type: 'boolean', value: true) -option('nagios', type: 'boolean', value: false) -option('nagios_include_dir', type: 'string', value: '') diff --git a/naemon.Dockerfile b/naemon.Dockerfile index b6b5746..bec26e2 100644 --- a/naemon.Dockerfile +++ b/naemon.Dockerfile @@ -1,14 +1,13 @@ -FROM ubuntu:bionic +FROM ubuntu:focal RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y cmake gcc g++ gdb build-essential libglib2.0-dev libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev gearman-job-server gearman-tools automake gperf help2man libtool rabbitmq-server wget tar && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y cmake gcc g++ gdb build-essential libglib2.0-dev libgearman-dev uuid-dev libicu-dev libjson-c-dev pkg-config libssl-dev librabbitmq-dev gearman-job-server gearman-tools automake gperf help2man libtool rabbitmq-server wget tar libuchardet-dev git && \ apt-get clean -ENV NAEMON_VERSION=1.0.10 NAEMON_CHECKSUM=37353dd51a547b9e7f1b7d5e7e0b1716f9ea526d737c797d85431a83874736e5 +ENV NAEMON_VERSION=1.3.1 RUN useradd -d /opt/naemon -m -s /bin/bash --system naemon && \ wget -O /v${NAEMON_VERSION}.tar.gz https://github.com/naemon/naemon-core/archive/v${NAEMON_VERSION}.tar.gz && \ - echo "${NAEMON_CHECKSUM} /v${NAEMON_VERSION}.tar.gz" | sha256sum -c - && \ mkdir -p /build && tar xf /v${NAEMON_VERSION}.tar.gz -C /build --strip-components 1 && \ cd /build && ./autogen.sh --prefix=/opt/naemon --with-naemon-user=naemon --with-naemon-group=naemon --with-pluginsdir=/usr/lib/nagios/plugins && \ make -j2 && make install && \ @@ -19,12 +18,16 @@ RUN useradd -d /opt/naemon -m -s /bin/bash --system naemon && \ COPY devtools/buildenv/statusengine.toml /opt/naemon/etc/ COPY devtools/buildenv/statusengine.cfg /opt/naemon/etc/naemon/module-conf.d/ COPY devtools/buildenv/wait-for-it.sh devtools/buildenv/queuestatus /usr/bin/ -RUN mkdir -p /broker/source /broker/build && chmod +x /usr/bin/wait-for-it.sh /usr/bin/queuestatus +RUN mkdir -p /broker && chmod +x /usr/bin/wait-for-it.sh /usr/bin/queuestatus CMD ["/usr/bin/wait-for-it.sh", "rabbit:5672", "--", "/opt/naemon/bin/naemon", "/opt/naemon/etc/naemon/naemon.cfg"] -COPY . /broker/source/ - -RUN cd /broker/build && export PKG_CONFIG_PATH=/opt/naemon/lib/pkgconfig && cmake -DCMAKE_INSTALL_PREFIX:PATH=/opt/naemon ../source && make -j2 && make install +COPY --chown=naemon:naemon . /broker/ +RUN chown -R naemon:naemon /broker USER naemon +RUN rm -rf /broker/build && \ + mkdir -p /broker/build && \ + cd /broker/build && \ + export PKG_CONFIG_PATH=/opt/naemon/lib/pkgconfig && \ + cmake .. -DWITH_GEARMAN=ON -DWITH_RABBITMQ=ON && make -j diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..1cc9002 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,13 @@ +file(GLOB STATUSENGINE_SOURCES *.cpp) + +add_library(statusengine SHARED ${STATUSENGINE_SOURCES}) + +add_subdirectory(MessageHandler) + +target_link_libraries(statusengine PRIVATE ${STATUSENGINE_LIBS}) +target_include_directories(statusengine PUBLIC ${STATUSENGINE_INCLUDES}) +target_include_directories(statusengine PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + +install( + TARGETS statusengine +) \ No newline at end of file diff --git a/src/Configuration.h b/src/Configuration.h index ee072a9..0d8e85d 100644 --- a/src/Configuration.h +++ b/src/Configuration.h @@ -17,7 +17,7 @@ namespace statusengine { class MessageHandlerConfiguration { public: - bool InitLoad(const toml::Table &tbl) { + bool InitLoad(const toml::table &tbl) { for (auto &tableEntry : tbl) { auto QueueName = QueueNameHandler::Instance().QueueNames(); auto qName = QueueName.find(tableEntry.first); @@ -73,7 +73,7 @@ namespace statusengine { return queueIds; } - virtual bool Load(const toml::Table &tbl) = 0; + virtual bool Load(const toml::table &tbl) = 0; virtual ~MessageHandlerConfiguration() = default; @@ -89,12 +89,17 @@ namespace statusengine { std::shared_ptr> queues; std::shared_ptr> workerQueues; - template T GetTomlDefault(const toml::Table &tab, const char *ky, T &&opt) const { + template T GetTomlDefault(const toml::value &tab, const char *ky, T &&opt) const { try { - return toml::get_or(tab, ky, opt); + return toml::find(tab, ky); + //return toml::find_or(tab, ky, opt); } catch (const toml::type_error &tte) { se.Log() << "Invalid configuration: Invalid value for key " << ky << LogLevel::Error; + return std::move(opt); + } + catch (const std::out_of_range &oor) { + return std::move(opt); } return std::move(opt); } @@ -109,7 +114,7 @@ namespace statusengine { virtual ~RabbitmqConfiguration() = default; - bool Load(const toml::Table &tbl) override { + bool Load(const toml::table &tbl) override { Hostname = GetTomlDefault<>(tbl, "Hostname", std::string("")); if (Hostname.empty()) { @@ -166,7 +171,7 @@ namespace statusengine { public: explicit GearmanConfiguration(IStatusengine &se) : MessageHandlerConfiguration(se) {} - bool Load(const toml::Table &tbl) override { + bool Load(const toml::table &tbl) override { try { URL = toml::get(tbl.at("URL")); } @@ -190,7 +195,7 @@ namespace statusengine { bool Load(const std::string &configurationPath) { try { - cfg = toml::parse(configurationPath); + cfg = toml::parse(configurationPath).as_table(); } catch (std::runtime_error &rte) { se.Log() << "Could not read file: " << rte.what() << LogLevel::Error; @@ -202,7 +207,7 @@ namespace statusengine { } try { - bulkTable = cfg.at("Bulk").cast(); + bulkTable = cfg.at("Bulk").cast(); } catch (std::out_of_range &oor) { } @@ -212,8 +217,8 @@ namespace statusengine { } try { - auto logTable = cfg.at("Log").cast(); - auto logLevelStr = toml::get_or(logTable, "Level", "Warning"); + auto logTable = cfg.at("Log"); + auto logLevelStr = toml::find_or(logTable, "Level", "Warning"); if (logLevelStr == "Info") { logLevel = LogLevel::Info; } @@ -256,7 +261,7 @@ namespace statusengine { } try { - schedulerTable = cfg.at("Scheduler").cast(); + schedulerTable = cfg.at("Scheduler").cast(); } catch (std::out_of_range &oor) { } @@ -266,7 +271,7 @@ namespace statusengine { } try { - std::vector gearmans = toml::get>(cfg.at("Gearman")); + std::vector gearmans = toml::get>(cfg.at("Gearman")); for (auto &gearmanConfig : gearmans) { auto gfg = std::make_shared(se); if (!gfg->InitLoad(gearmanConfig)) { @@ -283,7 +288,7 @@ namespace statusengine { } try { - std::vector rabbits = toml::get>(cfg.at("Rabbitmq")); + std::vector rabbits = toml::get>(cfg.at("Rabbitmq")); for (auto &rabbitConfig : rabbits) { auto rfg = std::make_shared(se); if (!rfg->InitLoad(rabbitConfig)) { @@ -300,7 +305,7 @@ namespace statusengine { } try { - maxWorkerMessagesPerInterval = toml::get_or(toml::get(cfg.at("Worker")), + maxWorkerMessagesPerInterval = toml::find_or(cfg.at("Worker"), "MaxWorkerMessagesPerInterval", 1000000ul); } catch (const std::out_of_range &oor) { @@ -337,11 +342,11 @@ namespace statusengine { } time_t GetBulkFlushInterval() const { - return GetTomlDefault<>(bulkTable, "FlushInterval", static_cast(10)); + return GetTomlDefault(bulkTable, "FlushInterval", static_cast(10)); } unsigned long GetBulkMaximum() const { - return GetTomlDefault<>(bulkTable, "Maximum", 200ul); + return GetTomlDefault(bulkTable, "Maximum", 200ul); } bool IsBulkQueue(Queue queue) const { @@ -349,7 +354,7 @@ namespace statusengine { } time_t GetStartupScheduleMax() const { - return GetTomlDefault<>(schedulerTable, "StartupScheduleMax", 0); + return GetTomlDefault(schedulerTable, "StartupScheduleMax", 0); } std::vector> *GetGearmanConfiguration() { @@ -370,9 +375,9 @@ namespace statusengine { private: IStatusengine &se; - toml::Table cfg; - toml::Table bulkTable; - toml::Table schedulerTable; + toml::table cfg; + toml::table bulkTable; + toml::table schedulerTable; std::vector> rabbitmq; std::vector> gearman; @@ -382,13 +387,17 @@ namespace statusengine { LogLevel logLevel; - template T GetTomlDefault(const toml::Table &tab, const char *ky, T &&opt) const { + template T GetTomlDefault(const toml::value &tab, const char *ky, T &&opt) const { try { - return toml::get_or(tab, ky, opt); + return toml::find(tab, ky); + //return toml::find_or(tab, ky, opt); } catch (const toml::type_error &tte) { se.Log() << "Invalid configuration: Invalid value for key " << ky << LogLevel::Error; } + catch (const std::out_of_range &oor) { + return opt; + } return opt; } }; diff --git a/src/MessageHandler/CMakeLists.txt b/src/MessageHandler/CMakeLists.txt new file mode 100644 index 0000000..5a0569a --- /dev/null +++ b/src/MessageHandler/CMakeLists.txt @@ -0,0 +1,11 @@ +if(WITH_GEARMAN) + target_sources(statusengine PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/GearmanClient.cpp) +endif() + +if(WITH_RABBITMQ) + target_sources(statusengine PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/RabbitmqClient.cpp) +endif() + +target_sources(statusengine PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/MessageHandlerList.cpp) + +target_include_directories(statusengine PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) \ No newline at end of file diff --git a/src/meson.build b/src/meson.build deleted file mode 100644 index 0206048..0000000 --- a/src/meson.build +++ /dev/null @@ -1,35 +0,0 @@ -statusengine_sources = ['Nebmodule.cpp', 'Statusengine.cpp', 'MessageHandler/MessageHandlerList.cpp'] - -statusengine_deps = [uchardet_dep, jsonc_dep, toml_dep] -statusengine_cpp_args = [] - -if get_option('nagios') - statusengine_deps += [nagios_dep] - statusengine_cpp_args += ['-DBUILD_NAGIOS'] -else - statusengine_deps += [naemon_dep, glib_dep] -endif - -if get_option('gearman') and gearmand_dep.found() - statusengine_deps += [gearmand_dep] - statusengine_cpp_args += ['-DWITH_GEARMAN'] - statusengine_sources += ['MessageHandler/GearmanClient.cpp'] -endif - -if get_option('rabbitmq') and librabbitmq_dep.found() - statusengine_deps += [librabbitmq_dep] - statusengine_cpp_args += ['-DWITH_RABBITMQ'] - statusengine_sources += ['MessageHandler/RabbitmqClient.cpp'] - if librabbitmq_dep.version().version_compare('<0.6.0') - statusengine_cpp_args += ['-DWITH_RABBITMQ_CX060'] - endif - if librabbitmq_dep.version().version_compare('<0.8.0') - statusengine_cpp_args += ['-DWITH_RABBITMQ_CX080'] - endif -endif - -statusengine_lib = shared_module('statusengine', - statusengine_sources, - dependencies: statusengine_deps, - cpp_args: statusengine_cpp_args, - install: true) diff --git a/vendor/toml.hpp b/vendor/toml.hpp deleted file mode 100644 index cfae56b..0000000 --- a/vendor/toml.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2017 Toru Niina - * - * 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. - */ - -#ifndef TOML_FOR_MODERN_CPP -#define TOML_FOR_MODERN_CPP - -#ifndef __cplusplus -# error "__cplusplus is not defined" -#endif - -#if __cplusplus < 201103L && _MSC_VER < 1900 -# error "toml11 requires C++11 or later." -#endif - -#include "toml/parser.hpp" -#include "toml/to_toml.hpp" -#include "toml/from_toml.hpp" -#include "toml/get.hpp" - -#endif// TOML_FOR_MODERN_CPP diff --git a/vendor/toml/acceptor.hpp b/vendor/toml/acceptor.hpp deleted file mode 100644 index 11844ea..0000000 --- a/vendor/toml/acceptor.hpp +++ /dev/null @@ -1,777 +0,0 @@ -#ifndef TOML11_ACCEPTOR -#define TOML11_ACCEPTOR -#include -#include -#include -#include "exception.hpp" - -namespace toml -{ - -template -struct is_character -{ - typedef charT value_type; - constexpr static value_type target = c; - - template::value_type, - value_type>::value>::type> - constexpr static Iterator invoke(Iterator iter, Iterator end) - { - return iter == end ? iter : *iter == c ? std::next(iter) : iter; - } -}; - -template -struct is_in_range -{ - typedef charT value_type; - constexpr static value_type upper = up; - constexpr static value_type lower = lw; - static_assert(lower <= upper, "lower <= upper"); - - template::value_type, - value_type>::value>::type> - constexpr static Iterator invoke(Iterator iter, Iterator end) - { - return iter == end ? iter : - (lower <= *iter && *iter <= upper) ? std::next(iter) : iter; - } -}; - -template -struct is_one_of -{ - typedef typename headT::value_type value_type; - static_assert( - std::is_same::value_type>::value, - "different value_type"); - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - const Iterator tmp = headT::invoke(iter, end); - return (tmp != iter) ? tmp : is_one_of::invoke(iter, end); - } -}; -template -struct is_one_of -{ - typedef typename tailT::value_type value_type; - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - const Iterator tmp = tailT::invoke(iter, end); - return (tmp != iter) ? tmp : iter; - } -}; - -// just a wrapper for maybe_ignored -template -struct is_ignorable -{ - typedef typename condT::value_type value_type; - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - const Iterator tmp = condT::invoke(iter, end); - return (tmp != iter) ? tmp : iter; - } -}; - -template -struct maybe_ignored : std::false_type{}; -template -struct maybe_ignored> : std::true_type{}; - -template -struct is_chain_of_impl -{ - typedef typename headT::value_type value_type; - static_assert(std::is_same::value_type>::value, - "different value_type"); - - constexpr static bool ignorable = maybe_ignored::value; - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end, Iterator rollback) - { - const Iterator tmp = headT::invoke(iter, end); - return (tmp == iter && !ignorable) ? rollback : - is_chain_of_impl::invoke(tmp, end, rollback); - } -}; - -template -struct is_chain_of_impl -{ - typedef typename tailT::value_type value_type; - constexpr static bool ignorable = maybe_ignored::value; - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end, Iterator rollback) - { - const Iterator tmp = tailT::invoke(iter, end); - return (tmp == iter) ? (ignorable ? iter : rollback) : tmp; - } -}; - -template -struct is_chain_of -{ - typedef typename is_chain_of_impl::value_type value_type; - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - return is_chain_of_impl::invoke(iter, end, iter); - } -}; - -constexpr inline std::size_t repeat_infinite(){return 0ul;} - -template -struct is_repeat_of -{ - typedef typename condT::value_type value_type; - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - const Iterator rollback = iter; - Iterator tmp; - for(auto i=0ul; i -struct is_repeat_of -{ - typedef typename condT::value_type value_type; - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - Iterator tmp = condT::invoke(iter, end); - while(tmp != iter) - { - iter = tmp; - tmp = condT::invoke(iter, end); - } - return iter; - } -}; - -template -struct is_none_of -{ - typedef typename headT::value_type value_type; - static_assert( - std::is_same::value_type>::value, - "different value_type"); - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - const Iterator tmp = headT::invoke(iter, end); - return (tmp != iter) ? iter : is_none_of::invoke(iter, end); - } -}; - -template -struct is_none_of -{ - typedef typename tailT::value_type value_type; - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - const Iterator tmp = tailT::invoke(iter, end); - return (tmp != iter) ? iter : std::next(iter); - } -}; - -template -struct is_not_but -{ - typedef typename notT::value_type value_type; - static_assert( - std::is_same::value, - "different value type"); - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - return (iter != notT::invoke(iter, end)) ? iter : butT::invoke(iter, end); - } -}; - -template -using is_space = is_character; -template -using is_tab = is_character; -template -using is_number = is_in_range; -template -using is_lowercase = is_in_range; -template -using is_uppercase = is_in_range; -template -using is_alphabet = is_one_of, is_uppercase>; -template -using is_hex = is_one_of, is_in_range, - is_in_range>; -template -using is_whitespace = is_one_of, is_tab>; -template -using is_any_num_of_ws = - is_ignorable, repeat_infinite()>>; - -template -using is_newline = is_one_of, - is_chain_of, is_character>>; -template -using is_barekey_component = is_one_of, is_number, - is_character, is_character>; -template -using is_barekey = is_repeat_of, repeat_infinite()>; -template -using is_comment = - is_chain_of< - is_character, - is_repeat_of>, repeat_infinite()>, - is_newline - >; - -template -using is_basic_inline_string_component = - is_one_of< - is_none_of< is_in_range, is_character, - is_character, is_newline>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character, - is_repeat_of, 4>>, - is_chain_of, is_character, - is_repeat_of, 8>> - >; -template -using is_basic_inline_string = - is_not_but< - is_repeat_of, 3>, // not multiline - is_chain_of< - is_character, - is_ignorable, - repeat_infinite()>>, - is_character - > - >; -template -using is_basic_multiline_string_component = - is_one_of< - is_none_of< is_in_range, - is_repeat_of, 3>, - is_character>, - is_newline, - is_chain_of, is_newline>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character>, - is_chain_of, is_character, - is_repeat_of, 4>>, - is_chain_of, is_character, - is_repeat_of, 8>> - >; -template -using is_basic_multiline_string = - is_chain_of< - is_repeat_of, 3>, - is_ignorable, - repeat_infinite()>>, - is_repeat_of, 3> - >; - -template -using is_literal_inline_string_component = - is_none_of, is_character>; - -template -using is_literal_inline_string = - is_not_but< - is_repeat_of, 3>, - is_chain_of< - is_character, - is_ignorable, - repeat_infinite()>>, - is_character - > - >; - -template -using is_literal_multiline_string_component = - is_one_of< - is_none_of, - is_repeat_of, 3>>, - is_newline - >; - -template -using is_literal_multiline_string = - is_chain_of< - is_repeat_of, 3>, - is_ignorable, - repeat_infinite()>>, - is_repeat_of, 3> - >; - -template -using is_string = - is_one_of< - is_basic_inline_string, - is_basic_multiline_string, - is_literal_inline_string, - is_literal_multiline_string - >; - - -template -using is_sign = is_one_of, is_character>; -template -using is_nonzero_number = is_in_range; - -template -using is_integer_component = - is_not_but< - is_repeat_of, 2>, - is_one_of< - is_character, is_number - > - >; -template -using is_integer = - is_chain_of< - is_ignorable>, - is_one_of< - is_character, - is_chain_of< - is_nonzero_number, - is_ignorable, - repeat_infinite()> - > - > - > - >; - -template -using is_fractional_part = - is_chain_of< - is_character, - is_repeat_of, repeat_infinite()> - >; -template -using is_exponent_part = - is_chain_of< - is_one_of, is_character>, - is_integer - >; -template -using is_float = - is_one_of< - is_chain_of< - is_integer, - is_fractional_part, - is_exponent_part - >, - is_chain_of< - is_integer, - is_fractional_part - >, - is_chain_of< - is_integer, - is_exponent_part - > - >; - -template -using is_boolean = - is_one_of< - is_chain_of< - is_character, - is_character, - is_character, - is_character - >, - is_chain_of< - is_character, - is_character, - is_character, - is_character, - is_character - > - >; - -template -using is_local_time = - is_chain_of< - is_repeat_of, 2>, - is_character, - is_repeat_of, 2>, - is_character, - is_repeat_of, 2>, - is_ignorable< - is_chain_of< - is_character, - is_repeat_of, repeat_infinite()> - > - > - >; - -template -using is_local_date = - is_chain_of< - is_repeat_of, 4>, - is_character, - is_repeat_of, 2>, - is_character, - is_repeat_of, 2> - >; - -template -using is_local_date_time = - is_chain_of< - is_local_date, - is_character, - is_local_time - >; - -template -using is_offset = - is_one_of< - is_character, - is_chain_of< - is_sign, - is_repeat_of, 2>, - is_character, - is_repeat_of, 2> - > - >; - -template -using is_offset_date_time = - is_chain_of< - is_local_date_time, - is_offset - >; - -template -using is_datetime = - is_one_of< - is_offset_date_time, - is_local_date_time, - is_local_date, - is_local_time - >; - -template -using is_fundamental_type = - is_one_of< - is_basic_inline_string, - is_basic_multiline_string, - is_literal_inline_string, - is_literal_multiline_string, - is_offset_date_time, - is_local_date_time, - is_local_date, - is_local_time, - is_boolean, - is_float, - is_integer - >; - -template -using is_skippable_in_array = - is_repeat_of< - is_one_of, is_newline, is_comment>, - repeat_infinite() - >; - -template -struct is_inline_table; - -template -using is_key = - is_one_of< - is_barekey, - is_string - >; - - -template -using is_fixed_type_array = - is_chain_of< - is_character, - is_ignorable< - is_repeat_of< - is_chain_of< - is_ignorable>, - is_array_component, - is_ignorable>, - is_character - >, - repeat_infinite() - > - >, - is_ignorable< - is_chain_of< - is_ignorable>, - is_array_component, - is_ignorable>, - is_ignorable> - > - >, - is_ignorable>, - is_character - >; - -template -struct is_array -{ - typedef charT value_type; - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - return is_one_of< - is_fixed_type_array>, - is_fixed_type_array>, - is_fixed_type_array>, - is_fixed_type_array>, - is_fixed_type_array>, - is_fixed_type_array>, - is_fixed_type_array> - >::invoke(iter, end); - } -}; - -template -struct is_inline_table -{ - typedef charT value_type; - - template::value_type, - value_type>::value>::type> - static Iterator invoke(Iterator iter, Iterator end) - { - typedef is_one_of, - is_array, is_inline_table> is_component; - - typedef is_chain_of< - is_any_num_of_ws, - is_key, - is_any_num_of_ws, - is_character, - is_ignorable< - is_repeat_of< - is_chain_of< - is_any_num_of_ws, - is_inline_key_value_pair, - is_any_num_of_ws, - is_character - >, - repeat_infinite() - > - >, - is_ignorable< - is_chain_of< - is_any_num_of_ws, - is_inline_key_value_pair, - is_any_num_of_ws, - is_ignorable> - > - >, - is_any_num_of_ws, - is_character - > entity; - return entity::invoke(iter, end); - } -}; - -template -using is_value = - is_one_of, is_array, is_inline_table>; - -// [] -template -using is_table_definition = - is_chain_of< - is_any_num_of_ws, - is_character, - is_any_num_of_ws, - is_key, - is_ignorable< - is_repeat_of< - is_chain_of< - is_any_num_of_ws, - is_character, - is_any_num_of_ws, - is_key, - is_any_num_of_ws - >, - repeat_infinite()> - >, - is_character - >; - -template -using is_array_of_table_definition = - is_chain_of< - is_any_num_of_ws, - is_repeat_of, 2>, - is_any_num_of_ws, - is_key, - is_ignorable< - is_repeat_of< - is_chain_of< - is_any_num_of_ws, - is_character, - is_any_num_of_ws, - is_key, - is_any_num_of_ws - >, - repeat_infinite()> - >, - is_repeat_of, 2> - >; - -template -using is_key_value_pair = - is_chain_of< - is_any_num_of_ws, - is_key, - is_any_num_of_ws, - is_character::undef && - dt.minute != basic_datetime::undef && - dt.second != basic_datetime::undef) - { - if(date) os << 'T'; - os << std::setfill('0') << std::setw(2) << dt.hour << ':' - << std::setfill('0') << std::setw(2) << dt.minute << ':' - << std::setfill('0') << std::setw(2) << dt.second << '.' - << std::setfill('0') << std::setw(3) << dt.millisecond - << std::setfill('0') << std::setw(3) << dt.microsecond; - } - if(dt.offset_hour != basic_datetime::nooffset && - dt.offset_minute != basic_datetime::nooffset) - { - if(dt.offset_hour == 0 && dt.offset_minute == 0) - { - os << 'Z'; - } - else - { - char sign = ' '; - iT oh = dt.offset_hour; - iT om = dt.offset_minute; - om += oh * 60; - if(om > 0) sign = '+'; else sign='-'; - oh = om / 60; - om -= oh * 60; - os << sign << std::setfill('0') << std::setw(2) << std::abs(oh) << ':' - << std::setfill('0') << std::setw(2) << std::abs(om); - } - } - return os; -} - -template -inline bool -operator==(basic_datetime const& lhs, basic_datetime const& rhs) -{ - return lhs.year == rhs.year && lhs.month == rhs.month && - lhs.day == rhs.day && lhs.minute == rhs.minute && - lhs.second == rhs.second && lhs.millisecond == rhs.millisecond && - lhs.microsecond == rhs.microsecond && - lhs.offset_hour == rhs.offset_hour && - lhs.offset_minute == rhs.offset_minute; -} - -template -inline bool -operator!=(basic_datetime const& lhs, basic_datetime const& rhs) -{ - return !(lhs == rhs); -} - -template -inline bool -operator<(basic_datetime const& lhs, basic_datetime const& rhs) -{ - return std::time_t(lhs) < std::time_t(rhs); -} - -template -inline bool -operator<=(basic_datetime const& lhs, basic_datetime const& rhs) -{ - return std::time_t(lhs) <= std::time_t(rhs); -} - -template -inline bool -operator>(basic_datetime const& lhs, basic_datetime const& rhs) -{ - return std::time_t(lhs) > std::time_t(rhs); -} - -template -inline bool -operator>=(basic_datetime const& lhs, basic_datetime const& rhs) -{ - return std::time_t(lhs) >= std::time_t(rhs); -} - - -}//toml -#endif// TOML11_DATETIME diff --git a/vendor/toml/exception.hpp b/vendor/toml/exception.hpp deleted file mode 100644 index 87316b6..0000000 --- a/vendor/toml/exception.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef TOML11_EXCEPTION -#define TOML11_EXCEPTION -#include -#include - -namespace toml -{ - -struct exception : public std::exception -{ - public: - virtual ~exception() noexcept override = default; - virtual const char* what() const noexcept override {return "";} -}; - -struct syntax_error : public toml::exception -{ - public: - explicit syntax_error(const std::string& what_arg) : what_(what_arg){} - explicit syntax_error(const char* what_arg) : what_(what_arg){} - virtual ~syntax_error() noexcept override = default; - virtual const char* what() const noexcept override {return what_.c_str();} - - protected: - std::string what_; -}; - -struct type_error : public toml::exception -{ - public: - explicit type_error(const std::string& what_arg) : what_(what_arg){} - explicit type_error(const char* what_arg) : what_(what_arg){} - virtual ~type_error() noexcept override = default; - virtual const char* what() const noexcept override {return what_.c_str();} - - protected: - std::string what_; -}; - -struct internal_error : public toml::exception -{ - public: - explicit internal_error(const std::string& what_arg) : what_(what_arg){} - explicit internal_error(const char* what_arg) : what_(what_arg){} - virtual ~internal_error() noexcept override = default; - virtual const char* what() const noexcept override {return what_.c_str();} - protected: - std::string what_; -}; - -} // toml -#endif // TOML_EXCEPTION diff --git a/vendor/toml/format.hpp b/vendor/toml/format.hpp deleted file mode 100644 index c4726dc..0000000 --- a/vendor/toml/format.hpp +++ /dev/null @@ -1,386 +0,0 @@ -#ifndef TOML11_FORMAT -#define TOML11_FORMAT -#include "value.hpp" -#include -#include -#include -#include -#include - -namespace toml -{ - -// synopsis -// toml::format("key", value, toml::make_inline(80)) -// toml::format("key", value, toml::forceinline) -// std::cout << toml::make_inline(80) << value; -// std::cout << toml::forceinline << value; - -template, - typename alloc = std::allocator> -std::basic_string -format(const value& v); - -template, - typename alloc = std::allocator> -std::basic_string -format(const value& v, std::size_t mk); - -template, - typename alloc = std::allocator> -std::basic_string -format(const toml::key& k, const value& v); - -template, - typename alloc = std::allocator> -std::basic_string -format(const toml::key& k, const value& v, std::size_t mk); - -template -struct format_impl; - -template<> struct format_impl -{ - typedef detail::toml_default_type::type type; - - std::basic_string - operator()(const type& val) - { - return val ? "true" : "false"; - } -}; - -template<> struct format_impl -{ - typedef detail::toml_default_type::type type; - - std::basic_string - operator()(const type& val) - { - return std::to_string(val); - } -}; - -template<> struct format_impl -{ - typedef detail::toml_default_type::type type; - - std::basic_string - operator()(const type& val) - { - std::basic_ostringstream oss; - oss << std::showpoint << val; - if(oss.str().back() == '.') oss << '0'; - return oss.str(); - } -}; - -template<> struct format_impl -{ - typedef detail::toml_default_type::type type; - - std::size_t max_length; - - format_impl() : max_length(80){} - format_impl(std::size_t mx) : max_length(mx){} - - std::basic_string - operator()(const type& val) - { - auto tmp = make_inline(val); - if(max_length == std::numeric_limits::max() || - tmp.size() <= max_length) return tmp; - return convert_multiline(std::move(tmp)); - } - - private: - - std::basic_string - make_inline(const std::basic_string& val) - { - std::basic_string str; - str += '"'; - for(const auto& c : val) - { - if('\0' < c && c < '\31') - { - switch(c) - { - case '\b': str += "\\b"; break; - case '\t': str += "\\t"; break; - case '\n': str += "\\n"; break; - case '\f': str += "\\f"; break; - case '\r': str += "\\r"; break; - default: - { - str += 'u'; - std::basic_ostringstream oss; - oss << std::setw(4) << std::setfill('0') << std::hex - << static_cast(c); - auto hexdig = oss.str(); - std::transform(hexdig.begin(), hexdig.end(), hexdig.begin(), ::toupper); - str += oss.str(); - break; - } - } - } - else if(c == '"') - { - str += "\\\""; - } - else if(c == '\\') - { - str += "\\\\"; - } - else - { - str += c; - } - } - str += '"'; - return str; - } - - std::basic_string - convert_multiline(std::basic_string&& val) - { - std::basic_string str; str.reserve(val.size() + 6); - str += "\"\"\"\n"; - std::size_t current = 0; - for(auto iter = val.begin()+1; iter != val.end()-1; ++iter) - { - if(*iter != '\\') - { - if(current + 1 == max_length) str += "\\\n"; - str += *iter; continue; - } - assert(std::next(iter) < val.end()-1); - if(*std::next(iter) == 'u') - { - if(current + 5 == max_length) str += "\\\n"; - assert(iter + 5 < val.end()-1); - str += *iter; ++iter; // u - str += *iter; ++iter; // 0 - str += *iter; ++iter; // 1 - str += *iter; ++iter; // 2 - str += *iter; continue;// 3 - } - if(current + 2 == max_length) str += "\\\n"; - str += *iter; ++iter; str += *iter; - } - str += "\"\"\""; - return str; - } - -}; - -template<> struct format_impl -{ - typedef detail::toml_default_type::type type; - - std::basic_string - operator()(const type& val) - { - std::basic_ostringstream oss; - oss << val; - return oss.str(); - } -}; - -// TODO max length! -template<> struct format_impl -{ - typedef detail::toml_default_type::type type; - - std::size_t max_length; - - format_impl() : max_length(80){} - format_impl(std::size_t mx) : max_length(mx){} - - std::basic_string - operator()(const type& val) - { - std::basic_string retval; - retval += '['; - for(const auto& item : val) - { - auto tmp = format(val, max_length - 1); - retval += tmp; - retval += ", "; - if(tmp.size() * 2 > max_length) retval += '\n'; - } - retval += ']'; - return retval; - } -}; - -// TODO max length && inline! -template<> struct format_impl -{ - typedef detail::toml_default_type::type type; - - std::size_t max_length; - - format_impl() : max_length(80){} - format_impl(std::size_t mx) : max_length(mx){} - - std::basic_string - operator()(const type& val) - { - std::basic_string retval; - for(const auto& item : val) - { - retval += item.first; - retval += " = "; - retval += format(item.second); - retval += '\n'; - } - return retval; - } -}; - -template -std::basic_string -format(const value& v) -{ - switch(v.type()) - { - case value_t::Boolean : return format_impl{}(v.template cast()); - case value_t::Integer : return format_impl{}(v.template cast()); - case value_t::Float : return format_impl{}(v.template cast()); - case value_t::String : return format_impl{}(v.template cast()); - case value_t::Datetime: return format_impl{}(v.template cast()); - case value_t::Array : return format_impl{}(v.template cast()); - case value_t::Table : return format_impl{}(v.template cast()); - case value_t::Empty : throw std::runtime_error("toml::format: empty value"); - case value_t::Unknown : throw std::runtime_error("toml::format: unknown value"); - default: throw std::logic_error("toml::format: unknown enum value"); - } -} - -template -std::basic_string -format(const value& v, std::size_t inl) -{ - switch(v.type()) - { - case value_t::Boolean : return format_impl{}(v.template cast()); - case value_t::Integer : return format_impl{}(v.template cast()); - case value_t::Float : return format_impl{}(v.template cast()); - case value_t::String : return format_impl{inl}(v.template cast()); - case value_t::Datetime: return format_impl{}(v.template cast()); - case value_t::Array : return format_impl{inl}(v.template cast()); - case value_t::Table : return format_impl{inl}(v.template cast()); - case value_t::Empty : throw std::runtime_error("toml::format: empty value"); - case value_t::Unknown : throw std::runtime_error("toml::format: unknown value"); - default: throw std::logic_error("toml::format: unknown enum value"); - } -} - -template -std::basic_string -format(std::basic_string key, const value& val) -{ - std::basic_string retval(std::move(key)); - retval += " = "; - retval += format(val); - return retval; -} - -template -std::basic_string -format(std::basic_string key, const value& val, std::size_t mk) -{ - std::basic_string retval(std::move(key)); - retval += " = "; - retval += format(val, mk); - return retval; -} - - -// ----------------------------- stream operators ----------------------------- - -namespace detail -{ - -template -struct inline_limit -{ - static_assert(std::is_same::value, "do not instantiate this"); - static const int index; - T limit; - inline_limit() = default; - ~inline_limit() = default; - constexpr inline_limit(T i): limit(i){} - constexpr operator T() const {return limit;} - - static void callback(std::ios_base::event ev, std::ios_base& ios, int idx) - { - void*& info = ios.pword(idx); - switch (ev) - { - case std::ios_base::erase_event: - { - delete static_cast(info); - break; - } - case std::ios_base::copyfmt_event: - { - info = new std::size_t(*static_cast(info)); - break; - } - case std::ios_base::imbue_event: - { - break; - } - } - } -}; - -template -const int inline_limit::index = std::ios_base::xalloc(); - -} //detail - -template> -std::basic_ostream& -operator<<(std::basic_ostream& os, - const detail::inline_limit& inl) -{ - void*& info = os.pword(detail::inline_limit::index); - if(!os.bad()) - { - if(info == nullptr) - { - os.register_callback(detail::inline_limit::callback, - detail::inline_limit::index); - info = new std::size_t(inl.limit); - } - else - { - *static_cast(info) = inl.limit; - } - } - return os; -} - -constexpr static detail::inline_limit forceinline( - std::numeric_limits::max()); - -inline detail::inline_limit make_inline(std::size_t sz) -{ - return detail::inline_limit(sz); -} - -template> -std::basic_ostream& -operator<<(std::basic_ostream& os, - const toml::value& v) -{ - std::size_t* info = - static_cast(os.pword(detail::inline_limit::index)); - return os << (info == nullptr ? toml::format(v) : toml::format(v, *info)); -} - -} -#endif // TOML11_FORMAT diff --git a/vendor/toml/from_toml.hpp b/vendor/toml/from_toml.hpp deleted file mode 100644 index 8014110..0000000 --- a/vendor/toml/from_toml.hpp +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef TOML11_FROM_TOML -#define TOML11_FROM_TOML -#include "value.hpp" - -namespace toml -{ - -template(), - typename std::enable_if<(vT != toml::value_t::Unknown && - vT != value_t::Empty), std::nullptr_t>::type = nullptr> -void from_toml(T& x, const toml::value& v) -{ - if(v.type() != vT) - throw type_error("from_toml: value type: " + stringize(v.type()) + - std::string(" is not arguemnt type: ") + stringize(vT)); - x = v.cast(); - return; -} - -template(), - typename std::enable_if<(vT == toml::value_t::Unknown) && - (!toml::detail::is_map::value) && - toml::detail::is_container::value, std::nullptr_t>::type = nullptr> -void from_toml(T& x, const toml::value& v) -{ - // TODO the case of x is not dynamic container case - if(v.type() != value_t::Array) - throw type_error("from_toml: value type: " + stringize(v.type()) + - std::string(" is not argument type: Array")); - const auto& ar = v.cast(); - try - { - toml::resize(x, ar.size()); - } - catch(std::invalid_argument& iv) - { - throw toml::type_error("toml::from_toml: static array size is not enough"); - } - auto iter = x.begin(); - for(const auto& val : ar) - { - typename T::value_type v; - from_toml(v, val); - *iter = std::move(v); - ++iter; - } - return; -} - -template(), - typename std::enable_if<(vT == toml::value_t::Unknown) && - toml::detail::is_map::value, std::nullptr_t>::type = nullptr> -void from_toml(T& x, const toml::value& v) -{ - if(v.type() != value_t::Table) - throw type_error("from_toml: value type: " + stringize(v.type()) + - std::string(" is not argument type: Table")); - x.clear(); - const auto& tb = v.cast(); - for(const auto& kv : tb) - { - x.insert(kv); - } - return; -} - -namespace detail -{ - -template -constexpr toml::value_t determine_castable_type() -{ - return check_type() != toml::value_t::Unknown ? check_type() : - toml::detail::is_map::value ? toml::value_t::Table : - toml::detail::is_container::value ? toml::value_t::Array : - toml::value_t::Unknown; -} - -template -struct from_toml_tie_impl -{ - constexpr static std::size_t index = sizeof...(Ts) - N; - constexpr static toml::value_t type_index = - determine_castable_type< - typename std::tuple_element>::type>(); - - static void invoke(std::tuple tie, const toml::value& v) - { - // static_cast is needed because with intel c++ compiler, operator== - // is only defined when the two types are strictly equal, and type_index - // is const toml::value_t, while v.type() is toml::value_t. - if(static_cast(type_index) == v.type()) - { - from_toml(std::get(tie), v); - return; - } - return from_toml_tie_impl::invoke(tie, v); - } -}; - -template -struct from_toml_tie_impl<0, Ts...> -{ - static void invoke(std::tuple tie, const toml::value& v) - { - return; - } -}; - -} // detail - -template -void from_toml(std::tuple tie, const toml::value& v) -{ - detail::from_toml_tie_impl::invoke(tie, v); - return; -} - - -} // toml -#endif // TOML11_FROM_TOML diff --git a/vendor/toml/get.hpp b/vendor/toml/get.hpp deleted file mode 100644 index c532fe5..0000000 --- a/vendor/toml/get.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef TOML11_GET -#define TOML11_GET -#include "value.hpp" -#include - -namespace toml -{ - -template(), - typename std::enable_if<(vT != toml::value_t::Unknown && - vT != value_t::Empty), std::nullptr_t>::type = nullptr> -inline T get(const toml::value& v) -{ - return static_cast(v.cast()); -} - -// array-like type -template(), - typename std::enable_if<(vT == toml::value_t::Unknown) && - (!toml::detail::is_map::value) && - toml::detail::is_container::value, std::nullptr_t>::type = nullptr> -T get(const toml::value& v) -{ - if(v.type() != value_t::Array) - throw type_error("get: value type: " + stringize(v.type()) + - std::string(" is not argument type: Array")); - - const auto& ar = v.cast(); - T tmp; - try - { - toml::resize(tmp, ar.size()); - } - catch(std::invalid_argument& iv) - { - throw toml::type_error("toml::get: static array size is not enough"); - } - std::transform(ar.cbegin(), ar.cend(), tmp.begin(), - [](toml::value const& elem){return get(elem);}); - return tmp; -} - -// table-like case -template(), - typename std::enable_if<(vT == toml::value_t::Unknown) && - toml::detail::is_map::value, std::nullptr_t>::type = nullptr> -T get(const toml::value& v) -{ - if(v.type() != value_t::Table) - throw type_error("get: value type: " + stringize(v.type()) + - std::string(" is not argument type: Table")); - T tmp; - const auto& tb = v.cast(); - for(const auto& kv : tb){tmp.insert(kv);} - return tmp; -} - -// get_or ----------------------------------------------------------------- - -template -inline typename std::remove_cv::type>::type -get_or(const toml::Table& tab, const toml::key& ky, T&& opt) -{ - if(tab.count(ky) == 0) {return std::forward(opt);} - return get::type>::type>(tab.find(ky)->second); -} - -} // toml -#endif// TOML11_GET diff --git a/vendor/toml/parser.hpp b/vendor/toml/parser.hpp deleted file mode 100644 index f470330..0000000 --- a/vendor/toml/parser.hpp +++ /dev/null @@ -1,1130 +0,0 @@ -#ifndef TOML11_PARSER -#define TOML11_PARSER -#include "value.hpp" -#include "acceptor.hpp" -#include -#include -#include -#include -#include - -namespace toml -{ - -namespace detail -{ - -// it is just an inferior vertion of boost/std::optional -template -struct result -{ - result() : ok_(false){} - ~result() = default; - result(const result& rhs) = default; - result(result&& rhs) = default; - result& operator=(const result& rhs) = default; - result& operator=(result&& rhs) = default; - - result(const T& v) : ok_(true), value_(v){} - result(T&& v) : ok_(true), value_(std::move(v)){} - result& operator=(const T& rhs){ok_ = true; value_ = rhs; return *this;} - result& operator=(T&& rhs) {ok_ = true; value_ = rhs; return *this;} - - template - result& operator=(const result& u) {ok_ = u.ok(); if(ok_)value_ = u.move(); return *this;} - template - result& operator=(result&& u) {ok_ = u.ok(); if(ok_)value_ = u.move(); return *this;} - template - result(const result& u): ok_(u.ok()){if(ok_)value_ = u.get();} - template - result(result&& u): ok_(u.ok()){if(ok_)value_ = u.move();} - - bool ok() const {return ok_;} - operator bool() const {return ok_;} - - T& get() {if(!ok_) throw std::logic_error("result::get"); return value_;} - T const& get() const {if(!ok_) throw std::logic_error("result::get"); return value_;} - T&& move() - {if(!ok_) throw std::logic_error("result::move"); ok_ = false; return std::move(value_);} - - private: - bool ok_; - T value_; -}; - -}//detail - -struct parse_escape_sequence -{ - typedef toml::character value_type; - typedef toml::String string_type; - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair invoke(Iterator iter, Iterator end) - { - const auto beg = iter; - if(iter == end || *iter != '\\') - return std::make_pair(result_type{}, iter); - ++iter; - switch(*iter) - { - case '\\': return std::make_pair(string_type("\\"), std::next(iter)); - case '"' : return std::make_pair(string_type("\""), std::next(iter)); - case 'b' : return std::make_pair(string_type("\b"), std::next(iter)); - case 't' : return std::make_pair(string_type("\t"), std::next(iter)); - case 'n' : return std::make_pair(string_type("\n"), std::next(iter)); - case 'f' : return std::make_pair(string_type("\f"), std::next(iter)); - case 'r' : return std::make_pair(string_type("\r"), std::next(iter)); - case 'u' : - { - if(std::distance(iter, end) < 5) - throw std::make_pair(iter, syntax_error( - "invalid escape sequence: " + std::string(beg, end))); - return std::make_pair(utf8_to_char(make_codepoint( - string_type(iter+1, iter+5))), iter+5); - } - case 'U': - { - if(std::distance(iter, end) < 8) - throw std::make_pair(iter, syntax_error( - "invalid escape sequence: " + std::string(beg, end))); - return std::make_pair(utf8_to_char(make_codepoint( - string_type(iter+1, iter+9))), iter+9); - } - default: throw std::make_pair(iter, syntax_error( - "unkwnon escape sequence: " + std::string(iter, end))); - } - } - - static unsigned int make_codepoint(string_type str) - { - unsigned int codepoint; - std::basic_istringstream iss(str); - iss >> std::hex >> codepoint; - return codepoint; - } - - static string_type utf8_to_char(const unsigned int codepoint) - { - string_type character; - if(codepoint < 0x80) - { - character += static_cast(codepoint); - } - else if(codepoint < 0x800) - { - character += static_cast(0xC0| codepoint >> 6); - character += static_cast(0x80|(codepoint & 0x3F)); - } - else if(codepoint < 0x10000) - { - character += static_cast(0xE0| codepoint >>12); - character += static_cast(0x80|(codepoint >>6&0x3F)); - character += static_cast(0x80|(codepoint & 0x3F)); - } - else - { - character += static_cast(0xF0| codepoint >>18); - character += static_cast(0x80|(codepoint >>12&0x3F)); - character += static_cast(0x80|(codepoint >>6 &0x3F)); - character += static_cast(0x80|(codepoint & 0x3F)); - } - return character; - } -}; - -struct parse_basic_inline_string -{ - typedef toml::character value_type; - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = - is_basic_inline_string::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - if(std::distance(iter, end) < 2) - throw internal_error("is_basic_inline_string"); - - toml::String result; result.reserve(std::distance(iter, end)-2); - ++iter; - const Iterator last = std::prev(end); // ignore '"' - while(iter != last) - { - if(*iter == '\\') - { - auto r = parse_escape_sequence::invoke(iter, last); - if(!r.first.ok()) - throw internal_error("parse_basic_inline_string"); - result += r.first.move(); - iter = r.second; - } - else - { - result += *iter; - ++iter; - } - } - return std::make_pair(result, end); - } -}; - -struct parse_basic_multiline_string -{ - typedef toml::character value_type; - typedef toml::String string_type; - typedef detail::result result_type; - - typedef is_chain_of, is_newline> - is_line_ending_backslash; - typedef is_repeat_of, is_newline>, - repeat_infinite()> ws_nl_after_backslash_remover; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = - is_basic_multiline_string::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - if(std::distance(iter, end) < 6) - throw internal_error("is_basic_inline_string"); - - toml::String result; result.reserve(std::distance(iter, end)-6); - std::advance(iter, 3); - const Iterator last = end - 3; - iter = is_newline::invoke(iter, last); - while(iter != last) - { - if(*iter == '\\') - { - if(is_line_ending_backslash::invoke(iter, last) != iter) - { - iter = ws_nl_after_backslash_remover::invoke(std::next(iter), last); - } - else - { - auto r = parse_escape_sequence::invoke(iter, last); - if(!r.first.ok()) - throw internal_error("parse_basic_inline_string"); - result += r.first.move(); - iter = r.second; - } - } - else - { - result.push_back(*iter); - ++iter; - } - } - return std::make_pair(result, end); - } -}; - -struct parse_literal_inline_string -{ - typedef toml::character value_type; - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = - is_literal_inline_string::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - if(std::distance(iter, end) < 2) - throw internal_error("is_literal_inline_string"); - - toml::String result; result.reserve(std::distance(iter, end)-2); - ++iter; - const Iterator last = end - 1; - while(iter != last) - { - result.push_back(*iter); - ++iter; - } - return std::make_pair(result, end); - } -}; - -struct parse_literal_multiline_string -{ - typedef toml::character value_type; - typedef detail::result result_type; - - typedef is_chain_of, is_newline> - is_line_ending_backslash; - typedef is_repeat_of, is_newline>, - repeat_infinite()> ws_nl_after_backslash_remover; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = - is_literal_multiline_string::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - if(std::distance(iter, end) < 6) - throw internal_error("is_literal_multiline_string"); - - toml::String result; result.reserve(std::distance(iter, end)-6); - std::advance(iter, 3); - const Iterator last = end - 3; - iter = is_newline::invoke(iter, last); // trim first newline if exist - while(iter != last) - { - result.push_back(*iter); - ++iter; - } - return std::make_pair(result, end); - } -}; - -struct parse_string -{ - typedef toml::character value_type; - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - std::pair result; - if((result = parse_basic_inline_string::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_basic_multiline_string::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_literal_inline_string::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_literal_multiline_string::invoke(iter, range_end)).first.ok()) - return result; - else - return std::make_pair(result_type{}, iter); - } -}; - -struct parse_integer -{ - typedef toml::character value_type; - typedef std::basic_string string_type; - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair invoke(Iterator iter, Iterator range_end) - { - const Iterator end = is_integer::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - - string_type result; result.resize(std::distance(iter, end)); - std::copy_if(iter, end, result.begin(), [](value_type c){return c != '_';}); - return std::make_pair(std::stoll(result), end); - } -}; - -struct parse_float -{ - typedef toml::character value_type; - typedef std::basic_string string_type; - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = is_float::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - - string_type result; result.resize(std::distance(iter, end)); - std::copy_if(iter, end, result.begin(), [](value_type c){return c != '_';}); - try{ - return std::make_pair(std::stod(result), end); - } - catch(std::out_of_range& oor) - { - std::cout << "extremely large Float value appeared: " - << result << "; it is negrected" << std::endl; - return std::make_pair(0, end); - } - } -}; - -struct parse_boolean -{ - typedef toml::character value_type; - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = is_boolean::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - return std::make_pair((std::distance(iter, end) == 4), end); - } -}; - -struct parse_local_time -{ - typedef toml::character value_type; - typedef std::basic_string string_type; - typedef detail::result result_type; - typedef typename toml::Datetime::number_type number_type; - template - using nums = is_repeat_of, N>; - typedef is_character delim; - typedef is_character fract; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = is_local_time::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - - toml::Datetime result; - result.hour = std::stoi(string_type(iter, nums<2>::invoke(iter, end))); - iter = delim::invoke(nums<2>::invoke(iter, end), end); - result.minute = std::stoi(string_type(iter, nums<2>::invoke(iter, end))); - iter = delim::invoke(nums<2>::invoke(iter, end), end); - result.second = std::stoi(string_type(iter, nums<2>::invoke(iter, end))); - iter = fract::invoke(nums<2>::invoke(iter, end), end); - if(iter == end) - { - result.millisecond = 0.0; - result.microsecond = 0.0; - } - else if(std::distance(iter, end) <= 3) - { - result.millisecond = parse_number(iter, end); - result.microsecond = 0.0; - } - else - { - result.millisecond = parse_number(iter, iter + 3); - result.microsecond = parse_number(iter + 3, end); - } - result.offset_hour = toml::Datetime::nooffset; - result.offset_minute = toml::Datetime::nooffset; - result.year = toml::Datetime::undef; - result.month = toml::Datetime::undef; - result.day = toml::Datetime::undef; - return std::make_pair(result, end); - } - - template::value_type, - value_type>::value>::type> - static number_type parse_number(Iterator iter, Iterator end) - { - if(std::distance(iter, end) > 3) end = iter + 3; - string_type str(iter, end); - while(str.size() < 3){str += '0';} - return std::stoi(str); - } -}; - -struct parse_local_date -{ - typedef toml::character value_type; - typedef std::basic_string string_type; - typedef detail::result result_type; - template - using nums = is_repeat_of, N>; - typedef is_character delim; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = is_local_date::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - - toml::Datetime result; - result.year = std::stoi(string_type(iter, nums<4>::invoke(iter, end))); - iter = delim::invoke(nums<4>::invoke(iter, end), end); - result.month = std::stoi(string_type(iter, nums<2>::invoke(iter, end))); - iter = delim::invoke(nums<2>::invoke(iter, end), end); - result.day = std::stoi(string_type(iter, nums<2>::invoke(iter, end))); - - result.offset_hour = toml::Datetime::nooffset; - result.offset_minute = toml::Datetime::nooffset; - result.hour = toml::Datetime::undef; - result.minute = toml::Datetime::undef; - result.second = toml::Datetime::undef; - result.millisecond = toml::Datetime::undef; - result.microsecond = toml::Datetime::undef; - return std::make_pair(result, end); - } -}; - -struct parse_local_date_time -{ - typedef toml::character value_type; - typedef std::basic_string string_type; - typedef detail::result result_type; - template - using nums = is_repeat_of, N>; - typedef is_character delim; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = - is_local_date_time::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - - auto ld = parse_local_date::invoke(iter, end); - if(!ld.first.ok()) - throw std::make_pair(iter, syntax_error("invalid local datetime")); - toml::Datetime result(ld.first.move()); - iter = delim::invoke(ld.second, end);// 'T' - - const auto time = parse_local_time::invoke(iter, end); - result.hour = time.first.get().hour; - result.minute = time.first.get().minute; - result.second = time.first.get().second; - result.millisecond = time.first.get().millisecond; - result.microsecond = time.first.get().microsecond; - result.offset_hour = toml::Datetime::nooffset; - result.offset_minute = toml::Datetime::nooffset; - return std::make_pair(result, end); - } -}; - -struct parse_offset_date_time -{ - typedef toml::character value_type; - typedef std::basic_string string_type; - typedef detail::result result_type; - template - using nums = is_repeat_of, N>; - typedef is_character delim; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = - is_offset_date_time::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - - auto ldt = parse_local_date_time::invoke(iter, end); - if(!ldt.first.ok()) - throw std::make_pair(iter, syntax_error("invalid offset datetime")); - toml::Datetime result(ldt.first.move()); - iter = ldt.second; - if(*iter == 'Z') - { - result.offset_hour = 0; - result.offset_minute = 0; - } - else - { - if(*iter != '+' && *iter != '-') - throw std::make_pair(iter, syntax_error("invalid offset-datetime")); - const int sign = (*iter == '-') ? -1 : 1; - ++iter; - result.offset_hour = sign * - std::stoi(string_type(iter, nums<2>::invoke(iter, end))); - iter = delim::invoke(nums<2>::invoke(iter, end), end); - result.offset_minute = sign * - std::stoi(string_type(iter, nums<2>::invoke(iter, end))); - } - return std::make_pair(result, end); - } -}; - -struct parse_datetime -{ - typedef toml::character value_type; - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - std::pair result; - if((result = parse_offset_date_time::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_local_date_time::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_local_date::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_local_time::invoke(iter, range_end)).first.ok()) - return result; - else - return std::make_pair(result_type{}, iter); - } -}; - -template -struct parse_fixed_type_array -{ - typedef toml::character value_type; - typedef detail::result result_type; - typedef acceptorT acceptor_type; - typedef parserT parser_type; - typedef is_skippable_in_array skippable; - - template::value_type, - value_type>::value>::type> - static std::pair invoke(Iterator iter, Iterator range_end) - { - const Iterator end = - is_fixed_type_array::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - - toml::Array result; - const Iterator last = std::prev(end); - iter = skippable::invoke(std::next(iter), last); - while(iter != last) - { - const Iterator tmp = acceptor_type::invoke(iter, last); - if(tmp == iter) - throw std::make_pair(iter, syntax_error("parse_array")); - auto next = parser_type::invoke(iter, last); - if(!next.first.ok()) - throw std::make_pair(iter, syntax_error("parse_array")); - result.emplace_back(next.first.move()); - iter = tmp; - iter = skippable::invoke(iter, last); - iter = is_character::invoke(iter, last); - iter = skippable::invoke(iter, last); - } - return std::make_pair(result, end); - } -}; - -template -struct parse_inline_table; - -template -struct parse_array -{ - typedef charT value_type; - static_assert(std::is_same::value, ""); - typedef detail::result result_type; - typedef is_skippable_in_array skippable; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - if(iter == is_array::invoke(iter, range_end)) - return std::make_pair(result_type{}, iter); - - std::pair result; - if((result = parse_fixed_type_array, - parse_boolean>::invoke(iter, range_end)).first.ok()) return result; - else if((result = parse_fixed_type_array, - parse_string>::invoke(iter, range_end)).first.ok()) return result; - else if((result = parse_fixed_type_array, - parse_datetime>::invoke(iter, range_end)).first.ok()) return result; - else if((result = parse_fixed_type_array, - parse_float>::invoke(iter, range_end)).first.ok()) return result; - else if((result = parse_fixed_type_array, - parse_integer>::invoke(iter, range_end)).first.ok()) return result; - else if((result = parse_fixed_type_array, - parse_array>::invoke(iter, range_end)).first.ok()) return result; - else if((result = parse_fixed_type_array, - parse_inline_table>::invoke(iter, range_end)).first.ok()) - return result; - else if(skippable::invoke(std::next(iter), range_end) == // empty - std::prev(is_array::invoke(iter, range_end)) - ) return std::make_pair( - toml::Array{}, is_array::invoke(iter, range_end)); - else throw std::make_pair(iter, syntax_error("no valid array here")); - } -}; - -template -struct parse_value -{ - typedef charT value_type; - static_assert(std::is_same::value, ""); - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - std::pair result; - if((result = parse_boolean::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_string::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_datetime::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_float::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_integer::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_array::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_inline_table::invoke(iter, range_end)).first.ok()) - return result; - else - return std::make_pair(result_type{}, iter); - } -}; - -struct parse_barekey -{ - typedef toml::character value_type; - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = is_barekey::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - return std::make_pair(toml::key(iter, end), end); - } -}; - -struct parse_key -{ - typedef toml::character value_type; - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - std::pair result; - if((result = parse_barekey::invoke(iter, range_end)).first.ok()) - return result; - else if((result = parse_string::invoke(iter, range_end)).first.ok()) - return result; - else return std::make_pair(result_type{}, iter); - } -}; - -template -struct parse_key_value_pair -{ - typedef charT value_type; - static_assert(std::is_same::value, ""); - typedef detail::result> result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - auto tmp_key = parse_key::invoke(iter, range_end); - if(!tmp_key.first.ok()) - return std::make_pair(result_type{}, iter); - iter = is_any_num_of_ws::invoke(tmp_key.second, range_end); - if(*iter != '=') - throw std::make_pair(iter, syntax_error("invalid key value pair")); - iter = is_any_num_of_ws::invoke(std::next(iter), range_end); - - auto tmp_value = parse_value::invoke(iter, range_end); - if(!tmp_value.first.ok()) - throw std::make_pair(iter, syntax_error("invalid key value pair")); - - iter = tmp_value.second; - - return std::make_pair(std::make_pair( - tmp_key.first.move(), tmp_value.first.move()), - is_any_num_of_ws::invoke(tmp_value.second, range_end)); - } -}; - -template -struct parse_inline_table -{ - typedef charT value_type; - static_assert(std::is_same::value, ""); - typedef detail::result result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = is_inline_table::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - - iter = is_any_num_of_ws::invoke(std::next(iter), range_end); - - const Iterator last = std::prev(end); - toml::Table result; - while(iter != last) - { - auto tmp = parse_key_value_pair::invoke(iter, last); - if(!tmp.first.ok()) - throw std::make_pair(iter, syntax_error("parse_inline_table")); - - result.emplace(tmp.first.move()); - iter = tmp.second; - - iter = is_any_num_of_ws::invoke(iter, last); - iter = is_character::invoke(iter, last); - iter = is_any_num_of_ws::invoke(iter, last); - } - return std::make_pair(result, end); - } -}; - -struct parse_table_definition -{ - typedef toml::character value_type; - typedef detail::result> result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = - is_table_definition::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - - std::vector result; - result.reserve(std::count(iter, end, '.')+1); - - const Iterator last = std::prev(end); - iter = is_any_num_of_ws::invoke(iter, last); - iter = is_any_num_of_ws::invoke(std::next(iter), last); - - auto tmp = parse_key::invoke(iter, last); - if(!tmp.first.ok()) - throw std::make_pair(iter, syntax_error("table definition")); - result.emplace_back(tmp.first.move()); - iter = is_any_num_of_ws::invoke(tmp.second, last); - - while(iter != last) - { - iter = is_character::invoke(iter, last); - iter = is_any_num_of_ws::invoke(iter, last); - - tmp = parse_key::invoke(iter, last); - if(!tmp.first.ok()) - throw std::make_pair(iter, syntax_error("table definition")); - result.emplace_back(tmp.first.move()); - iter = is_any_num_of_ws::invoke(tmp.second, last); - } - return std::make_pair(result, end); - } -}; - -struct parse_array_of_table_definition -{ - typedef toml::character value_type; - typedef detail::result> result_type; - - template::value_type, - value_type>::value>::type> - static std::pair - invoke(Iterator iter, Iterator range_end) - { - const Iterator end = - is_array_of_table_definition::invoke(iter, range_end); - if(iter == end) return std::make_pair(result_type{}, iter); - - if(std::distance(iter, end) < 5) - throw std::make_pair(iter, syntax_error("invalid array_of_table definition")); - - std::vector result; - result.reserve(std::count(iter, end, '.')+1); - - const Iterator last = end - 2; - iter = is_any_num_of_ws::invoke(iter, last) + 2; - iter = is_any_num_of_ws::invoke(iter, last); - - auto tmp = parse_key::invoke(iter, last); - if(!tmp.first.ok()) - throw std::make_pair(iter, syntax_error("array of table definition")); - result.emplace_back(tmp.first.move()); - iter = is_any_num_of_ws::invoke(tmp.second, last); - - while(iter != last) - { - iter = is_character::invoke(iter, last); - iter = is_any_num_of_ws::invoke(iter, last); - - tmp = parse_key::invoke(iter, last); - if(!tmp.first.ok()) - throw std::make_pair(iter, syntax_error("array of table definition")); - result.emplace_back(tmp.first.move()); - iter = is_any_num_of_ws::invoke(tmp.second, last); - } - return std::make_pair(result, end); - } -}; - -struct parse_data -{ - typedef toml::character value_type; - typedef toml::Table result_type; - - template::value_type, - value_type>::value>::type> - static result_type invoke(Iterator iter, const Iterator end) - { - toml::Table result; - auto noname = parse_table_contents(iter, end); - result = std::move(noname.first); - iter = skip_empty(noname.second, end); - - while(iter != end) - { - iter = skip_empty(iter, end); - std::pair>, Iterator> tabname; - if((tabname = parse_table_definition::invoke(iter, end)).first.ok()) - { - auto contents = parse_table_contents(tabname.second, end); - push_table(result, std::move(contents.first), - tabname.first.get().begin(), tabname.first.get().end()); - iter = contents.second; - } - else if((tabname = parse_array_of_table_definition::invoke(iter, end)).first.ok()) - { - auto contents = parse_table_contents(tabname.second, end); - push_array_of_table(result, std::move(contents.first), - tabname.first.get().begin(), tabname.first.get().end()); - iter = contents.second; - } - else - throw std::make_pair(iter, syntax_error("parse_data: unknown line")); - } - return result; - } - - template::value_type, - value_type>::value>::type> - static Iterator - skip_empty(Iterator iter, Iterator end) - { - while(iter != end) - { - if(*iter == '#') - { - while(iter != end && - iter == is_newline::invoke(iter, end)){++iter;} - } - else if(iter == is_newline::invoke(iter, end) && - iter == is_whitespace::invoke(iter, end)) - { - return iter; - } - else - { - ++iter; - } - } - return iter; - } - - template::value_type, - value_type>::value>::type> - static std::pair - parse_table_contents(Iterator iter, Iterator end) - { - toml::Table table; - iter = skip_empty(iter, end); - while(iter != end) - { - auto kv = parse_key_value_pair::invoke(iter, end); - if(!kv.first.ok()) return std::make_pair(table, iter); - - table.emplace(kv.first.move()); - iter = kv.second; - iter = skip_empty(iter, end); - } - return std::make_pair(table, iter); - } - - template::value_type, - toml::key>::value>::type> - static void - push_table(toml::Table& data, toml::Table&& v, Iterator iter, Iterator end) - { - if(iter == std::prev(end)) - { - if(data.count(*iter) == 1) - throw syntax_error("duplicate key: " + *iter); - data.emplace(*iter, std::move(v)); - return; - } - - if(data.count(*iter) == 0) - { - data.emplace(*iter, toml::Table()); - return push_table(data[*iter].template cast(), - std::move(v), std::next(iter), end); - } - else if(data[*iter].type() == value_t::Table) - { - return push_table(data[*iter].template cast(), - std::move(v), std::next(iter), end); - } - else if(data[*iter].type() == value_t::Array) - { - auto& ar = data[*iter].template cast(); - if(ar.empty()) ar.emplace_back(toml::Table{}); - if(ar.back().type() != value_t::Table) - throw syntax_error("assign table into array having non-table type: " + *iter); - return push_table(ar.back().template cast(), - std::move(v), std::next(iter), end); - } - else - throw syntax_error("assign table into not table: " + *iter); - } - - template::value_type, - toml::key>::value>::type> - static void - push_array_of_table(toml::Table& data, toml::Table&& v, - Iterator iter, Iterator end) - { - //XXX Iterator::value_type == toml::key - if(iter == std::prev(end)) - { - if(data.count(*iter) == 0) - data.emplace(*iter, toml::Array()); - else if(data.at(*iter).type() != value_t::Array) - throw syntax_error("duplicate key: " + *iter); - - data[*iter].template cast().emplace_back(std::move(v)); - return; - } - - if(data.count(*iter) == 0) - { - data.emplace(*iter, toml::Table()); - return push_array_of_table(data[*iter].template cast(), - std::move(v), std::next(iter), end); - } - else if(data[*iter].type() == value_t::Table) - { - return push_array_of_table(data[*iter].template cast(), - std::move(v), std::next(iter), end); - } - else if(data[*iter].type() == value_t::Array) - { - auto& ar = data[*iter].template cast(); - if(ar.empty()) ar.emplace_back(toml::Table{}); - if(ar.back().type() != value_t::Table) - throw syntax_error("assign table into array having non-table type: " + *iter); - return push_array_of_table(ar.back().template cast(), - std::move(v), std::next(iter), end); - } - else - throw syntax_error("assign array of table into not table: " + *iter); - } - -}; - -template> -toml::Table parse(std::basic_istream& is) -{ - const auto initial = is.tellg(); - is.seekg(0, std::ios::end); - const auto eofpos = is.tellg(); - const std::size_t size = eofpos - initial; - is.seekg(initial); - std::vector contents(size); - typedef std::vector::const_iterator iterator_type; - is.read(contents.data(), size); - try - { - return parse_data::invoke(contents.cbegin(), contents.cend()); - } - catch(std::pair iter_except) - { - std::cerr << "toml syntax error." << std::endl; - auto iter = iter_except.first; - const std::size_t nline = 1 + std::count(contents.cbegin(), iter, '\n'); - std::cerr << "processing at line " << nline << std::endl; - while(*iter != '\n' && iter != contents.cbegin()){--iter;} - ++iter; - while(*iter != '\n' && iter != contents.cend()) - { - std::cerr << *iter; ++iter; - } - std::cerr << std::endl; - - throw iter_except.second; - } -} - -inline toml::Table parse(const char* filename) -{ - std::ifstream ifs(filename, std::ios_base::in | std::ios_base::binary); - if(!ifs.good()) - { - throw std::runtime_error("file open error: " + std::string(filename)); - } - return parse(ifs); -} - -template> -inline toml::Table parse(const std::basic_string& filename) -{ - std::ifstream ifs(filename, std::ios_base::in | std::ios_base::binary); - if(!ifs.good()) - { - throw std::runtime_error("file open error: " + filename); - } - return parse(ifs); -} - - - -}// toml -#endif// TOML11_PARSER diff --git a/vendor/toml/to_toml.hpp b/vendor/toml/to_toml.hpp deleted file mode 100644 index 9f373dd..0000000 --- a/vendor/toml/to_toml.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef TOML11_TO_TOML -#define TOML11_TO_TOML -#include "value.hpp" - -namespace toml -{ - -template(), - typename std::enable_if<(vT != toml::value_t::Unknown && - vT != value_t::Empty), std::nullptr_t>::type = nullptr> -inline toml::value to_toml(T&& x) -{ - return toml::value(std::forward(x)); -} - -template(), - typename std::enable_if<(vT == toml::value_t::Unknown) && - (!toml::detail::is_map::value) && - toml::detail::is_container::value, std::nullptr_t>::type = nullptr> -toml::value to_toml(T&& x) -{ - toml::Array tmp; tmp.reserve(std::distance(std::begin(x), std::end(x))); - for(auto iter = std::begin(x); iter != std::end(x); ++iter) - tmp.emplace_back(*iter); - return toml::value(std::move(tmp)); -} - -template(), - typename std::enable_if<(vT == toml::value_t::Unknown) && - toml::detail::is_map::value, std::nullptr_t>::type = nullptr> -toml::value to_toml(T&& x) -{ - toml::Table tmp; - for(auto iter = std::begin(x); iter != std::end(x); ++iter) - tmp.emplace(iter->first, to_toml(iter->second)); - return toml::value(std::move(tmp)); -} - -template -inline toml::value to_toml(std::initializer_list init) -{ - return toml::value(std::move(init)); -} - -inline toml::value -to_toml(std::initializer_list> init) -{ - return toml::value(std::move(init)); -} - -} // toml -#endif // TOML11_TO_TOML diff --git a/vendor/toml/traits.hpp b/vendor/toml/traits.hpp deleted file mode 100644 index 5e6e425..0000000 --- a/vendor/toml/traits.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef TOML11_TRAITS -#define TOML11_TRAITS -#include - -namespace toml -{ -namespace detail -{ - -template -using unwrap_t = typename std::decay::type; - -struct has_iterator_impl -{ - template static std::true_type check(typename T::iterator*); - template static std::false_type check(...); -}; -struct has_value_type_impl -{ - template static std::true_type check(typename T::value_type*); - template static std::false_type check(...); -}; -struct has_key_type_impl -{ - template static std::true_type check(typename T::key_type*); - template static std::false_type check(...); -}; -struct has_mapped_type_impl -{ - template static std::true_type check(typename T::mapped_type*); - template static std::false_type check(...); -}; -struct has_resize_method_impl -{ - constexpr static std::size_t dummy=0; - template static std::true_type check(decltype(std::declval().resize(dummy))*); - template static std::false_type check(...); -}; - -/// Intel C++ compiler can not use decltype in parent class declaration, here -/// is a hack to work around it. https://stackoverflow.com/a/23953090/4692076 -#ifdef __INTEL_COMPILER -#define decltype(...) std::enable_if::type -#endif - -template -struct has_iterator : decltype(has_iterator_impl::check(nullptr)){}; -template -struct has_value_type : decltype(has_value_type_impl::check(nullptr)){}; -template -struct has_key_type : decltype(has_key_type_impl::check(nullptr)){}; -template -struct has_mapped_type : decltype(has_mapped_type_impl::check(nullptr)){}; -template -struct has_resize_method : decltype(has_resize_method_impl::check(nullptr)){}; - -#ifdef __INTEL_COMPILER -#undef decltype(...) -#endif - -template -struct is_container : std::integral_constant::value && has_value_type::value>{}; - -template -struct is_map : std::integral_constant::value && has_key_type::value && - has_mapped_type::value>{}; - -}// detail -}//toml -#endif // TOML_TRAITS diff --git a/vendor/toml/utility.hpp b/vendor/toml/utility.hpp deleted file mode 100644 index 0df0d07..0000000 --- a/vendor/toml/utility.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef TOML11_UTILITY -#define TOML11_UTILITY -#include "traits.hpp" -#include -#include - -namespace toml -{ - -template -inline std::unique_ptr make_unique(Ts&& ... args) -{ - return std::unique_ptr(new T(std::forward(args)...)); -} - -namespace detail -{ - -template -inline void resize_impl(T& container, std::size_t N, std::true_type) -{ - container.resize(N); - return ; -} - -template -inline void resize_impl(T& container, std::size_t N, std::false_type) -{ - if(container.size() >= N) return; - else throw std::invalid_argument("not resizable type"); -} - -} - -template -inline void resize(T& container, std::size_t N) -{ - if(container.size() == N) return; - else return detail::resize_impl(container, N, detail::has_resize_method()); -} - -}// toml -#endif // TOML11_UTILITY diff --git a/vendor/toml/value.hpp b/vendor/toml/value.hpp deleted file mode 100644 index d773c24..0000000 --- a/vendor/toml/value.hpp +++ /dev/null @@ -1,719 +0,0 @@ -#ifndef TOML11_VALUE -#define TOML11_VALUE -#include "datetime.hpp" -#include "traits.hpp" -#include "utility.hpp" -#include "exception.hpp" -#include -#include -#include -#include -#include - -namespace toml -{ - -using character = char; - -class value; -using key = std::basic_string; - -using Boolean = bool; -using Integer = std::int64_t; -using Float = double; -using String = std::basic_string; -using Datetime = basic_datetime; -using Array = std::vector; -using Table = std::unordered_map; - -enum class value_t : std::uint8_t -{ - Boolean = 1, - Integer = 2, - Float = 3, - String = 4, - Datetime = 5, - Array = 6, - Table = 7, - Empty = 0, - Unknown = 255, -}; - -template> -inline std::basic_ostream& -operator<<(std::basic_ostream& os, value_t t) -{ - switch(t) - { - case toml::value_t::Boolean : os << "Boolean"; return os; - case toml::value_t::Integer : os << "Integer"; return os; - case toml::value_t::Float : os << "Float"; return os; - case toml::value_t::String : os << "String"; return os; - case toml::value_t::Datetime: os << "Datetime"; return os; - case toml::value_t::Array : os << "Array"; return os; - case toml::value_t::Table : os << "Table"; return os; - case toml::value_t::Empty : os << "Empty"; return os; - case toml::value_t::Unknown : os << "Unknown"; return os; - default : os << "Nothing"; return os; - } -} - -template, - typename alloc = std::allocator> -inline std::basic_string -stringize(value_t t) -{ - switch(t) - { - case toml::value_t::Boolean : return "Boolean"; - case toml::value_t::Integer : return "Integer"; - case toml::value_t::Float : return "Float"; - case toml::value_t::String : return "String"; - case toml::value_t::Datetime: return "Datetime"; - case toml::value_t::Array : return "Array"; - case toml::value_t::Table : return "Table"; - case toml::value_t::Empty : return "Empty"; - case toml::value_t::Unknown : return "Unknown"; - default : return "Nothing"; - } -} - -namespace detail -{ - -template -constexpr inline value_t check_type() -{ - return std::is_same, toml::Boolean >::value ? value_t::Boolean : - std::is_integral>::value ? value_t::Integer : - std::is_floating_point>::value ? value_t::Float : - std::is_convertible, toml::String >::value ? value_t::String : - std::is_convertible, toml::Datetime>::value ? value_t::Datetime: - std::is_convertible, toml::Array >::value ? value_t::Array : - std::is_convertible, toml::Table >::value ? value_t::Table : - value_t::Unknown; -} - -constexpr inline bool is_valid(value_t vt) -{ - return vt != value_t::Unknown; -} - -template struct is_toml_array : std::false_type{}; -template<> struct is_toml_array : std::true_type {}; -template struct is_toml_table : std::false_type{}; -template<> struct is_toml_table : std::true_type {}; - -struct is_key_convertible_impl -{ - template - static std::is_convertible - check(typename T::key_type*); - - template static std::false_type check(...); -}; - -/// Intel C++ compiler can not use decltype in parent class declaration, here -/// is a hack to work around it. https://stackoverflow.com/a/23953090/4692076 -#ifdef __INTEL_COMPILER -#define decltype(...) std::enable_if::type -#endif - -template -struct is_key_convertible : decltype(is_key_convertible_impl::check(nullptr)){}; - -#ifdef __INTEL_COMPILER -#undef decltype(...) -#endif - -template struct toml_default_type{}; -template<> struct toml_default_type{typedef Boolean type;}; -template<> struct toml_default_type{typedef Integer type;}; -template<> struct toml_default_type{typedef Float type;}; -template<> struct toml_default_type{typedef String type;}; -template<> struct toml_default_type{typedef Datetime type;}; -template<> struct toml_default_type{typedef Array type;}; -template<> struct toml_default_type{typedef Table type;}; -template<> struct toml_default_type{typedef void type;}; -template<> struct toml_default_type{typedef void type;}; - -struct storage_base -{ - storage_base(): type(toml::value_t::Empty){} - storage_base(toml::value_t t): type(t){} - virtual ~storage_base() = default; - toml::value_t type; -}; - -template -struct storage : public storage_base -{ - static_assert(is_toml_array::value || is_toml_table::value, - "toml::detail::storage is for toml::Array or toml::Table!"); - typedef T value_type; - - storage() = default; - ~storage() noexcept override = default; - storage(storage const&) = default; - storage(storage&&) = default; - storage& operator=(storage const&) = default; - storage& operator=(storage&&) = default; - - storage(value_type const& v) : value(v){} - storage(value_type&& v) : value(std::move(v)){} - - value_type value; -}; -} // detail - -template -struct value_traits -{ - constexpr static value_t type_index = detail::check_type(); - constexpr static bool is_toml_type = detail::is_valid(detail::check_type()); - typedef typename detail::toml_default_type::type type; -}; - -class value -{ - typedef std::unique_ptr storage_ptr; - - public: - - value() : type_(value_t::Empty){} - ~value(); - - value(const value& v); - value(value&& v); - value& operator=(const value& v); - value& operator=(value&& v); - - template::is_toml_type, std::nullptr_t>::type = nullptr> - value(T&& v); - - template::is_toml_type, std::nullptr_t>::type = nullptr> - value& operator=(T&& v); - - template::is_toml_type, std::nullptr_t>::type = nullptr> - value(std::initializer_list init); - - value(std::initializer_list> init); - - value_t type() const {return type_;} - - template - typename detail::toml_default_type::type const& cast() const; - template - typename detail::toml_default_type::type& cast(); - - private: - - void switch_clean(value_t t); - template struct switch_assign; - template struct switch_cast; - - static bool should_be_cleaned(value_t vt) - { - return (vt == value_t::String) || (vt == value_t::Array) || - (vt == value_t::Table) || (vt == value_t::Datetime); - } - - private: - - value_t type_; - union - { - Boolean boolean_; - Integer integer_; - Float float_; - String string_; - Datetime datetime_; - storage_ptr storage_; //ptr to table or array - }; -}; - -template<> struct value::switch_assign -{ - template - static void invoke(value& v, valT&& val) - { - v.boolean_ = static_cast(val); - } -}; -template<> struct value::switch_assign -{ - template - static void invoke(value& v, valT&& val) - { - v.integer_ = static_cast(val); - } -}; -template<> struct value::switch_assign -{ - template - static void invoke(value& v, valT&& val) - { - v.float_ = static_cast(val); - } -}; -template<> struct value::switch_assign -{ - template - static void invoke(value& v, valT&& val) - { - new(&v.string_) String(val); - } -}; -template<> struct value::switch_assign -{ - template - static void invoke(value& v, valT&& val) - { - new(&v.datetime_) Datetime(val); - } -}; -template<> struct value::switch_assign -{ - template - static void invoke(value& v, valT&& val) - { - new(&v.storage_) storage_ptr( - toml::make_unique>(val)); - } -}; -template<> struct value::switch_assign -{ - template - static void invoke(value& v, valT&& val) - { - new(&v.storage_) storage_ptr( - toml::make_unique>(val)); - } -}; - -template<> struct value::switch_cast -{ - static Boolean& invoke(value& v) {return v.boolean_;} - static Boolean const& invoke(value const& v) {return v.boolean_;} -}; -template<> struct value::switch_cast -{ - static Integer& invoke(value& v) {return v.integer_;} - static Integer const& invoke(value const& v) {return v.integer_;} -}; -template<> struct value::switch_cast -{ - static Float& invoke(value& v) {return v.float_;} - static Float const& invoke(value const& v) {return v.float_;} -}; -template<> struct value::switch_cast -{ - static String& invoke(value& v) {return v.string_;} - static String const& invoke(value const& v) {return v.string_;} -}; -template<> struct value::switch_cast -{ - static Datetime& invoke(value& v) {return v.datetime_;} - static Datetime const& invoke(value const& v) {return v.datetime_;} -}; -template<> struct value::switch_cast -{ - // switch_cast assumes tmeplate argument is correct. - // if not, the behaviour is undefined. - static Array& invoke(value& v) - { - return static_cast*>(v.storage_.get())->value; - } - static Array const& invoke(value const& v) - { - return static_cast*>(v.storage_.get())->value; - } -}; -template<> struct value::switch_cast -{ - static Table& invoke(value& v) - { - return static_cast*>(v.storage_.get())->value; - } - static Table const& invoke(value const& v) - { - return static_cast*>(v.storage_.get())->value; - } -}; - -inline void value::switch_clean(value_t t) -{ - switch(t) - { - case value_t::Boolean : {boolean_.~Boolean(); return;} - case value_t::Integer : {integer_.~Integer(); return;} - case value_t::Float : {float_.~Float(); return;} - case value_t::String : {string_.~String(); return;} - case value_t::Datetime : {datetime_.~Datetime(); return;} - case value_t::Array : {storage_.~storage_ptr(); return;} - case value_t::Table : {storage_.~storage_ptr(); return;} - case value_t::Empty : return; - case value_t::Unknown : assert(false); - default : assert(false); - } -} - -inline value::~value() -{ - switch_clean(this->type_); -} - -inline value::value(const value& v) : type_(v.type()) -{ - switch(v.type()) - { - case value_t::Boolean : - { - switch_assign::invoke( - *this, v.cast()); - break; - } - case value_t::Integer : - { - switch_assign::invoke( - *this, v.cast()); - break; - } - case value_t::Float : - { - switch_assign::invoke( - *this, v.cast()); - break; - } - case value_t::String : - { - switch_assign::invoke( - *this, v.cast()); - break; - } - case value_t::Datetime: - { - switch_assign::invoke( - *this, v.cast()); - break; - } - case value_t::Array : - { - switch_assign::invoke( - *this, v.cast()); - break; - } - case value_t::Table : - { - switch_assign::invoke( - *this, v.cast()); - break; - } - case value_t::Empty : break; - case value_t::Unknown : assert(false); - default: assert(false); - } -} - -inline value::value(value&& v) -{ - this->type_ = v.type_; - switch(this->type_) - { - case value_t::Boolean : - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::Integer : - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::Float : - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::String : - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::Datetime: - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::Array : - { - new(&this->storage_) storage_ptr(std::move(v.storage_)); - break; - } - case value_t::Table : - { - new(&this->storage_) storage_ptr(std::move(v.storage_)); - break; - } - case value_t::Empty : break; - case value_t::Unknown : assert(false); - default: assert(false); - } -} - -inline value& value::operator=(const value& v) -{ - if(should_be_cleaned(this->type_)) - { - this->switch_clean(this->type_); - } - this->type_ = v.type(); - - switch(this->type_) - { - case value_t::Boolean : - { - switch_assign::invoke(*this, - v.cast()); - break; - } - case value_t::Integer : - { - switch_assign::invoke(*this, - v.cast()); - break; - } - case value_t::Float : - { - switch_assign::invoke(*this, - v.cast()); - break; - } - case value_t::String : - { - switch_assign::invoke(*this, - v.cast()); - break; - } - case value_t::Datetime: - { - switch_assign::invoke(*this, - v.cast()); - break; - } - case value_t::Array : - { - switch_assign::invoke(*this, - v.cast()); - break; - } - case value_t::Table : - { - switch_assign::invoke(*this, - v.cast()); - break; - } - case value_t::Empty : break; - case value_t::Unknown : assert(false); - default: assert(false); - } - return *this; -} - -inline value& value::operator=(value&& v) -{ - if(should_be_cleaned(this->type_)) - { - this->switch_clean(this->type_); - } - this->type_ = v.type_; - - switch(this->type_) - { - case value_t::Boolean : - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::Integer : - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::Float : - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::String : - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::Datetime: - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::Array : - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::Table : - { - switch_assign::invoke(*this, - std::move(v.cast())); - break; - } - case value_t::Empty : break; - case value_t::Unknown : assert(false); - default: assert(false); - } - return *this; -} - -template::is_toml_type, std::nullptr_t>::type> -value::value(T&& v) : type_(toml::detail::check_type()) -{ - switch_assign()>::invoke( - *this, std::forward(v)); -} - -template::is_toml_type, std::nullptr_t>::type> -value& value::operator=(T&& v) -{ - if(should_be_cleaned(this->type_)) - { - switch_clean(this->type_); - } - this->type_ = toml::detail::check_type(); - switch_assign()>::invoke( - *this, std::forward(v)); - return *this; -} - -template::is_toml_type, std::nullptr_t>::type> -value::value(std::initializer_list init) - : type_(toml::value_t::Array) -{ - toml::Array arr; arr.reserve(init.size()); - for(auto&& item : init) - arr.emplace_back(std::move(item)); - switch_assign::invoke(*this, std::move(arr)); -} - -inline value::value( - std::initializer_list> init) - : type_(toml::value_t::Table) -{ - toml::Table tmp; - for(auto&& item : init) - tmp.emplace(std::move(item.first), std::move(item.second)); - switch_assign::invoke(*this, std::move(tmp)); -} - -template -inline typename detail::toml_default_type::type const& -value::cast() const -{ - if(T != this->type_) - throw type_error("current type: " + stringize(this->type_) + - std::string(" is not query type: ") + stringize(T)); - return switch_cast::invoke(*this); -} -template -inline typename detail::toml_default_type::type& -value::cast() -{ - if(T != this->type_) - throw type_error("current type: " + stringize(this->type_) + - std::string(" is not query type: ") + stringize(T)); - return switch_cast::invoke(*this); -} - -inline bool operator==(const toml::value& lhs, const toml::value& rhs) -{ - if(lhs.type() != rhs.type()) return false; - switch(lhs.type()) - { - case value_t::Boolean : - return lhs.cast() == rhs.cast(); - case value_t::Integer : - return lhs.cast() == rhs.cast(); - case value_t::Float : - return lhs.cast() == rhs.cast(); - case value_t::String : - return lhs.cast() == rhs.cast(); - case value_t::Datetime: - return lhs.cast() == rhs.cast(); - case value_t::Array : - return lhs.cast() == rhs.cast(); - case value_t::Table : - return lhs.cast() == rhs.cast(); - case value_t::Empty : return true; - case value_t::Unknown : return false; - default: return false; - } -} -inline bool operator<(const toml::value& lhs, const toml::value& rhs) -{ - if(lhs.type() != rhs.type()) return (lhs.type() < rhs.type()); - switch(lhs.type()) - { - case value_t::Boolean : - return lhs.cast() < rhs.cast(); - case value_t::Integer : - return lhs.cast() < rhs.cast(); - case value_t::Float : - return lhs.cast() < rhs.cast(); - case value_t::String : - return lhs.cast() < rhs.cast(); - case value_t::Datetime: - return lhs.cast() < rhs.cast(); - case value_t::Array : - return lhs.cast() < rhs.cast(); - case value_t::Table : - return lhs.cast() < rhs.cast(); - case value_t::Empty : return false; - case value_t::Unknown : return false; - default: return false; - } -} - -inline bool operator!=(const toml::value& lhs, const toml::value& rhs) -{ - return !(lhs == rhs); -} -inline bool operator<=(const toml::value& lhs, const toml::value& rhs) -{ - return (lhs < rhs) || (lhs == rhs); -} -inline bool operator>(const toml::value& lhs, const toml::value& rhs) -{ - return !(lhs <= rhs); -} -inline bool operator>=(const toml::value& lhs, const toml::value& rhs) -{ - return !(lhs < rhs); -} - -}// toml -#endif// TOML11_VALUE