Skip to content

feature: Add an option to set the interval of email notification instead of once daily, however, send the email notification everyday if the certificate expiry date is passed - #139

Merged
xmacan merged 5 commits into
Cacti:mainfrom
MSS970:main
Nov 7, 2026

Conversation

@MSS970

@MSS970 MSS970 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

feature: Add an option to set the interval of email notification instead of once daily, however, send the email notification everyday if the certificate expiry date is passed

setup.php

	'servcheck_certificate_expiry_email_interval' => [
		'friendly_name' => __('Certificate expiry notification email interval', 'servcheck'),
		'description'   => __('If SSL/TLS service certificate expiration is enabled, set how the interval (days) for the email notification to be sent, however, if the expiry date is passed, the email notification will be sent everyday', 'servcheck'),
		'method'        => 'drop_array',
		'default'       => 10,
		'array'         => [
			'1'  => __('1 day', 'servcheck'),
			'3'  => __('3 days', 'servcheck'),
			'5'  => __('5 days', 'servcheck'),
			'7'  => __('7 days', 'servcheck'),
			'10' => __('10 days', 'servcheck'),
			'20' => __('20 days', 'servcheck'),
			'30' => __('30 days', 'servcheck'),
		]
	],

servcheck_process.php

// checks only if test passed or some search string exists
if ($results['result_search'] != 'not tested' && $results['result'] == 'ok') {
	// modified by MSS on 2026-11-04
	//if ($last_log['result_search'] != $results['result_search']) {
	if ($last_log['result_search'] != $results['result_search'] && ($results['result_search'] == 'failed ok' || $results['result_search'] == 'not ok') ) {
		servcheck_debug('Search result changed, notification will be send');
		$test['notify_search'] = true;
	}
}

// check certificate expiry
// Modified by MSS on 2026-11-04
//if ($test['certexpirenotify'] && $cert_expiry_days > 0 && $test['days_left'] < $cert_expiry_days && $results['result'] == 'ok') {
if ($test['certexpirenotify'] && $cert_expiry_days > 0 && $test['days_left'] <= $cert_expiry_days && $results['result'] == 'ok') {
	// modified by MSS on 2026-11-04
	// notify once per $cert_expiry_interval_days
	if ($test['days_left'] > 0) {
		/* added by MSS on 2026-11-04 */
		$cert_expiry_interval_days = read_config_option('servcheck_certificate_expiry_email_interval');
	}
	// nofify once per day
	else {
		$cert_expiry_interval_days = 1;
	}
	$new_notify = db_fetch_cell_prepared('SELECT UNIX_TIMESTAMP(DATE_ADD(last_exp_notify, INTERVAL ' . $cert_expiry_interval_days . ' DAY)) FROM plugin_servcheck_test WHERE id = ?', [$test['id']]);

Added new features for email notification intervals and test status display, improved security on confirmation pages, and enhanced development practices for CI coverage and status legend.
Update CHANGELOG with new features and improvements
Added configuration for certificate expiry notification email interval.
Updated conditions for search result notifications and certificate expiry notifications.
@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
57.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@xmacan

xmacan commented Nov 6, 2026

Copy link
Copy Markdown
Member

Thank you @MSS970

@MSS970

MSS970 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Hi @xmacan,
I hope you are well.
The above change is still not reflected in the published version.
Can you please expedite.

@xmacan
xmacan merged commit 8afa17a into Cacti:main Nov 7, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants