* Added plugins: check_*_uptim, check_linux_fetchmail_status, check_linux_dovecot_status
* Fixes for check_*_ntp_status plugins. * Added log check for check_*_postfix plugins.
This commit is contained in:
parent
cc1d9e5c98
commit
1fd486b036
@ -32,12 +32,14 @@ Fileset
|
|||||||
/opt/hc/lib/platform/aix/check_aix_subsystems.sh
|
/opt/hc/lib/platform/aix/check_aix_subsystems.sh
|
||||||
/opt/hc/lib/platform/aix/check_aix_sysbackup.sh
|
/opt/hc/lib/platform/aix/check_aix_sysbackup.sh
|
||||||
/opt/hc/lib/platform/aix/check_aix_topasrec.sh
|
/opt/hc/lib/platform/aix/check_aix_topasrec.sh
|
||||||
|
/opt/hc/lib/platform/aix/check_aix_uptime.sh
|
||||||
/etc/opt/hc
|
/etc/opt/hc
|
||||||
/etc/opt/hc/check_aix_file_age.conf.dist
|
/etc/opt/hc/check_aix_file_age.conf.dist
|
||||||
/etc/opt/hc/check_aix_file_change.conf.dist
|
/etc/opt/hc/check_aix_file_change.conf.dist
|
||||||
/etc/opt/hc/check_aix_root_crontab.conf.dist
|
/etc/opt/hc/check_aix_root_crontab.conf.dist
|
||||||
/etc/opt/hc/check_aix_subsystems.conf.dist
|
/etc/opt/hc/check_aix_subsystems.conf.dist
|
||||||
/etc/opt/hc/check_aix_sysbackup.conf.dist
|
/etc/opt/hc/check_aix_sysbackup.conf.dist
|
||||||
|
/etc/opt/hc/check_aix_uptime.conf.dist
|
||||||
EOROOTFiles
|
EOROOTFiles
|
||||||
Relocatable: N
|
Relocatable: N
|
||||||
EOFileset
|
EOFileset
|
||||||
|
@ -72,7 +72,7 @@ This is the OS/platform plugin package"
|
|||||||
file -m 755 check_hpux_ignite_backup.sh
|
file -m 755 check_hpux_ignite_backup.sh
|
||||||
file -m 755 check_hpux_ioscan.sh
|
file -m 755 check_hpux_ioscan.sh
|
||||||
file -m 755 check_hpux_guid_status.sh
|
file -m 755 check_hpux_guid_status.sh
|
||||||
file -m 644 check_hpux_hpvm_vpar_status.sh
|
file -m 755 check_hpux_hpvm_vpar_status.sh
|
||||||
file -m 755 check_hpux_httpd_status.sh
|
file -m 755 check_hpux_httpd_status.sh
|
||||||
file -m 755 check_hpux_kernel_params.sh
|
file -m 755 check_hpux_kernel_params.sh
|
||||||
file -m 755 check_hpux_kernel_usage.sh
|
file -m 755 check_hpux_kernel_usage.sh
|
||||||
@ -87,6 +87,7 @@ This is the OS/platform plugin package"
|
|||||||
file -m 755 check_hpux_sshd_status.sh
|
file -m 755 check_hpux_sshd_status.sh
|
||||||
file -m 755 check_hpux_syslog.sh
|
file -m 755 check_hpux_syslog.sh
|
||||||
file -m 755 check_hpux_syslogd_status.sh
|
file -m 755 check_hpux_syslogd_status.sh
|
||||||
|
file -m 755 check_hpux_uptime.sh
|
||||||
file -m 755 check_hpux_vg_minor_number.sh
|
file -m 755 check_hpux_vg_minor_number.sh
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -115,11 +116,12 @@ This is the OS/platform plugin package"
|
|||||||
file -m 644 check_hpux_kernel_params.conf.dist
|
file -m 644 check_hpux_kernel_params.conf.dist
|
||||||
file -m 644 check_hpux_kernel_usage.conf.dist
|
file -m 644 check_hpux_kernel_usage.conf.dist
|
||||||
file -m 644 check_hpux_ntp_status.conf.dist
|
file -m 644 check_hpux_ntp_status.conf.dist
|
||||||
file -m 755 check_hpux_ovpa_status.conf.dist
|
file -m 644 check_hpux_ovpa_status.conf.dist
|
||||||
file -m 755 check_hpux_patch_version.conf.dist
|
file -m 644 check_hpux_patch_version.conf.dist
|
||||||
file -m 644 check_hpux_root_crontab.conf.dist
|
file -m 644 check_hpux_root_crontab.conf.dist
|
||||||
file -m 644 check_hpux_sfm_status.conf.dist
|
file -m 644 check_hpux_sfm_status.conf.dist
|
||||||
file -m 644 check_hpux_syslog.conf.dist
|
file -m 644 check_hpux_syslog.conf.dist
|
||||||
|
file -m 644 check_hpux_uptime.conf.dist
|
||||||
end
|
end
|
||||||
|
|
||||||
fileset
|
fileset
|
||||||
|
@ -22,8 +22,10 @@ package() {
|
|||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_autofs.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_autofs.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_autofs.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_autofs.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_burp_backup.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_burp_backup.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_burp_backup.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_burp_backup.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_burp_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_burp_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
||||||
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_dovecot_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_dovecot_status.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_es_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_es_status.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_es_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_es_status.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh
|
||||||
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_file_age.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_file_age.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_file_age.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_file_age.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_file_change.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_file_change.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_file_change.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_file_change.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_fs_mounts.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_fs_mounts.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
||||||
@ -43,6 +45,7 @@ package() {
|
|||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_hpssacli.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_hpssacli.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_process_limits.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_process_limits.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_root_crontab.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_root_crontab.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
||||||
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_uptime.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_uptime.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
||||||
install -d -m 755 ${pkgdir}/etc/opt/hc
|
install -d -m 755 ${pkgdir}/etc/opt/hc
|
||||||
@ -50,6 +53,7 @@ package() {
|
|||||||
install -D -m 644 etc/opt/hc/check_linux_burp_backup.conf.dist ${pkgdir}/etc/opt/hc/check_linux_burp_backup.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_burp_backup.conf.dist ${pkgdir}/etc/opt/hc/check_linux_burp_backup.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_es_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_es_status.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_es_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_es_status.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_fail2ban_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_fail2ban_status.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_fail2ban_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_fail2ban_status.conf.dist
|
||||||
|
install -D -m 644 etc/opt/hc/check_linux_fetchmail_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_fetchmail_status.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_file_age.conf.dist ${pkgdir}/etc/opt/hc/check_linux_file_age.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_file_age.conf.dist ${pkgdir}/etc/opt/hc/check_linux_file_age.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_file_change.conf.dist ${pkgdir}/etc/opt/hc/check_linux_file_change.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_file_change.conf.dist ${pkgdir}/etc/opt/hc/check_linux_file_change.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_fs_usage.conf.dist ${pkgdir}/etc/opt/hc/check_linux_fs_usage.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_fs_usage.conf.dist ${pkgdir}/etc/opt/hc/check_linux_fs_usage.conf.dist
|
||||||
@ -62,6 +66,7 @@ package() {
|
|||||||
install -D -m 644 etc/opt/hc/check_linux_ntp_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_ntp_status.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_ntp_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_ntp_status.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_process_limits.conf.dist ${pkgdir}/etc/opt/hc/check_linux_process_limits.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_process_limits.conf.dist ${pkgdir}/etc/opt/hc/check_linux_process_limits.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_root_crontab.conf.dist ${pkgdir}/etc/opt/hc/check_linux_root_crontab.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_root_crontab.conf.dist ${pkgdir}/etc/opt/hc/check_linux_root_crontab.conf.dist
|
||||||
|
install -D -m 644 etc/opt/hc/check_linux_uptime.conf.dist ${pkgdir}/etc/opt/hc/check_linux_uptime.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_vz_ct_counters.conf.dist ${pkgdir}/etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_vz_ct_counters.conf.dist ${pkgdir}/etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_vz_ct_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_vz_ct_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
||||||
install -d -m 755 ${pkgdir}/etc/opt/hc/core
|
install -d -m 755 ${pkgdir}/etc/opt/hc/core
|
||||||
|
@ -30,8 +30,10 @@ install -d -m 755 $RPM_BUILD_ROOT/opt/hc/lib/platform/linux
|
|||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_autofs.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_autofs.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_autofs.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_autofs.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_burp_backup.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_burp_backup.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_burp_backup.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_burp_backup.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_burp_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_burp_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
||||||
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_dovecot_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_dovecot_status.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_es_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_es_status.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_es_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_es_status.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh
|
||||||
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_file_age.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_file_age.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_file_age.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_file_age.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_file_change.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_file_change.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_file_change.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_file_change.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
||||||
@ -51,6 +53,7 @@ cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_hplog.sh $RPM_BUILD_ROOT/opt
|
|||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_hpssacli.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_hpssacli.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_process_limits.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_process_limits.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_root_crontab.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_root_crontab.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
||||||
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_uptime.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_uptime.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc
|
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc
|
||||||
@ -58,6 +61,7 @@ cp ../SOURCES/etc/opt/hc/check_linux_autofs.conf.dist $RPM_BUILD_ROOT/etc/opt/hc
|
|||||||
cp ../SOURCES/etc/opt/hc/check_linux_burp_backup.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_burp_backup.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_burp_backup.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_burp_backup.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_es_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_es_status.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_es_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_es_status.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_fail2ban_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_fail2ban_status.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_fail2ban_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_fail2ban_status.conf.dist
|
||||||
|
cp ../SOURCES/etc/opt/hc/check_linux_fetchmail_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_fetchmail_status.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_file_age.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_file_age.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_file_age.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_file_age.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_file_change.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_file_change.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_file_change.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_file_change.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_fs_usage.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_fs_usage.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_fs_usage.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_fs_usage.conf.dist
|
||||||
@ -70,6 +74,7 @@ cp ../SOURCES/etc/opt/hc/check_linux_mysqld_status.conf.dist $RPM_BUILD_ROOT/etc
|
|||||||
cp ../SOURCES/etc/opt/hc/check_linux_ntp_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_ntp_status.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_ntp_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_ntp_status.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_process_limits.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_process_limits.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_process_limits.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_process_limits.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_root_crontab.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_root_crontab.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_root_crontab.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_root_crontab.conf.dist
|
||||||
|
cp ../SOURCES/etc/opt/hc/check_linux_uptime.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_uptime.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_vz_ct_counters.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_vz_ct_counters.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_vz_ct_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_vz_ct_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc/core
|
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc/core
|
||||||
@ -115,8 +120,10 @@ echo "INFO: finished post-uninstall script"
|
|||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_autofs.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_autofs.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_burp_backup.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_burp_backup.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
||||||
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_dovecot_status.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_es_status.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_es_status.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh
|
||||||
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_file_age.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_file_age.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_file_change.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_file_change.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
||||||
@ -136,6 +143,7 @@ echo "INFO: finished post-uninstall script"
|
|||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
||||||
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_uptime.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
||||||
%dir /etc/opt/hc
|
%dir /etc/opt/hc
|
||||||
@ -143,6 +151,7 @@ echo "INFO: finished post-uninstall script"
|
|||||||
%attr(644, root, root) /etc/opt/hc/check_linux_burp_backup.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_burp_backup.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_es_status.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_es_status.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_fail2ban_status.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_fail2ban_status.conf.dist
|
||||||
|
%attr(644, root, root) /etc/opt/hc/check_linux_fetchmail_status.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_file_age.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_file_age.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_file_change.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_file_change.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_fs_usage.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_fs_usage.conf.dist
|
||||||
@ -155,6 +164,7 @@ echo "INFO: finished post-uninstall script"
|
|||||||
%attr(644, root, root) /etc/opt/hc/check_linux_ntp_status.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_ntp_status.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_process_limits.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_process_limits.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_root_crontab.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_root_crontab.conf.dist
|
||||||
|
%attr(644, root, root) /etc/opt/hc/check_linux_uptime.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
||||||
%dir /etc/opt/hc/core
|
%dir /etc/opt/hc/core
|
||||||
@ -163,6 +173,11 @@ echo "INFO: finished post-uninstall script"
|
|||||||
%attr(644, root, root) /etc/opt/hc/core/templates/mail_body.tpl-check_linux_root_crontab
|
%attr(644, root, root) /etc/opt/hc/core/templates/mail_body.tpl-check_linux_root_crontab
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat Dec 26 2020 <patrick@kudos.be> - 0.3.5
|
||||||
|
- Added check_linux_fetchmail_status plugin
|
||||||
|
- Added check_linux_dovecot_status plugin
|
||||||
|
* Mon Dec 21 2020 <patrick@kudos.be> - 0.3.4
|
||||||
|
- Added check_linux_uptime plugin
|
||||||
* Fri Oct 18 2020 <patrick@kudos.be> - 0.3.3
|
* Fri Oct 18 2020 <patrick@kudos.be> - 0.3.3
|
||||||
- Added check_linux_fail2ban_status plugin
|
- Added check_linux_fail2ban_status plugin
|
||||||
* Fri Nov 1 2019 <patrick@kudos.be> - 0.3.2
|
* Fri Nov 1 2019 <patrick@kudos.be> - 0.3.2
|
||||||
|
41
etc/opt/hc/check_aix_uptime.conf.dist
Normal file
41
etc/opt/hc/check_aix_uptime.conf.dist
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#******************************************************************************
|
||||||
|
# @(#) check_aix_uptime.conf
|
||||||
|
#******************************************************************************
|
||||||
|
# This is a configuration file for the check_aix_uptime HC plugin.
|
||||||
|
# All lines starting with a '#' are comment lines.
|
||||||
|
# [default: indicates hardcoded script values if no value is defined here]
|
||||||
|
#******************************************************************************
|
||||||
|
|
||||||
|
# specify whether to also log passed health checks
|
||||||
|
# (warning: this may rapidly grow the HC log)
|
||||||
|
# [default: no]
|
||||||
|
log_healthy="no"
|
||||||
|
|
||||||
|
# trigger event when current uptime is less than previously record uptime?
|
||||||
|
# [default: yes]
|
||||||
|
check_reboot="yes"
|
||||||
|
|
||||||
|
# time to wait before the current uptime is considered for the reboot check.
|
||||||
|
# Example: a value of 60m means the check for a previous reboot will be at earliest
|
||||||
|
# performed 1 hour after the last reboot of the host.
|
||||||
|
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
||||||
|
# if no suffix is specified, then minutes are assumed.
|
||||||
|
# [default: 60m]
|
||||||
|
reboot_time="60m"
|
||||||
|
|
||||||
|
# trigger event when current uptime goes over the maximum threshold?
|
||||||
|
# [default: no]
|
||||||
|
check_old_age="no"
|
||||||
|
|
||||||
|
# time to expire before the current uptime is considered "old age".
|
||||||
|
# Example: a value of 365d means a must-reboot will be flagged at earliest after
|
||||||
|
# 1 year of uptime of the host
|
||||||
|
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
||||||
|
# if no suffix is specified, then minutes are assumed.
|
||||||
|
# [default: 365d]
|
||||||
|
old_age_time="365d"
|
||||||
|
|
||||||
|
|
||||||
|
#******************************************************************************
|
||||||
|
# End of FILE
|
||||||
|
#******************************************************************************
|
41
etc/opt/hc/check_hpux_uptime.conf.dist
Normal file
41
etc/opt/hc/check_hpux_uptime.conf.dist
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#******************************************************************************
|
||||||
|
# @(#) check_hpux_uptime.conf
|
||||||
|
#******************************************************************************
|
||||||
|
# This is a configuration file for the check_hpux_uptime HC plugin.
|
||||||
|
# All lines starting with a '#' are comment lines.
|
||||||
|
# [default: indicates hardcoded script values if no value is defined here]
|
||||||
|
#******************************************************************************
|
||||||
|
|
||||||
|
# specify whether to also log passed health checks
|
||||||
|
# (warning: this may rapidly grow the HC log)
|
||||||
|
# [default: no]
|
||||||
|
log_healthy="no"
|
||||||
|
|
||||||
|
# trigger event when current uptime is less than previously record uptime?
|
||||||
|
# [default: yes]
|
||||||
|
check_reboot="yes"
|
||||||
|
|
||||||
|
# time to wait before the current uptime is considered for the reboot check.
|
||||||
|
# Example: a value of 60m means the check for a previous reboot will be at earliest
|
||||||
|
# performed 1 hour after the last reboot of the host.
|
||||||
|
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
||||||
|
# if no suffix is specified, then minutes are assumed.
|
||||||
|
# [default: 60m]
|
||||||
|
reboot_time="60m"
|
||||||
|
|
||||||
|
# trigger event when current uptime goes over the maximum threshold?
|
||||||
|
# [default: no]
|
||||||
|
check_old_age="no"
|
||||||
|
|
||||||
|
# time to expire before the current uptime is considered "old age".
|
||||||
|
# Example: a value of 365d means a must-reboot will be flagged at earliest after
|
||||||
|
# 1 year of uptime of the host
|
||||||
|
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
||||||
|
# if no suffix is specified, then minutes are assumed.
|
||||||
|
# [default: 365d]
|
||||||
|
old_age_time="365d"
|
||||||
|
|
||||||
|
|
||||||
|
#******************************************************************************
|
||||||
|
# End of FILE
|
||||||
|
#******************************************************************************
|
28
etc/opt/hc/check_linux_fetchmail_status.conf.dist
Normal file
28
etc/opt/hc/check_linux_fetchmail_status.conf.dist
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#******************************************************************************
|
||||||
|
# @(#) check_linux_fetchmail_status.conf
|
||||||
|
#******************************************************************************
|
||||||
|
# This is a configuration file for the check_linux_fetchmail_status HC plugin.
|
||||||
|
# All lines starting with a '#' are comment lines.
|
||||||
|
# [default: indicates hardcoded script values if no value is defined here]
|
||||||
|
#******************************************************************************
|
||||||
|
|
||||||
|
# specify whether to also log passed health checks
|
||||||
|
# (warning: this may rapidly grow the HC log)
|
||||||
|
# [default: no]
|
||||||
|
log_healthy="no"
|
||||||
|
|
||||||
|
# specify the regex of error codes that will be used to search the log file_path
|
||||||
|
# [default: error|authfail|lockbusy|ioerr]
|
||||||
|
error_regex="error|authfail|lockbusy|ioerr"
|
||||||
|
|
||||||
|
# specify fetchmail details
|
||||||
|
# Format:
|
||||||
|
# fetchmail:<account>:<rc_file>:<check_log=Yes|No>
|
||||||
|
# Examples:
|
||||||
|
#fetchmail:vmail:/srv/vmail/janedoe/.fetchmailrc:Yes
|
||||||
|
#fetchmail:vmail:/srv/vmail/johndoe/.fetchmailrc:No
|
||||||
|
|
||||||
|
|
||||||
|
#******************************************************************************
|
||||||
|
# End of FILE
|
||||||
|
#******************************************************************************
|
41
etc/opt/hc/check_linux_uptime.conf.dist
Normal file
41
etc/opt/hc/check_linux_uptime.conf.dist
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#******************************************************************************
|
||||||
|
# @(#) check_linux_uptime.conf
|
||||||
|
#******************************************************************************
|
||||||
|
# This is a configuration file for the check_linux_uptime HC plugin.
|
||||||
|
# All lines starting with a '#' are comment lines.
|
||||||
|
# [default: indicates hardcoded script values if no value is defined here]
|
||||||
|
#******************************************************************************
|
||||||
|
|
||||||
|
# specify whether to also log passed health checks
|
||||||
|
# (warning: this may rapidly grow the HC log)
|
||||||
|
# [default: no]
|
||||||
|
log_healthy="no"
|
||||||
|
|
||||||
|
# trigger event when current uptime is less than previously record uptime?
|
||||||
|
# [default: yes]
|
||||||
|
check_reboot="yes"
|
||||||
|
|
||||||
|
# time to wait before the current uptime is considered for the reboot check.
|
||||||
|
# Example: a value of 60m means the check for a previous reboot will be at earliest
|
||||||
|
# performed 1 hour after the last reboot of the host.
|
||||||
|
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
||||||
|
# if no suffix is specified, then minutes are assumed.
|
||||||
|
# [default: 60m]
|
||||||
|
reboot_time="60m"
|
||||||
|
|
||||||
|
# trigger event when current uptime goes over the maximum threshold?
|
||||||
|
# [default: no]
|
||||||
|
check_old_age="no"
|
||||||
|
|
||||||
|
# time to expire before the current uptime is considered "old age".
|
||||||
|
# Example: a value of 365d means a must-reboot will be flagged at earliest after
|
||||||
|
# 1 year of uptime of the host
|
||||||
|
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
||||||
|
# if no suffix is specified, then minutes are assumed.
|
||||||
|
# [default: 365d]
|
||||||
|
old_age_time="365d"
|
||||||
|
|
||||||
|
|
||||||
|
#******************************************************************************
|
||||||
|
# End of FILE
|
||||||
|
#******************************************************************************
|
@ -937,6 +937,7 @@ print ${_EPOCH}
|
|||||||
# REQUIRES: n/a
|
# REQUIRES: n/a
|
||||||
function data_epoch2date
|
function data_epoch2date
|
||||||
{
|
{
|
||||||
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
typeset _UNIX_EPOCH="${1}"
|
typeset _UNIX_EPOCH="${1}"
|
||||||
typeset _CONVERT_DATE=""
|
typeset _CONVERT_DATE=""
|
||||||
|
|
||||||
@ -962,6 +963,155 @@ fi
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# @(#) FUNCTION: data_timestring_to_days()
|
||||||
|
# DOES: converts a specific timestring to days (rounded to integer)
|
||||||
|
# EXPECTS: time definition with a single s|m|h|d suffix [string]
|
||||||
|
# OUTPUTS: time value in hours [string]
|
||||||
|
# RETURNS: 0=conversion OK; 1=conversion failed
|
||||||
|
# REQUIRES: n/a
|
||||||
|
function data_timestring_to_days
|
||||||
|
{
|
||||||
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
|
typeset _DAYS=""
|
||||||
|
|
||||||
|
case "${1}" in
|
||||||
|
*s|*s)
|
||||||
|
_DAYS=$(( $(print "${1%*[sS]}") / 60 / 60 / 24 ))
|
||||||
|
;;
|
||||||
|
*m|*M)
|
||||||
|
_DAYS=$(( $(print "${1%*[mM]}") / 60 / 24 ))
|
||||||
|
;;
|
||||||
|
*h|*H)
|
||||||
|
_DAYS=$(( $(print "${1%*[hH]}") / 24 ))
|
||||||
|
;;
|
||||||
|
*d|*D)
|
||||||
|
_DAYS=$(print "${1%*[dD]}")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# invalid suffix specified
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "invalid time suffix specified (only s[econds]|m[inutes]|h[ours]|d[days] allowed)"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
print "${_HOURS}"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# @(#) FUNCTION: data_timestring_to_hours()
|
||||||
|
# DOES: converts a specific timestring to hours (rounded to integer)
|
||||||
|
# EXPECTS: time definition with a single s|m|h|d suffix [string]
|
||||||
|
# OUTPUTS: time value in hours [string]
|
||||||
|
# RETURNS: 0=conversion OK; 1=conversion failed
|
||||||
|
# REQUIRES: n/a
|
||||||
|
function data_timestring_to_hours
|
||||||
|
{
|
||||||
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
|
typeset _HOURS=""
|
||||||
|
|
||||||
|
case "${1}" in
|
||||||
|
*s|*s)
|
||||||
|
_HOURS=$(( $(print "${1%*[sS]}") / 60 / 24 ))
|
||||||
|
;;
|
||||||
|
*m|*M)
|
||||||
|
_HOURS=$(( $(print "${1%*[mM]}") / 60 ))
|
||||||
|
;;
|
||||||
|
*h|*H)
|
||||||
|
_HOURS=$(print "${1%*[hH]}")
|
||||||
|
;;
|
||||||
|
*d|*D)
|
||||||
|
_HOURS=$(( $(print "${1%*[dD]}") * 24 ))
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# invalid suffix specified
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "invalid time suffix specified (only s[econds]|m[inutes]|h[ours]|d[days] allowed)"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
print "${_HOURS}"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# @(#) FUNCTION: data_timestring_to_mins()
|
||||||
|
# DOES: converts a specific timestring to minutes (rounded to integer)
|
||||||
|
# EXPECTS: time definition with a single s|m|h|d suffix [string]
|
||||||
|
# OUTPUTS: time value in minutes [string]
|
||||||
|
# RETURNS: 0=conversion OK; 1=conversion failed
|
||||||
|
# REQUIRES: n/a
|
||||||
|
function data_timestring_to_mins
|
||||||
|
{
|
||||||
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
|
typeset _MINUTES=""
|
||||||
|
|
||||||
|
case "${1}" in
|
||||||
|
*s|*s)
|
||||||
|
_MINUTES=$(( $(print "${1%*[sS]}") / 60 ))
|
||||||
|
;;
|
||||||
|
*m|*M)
|
||||||
|
_MINUTES=$(print "${1%*[mM]}")
|
||||||
|
;;
|
||||||
|
*h|*H)
|
||||||
|
_MINUTES=$(( $(print "${1%*[hH]}") * 60 ))
|
||||||
|
;;
|
||||||
|
*d|*D)
|
||||||
|
_MINUTES=$(( $(print "${1%*[dD]}") * 60 * 24 ))
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# invalid suffix specified
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "invalid time suffix specified (only s[econds]|m[inutes]|h[ours]|d[days] allowed)"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
print "${_MINUTES}"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# @(#) FUNCTION: data_timestring_to_secs()
|
||||||
|
# DOES: converts a specific timestring to seconds (rounded to integer)
|
||||||
|
# EXPECTS: time definition with a single m|h|d suffix [string]
|
||||||
|
# OUTPUTS: time value in seconds [string]
|
||||||
|
# RETURNS: 0=conversion OK; 1=conversion failed
|
||||||
|
# REQUIRES: n/a
|
||||||
|
function data_timestring_to_secs
|
||||||
|
{
|
||||||
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
|
typeset _SECONDS=""
|
||||||
|
|
||||||
|
case "${1}" in
|
||||||
|
*s|*s)
|
||||||
|
_SECONDS=$(print "${1%*[sS]}")
|
||||||
|
;;
|
||||||
|
*m|*M)
|
||||||
|
_SECONDS=$(( $(print "${1%*[Mm]}") * 60 ))
|
||||||
|
;;
|
||||||
|
*h|*H)
|
||||||
|
_SECONDS=$(( $(print "${1%*[hH]}") * 60 * 60 ))
|
||||||
|
;;
|
||||||
|
*d|*D)
|
||||||
|
_SECONDS=$(( $(print "${1%*[dD]}") * 60 * 60 * 24 ))
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# invalid suffix specified
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "invalid time suffix specified (only s[econds]|m[inutes]|h[ours]|d[days] allowed)"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
print "${_SECONDS}"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# END of script
|
# END of script
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
|
349
opt/hc/lib/platform/aix/check_aix_uptime.sh
Normal file
349
opt/hc/lib/platform/aix/check_aix_uptime.sh
Normal file
@ -0,0 +1,349 @@
|
|||||||
|
#!/usr/bin/env ksh
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# @(#) check_aix_uptime
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# @(#) Copyright (C) 2020 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is a free software; you can redistribute it and/or modify
|
||||||
|
# it under the same terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# DOCUMENTATION (MAIN)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# @(#) MAIN: check_aix_uptime
|
||||||
|
# DOES: see _show_usage()
|
||||||
|
# EXPECTS: see _show_usage()
|
||||||
|
# REQUIRES: data_is_numeric(), data_timestring_to_mins(), data_comma2space(),
|
||||||
|
# init_hc(), log_hc(), warn()
|
||||||
|
#
|
||||||
|
# @(#) HISTORY:
|
||||||
|
# @(#) 2020-12-21: initial version [Patrick Van der Veken]
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function check_aix_uptime
|
||||||
|
{
|
||||||
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
|
typeset _STATE_FILE="${STATE_PERM_DIR}/current.uptime"
|
||||||
|
typeset _VERSION="2020-12-21" # YYYY-MM-DD
|
||||||
|
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
|
||||||
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
|
# set defaults
|
||||||
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
|
typeset _ARG=""
|
||||||
|
typeset _MSG=""
|
||||||
|
typeset _STC=0
|
||||||
|
typeset _LOG_HEALTHY=0
|
||||||
|
typeset _CFG_HEALTHY=""
|
||||||
|
typeset _CFG_CHECK_REBOOT=""
|
||||||
|
typeset _CFG_REBOOT_TIME=""
|
||||||
|
typeset _CFG_CHECK_OLD_AGE=""
|
||||||
|
typeset _CFG_OLD_AGE_TIME=""
|
||||||
|
typeset _CHECK_REBOOT=""
|
||||||
|
typeset _REBOOT_TIME=""
|
||||||
|
typeset _REBOOT_TIME_MINS=""
|
||||||
|
typeset _CHECK_OLD_AGE=""
|
||||||
|
typeset _OLD_AGE_TIME=""
|
||||||
|
typeset _OLD_AGE_TIME_MINS=""
|
||||||
|
typeset _CURRENT_UPTIME=""
|
||||||
|
typeset _CURRENT_UPTIME_MINS=""
|
||||||
|
typeset _INIT_TIME=""
|
||||||
|
typeset _PREVIOUS_UPTIME=""
|
||||||
|
typeset _PREVIOUS_UPTIME_MINS=""
|
||||||
|
typeset _THRESHOLD_UPTIME_MINS=""
|
||||||
|
|
||||||
|
# handle arguments (originally comma-separated)
|
||||||
|
for _ARG in ${_ARGS}
|
||||||
|
do
|
||||||
|
case "${_ARG}" in
|
||||||
|
help)
|
||||||
|
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# handle config file
|
||||||
|
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
|
||||||
|
if [[ ! -r ${_CONFIG_FILE} ]]
|
||||||
|
then
|
||||||
|
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# read required config values
|
||||||
|
_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy')
|
||||||
|
case "${_CFG_HEALTHY}" in
|
||||||
|
yes|YES|Yes)
|
||||||
|
_LOG_HEALTHY=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# do not override hc_arg
|
||||||
|
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_CFG_CHECK_REBOOT=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_reboot')
|
||||||
|
case "${_CFG_CHECK_REBOOT}" in
|
||||||
|
no|No|NO)
|
||||||
|
_CHECK_REBOOT=0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_CHECK_REBOOT=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_CFG_REBOOT_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'reboot_time')
|
||||||
|
if [[ -z "${_CFG_REBOOT_TIME}" ]]
|
||||||
|
then
|
||||||
|
# default
|
||||||
|
_REBOOT_TIME="60m"
|
||||||
|
else
|
||||||
|
_REBOOT_TIME="${_CFG_REBOOT_TIME}"
|
||||||
|
fi
|
||||||
|
_CFG_CHECK_OLD_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_old_age')
|
||||||
|
case "${_CFG_CHECK_OLD_AGE}" in
|
||||||
|
yes|Yes|Yes)
|
||||||
|
_CHECK_OLD_AGE=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_CHECK_OLD_AGE=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_CFG_OLD_AGE_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'old_age_time')
|
||||||
|
if [[ -z "${_CFG_OLD_AGE_TIME}" ]]
|
||||||
|
then
|
||||||
|
# default
|
||||||
|
_OLD_AGE_TIME="365d"
|
||||||
|
else
|
||||||
|
_OLD_AGE_TIME="${_CFG_OLD_AGE_TIME}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# log_healthy
|
||||||
|
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||||
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
|
then
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
log "logging/showing passed health checks"
|
||||||
|
else
|
||||||
|
log "showing passed health checks (but not logging)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "not logging/showing passed health checks"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# read uptime from init process
|
||||||
|
# shellcheck disable=SC1007
|
||||||
|
_INIT_TIME=$(UNIX95= ps -p 1 -o etime 2>/dev/null | tail -1)
|
||||||
|
if [[ -n "${_INIT_TIME}" ]]
|
||||||
|
then
|
||||||
|
# calculate exact uptime (seconds)
|
||||||
|
_CURRENT_UPTIME=$(print "${_INIT_TIME}" |\
|
||||||
|
awk '
|
||||||
|
BEGIN { days = 0; hours = 0; mins = 0; seconds = 0 };
|
||||||
|
{
|
||||||
|
gsub(/[ \t]/, "");
|
||||||
|
# get days
|
||||||
|
split ($0, day_str, "-");
|
||||||
|
if (2 in day_str) {
|
||||||
|
# string has days
|
||||||
|
days = day_str[1];
|
||||||
|
split (day_str[2], hour_str, ":");
|
||||||
|
} else {
|
||||||
|
split (day_str[1], hour_str, ":");
|
||||||
|
}
|
||||||
|
# get hours/minutes/seconds
|
||||||
|
hours = hour_str[1];
|
||||||
|
mins = hour_str[2];
|
||||||
|
if (3 in hour_str) {
|
||||||
|
# string has seconds
|
||||||
|
secs = hour_str[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
time = (days * 24 * 60 * 60) + (hours * 60 * 60) + (mins * 60) + secs;
|
||||||
|
print time;
|
||||||
|
}' 2>/dev/null)
|
||||||
|
data_is_numeric "${_CURRENT_UPTIME}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate uptime value (seconds)"
|
||||||
|
(( ARG_DEBUG )) && debug "_CURRENT_UPTIME=${_CURRENT_UPTIME}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "uptime of INIT (1) process cannot be determined"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# read state file
|
||||||
|
if [[ -r ${_STATE_FILE} ]]
|
||||||
|
then
|
||||||
|
_PREVIOUS_UPTIME=$(<"${_STATE_FILE}")
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "failed to read state file at ${_STATE_FILE}"
|
||||||
|
_PREVIOUS_UPTIME=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# convert uptimes values
|
||||||
|
_CURRENT_UPTIME_MINS=$(( _CURRENT_UPTIME / 60 ))
|
||||||
|
data_is_numeric "${_CURRENT_UPTIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate current uptime value (minutes)"
|
||||||
|
(( ARG_DEBUG )) && debug "_CURRENT_UPTIME_MINS=${_CURRENT_UPTIME_MINS}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_PREVIOUS_UPTIME_MINS=$(( _PREVIOUS_UPTIME / 60 ))
|
||||||
|
data_is_numeric "${_CURRENT_UPTIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate previous uptime value (minutes)"
|
||||||
|
(( ARG_DEBUG )) && debug "_PREVIOUS_UPTIME_MINS=${_PREVIOUS_UPTIME_MINS}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# check reboot event
|
||||||
|
if (( _CHECK_REBOOT > 0 ))
|
||||||
|
then
|
||||||
|
# convert _REBOOT_TIME to minutes
|
||||||
|
_REBOOT_TIME_MINS=$(data_timestring_to_mins "${_REBOOT_TIME}")
|
||||||
|
data_is_numeric "${_REBOOT_TIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate 'reboot_time' value from configuration file ${_CONFIG_FILE}"
|
||||||
|
(( ARG_DEBUG )) && debug "_REBOOT_TIME=${_REBOOT_TIME}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# previous uptime missing?
|
||||||
|
if [[ -z "${_PREVIOUS_UPTIME}" ]]
|
||||||
|
then
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
print "${_CURRENT_UPTIME}" >"${_STATE_FILE}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "failed to update state file at ${_STATE_FILE}"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
log "unable to find previously recorded uptime, resetting to current uptime"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "unable to find previously recorded uptime, resetting to current uptime"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# current uptime + reboot time is smaller than previous uptime?
|
||||||
|
_THRESHOLD_UPTIME_MINS=$(( _CURRENT_UPTIME_MINS + _REBOOT_TIME_MINS ))
|
||||||
|
if (( _THRESHOLD_UPTIME_MINS < _PREVIOUS_UPTIME_MINS ))
|
||||||
|
then
|
||||||
|
_MSG="reboot check: current uptime is NOK; check if reboot occurred"
|
||||||
|
_STC=1
|
||||||
|
else
|
||||||
|
_MSG="reboot check: current uptime is OK"
|
||||||
|
_STC=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}" "${_THRESHOLD_UPTIME_MINS}" "${_PREVIOUS_UPTIME_MINS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# update state file
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
print "${_CURRENT_UPTIME}" >"${_STATE_FILE}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "failed to update state file at ${_STATE_FILE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "reboot check: not enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# check old age event
|
||||||
|
if (( _CHECK_OLD_AGE > 0 ))
|
||||||
|
then
|
||||||
|
# convert _OLD_AGE_TIME to minutes
|
||||||
|
_OLD_AGE_TIME_MINS=$(data_timestring_to_mins "${_OLD_AGE_TIME}")
|
||||||
|
data_is_numeric "${_OLD_AGE_TIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate 'old_age_time' value from configuration file ${_CONFIG_FILE}"
|
||||||
|
(( ARG_DEBUG )) && debug "_OLD_AGE_TIME=${_OLD_AGE_TIME}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# are we old age yet?
|
||||||
|
if (( _CURRENT_UPTIME_MINS > _OLD_AGE_TIME_MINS ))
|
||||||
|
then
|
||||||
|
_MSG="old_age check: current uptime is NOK; old age has arrived (>${_OLD_AGE_TIME})"
|
||||||
|
_STC=1
|
||||||
|
else
|
||||||
|
_MSG="old_age check: current uptime is OK"
|
||||||
|
_STC=0
|
||||||
|
fi
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}" "${_CURRENT_UPTIME_MINS}" "${_OLD_AGE_TIME_MINS}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "old age check: not enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function _show_usage
|
||||||
|
{
|
||||||
|
cat <<- EOT
|
||||||
|
NAME : $1
|
||||||
|
VERSION : $2
|
||||||
|
CONFIG : $3 with:
|
||||||
|
log_healthy=<yes|no>
|
||||||
|
check_reboot=<yes|no>
|
||||||
|
reboot_time=<timestring>
|
||||||
|
check_old_age=<yes|no>
|
||||||
|
old_age_time=<timestring>
|
||||||
|
PURPOSE : Checks for unexpected/unplanned reboot events based on uptime
|
||||||
|
values.
|
||||||
|
Checks whether the host has been up and running for too much time.
|
||||||
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
|
EOT
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# END of script
|
||||||
|
#------------------------------------------------------------------------------
|
@ -30,6 +30,7 @@
|
|||||||
# @(#) with offset calculation [Patrick Van der Veken]
|
# @(#) with offset calculation [Patrick Van der Veken]
|
||||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-09: Text updates [Patrick Van der Veken]
|
# @(#) 2019-03-09: Text updates [Patrick Van der Veken]
|
||||||
|
# @(#) 2020-12-21: fixes for --log-healthy [Patrick Van der Veken]
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
@ -39,14 +40,14 @@ function check_hpux_ntp_status
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
typeset _VERSION="2020-12-21" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
typeset _NTPQ_BIN="/usr/sbin/ntpq"
|
typeset _NTPQ_BIN="/usr/sbin/ntpq"
|
||||||
typeset _NTPQ_OPTS="-pn"
|
typeset _NTPQ_OPTS="-pn"
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
typeset _ARGS=$(data_comma2space "$*")
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
typeset _ARG=""
|
typeset _ARG=""
|
||||||
@ -65,7 +66,7 @@ for _ARG in ${_ARGS}
|
|||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
help)
|
help)
|
||||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -148,7 +149,10 @@ case "${_NTP_PEER}" in
|
|||||||
_MSG="NTP is synchronizing against ${_NTP_PEER##*\*}"
|
_MSG="NTP is synchronizing against ${_NTP_PEER##*\*}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
|
|
||||||
# 2) offset value
|
# 2) offset value
|
||||||
if (( _STC == 0 ))
|
if (( _STC == 0 ))
|
||||||
@ -165,7 +169,10 @@ then
|
|||||||
else
|
else
|
||||||
_MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range"
|
_MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range"
|
||||||
fi
|
fi
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# not numeric
|
# not numeric
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
||||||
|
# @(#) 2020-12-27: add configuration check + quoting fixes [Patrick Van der Veken]
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
@ -34,16 +35,17 @@
|
|||||||
function check_hpux_postfix_status
|
function check_hpux_postfix_status
|
||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
typeset _VERSION="2020-12-27" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
typeset _ARGS=$(data_comma2space "$*")
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
typeset _ARG=""
|
typeset _ARG=""
|
||||||
typeset _POSTFIX_BIN=""
|
typeset _POSTFIX_BIN=""
|
||||||
|
typeset _POSTFIX_CHECKER=""
|
||||||
typeset _MSG=""
|
typeset _MSG=""
|
||||||
typeset _STC=0
|
typeset _STC=0
|
||||||
typeset _LOG_HEALTHY=0
|
typeset _LOG_HEALTHY=0
|
||||||
@ -53,7 +55,7 @@ for _ARG in ${_ARGS}
|
|||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
help)
|
help)
|
||||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -72,10 +74,14 @@ else
|
|||||||
log "not logging/showing passed health checks"
|
log "not logging/showing passed health checks"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# process state
|
||||||
|
|
||||||
_POSTFIX_BIN="$(command -v postfix 2>>${HC_STDERR_LOG})"
|
_POSTFIX_BIN="$(command -v postfix 2>>${HC_STDERR_LOG})"
|
||||||
if [[ -x ${_POSTFIX_BIN} && -n "${_POSTFIX_BIN}" ]]
|
if [[ -x ${_POSTFIX_BIN} && -n "${_POSTFIX_BIN}" ]]
|
||||||
then
|
then
|
||||||
${_POSTFIX_BIN} status >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
${_POSTFIX_BIN} status >>"${HC_STDOUT_LOG}" 2>>"${HC_STDERR_LOG}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if (( $? == 0 ))
|
if (( $? == 0 ))
|
||||||
then
|
then
|
||||||
_MSG="postfix is running"
|
_MSG="postfix is running"
|
||||||
@ -87,13 +93,35 @@ else
|
|||||||
warn "postfix is not installed here"
|
warn "postfix is not installed here"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# report result
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# configuration state
|
||||||
|
_POSTFIX_CHECKER="$(command -v postconf 2>>${HC_STDERR_LOG})"
|
||||||
|
if [[ -x ${_POSTFIX_CHECKER} && -n "${_POSTFIX_CHECKER}" ]]
|
||||||
|
then
|
||||||
|
# dump configuration
|
||||||
|
${_POSTFIX_CHECKER} -n >>"${HC_STDOUT_LOG}" 2>>"${HC_STDERR_LOG}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
_MSG="postfix configuration files have syntax error(s) {${_POSTFIX_CHECKER} -n}"
|
||||||
|
_STC=1
|
||||||
|
else
|
||||||
|
_MSG="postfix configuration files are syntactically correct"
|
||||||
|
_STC=0
|
||||||
|
fi
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "skipping syntax check (unable to find syntax check tool)"
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +131,8 @@ function _show_usage
|
|||||||
cat <<- EOT
|
cat <<- EOT
|
||||||
NAME : $1
|
NAME : $1
|
||||||
VERSION : $2
|
VERSION : $2
|
||||||
PURPOSE : Checks whether postfix (mail system) is running
|
PURPOSE : Checks whether postfix (mail system) is running and whether the
|
||||||
|
postfix configuration files are syntactically correct
|
||||||
LOG HEALTHY : Supported
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
349
opt/hc/lib/platform/hp-ux/check_hpux_uptime.sh
Normal file
349
opt/hc/lib/platform/hp-ux/check_hpux_uptime.sh
Normal file
@ -0,0 +1,349 @@
|
|||||||
|
#!/usr/bin/env ksh
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# @(#) check_hpux_uptime
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# @(#) Copyright (C) 2020 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is a free software; you can redistribute it and/or modify
|
||||||
|
# it under the same terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# DOCUMENTATION (MAIN)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# @(#) MAIN: check_hpux_uptime
|
||||||
|
# DOES: see _show_usage()
|
||||||
|
# EXPECTS: see _show_usage()
|
||||||
|
# REQUIRES: data_is_numeric(), data_timestring_to_mins(), data_comma2space(),
|
||||||
|
# init_hc(), log_hc(), warn()
|
||||||
|
#
|
||||||
|
# @(#) HISTORY:
|
||||||
|
# @(#) 2020-12-21: initial version [Patrick Van der Veken]
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function check_hpux_uptime
|
||||||
|
{
|
||||||
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
|
typeset _STATE_FILE="${STATE_PERM_DIR}/current.uptime"
|
||||||
|
typeset _VERSION="2020-12-21" # YYYY-MM-DD
|
||||||
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
|
# set defaults
|
||||||
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
|
typeset _ARG=""
|
||||||
|
typeset _MSG=""
|
||||||
|
typeset _STC=0
|
||||||
|
typeset _LOG_HEALTHY=0
|
||||||
|
typeset _CFG_HEALTHY=""
|
||||||
|
typeset _CFG_CHECK_REBOOT=""
|
||||||
|
typeset _CFG_REBOOT_TIME=""
|
||||||
|
typeset _CFG_CHECK_OLD_AGE=""
|
||||||
|
typeset _CFG_OLD_AGE_TIME=""
|
||||||
|
typeset _CHECK_REBOOT=""
|
||||||
|
typeset _REBOOT_TIME=""
|
||||||
|
typeset _REBOOT_TIME_MINS=""
|
||||||
|
typeset _CHECK_OLD_AGE=""
|
||||||
|
typeset _OLD_AGE_TIME=""
|
||||||
|
typeset _OLD_AGE_TIME_MINS=""
|
||||||
|
typeset _CURRENT_UPTIME=""
|
||||||
|
typeset _CURRENT_UPTIME_MINS=""
|
||||||
|
typeset _INIT_TIME=""
|
||||||
|
typeset _PREVIOUS_UPTIME=""
|
||||||
|
typeset _PREVIOUS_UPTIME_MINS=""
|
||||||
|
typeset _THRESHOLD_UPTIME_MINS=""
|
||||||
|
|
||||||
|
# handle arguments (originally comma-separated)
|
||||||
|
for _ARG in ${_ARGS}
|
||||||
|
do
|
||||||
|
case "${_ARG}" in
|
||||||
|
help)
|
||||||
|
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# handle config file
|
||||||
|
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
|
||||||
|
if [[ ! -r ${_CONFIG_FILE} ]]
|
||||||
|
then
|
||||||
|
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# read required config values
|
||||||
|
_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy')
|
||||||
|
case "${_CFG_HEALTHY}" in
|
||||||
|
yes|YES|Yes)
|
||||||
|
_LOG_HEALTHY=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# do not override hc_arg
|
||||||
|
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_CFG_CHECK_REBOOT=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_reboot')
|
||||||
|
case "${_CFG_CHECK_REBOOT}" in
|
||||||
|
no|No|NO)
|
||||||
|
_CHECK_REBOOT=0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_CHECK_REBOOT=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_CFG_REBOOT_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'reboot_time')
|
||||||
|
if [[ -z "${_CFG_REBOOT_TIME}" ]]
|
||||||
|
then
|
||||||
|
# default
|
||||||
|
_REBOOT_TIME="60m"
|
||||||
|
else
|
||||||
|
_REBOOT_TIME="${_CFG_REBOOT_TIME}"
|
||||||
|
fi
|
||||||
|
_CFG_CHECK_OLD_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_old_age')
|
||||||
|
case "${_CFG_CHECK_OLD_AGE}" in
|
||||||
|
yes|Yes|Yes)
|
||||||
|
_CHECK_OLD_AGE=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_CHECK_OLD_AGE=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_CFG_OLD_AGE_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'old_age_time')
|
||||||
|
if [[ -z "${_CFG_OLD_AGE_TIME}" ]]
|
||||||
|
then
|
||||||
|
# default
|
||||||
|
_OLD_AGE_TIME="365d"
|
||||||
|
else
|
||||||
|
_OLD_AGE_TIME="${_CFG_OLD_AGE_TIME}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# log_healthy
|
||||||
|
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||||
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
|
then
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
log "logging/showing passed health checks"
|
||||||
|
else
|
||||||
|
log "showing passed health checks (but not logging)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "not logging/showing passed health checks"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# read uptime from init process
|
||||||
|
# shellcheck disable=SC1007
|
||||||
|
_INIT_TIME=$(UNIX95= ps -p 1 -o etime 2>/dev/null | tail -1)
|
||||||
|
if [[ -n "${_INIT_TIME}" ]]
|
||||||
|
then
|
||||||
|
# calculate exact uptime (seconds)
|
||||||
|
_CURRENT_UPTIME=$(print "${_INIT_TIME}" |\
|
||||||
|
awk '
|
||||||
|
BEGIN { days = 0; hours = 0; mins = 0; seconds = 0 };
|
||||||
|
{
|
||||||
|
gsub(/[ \t]/, "");
|
||||||
|
# get days
|
||||||
|
split ($0, day_str, "-");
|
||||||
|
if (2 in day_str) {
|
||||||
|
# string has days
|
||||||
|
days = day_str[1];
|
||||||
|
split (day_str[2], hour_str, ":");
|
||||||
|
} else {
|
||||||
|
split (day_str[1], hour_str, ":");
|
||||||
|
}
|
||||||
|
# get hours/minutes/seconds
|
||||||
|
hours = hour_str[1];
|
||||||
|
mins = hour_str[2];
|
||||||
|
if (3 in hour_str) {
|
||||||
|
# string has seconds
|
||||||
|
secs = hour_str[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
time = (days * 24 * 60 * 60) + (hours * 60 * 60) + (mins * 60) + secs;
|
||||||
|
print time;
|
||||||
|
}' 2>/dev/null)
|
||||||
|
data_is_numeric "${_CURRENT_UPTIME}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate uptime value (seconds)"
|
||||||
|
(( ARG_DEBUG )) && debug "_CURRENT_UPTIME=${_CURRENT_UPTIME}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "uptime of INIT (1) process cannot be determined"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# read state file
|
||||||
|
if [[ -r ${_STATE_FILE} ]]
|
||||||
|
then
|
||||||
|
_PREVIOUS_UPTIME=$(<"${_STATE_FILE}")
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "failed to read state file at ${_STATE_FILE}"
|
||||||
|
_PREVIOUS_UPTIME=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# convert uptimes values
|
||||||
|
_CURRENT_UPTIME_MINS=$(( _CURRENT_UPTIME / 60 ))
|
||||||
|
data_is_numeric "${_CURRENT_UPTIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate current uptime value (minutes)"
|
||||||
|
(( ARG_DEBUG )) && debug "_CURRENT_UPTIME_MINS=${_CURRENT_UPTIME_MINS}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_PREVIOUS_UPTIME_MINS=$(( _PREVIOUS_UPTIME / 60 ))
|
||||||
|
data_is_numeric "${_CURRENT_UPTIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate previous uptime value (minutes)"
|
||||||
|
(( ARG_DEBUG )) && debug "_PREVIOUS_UPTIME_MINS=${_PREVIOUS_UPTIME_MINS}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# check reboot event
|
||||||
|
if (( _CHECK_REBOOT > 0 ))
|
||||||
|
then
|
||||||
|
# convert _REBOOT_TIME to minutes
|
||||||
|
_REBOOT_TIME_MINS=$(data_timestring_to_mins "${_REBOOT_TIME}")
|
||||||
|
data_is_numeric "${_REBOOT_TIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate 'reboot_time' value from configuration file ${_CONFIG_FILE}"
|
||||||
|
(( ARG_DEBUG )) && debug "_REBOOT_TIME=${_REBOOT_TIME}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# previous uptime missing?
|
||||||
|
if [[ -z "${_PREVIOUS_UPTIME}" ]]
|
||||||
|
then
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
print "${_CURRENT_UPTIME}" >"${_STATE_FILE}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "failed to update state file at ${_STATE_FILE}"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
log "unable to find previously recorded uptime, resetting to current uptime"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "unable to find previously recorded uptime, resetting to current uptime"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# current uptime + reboot time is smaller than previous uptime?
|
||||||
|
_THRESHOLD_UPTIME_MINS=$(( _CURRENT_UPTIME_MINS + _REBOOT_TIME_MINS ))
|
||||||
|
if (( _THRESHOLD_UPTIME_MINS < _PREVIOUS_UPTIME_MINS ))
|
||||||
|
then
|
||||||
|
_MSG="reboot check: current uptime is NOK; check if reboot occurred"
|
||||||
|
_STC=1
|
||||||
|
else
|
||||||
|
_MSG="reboot check: current uptime is OK"
|
||||||
|
_STC=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}" "${_THRESHOLD_UPTIME_MINS}" "${_PREVIOUS_UPTIME_MINS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# update state file
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
print "${_CURRENT_UPTIME}" >"${_STATE_FILE}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "failed to update state file at ${_STATE_FILE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "reboot check: not enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# check old age event
|
||||||
|
if (( _CHECK_OLD_AGE > 0 ))
|
||||||
|
then
|
||||||
|
# convert _OLD_AGE_TIME to minutes
|
||||||
|
_OLD_AGE_TIME_MINS=$(data_timestring_to_mins "${_OLD_AGE_TIME}")
|
||||||
|
data_is_numeric "${_OLD_AGE_TIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate 'old_age_time' value from configuration file ${_CONFIG_FILE}"
|
||||||
|
(( ARG_DEBUG )) && debug "_OLD_AGE_TIME=${_OLD_AGE_TIME}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# are we old age yet?
|
||||||
|
if (( _CURRENT_UPTIME_MINS > _OLD_AGE_TIME_MINS ))
|
||||||
|
then
|
||||||
|
_MSG="old_age check: current uptime is NOK; old age has arrived (>${_OLD_AGE_TIME})"
|
||||||
|
_STC=1
|
||||||
|
else
|
||||||
|
_MSG="old_age check: current uptime is OK"
|
||||||
|
_STC=0
|
||||||
|
fi
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}" "${_CURRENT_UPTIME_MINS}" "${_OLD_AGE_TIME_MINS}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "old age check: not enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function _show_usage
|
||||||
|
{
|
||||||
|
cat <<- EOT
|
||||||
|
NAME : $1
|
||||||
|
VERSION : $2
|
||||||
|
CONFIG : $3 with:
|
||||||
|
log_healthy=<yes|no>
|
||||||
|
check_reboot=<yes|no>
|
||||||
|
reboot_time=<timestring>
|
||||||
|
check_old_age=<yes|no>
|
||||||
|
old_age_time=<timestring>
|
||||||
|
PURPOSE : Checks for unexpected/unplanned reboot events based on uptime
|
||||||
|
values.
|
||||||
|
Checks whether the host has been up and running for too much time.
|
||||||
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
|
EOT
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# END of script
|
||||||
|
#------------------------------------------------------------------------------
|
209
opt/hc/lib/platform/linux/check_linux_dovecot_status.sh
Normal file
209
opt/hc/lib/platform/linux/check_linux_dovecot_status.sh
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
#!/usr/bin/env ksh
|
||||||
|
#******************************************************************************
|
||||||
|
# @(#) check_linux_dovecot_status.sh
|
||||||
|
#******************************************************************************
|
||||||
|
# @(#) Copyright (C) 2020 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is a free software; you can redistribute it and/or modify
|
||||||
|
# it under the same terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#******************************************************************************
|
||||||
|
#
|
||||||
|
# DOCUMENTATION (MAIN)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# @(#) MAIN: check_linux_dovecot_status
|
||||||
|
# DOES: see _show_usage()
|
||||||
|
# EXPECTS: n/a
|
||||||
|
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn()
|
||||||
|
#
|
||||||
|
# @(#) HISTORY:
|
||||||
|
# @(#) 2020-12-27: initial version [Patrick Van der Veken]
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
|
#******************************************************************************
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function check_linux_dovecot_status
|
||||||
|
{
|
||||||
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
|
typeset _DOVECOT_INIT_SCRIPT="/etc/init.d/dovecot"
|
||||||
|
typeset _DOVECOT_SYSTEMD_SERVICE="dovecot.service"
|
||||||
|
typeset _VERSION="2020-12-27" # YYYY-MM-DD
|
||||||
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
|
# set defaults
|
||||||
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
|
typeset _ARG=""
|
||||||
|
typeset _DOVECOT_BIN=""
|
||||||
|
typeset _DOVECOT_CHECKER=""
|
||||||
|
typeset _MSG=""
|
||||||
|
typeset _STC=0
|
||||||
|
typeset _LOG_HEALTHY=0
|
||||||
|
typeset _RC=0
|
||||||
|
typeset _CHECK_SYSTEMD_SERVICE=0
|
||||||
|
|
||||||
|
# handle arguments (originally comma-separated)
|
||||||
|
for _ARG in ${_ARGS}
|
||||||
|
do
|
||||||
|
case "${_ARG}" in
|
||||||
|
help)
|
||||||
|
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# log_healthy
|
||||||
|
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||||
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
|
then
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
log "logging/showing passed health checks"
|
||||||
|
else
|
||||||
|
log "showing passed health checks (but not logging)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "not logging/showing passed health checks"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# process state
|
||||||
|
|
||||||
|
# 1) try using the init ways
|
||||||
|
linux_get_init
|
||||||
|
case "${LINUX_INIT}" in
|
||||||
|
'systemd')
|
||||||
|
# Debian8/Ubuntu16 do not correctly report a unit file for dovecot,
|
||||||
|
# do not check for it and instead just query systemd service
|
||||||
|
linux_get_distro
|
||||||
|
if [[ "${LINUX_DISTRO}" = "Debian" ]] && (( ${LINUX_RELEASE%%.*} < 9 ))
|
||||||
|
then
|
||||||
|
_CHECK_SYSTEMD_SERVICE=1
|
||||||
|
elif [[ "${LINUX_DISTRO}" = "Ubuntu" ]] && (( ${LINUX_RELEASE%%.*} < 17 ))
|
||||||
|
then
|
||||||
|
_CHECK_SYSTEMD_SERVICE=1
|
||||||
|
else
|
||||||
|
_CHECK_SYSTEMD_SERVICE=$(linux_has_systemd_service "${_DOVECOT_SYSTEMD_SERVICE}")
|
||||||
|
fi
|
||||||
|
if (( _CHECK_SYSTEMD_SERVICE > 0 ))
|
||||||
|
then
|
||||||
|
systemctl --quiet is-active ${_DOVECOT_SYSTEMD_SERVICE} 2>>"${HC_STDERR_LOG}" || _STC=1
|
||||||
|
else
|
||||||
|
warn "systemd unit file not found {${_DOVECOT_SYSTEMD_SERVICE}}"
|
||||||
|
_RC=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
'upstart')
|
||||||
|
warn "code for upstart managed systems not implemented, NOOP"
|
||||||
|
_RC=1
|
||||||
|
;;
|
||||||
|
'sysv')
|
||||||
|
# check running SysV
|
||||||
|
if [[ -x ${_DOVECOT_INIT_SCRIPT} ]]
|
||||||
|
then
|
||||||
|
if (( $(${_DOVECOT_INIT_SCRIPT} status 2>>"${HC_STDERR_LOG}" | grep -c -i 'is running' 2>/dev/null) == 0 ))
|
||||||
|
then
|
||||||
|
_STC=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "sysv init script not found {${_DOVECOT_INIT_SCRIPT}}"
|
||||||
|
_RC=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_RC=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# 2) try the dovecot way
|
||||||
|
if (( _RC > 0 ))
|
||||||
|
then
|
||||||
|
_DOVECOT_BIN="$(command -v dovecot 2>>${HC_STDERR_LOG})"
|
||||||
|
if [[ -x ${_DOVECOT_BIN} && -n "${_DOVECOT_BIN}" ]]
|
||||||
|
then
|
||||||
|
if (( $(${_DOVECOT_BIN} status 2>>"${HC_STDERR_LOG}" | grep -c -i 'is running' 2>/dev/null) == 0 ))
|
||||||
|
then
|
||||||
|
_RC=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "dovecot is not installed here"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3) try the pgrep way (note: old pgreps do not support '-c')
|
||||||
|
if (( _RC > 0 ))
|
||||||
|
then
|
||||||
|
(( $(pgrep -u dovecot 2>>"${HC_STDERR_LOG}" | wc -l 2>/dev/null) == 0 )) && _STC=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# evaluate results
|
||||||
|
case ${_STC} in
|
||||||
|
0)
|
||||||
|
_MSG="dovecot is running"
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
_MSG="dovecot is not running"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_MSG="could not determine status of dovecot"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# configuration state
|
||||||
|
_DOVECOT_CHECKER="$(command -v doveconf 2>>${HC_STDERR_LOG})"
|
||||||
|
if [[ -x ${_DOVECOT_CHECKER} && -n "${_DOVECOT_CHECKER}" ]]
|
||||||
|
then
|
||||||
|
# dump configuration
|
||||||
|
${_DOVECOT_CHECKER} -n >>"${HC_STDOUT_LOG}" 2>>"${HC_STDERR_LOG}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
_MSG="dovecot configuration files have syntax error(s) {${_DOVECOT_CHECKER} -n}"
|
||||||
|
_STC=1
|
||||||
|
else
|
||||||
|
_MSG="dovecot configuration files are syntactically correct"
|
||||||
|
_STC=0
|
||||||
|
fi
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "skipping syntax check (unable to find syntax check tool)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function _show_usage
|
||||||
|
{
|
||||||
|
cat <<- EOT
|
||||||
|
NAME : $1
|
||||||
|
VERSION : $2
|
||||||
|
PURPOSE : Checks whether dovecot (mail system) is running and whether the
|
||||||
|
dovecot configuration files are syntactically correct
|
||||||
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
|
EOT
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#******************************************************************************
|
||||||
|
# END of script
|
||||||
|
#******************************************************************************
|
319
opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh
Normal file
319
opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh
Normal file
@ -0,0 +1,319 @@
|
|||||||
|
#!/usr/bin/env ksh
|
||||||
|
#******************************************************************************
|
||||||
|
# @(#) check_linux_fetchmail_status.sh
|
||||||
|
#******************************************************************************
|
||||||
|
# @(#) Copyright (C) 2020 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is a free software; you can redistribute it and/or modify
|
||||||
|
# it under the same terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#******************************************************************************
|
||||||
|
#
|
||||||
|
# DOCUMENTATION (MAIN)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# @(#) MAIN: check_linux_fetchmail_status
|
||||||
|
# DOES: see _show_usage()
|
||||||
|
# EXPECTS: n/a
|
||||||
|
# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn')
|
||||||
|
#
|
||||||
|
# @(#) HISTORY:
|
||||||
|
# @(#) 2016-12-26: initial version [Patrick Van der Veken]
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
|
#******************************************************************************
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function check_linux_fetchmail_status
|
||||||
|
{
|
||||||
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
|
typeset _VERSION="2020-12-26" # YYYY-MM-DD
|
||||||
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
|
# set defaults
|
||||||
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
|
typeset _ARG=""
|
||||||
|
typeset _MSG=""
|
||||||
|
typeset _STC=0
|
||||||
|
typeset _LOG_HEALTHY=0
|
||||||
|
typeset _CFG_HEALTHY=""
|
||||||
|
typeset _CFG_ERROR_REGEX=""
|
||||||
|
typeset _ERROR_REGEX=""
|
||||||
|
typeset _CFG_ACCOUNT=""
|
||||||
|
typeset _CFG_RC_FILE=""
|
||||||
|
typeset _CFG_CHECK_LOG=""
|
||||||
|
typeset _OPENSSL_BIN=""
|
||||||
|
typeset _MD5SUM_BIN=""
|
||||||
|
typeset _HAS_OPENSSL=0
|
||||||
|
typeset _HAS_MD5SUM=0
|
||||||
|
typeset _USE_OPENSSL=0
|
||||||
|
typeset _USE_MD5SUM=0
|
||||||
|
typeset _DO_LOG=0
|
||||||
|
typeset _LOG_FILE=""
|
||||||
|
typeset _HASH_FILE_NAME=""
|
||||||
|
typeset _STATE_FILE=""
|
||||||
|
typeset _LAST_POINTER=""
|
||||||
|
typeset _NEW_LAST_POINTER=""
|
||||||
|
typeset _LOG_COUNT=""
|
||||||
|
typeset _LINE_NR=""
|
||||||
|
typeset _LINE_TEXT=""
|
||||||
|
|
||||||
|
# handle arguments (originally comma-separated)
|
||||||
|
for _ARG in ${_ARGS}
|
||||||
|
do
|
||||||
|
case "${_ARG}" in
|
||||||
|
help)
|
||||||
|
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# handle config file
|
||||||
|
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
|
||||||
|
if [[ ! -r ${_CONFIG_FILE} ]]
|
||||||
|
then
|
||||||
|
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# read required config values
|
||||||
|
_CFG_ERROR_REGEX=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'error_regex')
|
||||||
|
if [[ -n "${_CFG_ERROR_REGEX}" ]]
|
||||||
|
then
|
||||||
|
_ERROR_REGEX="${_CFG_ERROR_REGEX}"
|
||||||
|
else
|
||||||
|
_ERROR_REGEX="error|authfail|lockbusy|ioerr"
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "setting error_regex to default value: ${_ERROR_REGEX}"
|
||||||
|
fi
|
||||||
|
_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy')
|
||||||
|
case "${_CFG_HEALTHY}" in
|
||||||
|
yes|YES|Yes)
|
||||||
|
_LOG_HEALTHY=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# do not override hc_arg
|
||||||
|
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# log_healthy
|
||||||
|
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||||
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
|
then
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
log "logging/showing passed health checks"
|
||||||
|
else
|
||||||
|
log "showing passed health checks (but not logging)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "not logging/showing passed health checks"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# check for auxiliary tools
|
||||||
|
_OPENSSL_BIN="$(command -v openssl 2>>${HC_STDERR_LOG})"
|
||||||
|
[[ -x ${_OPENSSL_BIN} && -n "${_OPENSSL_BIN}" ]] && _HAS_OPENSSL=1
|
||||||
|
_MD5SUM_BIN="$(command -v md5sum 2>>${HC_STDERR_LOG})"
|
||||||
|
[[ -x ${_MD5SUM_BIN} && -n "${_MD5SUM_BIN}" ]] && _HAS_MD5SUM=1
|
||||||
|
# prefer openssl
|
||||||
|
if (( _HAS_OPENSSL == 1 ))
|
||||||
|
then
|
||||||
|
_USE_OPENSSL=1
|
||||||
|
elif (( _HAS_MD5SUM == 1 ))
|
||||||
|
then
|
||||||
|
_USE_MD5SUM=1
|
||||||
|
else
|
||||||
|
warn "unable to find the 'openssl/md5sum' tools, will not do fetchmail log checking"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# perform check(s)
|
||||||
|
grep -E -e "^fetchmail:" "${_CONFIG_FILE}" 2>/dev/null | while IFS=":" read -r _ _CFG_ACCOUNT _CFG_RC_FILE _CFG_CHECK_LOG
|
||||||
|
do
|
||||||
|
_STC=0
|
||||||
|
|
||||||
|
# check config
|
||||||
|
if [[ -z "${_CFG_ACCOUNT}" ]] && [[ -z "${_CFG_RC_FILE}" ]]
|
||||||
|
then
|
||||||
|
warn "missing values in configuration file at ${_CONFIG_FILE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if account exists
|
||||||
|
id "${_CFG_ACCOUNT}" >/dev/null 2>/dev/null || {
|
||||||
|
warn "account ${_CFG_ACCOUNT} does not exist on host, skipping"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# check if fetchmailrc file exists
|
||||||
|
[[ -r "${_CFG_RC_FILE}" ]] || {
|
||||||
|
warn "unable to read fetchmailrc file at ${_CFG_RC_FILE} for account ${_CFG_ACCOUNT}, skipping"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# get process details
|
||||||
|
(( $(pgrep -u "${_CFG_ACCOUNT}" -f "fetchmail.*${_CFG_RC_FILE}" | wc -l 2>/dev/null) == 0 )) && _STC=1
|
||||||
|
|
||||||
|
# evaluate results
|
||||||
|
case ${_STC} in
|
||||||
|
0)
|
||||||
|
_MSG="fetchmail is running for account ${_CFG_ACCOUNT} (${_CFG_RC_FILE})"
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
_MSG="fetchmail is not running for account ${_CFG_ACCOUNT} (${_CFG_RC_FILE})"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_MSG="could not determine status of fetchmail for account ${_CFG_ACCOUNT} (${_CFG_RC_FILE})"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check log?
|
||||||
|
case "${_CFG_CHECK_LOG}" in
|
||||||
|
Yes|YES|yes)
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "doing log check for account ${_CFG_ACCOUNT} (${_CFG_RC_FILE})"
|
||||||
|
_DO_LOG=1;
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log "skipping fetchmail log check for account ${_CFG_ACCOUNT} (${_CFG_RC_FILE})"
|
||||||
|
_DO_LOG=0;
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# check auxiliary tools
|
||||||
|
if (( _HAS_OPENSSL == 0 && _HAS_MD5SUM == 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to find the 'openssl/md5sum' tools, will not do fetchmail log checking for account ${_CFG_ACCOUNT}"
|
||||||
|
_DO_LOG=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( _DO_LOG > 0 ))
|
||||||
|
then
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "will do log check for account ${_CFG_ACCOUNT} [${_CFG_RC_FILE}]"
|
||||||
|
# get logfile statement in .fetchmailrc
|
||||||
|
_LOG_FILE=$(grep "^set logfile" "${_CFG_RC_FILE}" 2>/dev/null | awk '{ print $3 }' 2>/dev/null)
|
||||||
|
[[ -z "${_LOG_FILE}" ]] && {
|
||||||
|
warn "no fetchmail log file defined in fetchmailrc file at ${_CFG_RC_FILE} for account ${_CFG_ACCOUNT}, skipping log check"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
[[ -r "${_LOG_FILE}" ]] || {
|
||||||
|
warn "unable to read fetchmail log file at ${_LOG_FILE} for account ${_CFG_ACCOUNT}, skipping log check"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "log file found at ${_LOG_FILE}"
|
||||||
|
|
||||||
|
# determine state file (we use a hashed file name based on the fetchmail log file full path
|
||||||
|
# to avoid globbing when account has the same name for multiple entries in the configuration file)
|
||||||
|
(( _USE_OPENSSL == 1 )) && \
|
||||||
|
_HASH_FILE_NAME=$(${_OPENSSL_BIN} dgst -md5 "${_LOG_FILE}" 2>>"${HC_STDERR_LOG}" | cut -f2 -d'=' 2>/dev/null | tr -d ' ' 2>/dev/null)
|
||||||
|
(( _USE_MD5SUM == 1 )) && \
|
||||||
|
_HASH_FILE_NAME=$(${_MD5SUM_BIN} dgst -md5 "${_LOG_FILE}" 2>>"${HC_STDERR_LOG}" | cut -f1 -d' ' 2>/dev/null)
|
||||||
|
if [[ -z "${_HASH_FILE_NAME}" ]]
|
||||||
|
then
|
||||||
|
warn "unable to determine log state file for account ${_CFG_ACCOUNT}, skipping log check"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get log pointer from state file
|
||||||
|
_STATE_FILE="${STATE_PERM_DIR}/${_HASH_FILE_NAME}.fetchmail"
|
||||||
|
if [[ -r "${_STATE_FILE}" ]]
|
||||||
|
then
|
||||||
|
_LAST_POINTER=$(<"${_STATE_FILE}")
|
||||||
|
fi
|
||||||
|
if [[ -z "${_LAST_POINTER}" ]]
|
||||||
|
then
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "could not determine last known log entry, resetting to 0"
|
||||||
|
_LAST_POINTER=0
|
||||||
|
else
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "old _LAST_POINTER=${_LAST_POINTER}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check last known vs current pointer
|
||||||
|
_LOG_COUNT=$(wc -l "${_LOG_FILE}" 2>/dev/null | cut -f1 -d' ')
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "line count for current log: ${_LOG_COUNT}"
|
||||||
|
if (( _LOG_COUNT >= _LAST_POINTER ))
|
||||||
|
then
|
||||||
|
# find errors in later log lines
|
||||||
|
awk -F':' -v error_regex="${_ERROR_REGEX}" -v last_pointer=${_LAST_POINTER} '
|
||||||
|
{
|
||||||
|
# find error lines which have a line count > last pointer
|
||||||
|
if (NR > last_pointer && $0 ~ error_regex) {
|
||||||
|
# cut fetchmail: prefix & replce possible pipes
|
||||||
|
gsub(/^fetchmail: +/, "");
|
||||||
|
gsub(/\|/, "_");
|
||||||
|
# report issue with line number
|
||||||
|
print $0 "|" NR;
|
||||||
|
}
|
||||||
|
}' "${_LOG_FILE}" 2>/dev/null | while IFS="|" read -r _LINE_TEXT _LINE_NR
|
||||||
|
do
|
||||||
|
_MSG="found issue in ${_LOG_FILE}: ${_LINE_TEXT} (LINENO=${_LINE_NR})"
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" 1 "${_MSG}"
|
||||||
|
fi
|
||||||
|
# update new last pointer
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "updating _NEW_LAST_POINTER=${_LINE_NR}"
|
||||||
|
_NEW_LAST_POINTER=${_LINE_NR}
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# log small has shrunk, assume it has been rotated, resetting pointer to zero
|
||||||
|
log "log file for account ${_CFG_ACCOUNT} seems to have been rotated, resetting log file pointer to 0"
|
||||||
|
_LAST_POINTER=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# update state file with new last pointer
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
if [[ -n "${_NEW_LAST_POINTER}" ]] && (( _NEW_LAST_POINTER > _LAST_POINTER ))
|
||||||
|
then
|
||||||
|
_LAST_POINTER=${_NEW_LAST_POINTER}
|
||||||
|
fi
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "new _LAST_POINTER=${_LAST_POINTER}"
|
||||||
|
print "${_LAST_POINTER}" >"${_STATE_FILE}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "failed to update state file at ${_STATE_FILE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function _show_usage
|
||||||
|
{
|
||||||
|
cat <<- EOT
|
||||||
|
NAME : $1
|
||||||
|
VERSION : $2
|
||||||
|
CONFIG : $3 with parameters:
|
||||||
|
log_healthy=<yes|no>
|
||||||
|
and formatted stanzas:
|
||||||
|
fetchmail:<account>:<rc_file>:<check_log=Yes|No>
|
||||||
|
PURPOSE : Checks the status of local fetchmail services (process & log).
|
||||||
|
Fetchmail should be configured to run in daemon mode.
|
||||||
|
LOG HEALTHY : Supported
|
||||||
|
EOT
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#******************************************************************************
|
||||||
|
# END of script
|
||||||
|
#******************************************************************************
|
@ -35,6 +35,7 @@
|
|||||||
# @(#) fixed problem with offset calculation [Patrick Van der Veken]
|
# @(#) fixed problem with offset calculation [Patrick Van der Veken]
|
||||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-24: set dynamic path to client tools [Patrick Van der Veken]
|
# @(#) 2019-03-24: set dynamic path to client tools [Patrick Van der Veken]
|
||||||
|
# @(#) 2020-12-21: fixes for --log-healthy [Patrick Van der Veken]
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
@ -50,13 +51,13 @@ typeset _CHRONYD_SYSTEMD_SERVICE="chronyd.service"
|
|||||||
typeset _NTPD_SYSTEMD_SERVICE="ntpd.service"
|
typeset _NTPD_SYSTEMD_SERVICE="ntpd.service"
|
||||||
typeset _CHRONYD_USER="chrony"
|
typeset _CHRONYD_USER="chrony"
|
||||||
typeset _NTPD_USER="ntp"
|
typeset _NTPD_USER="ntp"
|
||||||
typeset _VERSION="2019-03-24" # YYYY-MM-DD
|
typeset _VERSION="2020-12-21" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
typeset _NTPQ_OPTS="-pn"
|
typeset _NTPQ_OPTS="-pn"
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
typeset _ARGS=$(data_comma2space "$*")
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
typeset _ARG=""
|
typeset _ARG=""
|
||||||
@ -82,7 +83,7 @@ for _ARG in ${_ARGS}
|
|||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
help)
|
help)
|
||||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
||||||
;;
|
;;
|
||||||
force_chrony)
|
force_chrony)
|
||||||
log "forcing chrony since force_chrony was used"
|
log "forcing chrony since force_chrony was used"
|
||||||
@ -173,11 +174,8 @@ fi
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# check for client tools
|
# check for client tools
|
||||||
_CHRONYC_BIN="$(command -v chronyc 2>>${HC_STDERR_LOG})"
|
_CHRONYC_BIN="$(command -v chronyc 2>>${HC_STDERR_LOG})"
|
||||||
|
|
||||||
|
|
||||||
_NTPQ_BIN="$(command -v ntpq 2>>${HC_STDERR_LOG})"
|
_NTPQ_BIN="$(command -v ntpq 2>>${HC_STDERR_LOG})"
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# chronyd (prefer) or ntpd (fallback)
|
# chronyd (prefer) or ntpd (fallback)
|
||||||
# but do not check if _USE_CHRONYD or _USE_NTPD is already set
|
# but do not check if _USE_CHRONYD or _USE_NTPD is already set
|
||||||
@ -202,6 +200,7 @@ then
|
|||||||
;;
|
;;
|
||||||
'sysv')
|
'sysv')
|
||||||
chkconfig chronyd >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
chkconfig chronyd >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if (( $? == 0 ))
|
if (( $? == 0 ))
|
||||||
then
|
then
|
||||||
_USE_CHRONYD=1
|
_USE_CHRONYD=1
|
||||||
@ -333,7 +332,10 @@ case ${_STC} in
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# check chronyc/ntpq results
|
# check chronyc/ntpq results
|
||||||
@ -341,6 +343,7 @@ _STC=0
|
|||||||
if (( _USE_CHRONYD > 0 ))
|
if (( _USE_CHRONYD > 0 ))
|
||||||
then
|
then
|
||||||
${_CHRONYC_BIN} -nc sources 2>>${HC_STDERR_LOG} >>${HC_STDOUT_LOG}
|
${_CHRONYC_BIN} -nc sources 2>>${HC_STDERR_LOG} >>${HC_STDOUT_LOG}
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if (( $? > 0 ))
|
if (( $? > 0 ))
|
||||||
then
|
then
|
||||||
_MSG="unable to execute {${_CHRONYC_BIN}}"
|
_MSG="unable to execute {${_CHRONYC_BIN}}"
|
||||||
@ -368,7 +371,10 @@ then
|
|||||||
_MSG="chrony is synchronizing against ${_CHRONY_PEER}"
|
_MSG="chrony is synchronizing against ${_CHRONY_PEER}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
|
|
||||||
# 2) offset value
|
# 2) offset value
|
||||||
if (( _STC == 0 ))
|
if (( _STC == 0 ))
|
||||||
@ -380,6 +386,7 @@ then
|
|||||||
# numeric, OK (negatives are OK too!)
|
# numeric, OK (negatives are OK too!)
|
||||||
# convert from us to ms
|
# convert from us to ms
|
||||||
_CURR_OFFSET=$(print -R "${_CURR_OFFSET} * 1000" | bc 2>/dev/null)
|
_CURR_OFFSET=$(print -R "${_CURR_OFFSET} * 1000" | bc 2>/dev/null)
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if (( $? > 0 )) || [[ -z "${_CURR_OFFSET}" ]]
|
if (( $? > 0 )) || [[ -z "${_CURR_OFFSET}" ]]
|
||||||
then
|
then
|
||||||
:
|
:
|
||||||
@ -393,7 +400,10 @@ then
|
|||||||
else
|
else
|
||||||
_MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range"
|
_MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range"
|
||||||
fi
|
fi
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# not numeric
|
# not numeric
|
||||||
@ -425,7 +435,10 @@ else
|
|||||||
_MSG="NTP is synchronizing against ${_NTP_PEER##*\*}"
|
_MSG="NTP is synchronizing against ${_NTP_PEER##*\*}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
|
|
||||||
# 2) offset value
|
# 2) offset value
|
||||||
if (( _STC == 0 ))
|
if (( _STC == 0 ))
|
||||||
@ -442,7 +455,10 @@ else
|
|||||||
else
|
else
|
||||||
_MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range"
|
_MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range"
|
||||||
fi
|
fi
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# not numeric
|
# not numeric
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
# @(#) MAIN: check_linux_postfix_status
|
# @(#) MAIN: check_linux_postfix_status
|
||||||
# DOES: see _show_usage()
|
# DOES: see _show_usage()
|
||||||
# EXPECTS: n/a
|
# EXPECTS: n/a
|
||||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn')
|
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn()
|
||||||
#
|
#
|
||||||
# @(#) HISTORY:
|
# @(#) HISTORY:
|
||||||
# @(#) 2016-12-01: initial version [Patrick Van der Veken]
|
# @(#) 2016-12-01: initial version [Patrick Van der Veken]
|
||||||
@ -32,6 +32,7 @@
|
|||||||
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-25: fix for older Debian & Ubuntu [Patrick Van der Veken]
|
# @(#) 2019-03-25: fix for older Debian & Ubuntu [Patrick Van der Veken]
|
||||||
# @(#) 2020-05-08: add pgrep als fallback check [Patrick Van der Veken]
|
# @(#) 2020-05-08: add pgrep als fallback check [Patrick Van der Veken]
|
||||||
|
# @(#) 2020-12-27: add configuration check + quoting fixes [Patrick Van der Veken]
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
@ -42,16 +43,17 @@ function check_linux_postfix_status
|
|||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _POSTFIX_INIT_SCRIPT="/etc/init.d/postfix"
|
typeset _POSTFIX_INIT_SCRIPT="/etc/init.d/postfix"
|
||||||
typeset _POSTFIX_SYSTEMD_SERVICE="postfix.service"
|
typeset _POSTFIX_SYSTEMD_SERVICE="postfix.service"
|
||||||
typeset _VERSION="2020-05-08" # YYYY-MM-DD
|
typeset _VERSION="2020-12-27" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
typeset _ARGS=$(data_comma2space "$*")
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
typeset _ARG=""
|
typeset _ARG=""
|
||||||
typeset _POSTFIX_BIN=""
|
typeset _POSTFIX_BIN=""
|
||||||
|
typeset _POSTFIX_CHECKER=""
|
||||||
typeset _MSG=""
|
typeset _MSG=""
|
||||||
typeset _STC=0
|
typeset _STC=0
|
||||||
typeset _LOG_HEALTHY=0
|
typeset _LOG_HEALTHY=0
|
||||||
@ -63,7 +65,7 @@ for _ARG in ${_ARGS}
|
|||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
help)
|
help)
|
||||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -82,6 +84,9 @@ else
|
|||||||
log "not logging/showing passed health checks"
|
log "not logging/showing passed health checks"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# process state
|
||||||
|
|
||||||
# 1) try using the init ways
|
# 1) try using the init ways
|
||||||
linux_get_init
|
linux_get_init
|
||||||
case "${LINUX_INIT}" in
|
case "${LINUX_INIT}" in
|
||||||
@ -100,7 +105,7 @@ case "${LINUX_INIT}" in
|
|||||||
fi
|
fi
|
||||||
if (( _CHECK_SYSTEMD_SERVICE > 0 ))
|
if (( _CHECK_SYSTEMD_SERVICE > 0 ))
|
||||||
then
|
then
|
||||||
systemctl --quiet is-active ${_POSTFIX_SYSTEMD_SERVICE} 2>>${HC_STDERR_LOG} || _STC=1
|
systemctl --quiet is-active ${_POSTFIX_SYSTEMD_SERVICE} 2>>"${HC_STDERR_LOG}" || _STC=1
|
||||||
else
|
else
|
||||||
warn "systemd unit file not found {${_POSTFIX_SYSTEMD_SERVICE}}"
|
warn "systemd unit file not found {${_POSTFIX_SYSTEMD_SERVICE}}"
|
||||||
_RC=1
|
_RC=1
|
||||||
@ -114,7 +119,7 @@ case "${LINUX_INIT}" in
|
|||||||
# check running SysV
|
# check running SysV
|
||||||
if [[ -x ${_POSTFIX_INIT_SCRIPT} ]]
|
if [[ -x ${_POSTFIX_INIT_SCRIPT} ]]
|
||||||
then
|
then
|
||||||
if (( $(${_POSTFIX_INIT_SCRIPT} status 2>>${HC_STDERR_LOG} | grep -c -i 'is running' 2>/dev/null) == 0 ))
|
if (( $(${_POSTFIX_INIT_SCRIPT} status 2>>"${HC_STDERR_LOG}" | grep -c -i 'is running' 2>/dev/null) == 0 ))
|
||||||
then
|
then
|
||||||
_STC=1
|
_STC=1
|
||||||
fi
|
fi
|
||||||
@ -134,10 +139,9 @@ then
|
|||||||
_POSTFIX_BIN="$(command -v postfix 2>>${HC_STDERR_LOG})"
|
_POSTFIX_BIN="$(command -v postfix 2>>${HC_STDERR_LOG})"
|
||||||
if [[ -x ${_POSTFIX_BIN} && -n "${_POSTFIX_BIN}" ]]
|
if [[ -x ${_POSTFIX_BIN} && -n "${_POSTFIX_BIN}" ]]
|
||||||
then
|
then
|
||||||
if (( $(${_POSTFIX_BIN} status 2>>${HC_STDERR_LOG} | grep -c -i 'is running' 2>/dev/null) == 0 ))
|
if (( $(${_POSTFIX_BIN} status 2>>"${HC_STDERR_LOG}" | grep -c -i 'is running' 2>/dev/null) == 0 ))
|
||||||
then
|
then
|
||||||
_RC=1
|
_RC=1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
warn "postfix is not installed here"
|
warn "postfix is not installed here"
|
||||||
@ -148,7 +152,7 @@ fi
|
|||||||
# 3) try the pgrep way (note: old pgreps do not support '-c')
|
# 3) try the pgrep way (note: old pgreps do not support '-c')
|
||||||
if (( _RC > 0 ))
|
if (( _RC > 0 ))
|
||||||
then
|
then
|
||||||
(( $(pgrep -u postfix pickup 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1
|
(( $(pgrep -u postfix pickup 2>>"${HC_STDERR_LOG}" | wc -l 2>/dev/null) == 0 )) && _STC=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# evaluate results
|
# evaluate results
|
||||||
@ -168,6 +172,30 @@ then
|
|||||||
log_hc "$0" ${_STC} "${_MSG}"
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# configuration state
|
||||||
|
_POSTFIX_CHECKER="$(command -v postconf 2>>${HC_STDERR_LOG})"
|
||||||
|
if [[ -x ${_POSTFIX_CHECKER} && -n "${_POSTFIX_CHECKER}" ]]
|
||||||
|
then
|
||||||
|
# dump configuration
|
||||||
|
${_POSTFIX_CHECKER} -n >>"${HC_STDOUT_LOG}" 2>>"${HC_STDERR_LOG}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
_MSG="postfix configuration files have syntax error(s) {${_POSTFIX_CHECKER} -n}"
|
||||||
|
_STC=1
|
||||||
|
else
|
||||||
|
_MSG="postfix configuration files are syntactically correct"
|
||||||
|
_STC=0
|
||||||
|
fi
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "skipping syntax check (unable to find syntax check tool)"
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +205,8 @@ function _show_usage
|
|||||||
cat <<- EOT
|
cat <<- EOT
|
||||||
NAME : $1
|
NAME : $1
|
||||||
VERSION : $2
|
VERSION : $2
|
||||||
PURPOSE : Checks whether postfix (mail system) is running
|
PURPOSE : Checks whether postfix (mail system) is running and whether the
|
||||||
|
postfix configuration files are syntactically correct
|
||||||
LOG HEALTHY : Supported
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
313
opt/hc/lib/platform/linux/check_linux_uptime.sh
Normal file
313
opt/hc/lib/platform/linux/check_linux_uptime.sh
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
#!/usr/bin/env ksh
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# @(#) check_linux_uptime
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# @(#) Copyright (C) 2020 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is a free software; you can redistribute it and/or modify
|
||||||
|
# it under the same terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# DOCUMENTATION (MAIN)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# @(#) MAIN: check_linux_uptime
|
||||||
|
# DOES: see _show_usage()
|
||||||
|
# EXPECTS: see _show_usage()
|
||||||
|
# REQUIRES: data_is_numeric(), data_timestring_to_mins(), data_comma2space(),
|
||||||
|
# init_hc(), log_hc(), warn()
|
||||||
|
#
|
||||||
|
# @(#) HISTORY:
|
||||||
|
# @(#) 2020-12-21: initial version [Patrick Van der Veken]
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function check_linux_uptime
|
||||||
|
{
|
||||||
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
|
typeset _STATE_FILE="${STATE_PERM_DIR}/current.uptime"
|
||||||
|
typeset _VERSION="2020-12-21" # YYYY-MM-DD
|
||||||
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
|
# set defaults
|
||||||
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
|
typeset _ARG=""
|
||||||
|
typeset _MSG=""
|
||||||
|
typeset _STC=0
|
||||||
|
typeset _LOG_HEALTHY=0
|
||||||
|
typset _CFG_HEALTHY=
|
||||||
|
typeset _CFG_CHECK_REBOOT=""
|
||||||
|
typeset _CFG_REBOOT_TIME=""
|
||||||
|
typeset _CFG_CHECK_OLD_AGE=""
|
||||||
|
typeset _CFG_OLD_AGE_TIME=""
|
||||||
|
typeset _CHECK_REBOOT=""
|
||||||
|
typeset _REBOOT_TIME=""
|
||||||
|
typeset _REBOOT_TIME_MINS=""
|
||||||
|
typeset _CHECK_OLD_AGE=""
|
||||||
|
typeset _OLD_AGE_TIME=""
|
||||||
|
typeset _OLD_AGE_TIME_MINS=""
|
||||||
|
typeset _CURRENT_UPTIME=""
|
||||||
|
typeset _CURRENT_UPTIME_MINS=""
|
||||||
|
typeset _PREVIOUS_UPTIME=""
|
||||||
|
typeset _PREVIOUS_UPTIME_MINS=""
|
||||||
|
typeset _THRESHOLD_UPTIME_MINS=""
|
||||||
|
|
||||||
|
# handle arguments (originally comma-separated)
|
||||||
|
for _ARG in ${_ARGS}
|
||||||
|
do
|
||||||
|
case "${_ARG}" in
|
||||||
|
help)
|
||||||
|
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# handle config file
|
||||||
|
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
|
||||||
|
if [[ ! -r ${_CONFIG_FILE} ]]
|
||||||
|
then
|
||||||
|
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# read required config values
|
||||||
|
_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy')
|
||||||
|
case "${_CFG_HEALTHY}" in
|
||||||
|
yes|YES|Yes)
|
||||||
|
_LOG_HEALTHY=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# do not override hc_arg
|
||||||
|
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_CFG_CHECK_REBOOT=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_reboot')
|
||||||
|
case "${_CFG_CHECK_REBOOT}" in
|
||||||
|
no|No|NO)
|
||||||
|
_CHECK_REBOOT=0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_CHECK_REBOOT=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_CFG_REBOOT_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'reboot_time')
|
||||||
|
if [[ -z "${_CFG_REBOOT_TIME}" ]]
|
||||||
|
then
|
||||||
|
# default
|
||||||
|
_REBOOT_TIME="60m"
|
||||||
|
else
|
||||||
|
_REBOOT_TIME="${_CFG_REBOOT_TIME}"
|
||||||
|
fi
|
||||||
|
_CFG_CHECK_OLD_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_old_age')
|
||||||
|
case "${_CFG_CHECK_OLD_AGE}" in
|
||||||
|
yes|Yes|Yes)
|
||||||
|
_CHECK_OLD_AGE=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_CHECK_OLD_AGE=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_CFG_OLD_AGE_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'old_age_time')
|
||||||
|
if [[ -z "${_CFG_OLD_AGE_TIME}" ]]
|
||||||
|
then
|
||||||
|
# default
|
||||||
|
_OLD_AGE_TIME="365d"
|
||||||
|
else
|
||||||
|
_OLD_AGE_TIME="${_CFG_OLD_AGE_TIME}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# log_healthy
|
||||||
|
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||||
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
|
then
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
log "logging/showing passed health checks"
|
||||||
|
else
|
||||||
|
log "showing passed health checks (but not logging)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "not logging/showing passed health checks"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# read /proc/uptime
|
||||||
|
if [[ -r /proc/uptime ]]
|
||||||
|
then
|
||||||
|
# drop decimals
|
||||||
|
_CURRENT_UPTIME=$(awk '{ printf("%2.d", $1)}' /proc/uptime 2>/dev/null)
|
||||||
|
else
|
||||||
|
warn "/proc/uptime cannot be found or queried"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# read state file
|
||||||
|
if [[ -r ${_STATE_FILE} ]]
|
||||||
|
then
|
||||||
|
_PREVIOUS_UPTIME=$(<"${_STATE_FILE}")
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "failed to read state file at ${_STATE_FILE}"
|
||||||
|
_PREVIOUS_UPTIME=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# convert uptimes values
|
||||||
|
_CURRENT_UPTIME_MINS=$(( _CURRENT_UPTIME / 60 ))
|
||||||
|
data_is_numeric "${_CURRENT_UPTIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate current uptime value (minutes)"
|
||||||
|
(( ARG_DEBUG )) && debug "_CURRENT_UPTIME_MINS=${_CURRENT_UPTIME_MINS}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_PREVIOUS_UPTIME_MINS=$(( _PREVIOUS_UPTIME / 60 ))
|
||||||
|
data_is_numeric "${_CURRENT_UPTIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate previous uptime value (minutes)"
|
||||||
|
(( ARG_DEBUG )) && debug "_PREVIOUS_UPTIME_MINS=${_PREVIOUS_UPTIME_MINS}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# check reboot event
|
||||||
|
if (( _CHECK_REBOOT > 0 ))
|
||||||
|
then
|
||||||
|
# convert _REBOOT_TIME to minutes
|
||||||
|
_REBOOT_TIME_MINS=$(data_timestring_to_mins "${_REBOOT_TIME}")
|
||||||
|
data_is_numeric "${_REBOOT_TIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate 'reboot_time' value from configuration file ${_CONFIG_FILE}"
|
||||||
|
(( ARG_DEBUG )) && debug "_REBOOT_TIME=${_REBOOT_TIME}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# previous uptime missing?
|
||||||
|
if [[ -z "${_PREVIOUS_UPTIME}" ]]
|
||||||
|
then
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
print "${_CURRENT_UPTIME}" >"${_STATE_FILE}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "failed to update state file at ${_STATE_FILE}"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
log "unable to find previously recorded uptime, resetting to current uptime"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "unable to find previously recorded uptime, resetting to current uptime"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# current uptime + reboot time is smaller than previous uptime?
|
||||||
|
_THRESHOLD_UPTIME_MINS=$(( _CURRENT_UPTIME_MINS + _REBOOT_TIME_MINS ))
|
||||||
|
if (( _THRESHOLD_UPTIME_MINS < _PREVIOUS_UPTIME_MINS ))
|
||||||
|
then
|
||||||
|
_MSG="reboot check: current uptime is NOK; check if reboot occurred"
|
||||||
|
_STC=1
|
||||||
|
else
|
||||||
|
_MSG="reboot check: current uptime is OK"
|
||||||
|
_STC=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}" "${_THRESHOLD_UPTIME_MINS}" "${_PREVIOUS_UPTIME_MINS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# update state file
|
||||||
|
if (( ARG_LOG > 0 ))
|
||||||
|
then
|
||||||
|
print "${_CURRENT_UPTIME}" >"${_STATE_FILE}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "failed to update state file at ${_STATE_FILE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "reboot check: not enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# check old age event
|
||||||
|
if (( _CHECK_OLD_AGE > 0 ))
|
||||||
|
then
|
||||||
|
# convert _OLD_AGE_TIME to minutes
|
||||||
|
_OLD_AGE_TIME_MINS=$(data_timestring_to_mins "${_OLD_AGE_TIME}")
|
||||||
|
data_is_numeric "${_OLD_AGE_TIME_MINS}"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if (( $? > 0 ))
|
||||||
|
then
|
||||||
|
warn "unable to calculate 'old_age_time' value from configuration file ${_CONFIG_FILE}"
|
||||||
|
(( ARG_DEBUG )) && debug "_OLD_AGE_TIME=${_OLD_AGE_TIME}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# are we old age yet?
|
||||||
|
if (( _CURRENT_UPTIME_MINS > _OLD_AGE_TIME_MINS ))
|
||||||
|
then
|
||||||
|
_MSG="old_age check: current uptime is NOK; old age has arrived (>${_OLD_AGE_TIME})"
|
||||||
|
_STC=1
|
||||||
|
else
|
||||||
|
_MSG="old_age check: current uptime is OK"
|
||||||
|
_STC=0
|
||||||
|
fi
|
||||||
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
|
then
|
||||||
|
log_hc "$0" ${_STC} "${_MSG}" "${_CURRENT_UPTIME_MINS}" "${_OLD_AGE_TIME_MINS}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "old age check: not enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function _show_usage
|
||||||
|
{
|
||||||
|
cat <<- EOT
|
||||||
|
NAME : $1
|
||||||
|
VERSION : $2
|
||||||
|
CONFIG : $3 with:
|
||||||
|
log_healthy=<yes|no>
|
||||||
|
check_reboot=<yes|no>
|
||||||
|
reboot_time=<timestring>
|
||||||
|
check_old_age=<yes|no>
|
||||||
|
old_age_time=<timestring>
|
||||||
|
PURPOSE : Checks for unexpected/unplanned reboot events based on uptime
|
||||||
|
values.
|
||||||
|
Checks whether the host has been up and running for too much time.
|
||||||
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
|
EOT
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# END of script
|
||||||
|
#------------------------------------------------------------------------------
|
Loading…
x
Reference in New Issue
Block a user