From 453683971055cd15fc0cee5322b3d3d0b956c825 Mon Sep 17 00:00:00 2001 From: shixuantong Date: Thu, 12 Dec 2024 11:14:20 +0800 Subject: [PATCH] set logrotate --- set-logrotate.patch | 53 +++++++++++++++++++++++++++++++++++++++++++++ sysSentry.spec | 23 ++++++++++++++++---- 2 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 set-logrotate.patch diff --git a/set-logrotate.patch b/set-logrotate.patch new file mode 100644 index 0000000..ba2634d --- /dev/null +++ b/set-logrotate.patch @@ -0,0 +1,53 @@ +From 962fd4079fa3af24a839c5fa00e591bf11e93c68 Mon Sep 17 00:00:00 2001 +From: shixuantong +Date: Mon, 16 Dec 2024 09:43:04 +0800 +Subject: [PATCH] set logrotate + +--- + config/{logrotate => logrotate-sysSentry.conf} | 5 +++-- + src/sh/logrotate-sysSentry.cron | 13 +++++++++++++ + 2 files changed, 16 insertions(+), 2 deletions(-) + rename config/{logrotate => logrotate-sysSentry.conf} (73%) + create mode 100644 src/sh/logrotate-sysSentry.cron + +diff --git a/config/logrotate b/config/logrotate-sysSentry.conf +similarity index 73% +rename from config/logrotate +rename to config/logrotate-sysSentry.conf +index f54e7b3..32f063f 100644 +--- a/config/logrotate ++++ b/config/logrotate-sysSentry.conf +@@ -1,8 +1,9 @@ + /var/log/sysSentry/*.log { +- nocompress ++ create ++ compress + missingok + notifempty + copytruncate +- rotate 2 ++ rotate 4 + size +4096k + } +diff --git a/src/sh/logrotate-sysSentry.cron b/src/sh/logrotate-sysSentry.cron +new file mode 100644 +index 0000000..64d02f9 +--- /dev/null ++++ b/src/sh/logrotate-sysSentry.cron +@@ -0,0 +1,13 @@ ++#!/bin/sh ++ ++TMPF=`mktemp /tmp/logrotate-sysSentry.XXXXXXXXX` ++ ++/usr/sbin/logrotate /etc/logrotate-sysSentry.conf -v --log=$TMPF -s /var/lib/logrotate-syssentry/logrotate.status ++EXITVALUE=$? ++if [ $EXITVALUE != 0 ]; then ++ /bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE], for details, see /var/log/sysSentry/logrotate.log" ++ /bin/logger -t logrotate -f $TMPF ++fi ++rm -rf $TMPF ++rm -rf /var/lib/logrotate-syssentry/logrotate.status ++exit $EXITVALUE +-- +2.27.0 + diff --git a/sysSentry.spec b/sysSentry.spec index 7385335..3e8e30e 100644 --- a/sysSentry.spec +++ b/sysSentry.spec @@ -4,7 +4,7 @@ Summary: System Inspection Framework Name: sysSentry Version: 1.0.2 -Release: 23 +Release: 24 License: Mulan PSL v2 Group: System Environment/Daemons Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz @@ -34,6 +34,7 @@ Patch21: update-the-commit-of-the-log-level-and-format-of-sys.patch Patch22: add-boundary-check-for-settings.patch Patch23: fix-xalarm-not-reject-alarm-msg-exceeds-max-length.patch Patch24: change-status-of-period-task-and-sort-mod-file.patch +Patch25: set-logrotate.patch BuildRequires: cmake gcc-c++ BuildRequires: python3 python3-setuptools @@ -121,12 +122,10 @@ install config/tasks/rasdaemon.mod %{buildroot}/etc/sysSentry/tasks/ # xalarm sh build/build.sh -i %{buildroot}%{_libdir} -mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d install -m 600 config/xalarm.conf %{buildroot}%{_sysconfdir}/sysSentry install -d %{buildroot}%{_libdir} install -d %{buildroot}%{_includedir}/xalarm install -m 600 service/xalarmd.service %{buildroot}%{_unitdir} -install -m 600 config/logrotate %{buildroot}%{_sysconfdir}/logrotate.d/sysSentry install -m 644 src/libso/xalarm/register_xalarm.h %{buildroot}%{_includedir}/xalarm/register_xalarm.h # cpu sentry @@ -144,6 +143,12 @@ install src/c/hbm_online_repair/hbm_online_repair.env %{buildroot}/etc/sysconfig chrpath -d %{buildroot}%{_bindir}/cat-cli chrpath -d %{buildroot}%{_libdir}/libcpu_patrol.so +# logrotate +mkdir -p %{buildroot}%{_localstatedir}/lib/logrotate-syssentry +mkdir -p %{buildroot}%{_sysconfdir}/cron.hourly +install -m 0600 config/logrotate-sysSentry.conf %{buildroot}%{_sysconfdir}/logrotate-sysSentry.conf +install -m 0500 src/sh/logrotate-sysSentry.cron %{buildroot}%{_sysconfdir}/cron.hourly/logrotate-sysSentry + pushd src/python python3 setup.py install -O1 --root=$RPM_BUILD_ROOT --record=SENTRY_FILES popd @@ -187,10 +192,14 @@ rm -rf %{buildroot} # xalarm %attr(0550,root,root) %{_bindir}/xalarmd -%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/logrotate.d/sysSentry %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/sysSentry/xalarm.conf %attr(0600,root,root) %{_unitdir}/xalarmd.service +# logrotate +%dir %{_localstatedir}/lib/logrotate-syssentry +%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/logrotate-sysSentry.conf +%attr(0500,root,root) %{_sysconfdir}/cron.hourly/logrotate-sysSentry + # cpu inspection module %exclude %{_sysconfdir}/sysSentry/tasks/cpu_sentry.mod %exclude %{_sysconfdir}/sysSentry/plugins/cpu_sentry.ini @@ -227,6 +236,12 @@ rm -rf %{buildroot} %attr(0550,root,root) %{python3_sitelib}/syssentry/bmc_alarm.py %changelog +* Wed Dec 18 2024 shixuantong - 1.0.2-24 +- Type:enhancement +- CVE:NA +- SUG:NA +- DESC:set logrotate + * Fri Dec 13 2024 zhuofeng - 1.0.2-23 - Type:bugfix - CVE:NA -- Gitee