Made option to read list of networks from OpenVZ configurable and optional (#831)

This commit is contained in:
Pavel Odintsov 2020-07-29 21:20:37 +01:00 committed by GitHub
parent b6039416c3
commit 20150977a5
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

@ -267,6 +267,9 @@ graphite_prefix = fastnetmon
# Works only for Linux # Works only for Linux
monitor_local_ip_addresses = on monitor_local_ip_addresses = on
# Add IP addresses for OpenVZ / Virtuozzo VEs to network monitoring list
monitor_openvz_vps_ip_addresses = off
# Create group of hosts with non-standard thresholds # Create group of hosts with non-standard thresholds
# You should create this group before (in configuration file) specifying any limits # You should create this group before (in configuration file) specifying any limits
# hostgroup = my_hosts:10.10.10.221/32,10.10.10.222/32 # hostgroup = my_hosts:10.10.10.221/32,10.10.10.222/32

@ -210,6 +210,9 @@ bool redis_enabled = false;
bool monitor_local_ip_addresses = true; bool monitor_local_ip_addresses = true;
// Enable monitoring for OpenVZ VPS IP addresses by reading their list from kernel
bool monitor_openvz_vps_ip_addresses = false;
// This flag could enable print of ban actions and thresholds on the client's screen // This flag could enable print of ban actions and thresholds on the client's screen
bool print_configuration_params_on_the_screen = false; bool print_configuration_params_on_the_screen = false;
@ -1133,6 +1136,10 @@ bool load_configuration_file() {
monitor_local_ip_addresses = configuration_map["monitor_local_ip_addresses"] == "on" ? true : false; monitor_local_ip_addresses = configuration_map["monitor_local_ip_addresses"] == "on" ? true : false;
} }
if (configuration_map.count("monitor_openvz_vps_ip_addresses") != 0) {
monitor_openvz_vps_ip_addresses = configuration_map["monitor_openvz_vps_ip_addresses"] == "on" ? true : false;
}
#ifdef FASTNETMON_API #ifdef FASTNETMON_API
if (configuration_map.count("enable_api") != 0) { if (configuration_map.count("enable_api") != 0) {
enable_api = configuration_map["enable_api"] == "on"; enable_api = configuration_map["enable_api"] == "on";
@ -1553,8 +1560,8 @@ bool load_our_networks_list() {
std::vector<std::string> networks_list_ipv4_as_string; std::vector<std::string> networks_list_ipv4_as_string;
std::vector<std::string> networks_list_ipv6_as_string; std::vector<std::string> networks_list_ipv6_as_string;
// We can bould "our subnets" automatically here // We can build list of our subnets automatically here
if (file_exists("/proc/vz/version")) { if (monitor_openvz_vps_ip_addresses && file_exists("/proc/vz/version")) {
logger << log4cpp::Priority::INFO << "We found OpenVZ"; logger << log4cpp::Priority::INFO << "We found OpenVZ";
// Add /32 CIDR mask for every IP here // Add /32 CIDR mask for every IP here
std::vector<std::string> openvz_ips = read_file_to_vector("/proc/vz/veip"); std::vector<std::string> openvz_ips = read_file_to_vector("/proc/vz/veip");