Code Monkey home page Code Monkey logo

netchasm's Introduction

NetCHASM

An Automated health checking and server status verifiction system.

standard-readme compliant

NetCHASM conducts periodic health checks and retrieves load-feed-back data from distributed servers. It stores the information in a backend database and exposes the results through an API. The daemon allows checks over all major protocols HTTP, HTTPS, FTP, FTPS, TCP, and DNS. NetCHASM provides C++ APIS to access the backend databases, and APIs to query the running Daemon in C++, Python and Perl. The Daemon retrieve load-feedback in addition to out-of-band information to control server status for traffic load balancers. The Daemon is configurage using simple YAML configs.

Table of Contents

Background

Load balancers need to make routing decisions based on health, load, and manual control flags in near realtime. NetCHASM provides an easy, extensible framework to collect health, load, and control signals periodically from remote servers aggregating the data for our load balancers. The daemon can be configured to check HTTP, HTTPS, FTP, FTPS, TCP and DNS. Remote information about load, and a generic out-of-band XML files can also be periodically retrieved. The Daemon automatically combines redundant checks, schedules checks, and combines the information into a persistent backend and responds through an API. The Daemon conducts checks through a dedicated thread pool allowing checks to be made efficiently in parallel.

While NetCHASM can do a lot out of the box, the code is also highly extensible with new check types, back ends, loggers, and control APIs having base classes allowing for easy additions of new types with all base functionality already available.

Install

NetCHASM uses CMake. For convenience, a Makefile is included allowing a default make, a unit test make, and a doxygen generation.

Dependency: NetCHASM requires: curl, ssl, cares, MDBM, yaml-cpp, cppunit, and libevent.

MDBM is available at: https://github.com/yahoo/mdbm.

Other dependencies can be installed via package utilities. For example, on Fedora/CentOS:

dnf install openssl-devel c-ares c-ares-devel yaml-cpp yaml-cpp-devel libevent libevent-devel make cmake gcc-c++ rapidxml-devel curl-devel cppunit-devel lcov protobuf protobuf-devel librdkafka librdkafka-devel rpm-build

make build
sudo make install

Unit tests can be built and run using:

make test

Doxygen can be created using:

make docs

Configuration

The Daemon is configured to run through a master configuration. An example with details on parameters can be found in master-config-sample.yaml.

Host checks are configured through check configuration files. An example showing all valid parameters are include in check-conf-sample.yaml.

Usage

Once the master and check configs are ready, the daemon can be run using:

NetCHASMDaemon <path to master config>

A variety of tools are included to interact with the daemon.

The hm_command tool issues commands to the daemon through the built in control socket. The hm_configure tool allows modifying the master config options on the daemon in real time. The hm_dumpconfig tool will write out the check configuration of the running daemon. The hm_reload tool will have the daemon reload updated configs without an interruption in checking. The hm_set tool allows an individual host to be manually set to down.

API

Additionally, NetCHASM provides a number of APIs. Python and Perl libraries that send commands through the control interface can be found in the API directory. NetCHASM exposes two C++ APIs. The first is the HMStorageAPI that allows a program to access the persistent backend database regardless of the daemon being running. The second API is a client control interface allowing a program full access to the control API of the running daemon.

Contribute

Please refer to the contributing.md file for information about how to get involved. We welcome issues, questions, and pull requests. Pull Requests are welcome.

Maintainers

Joshua Juen: [email protected] Uthira Mohan: [email protected] Raghavendra Nataraj: [email protected]

License

This project is licensed under the terms of the Apache 2.0 open source license. Please refer to LICENSE for the full terms.

netchasm's People

Contributors

gwirvin avatar juen1jp avatar raghavendra-nataraj avatar retlawrose avatar varsameer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netchasm's Issues

Usage of Dynamic libraries to avoid linking libraries that are not neeeded

If the current code can be modified to make use of Dynamic libraries for instantiation of derived class objects instead of concrete instantiation as is done currently during initialization from the master config, inclusion of unwanted libraries in the final binary can be avoided when developers have their own implementation of the derived classes . For example :- inclusion of MDBM library can be avoided when developers have their own implementation of the storage base class that makes use of a different backend database.

NetCHASM doesn't build against OpenSSL3.0

Expected Behavior

NetCHASM should build under Ubuntu LTS 22.04 and CentOS 9 which be default use OpenSSL3.

Current Behavior

NetCHASM fails to compile against OpenSSL3 because it uses a function that has been removed: FIPS_mode_set(). Here is the compile error:

/home/ubuntu/NetCHASM/src/internal/HMStateManager.cpp:106:5: error: ‘FIPS_mode_set’ was not declared in this scope
  106 |     FIPS_mode_set(0);
      |     ^~~~~~~~~~~~~
