From d1b746b6436121868aaa26cdc80a6952a4133f46 Mon Sep 17 00:00:00 2001 From: Simon Pichugin Date: Mar 20 2020 15:09:20 +0000 Subject: Issue 50960 - [RFE] Advance options in RHDS Disk Monitoring Framework Description: Add an attributes to cn=config nsslapd-disk-monitoring-readonly-on-threshold - it accepts 'on/off' values and changes the original behavior so when we reach the threshold, we set the read-only mode (and then we do other actions - like disable non-critical logging, etc.). When we reach half of the threshold, we start the graceful shutdown as it was before. Change the code so the instance doesn't start up if the disk space is still below half of the threshold. Add basic tests to disk monitoring test suite. https://pagure.io/389-ds-base/issue/50960 Reviewed by: firstyear, tbordaz (Thanks a lot!!) --- diff --git a/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py b/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py index c1d2974..200213e 100644 --- a/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py +++ b/dirsrvtests/tests/suites/disk_monitoring/disk_monitoring_test.py @@ -15,11 +15,13 @@ import pytest from lib389.tasks import * from lib389._constants import * from lib389.utils import ensure_bytes +from lib389.backend import Backends from lib389.topologies import topology_st as topo from lib389.paths import * from lib389.idm.user import UserAccounts pytestmark = pytest.mark.tier2 +disk_monitoring_ack = pytest.mark.skipif(not os.environ.get('DISK_MONITORING_ACK', False), reason="GSSAPI tests may damage system configuration.") THRESHOLD = '30' THRESHOLD_BYTES = '30000000' @@ -39,6 +41,7 @@ def _witherrorlog(topo, condition, maxtimesleep): with open(topo.standalone.errlog, 'r') as study: study = study.read() while condition not in study: time.sleep(1) + timecount += 1 with open(topo.standalone.errlog, 'r') as study: study = study.read() if timecount >= maxtimesleep: break assert condition in study @@ -94,6 +97,7 @@ def setup(request, topo): request.addfinalizer(fin) + @pytest.fixture(scope="function") def reset_logs(topo): """ @@ -102,6 +106,7 @@ def reset_logs(topo): open('{}/errors'.format(topo.standalone.ds_paths.log_dir), 'w').close() +@disk_monitoring_ack def test_verify_operation_when_disk_monitoring_is_off(topo, setup, reset_logs): """ Verify operation when Disk monitoring is off @@ -132,6 +137,7 @@ def test_verify_operation_when_disk_monitoring_is_off(topo, setup, reset_logs): os.remove('{}/foo1'.format(topo.standalone.ds_paths.log_dir)) +@disk_monitoring_ack def test_free_up_the_disk_space_and_change_ds_config(topo, setup, reset_logs): """ Free up the disk space and change DS config @@ -162,6 +168,7 @@ def test_free_up_the_disk_space_and_change_ds_config(topo, setup, reset_logs): assert 'deleting rotated logs' not in study +@disk_monitoring_ack def test_verify_operation_with_nsslapd_disk_monitoring_logging_critical_off(topo, setup, reset_logs): """ Verify operation with "nsslapd-disk-monitoring-logging-critical: off @@ -201,6 +208,7 @@ def test_verify_operation_with_nsslapd_disk_monitoring_logging_critical_off(topo os.remove('{}/foo'.format(topo.standalone.ds_paths.log_dir)) +@disk_monitoring_ack def test_operation_with_nsslapd_disk_monitoring_logging_critical_on_below_half_of_the_threshold(topo, setup, reset_logs): """ Verify operation with \"nsslapd-disk-monitoring-logging-critical: on\" below 1/2 of the threshold @@ -229,6 +237,7 @@ def test_operation_with_nsslapd_disk_monitoring_logging_critical_on_below_half_o _witherrorlog(topo, 'Available disk space is now acceptable', 25) +@disk_monitoring_ack def test_setting_nsslapd_disk_monitoring_logging_critical_to_off(topo, setup, reset_logs): """ Setting nsslapd-disk-monitoring-logging-critical to \"off\ @@ -246,6 +255,7 @@ def test_setting_nsslapd_disk_monitoring_logging_critical_to_off(topo, setup, re assert topo.standalone.status() == True +@disk_monitoring_ack def test_operation_with_nsslapd_disk_monitoring_logging_critical_off(topo, setup, reset_logs): """ Verify operation with \"nsslapd-disk-monitoring-logging-critical: off @@ -313,6 +323,7 @@ def test_operation_with_nsslapd_disk_monitoring_logging_critical_off(topo, setup os.remove('{}/foo2'.format(topo.standalone.ds_paths.log_dir)) +@disk_monitoring_ack def test_operation_with_nsslapd_disk_monitoring_logging_critical_off_below_half_of_the_threshold(topo, setup, reset_logs): """ Verify operation with \"nsslapd-disk-monitoring-logging-critical: off\" below 1/2 of the threshold @@ -344,8 +355,9 @@ def test_operation_with_nsslapd_disk_monitoring_logging_critical_off_below_half_ subprocess.call(['dd', 'if=/dev/zero', 'of={}/foo'.format(topo.standalone.ds_paths.log_dir), 'bs=1M', 'count={}'.format(FULL_THR_FILL_SIZE)]) # Increased sleep to avoid failure _witherrorlog(topo, 'is too far below the threshold', 100) - _witherrorlog(topo, 'Signaling slapd for shutdown', 2) + _witherrorlog(topo, 'Signaling slapd for shutdown', 90) # Verifying that DS has been shut down after the grace period + time.sleep(2) assert topo.standalone.status() == False # free_space os.remove('{}/foo'.format(topo.standalone.ds_paths.log_dir)) @@ -387,6 +399,7 @@ def test_operation_with_nsslapd_disk_monitoring_logging_critical_off_below_half_ for i in [i for i in users.list()]: i.delete() +@disk_monitoring_ack def test_go_straight_below_half_of_the_threshold(topo, setup, reset_logs): """ Go straight below 1/2 of the threshold @@ -441,6 +454,140 @@ def test_go_straight_below_half_of_the_threshold(topo, setup, reset_logs): assert 'disabling access and audit logging' not in study +@disk_monitoring_ack +def test_readonly_on_threshold(topo, setup, reset_logs): + """Verify that nsslapd-disk-monitoring-readonly-on-threshold switches the server to read-only mode + + :id: 06814c19-ef3c-4800-93c9-c7c6e76fcbb9 + :setup: Standalone + :steps: + 1. Verify that the backend is in read-only mode + 2. Go back above the threshold + 3. Verify that the backend is in read-write mode + :expectedresults: + 1. Should Success + 2. Should Success + 3. Should Success + """ + file_path = '{}/foo'.format(topo.standalone.ds_paths.log_dir) + backends = Backends(topo.standalone) + backend_name = backends.list()[0].rdn + # Verify that verbose logging was set to default level + topo.standalone.deleteErrorLogs() + assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on') + assert topo.standalone.config.set('nsslapd-disk-monitoring-readonly-on-threshold', 'on') + topo.standalone.restart() + try: + subprocess.call(['dd', 'if=/dev/zero', f'of={file_path}', 'bs=1M', f'count={HALF_THR_FILL_SIZE}']) + _witherrorlog(topo, f"Putting the backend '{backend_name}' to read-only mode", 11) + users = UserAccounts(topo.standalone, DEFAULT_SUFFIX) + try: + user = users.create_test_user() + user.delete() + except ldap.UNWILLING_TO_PERFORM as e: + if 'database is read-only' not in str(e): + raise + os.remove(file_path) + _witherrorlog(topo, f"Putting the backend '{backend_name}' back to read-write mode", 11) + user = users.create_test_user() + assert user.exists() + user.delete() + finally: + if os.path.exists(file_path): + os.remove(file_path) + + +@disk_monitoring_ack +def test_readonly_on_threshold_below_half_of_the_threshold(topo, setup, reset_logs): + """Go below 1/2 of the threshold when readonly on threshold is enabled + + :id: 10262663-b41f-420e-a2d0-9532dd54fa7c + :setup: Standalone + :steps: + :expectedresults: + 1. Go straight below 1/2 of the threshold + 2. Verify that the backend is in read-only mode + 3. Go back above the threshold + 4. Verify that the backend is in read-write mode + :expectedresults: + 1. Should Success + 2. Should Success + 3. Should Success + 4. Should Success + """ + file_path = '{}/foo'.format(topo.standalone.ds_paths.log_dir) + backends = Backends(topo.standalone) + backend_name = backends.list()[0].rdn + topo.standalone.deleteErrorLogs() + assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on') + assert topo.standalone.config.set('nsslapd-disk-monitoring-readonly-on-threshold', 'on') + topo.standalone.restart() + try: + if float(THRESHOLD) > FULL_THR_FILL_SIZE: + FULL_THR_FILL_SIZE_new = FULL_THR_FILL_SIZE + round(float(THRESHOLD) - FULL_THR_FILL_SIZE) + 1 + subprocess.call(['dd', 'if=/dev/zero', f'of={file_path}', 'bs=1M', f'count={FULL_THR_FILL_SIZE_new}']) + else: + subprocess.call(['dd', 'if=/dev/zero', f'of={file_path}', 'bs=1M', f'count={FULL_THR_FILL_SIZE}']) + _witherrorlog(topo, f"Putting the backend '{backend_name}' to read-only mode", 11) + users = UserAccounts(topo.standalone, DEFAULT_SUFFIX) + try: + user = users.create_test_user() + user.delete() + except ldap.UNWILLING_TO_PERFORM as e: + if 'database is read-only' not in str(e): + raise + _witherrorlog(topo, 'is too far below the threshold', 51) + # Verify DS has recovered from shutdown + os.remove(file_path) + _witherrorlog(topo, f"Putting the backend '{backend_name}' back to read-write mode", 51) + user = users.create_test_user() + assert user.exists() + user.delete() + finally: + if os.path.exists(file_path): + os.remove(file_path) + + +@disk_monitoring_ack +def test_below_half_of_the_threshold_not_starting_after_shutdown(topo, setup, reset_logs): + """Test that the instance won't start if we are below 1/2 of the threshold + + :id: cceeaefd-9fa4-45c5-9ac6-9887a0671ef8 + :setup: Standalone + :steps: + 1. Go straight below 1/2 of the threshold + 2. Try to start the instance + 3. Go back above the threshold + 2. Try to start the instance + :expectedresults: + 1. Should Success + 2. Should Fail + 3. Should Success + 4. Should Success + """ + file_path = '{}/foo'.format(topo.standalone.ds_paths.log_dir) + topo.standalone.deleteErrorLogs() + assert topo.standalone.config.set('nsslapd-disk-monitoring', 'on') + topo.standalone.restart() + try: + if float(THRESHOLD) > FULL_THR_FILL_SIZE: + FULL_THR_FILL_SIZE_new = FULL_THR_FILL_SIZE + round(float(THRESHOLD) - FULL_THR_FILL_SIZE) + 1 + subprocess.call(['dd', 'if=/dev/zero', f'of={file_path}', 'bs=1M', f'count={FULL_THR_FILL_SIZE_new}']) + else: + subprocess.call(['dd', 'if=/dev/zero', f'of={file_path}', 'bs=1M', f'count={FULL_THR_FILL_SIZE}']) + _withouterrorlog(topo, 'topo.standalone.status() == True', 120) + with pytest.raises(subprocess.CalledProcessError): + topo.standalone.start() + _witherrorlog(topo, f'is too far below the threshold({THRESHOLD_BYTES} bytes). Exiting now', 2) + # Verify DS has recovered from shutdown + os.remove(file_path) + topo.standalone.start() + finally: + if os.path.exists(file_path): + os.remove(file_path) + + +@disk_monitoring_ack def test_go_straight_below_4kb(topo, setup, reset_logs): """ Go straight below 4KB @@ -464,6 +611,7 @@ def test_go_straight_below_4kb(topo, setup, reset_logs): assert topo.standalone.status() == True +@disk_monitoring_ack @pytest.mark.bz982325 def test_threshold_to_overflow_value(topo, setup, reset_logs): """ @@ -483,6 +631,7 @@ def test_threshold_to_overflow_value(topo, setup, reset_logs): ['nsslapd-disk-monitoring-threshold'])))[0].split(' ')[1] +@disk_monitoring_ack @pytest.mark.bz970995 def test_threshold_is_reached_to_half(topo, setup, reset_logs): """ @@ -508,6 +657,7 @@ def test_threshold_is_reached_to_half(topo, setup, reset_logs): os.remove('{}/foo'.format(topo.standalone.ds_paths.log_dir)) +@disk_monitoring_ack @pytest.mark.parametrize("test_input,expected", [ ("nsslapd-disk-monitoring-threshold", '-2'), ("nsslapd-disk-monitoring-threshold", '9223372036854775808'), @@ -540,6 +690,7 @@ def test_negagtive_parameterize(topo, setup, reset_logs, test_input, expected): topo.standalone.config.set(test_input, ensure_bytes(expected)) +@disk_monitoring_ack def test_valid_operations_are_permitted(topo, setup, reset_logs): """ Verify that valid operations are permitted diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 7c6d35f..e5b4169 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -401,6 +401,7 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) time_t start = 0; time_t now = 0; int deleted_rotated_logs = 0; + int readonly_on_threshold = 0; int logging_critical = 0; int passed_threshold = 0; int verbose_logging = 0; @@ -411,6 +412,12 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) int grace_period = 0; int first_pass = 1; int ok_now = 0; + int32_t immediate_shutdown = 0; + Slapi_Backend *be = NULL; + char *cookie = NULL; + int32_t be_list_count = 0; /* Has the function scope and used to track adding new backends to read-only */ + int32_t be_index = 0; /* Is used locally to free backends and set back to read-write */ + Slapi_Backend *be_list[BE_LIST_SIZE + 1] = {0}; while (!g_get_shutdown()) { if (!first_pass) { @@ -430,6 +437,7 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) /* * Get the config settings, as they could have changed */ + readonly_on_threshold = config_get_disk_threshold_readonly(); logging_critical = config_get_disk_logging_critical(); grace_period = 60 * config_get_disk_grace_period(); /* convert it to seconds */ verbose_logging = config_get_errorlog_level(); @@ -455,9 +463,19 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) if (dirstr == NULL) { /* * Good, none of our disks are within the threshold, - * reset the logging if we turned it off + * disable readonly mode if it's on and reset the logging if we turned it off */ if (passed_threshold) { + if (readonly_on_threshold) { + be_index = 0; + if (be_list[be_index] != NULL) { + while ((be = be_list[be_index++])) { + slapi_log_err(SLAPI_LOG_INFO, "disk_monitoring_thread", + "Putting the backend '%s' back to read-write mode\n", be->be_name); + slapi_mtn_be_set_readonly(be, 0); + } + } + } if (logs_disabled) { slapi_log_err(SLAPI_LOG_INFO, "disk_monitoring_thread", "Disk space is now within acceptable levels. Restoring the log settings.\n"); @@ -477,11 +495,13 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) passed_threshold = 0; previous_mark = 0; logs_disabled = 0; + be_list_count = 0; } continue; } else { passed_threshold = 1; } + /* * Check if we are already critical */ @@ -489,8 +509,36 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space is critically low on disk (%s), remaining space: %" PRIu64 " Kb. Signaling slapd for shutdown...\n", dirstr, (disk_space / 1024)); - g_set_shutdown(SLAPI_SHUTDOWN_DISKFULL); - return; + immediate_shutdown = 1; + goto cleanup; + } + + /* If we are low, set all of the backends to readonly mode + * Some file system, hosting backend, are possibly not full but we switch them readonly as well. + * Only exception are in memory backend dse, schema, defaut_backend. + */ + if (readonly_on_threshold) { + be = slapi_get_first_backend(&cookie); + while (be) { + if (strcasecmp(be->be_name, DSE_BACKEND) != 0 && + strcasecmp(be->be_name, DSE_SCHEMA) != 0 && + strcasecmp(be->be_name, DEFBACKEND_NAME) != 0 && + !slapi_be_get_readonly(be)) + { + if (be_list_count == BE_LIST_SIZE) { /* error - too many backends */ + slapi_log_err(SLAPI_LOG_ERR, "disk_monitoring_thread", + "Too many backends match search request - cannot proceed"); + } else { + slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", + "Putting the backend '%s' to read-only mode\n", be->be_name); + slapi_mtn_be_set_readonly(be, 1); + be_list[be_list_count++] = be; + } + } + be = (Slapi_Backend *)slapi_get_next_backend(cookie); + } + be_list[be_list_count] = NULL; + slapi_ch_free_string(&cookie); } /* * If we are low, see if we are using verbose error logging, and turn it off @@ -558,6 +606,12 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) now = start; while ((now - start) < grace_period) { if (g_get_shutdown()) { + be_index = 0; + if (be_list[be_index] != NULL) { + while ((be = be_list[be_index++])) { + slapi_be_free(&be); + } + } return; } /* @@ -572,7 +626,18 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) if (!dirstr) { /* * Excellent, we are back to acceptable levels, reset everything... + * */ + if (readonly_on_threshold) { + be_index = 0; + if (be_list[be_index] != NULL) { + while ((be = be_list[be_index++])) { + slapi_log_err(SLAPI_LOG_INFO, "disk_monitoring_thread", + "Putting the backend '%s' back to read-write mode\n", be->be_name); + slapi_mtn_be_set_readonly(be, 0); + } + } + } slapi_log_err(SLAPI_LOG_INFO, "disk_monitoring_thread", "Available disk space is now acceptable (%" PRIu64 " bytes). Aborting shutdown, and restoring the log settings.\n", disk_space); @@ -592,6 +657,7 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) ok_now = 1; start = 0; now = 0; + be_list_count = 0; break; } else if (disk_space < 4096) { /* 4 k */ /* @@ -600,8 +666,8 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space is critically low on disk (%s), remaining space: %" PRIu64 " Kb. Signaling slapd for shutdown...\n", dirstr, (disk_space / 1024)); - g_set_shutdown(SLAPI_SHUTDOWN_DISKFULL); - return; + immediate_shutdown = 1; + goto cleanup; } now = slapi_current_utc_time(); } @@ -618,11 +684,34 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", "Disk space is still too low (%" PRIu64 " Kb). Signaling slapd for shutdown...\n", (disk_space / 1024)); - g_set_shutdown(SLAPI_SHUTDOWN_DISKFULL); - - return; + goto cleanup; + } + } + cleanup: + if (readonly_on_threshold) { + be_index = 0; + if (be_list[be_index] != NULL) { + while ((be = be_list[be_index++])) { + if (immediate_shutdown) { + slapi_log_err(SLAPI_LOG_ALERT, "disk_monitoring_thread", + "'%s' backend is set to read-only mode. " + "It should be set manually to read-write mode after the instance's start.\n", be->be_name); + } else { + slapi_log_err(SLAPI_LOG_INFO, "disk_monitoring_thread", + "Putting the backend '%s' back to read-write mode\n", be->be_name); + slapi_mtn_be_set_readonly(be, 0); + } + } + } } - } + be_index = 0; + if (be_list[be_index] != NULL) { + while ((be = be_list[be_index++])) { + slapi_be_free(&be); + } + } + g_set_shutdown(SLAPI_SHUTDOWN_DISKFULL); + return; } static void diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index c43c5ee..c4ac05f 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -237,6 +237,7 @@ slapi_onoff_t init_force_sasl_external; slapi_onoff_t init_slapi_counters; slapi_onoff_t init_entryusn_global; slapi_onoff_t init_disk_monitoring; +slapi_onoff_t init_disk_threshold_readonly; slapi_onoff_t init_disk_logging_critical; slapi_onoff_t init_ndn_cache_enabled; slapi_onoff_t init_sasl_mapping_fallback; @@ -1051,6 +1052,11 @@ static struct config_get_and_set (void **)&global_slapdFrontendConfig.disk_monitoring, CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_monitoring, &init_disk_monitoring, NULL}, + {CONFIG_DISK_THRESHOLD_READONLY, config_set_disk_threshold_readonly, + NULL, 0, + (void **)&global_slapdFrontendConfig.disk_threshold_readonly, + CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_threshold_readonly, + &init_disk_threshold_readonly, NULL}, {CONFIG_DISK_THRESHOLD, config_set_disk_threshold, NULL, 0, (void **)&global_slapdFrontendConfig.disk_threshold, @@ -1763,6 +1769,7 @@ FrontendConfig_init(void) cfg->allowed_sasl_mechs = NULL; init_disk_monitoring = cfg->disk_monitoring = LDAP_OFF; + init_disk_threshold_readonly = cfg->disk_threshold_readonly = LDAP_OFF; cfg->disk_threshold = SLAPD_DEFAULT_DISK_THRESHOLD; cfg->disk_grace_period = SLAPD_DEFAULT_DISK_GRACE_PERIOD; init_disk_logging_critical = cfg->disk_logging_critical = LDAP_OFF; @@ -1989,6 +1996,18 @@ config_set_disk_monitoring(const char *attrname, char *value, char *errorbuf, in return retVal; } +int32_t +config_set_disk_threshold_readonly(const char *attrname, char *value, char *errorbuf, int apply) +{ + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + int32_t retVal = LDAP_SUCCESS; + + retVal = config_set_onoff(attrname, value, &(slapdFrontendConfig->disk_threshold_readonly), + errorbuf, apply); + return retVal; +} + + int config_set_disk_threshold(const char *attrname, char *value, char *errorbuf, int apply) { @@ -5028,6 +5047,13 @@ config_get_disk_monitoring() } int32_t +config_get_disk_threshold_readonly() +{ + slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + return slapi_atomic_load_32(&(slapdFrontendConfig->disk_threshold_readonly), __ATOMIC_ACQUIRE); +} + +int32_t config_get_disk_logging_critical() { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index bebd3cf..c866d1f 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -940,6 +940,24 @@ main(int argc, char **argv) slapi_ch_free((void **)&versionstring); } + if (config_get_disk_monitoring()) { + char **dirs = NULL; + char *dirstr = NULL; + uint64_t disk_space = 0; + int64_t threshold = 0; + uint64_t halfway = 0; + threshold = config_get_disk_threshold(); + halfway = threshold / 2; + disk_mon_get_dirs(&dirs); + dirstr = disk_mon_check_diskspace(dirs, threshold, &disk_space); + if (dirstr != NULL && disk_space < halfway) { + slapi_log_err(SLAPI_LOG_EMERG, "main", + "Disk Monitoring is enabled and disk space on (%s) is too far below the threshold(%" PRIu64 " bytes). Exiting now.\n", + dirstr, threshold); + return_value = 1; + goto cleanup; + } + } /* log the max fd limit as it is typically set in env/systemd */ slapi_log_err(SLAPI_LOG_INFO, "main", "Setting the maximum file descriptor limit to: %ld\n", diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 3feea55..d4111cb 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -376,6 +376,7 @@ int config_set_entryusn_global(const char *attrname, char *value, char *errorbuf int config_set_entryusn_import_init(const char *attrname, char *value, char *errorbuf, int apply); int config_set_default_naming_context(const char *attrname, char *value, char *errorbuf, int apply); int config_set_disk_monitoring(const char *attrname, char *value, char *errorbuf, int apply); +int config_set_disk_threshold_readonly(const char *attrname, char *value, char *errorbuf, int apply); int config_set_disk_threshold(const char *attrname, char *value, char *errorbuf, int apply); int config_set_disk_grace_period(const char *attrname, char *value, char *errorbuf, int apply); int config_set_disk_logging_critical(const char *attrname, char *value, char *errorbuf, int apply); @@ -541,6 +542,7 @@ void config_set_auditlog_enabled(int value); void config_set_auditfaillog_enabled(int value); int config_get_accesslog_logging_enabled(void); int config_get_disk_monitoring(void); +int config_get_disk_threshold_readonly(void); PRInt64 config_get_disk_threshold(void); int config_get_disk_grace_period(void); int config_get_disk_logging_critical(void); @@ -1506,6 +1508,7 @@ void slapd_do_nothing(int); void slapd_wait4child(int); void disk_mon_get_dirs(char ***list); int32_t disk_get_info(char *dir, uint64_t *total_space, uint64_t *avail_space, uint64_t *used_space); +char *disk_mon_check_diskspace(char **dirs, uint64_t threshold, uint64_t *disk_space); /* * main.c diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 1faa02e..3b39a0a 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -2233,6 +2233,7 @@ typedef struct _slapdEntryPoints #define CONFIG_ENTRYUSN_IMPORT_INITVAL "nsslapd-entryusn-import-initval" #define CONFIG_DEFAULT_NAMING_CONTEXT "nsslapd-defaultnamingcontext" #define CONFIG_DISK_MONITORING "nsslapd-disk-monitoring" +#define CONFIG_DISK_THRESHOLD_READONLY "nsslapd-disk-monitoring-readonly-on-threshold" #define CONFIG_DISK_THRESHOLD "nsslapd-disk-monitoring-threshold" #define CONFIG_DISK_GRACE_PERIOD "nsslapd-disk-monitoring-grace-period" #define CONFIG_DISK_LOGGING_CRITICAL "nsslapd-disk-monitoring-logging-critical" @@ -2523,6 +2524,7 @@ typedef struct _slapdFrontendConfig /* disk monitoring */ slapi_onoff_t disk_monitoring; + slapi_onoff_t disk_threshold_readonly; uint64_t disk_threshold; int disk_grace_period; slapi_onoff_t disk_logging_critical;