make[2]: *** [src/internal/CMakeFiles/netchasm_core.dir/build.make:692: src/internal/CMakeFiles/netchasm_core.dir/HMStateManager.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:426: src/internal/CMakeFiles/netchasm_core.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Note that there are also some functions used in NetCHASM that have been deprecated in OpenSSL3 (and some deprecated in OpenSSL 1.1.0). These functions will still work for now, but it is advisable to use the newer, non-deprecated functions to avoid the build breaking in the future. I've attached a full build log against OpenSSL3 which contains all the warnings of deprecated functions. Here is an example:

/home/ubuntu/NetCHASM/src/api/HMControlTLSSocketClient.cpp: In constructor ‘HMControlTLSSocketClient::HMControlTLSSocketClient(HMAPIIPAddress&, uint16_t, std::string&, std::string&, std::string&)’:
/home/ubuntu/NetCHASM/src/api/HMControlTLSSocketClient.cpp:100:40: warning: ‘const SSL_METHOD* TLSv1_2_method()’ is deprecated: Since OpenSSL 1.1.0 [-Wdeprecated-declarations]
  100 |     m_ctx = SSL_CTX_new(TLSv1_2_method());
      |                                        ^
In file included from /home/ubuntu/NetCHASM/include/NetCHASM/HMControlTLSSocketClient.h:11,
                 from /home/ubuntu/NetCHASM/src/api/HMControlTLSSocketClient.cpp:12:
/usr/include/openssl/ssl.h:2020:50: note: declared here
 2020 | OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_2_method(void); /* TLSv1.2 */
      |                                                  ^~~~~~~~~~~~~~
/home/ubuntu/NetCHASM/src/api/HMControlTLSSocketClient.cpp:100:40: warning: ‘const SSL_METHOD* TLSv1_2_method()’ is deprecated: Since OpenSSL 1.1.0 [-Wdeprecated-declarations]
  100 |     m_ctx = SSL_CTX_new(TLSv1_2_method());
      |                                        ^
In file included from /home/ubuntu/NetCHASM/include/NetCHASM/HMControlTLSSocketClient.h:11,
                 from /home/ubuntu/NetCHASM/src/api/HMControlTLSSocketClient.cpp:12:
/usr/include/openssl/ssl.h:2020:50: note: declared here
 2020 | OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_2_method(void); /* TLSv1.2 */
      |                                                  ^~~~~~~~~~~~~~
/home/ubuntu/NetCHASM/src/internal/HMWorkHealthCheckCurl.cpp:86:21: warning: ‘void RSA_free(RSA*)’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
   86 |         RSA_free(rsa);
      |                     ^
In file included from /usr/include/openssl/x509.h:36,
                 from /usr/include/openssl/ssl.h:31,
                 from /home/ubuntu/NetCHASM/include/internal/HMEventLoopLibEvent.h:15,
                 from /home/ubuntu/NetCHASM/include/internal/HMStateManager.h:9,
                 from /home/ubuntu/NetCHASM/src/internal/HMWorkHealthCheckCurl.cpp:10:
/usr/include/openssl/rsa.h:293:28: note: declared here
  293 | OSSL_DEPRECATEDIN_3_0 void RSA_free(RSA *r);
      |                            ^~~~~~~~

Full Log: make.log

Possible Solution

I'm not really sure why FIPS_mode_set(0) (which would attempt to turn FIPS Mode off) is called as I can't find an instance in the NetCHASM code where FIPS mode is turned on. The OpenSSL page on migrating to OpenSSL3 is here: https://www.openssl.org/docs/man3.0/man7/migration_guide.html#Deprecated-low-level-encryption-functions and it says this:

Removed FIPS_mode() and FIPS_mode_set()
These functions are legacy APIs that are not applicable to the new provider model. Applications should instead use [EVP_default_properties_is_fips_enabled(3)](https://www.openssl.org/docs/man3.0/man3/EVP_default_properties_is_fips_enabled.html) and [EVP_default_properties_enable_fips(3)](https://www.openssl.org/docs/man3.0/man3/EVP_default_properties_enable_fips.html).

So I can't fully suggest what to change here to fix this issue.

Steps to Reproduce (for bugs)

Clone the repository on Ubuntu 22.04 LTS and follow the normal steps for building. Install the pre-reqs, run the cmake command then make. Note that I also had to install and use g++-9 because NetCHASM won't build with g++-11 due to compiler changes.

Context

OpenSSL3 is the current version of the OpenSSL project and has been adopted by Ubuntu 22.04, CentOS 9, and presumably will be the default for most distros going forward. The older OpenSSL versions will go EOL eventually thus meaning that all systems that want to use OpenSSL must upgrade. Unfortunately, OpenSSL has deprecated or removed some of their API in this major version update. If people want to use NetCHASM on these newer distros then it will have to be updated to support the OpenSSL 3.0 APIs. Here is the migration guide which helps explain this.

Your Environment

  • Version used: git master, as of this writing that is commit 3071241
  • Environment name and version (e.g. Chrome 39, node.js 5.4): Ubuntu 22.04, g++-9, OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
  • Operating System and version (desktop or mobile): Ubuntu 22.04

API to dynamically add/remove servers from Host groups

Currently, the only way to add/remove servers to host groups using the provided API is to make the desired changes in the config and to issue a reload of the config. A new API to dynamically add/remove servers to host groups will avoid this time consuming reload.

Avoid DNS lookup when a host group contains only IP addresses

An optimization can be introduced when a Host group consists of only IP addresses instead of Domain names for servers. Currently, Work orders for DNS resolution are placed on the Queue even when just the IP addresses for the servers are provided in the config. This can be avoided if NetCHASM can detect host groups with only IP addresses and cancel this part of the code flow.

Question: Support for http2/3 health checks?

Expected Behavior

Does NetCHASM support http2 (or later) health checks?

It's unclear from my scanning of the documentation whether NetCHASM supports making health checks to servers which support only http2 (i.e. no http/1.1 support).

Current Behavior

Change would be to add http2 support (if it does not exist).

Context

Such support would be useful for checking servers running gRPC services which are http2 based, but do not support http/1.1. We often have a situation now running Java gRPC services where a health check comes in for, say, GET /status.html HTTP/1.1 on the same port as the Java gRPC service. In Java gRPC, this results in an error and a long stack backtrace (see grpc/grpc-java#7692).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.