Accepting request 29009 from Base:System
Copy from Base:System/mcelog based on submit request 29009 from user coolo OBS-URL: https://build.opensuse.org/request/show/29009 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/mcelog?expand=0&rev=7
This commit is contained in:
parent
12cebb1f32
commit
d4c5115ba8
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bc931a0bf0eb221e3b01727f2dd59b0d39e94dbc30f5dd7134f78d61ea439986
|
||||
size 567856
|
3
mcelog-1.0pre1.tar.bz2
Normal file
3
mcelog-1.0pre1.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:80b0593c8d1923bc33a07ab72c84654aee492de0c3b5806553ac13fb6f8ee719
|
||||
size 759376
|
@ -1,3 +1,28 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Dec 3 12:12:40 CET 2009 - trenn@suse.de
|
||||
|
||||
- Minor .spec and init script fixes/cleanups
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Dec 3 11:28:05 CET 2009 - trenn@suse.de
|
||||
|
||||
- Add service parts:
|
||||
- let mcelog --daemon handle pid file in /var/run/mcelog.pid
|
||||
- add insserv logic
|
||||
- remove cron.daily script in update case
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 27 22:01:40 CET 2009 - trenn@suse.de
|
||||
|
||||
- Update to latest git version (called it 1.0pre1 myself, may differ
|
||||
with a possible public 1.0pre1 version), this includes
|
||||
following new featues:
|
||||
- yellow bit support
|
||||
- page predictive failure analysis support
|
||||
- Initial memdb support
|
||||
This allows to account memory errors in memory in daemon mode
|
||||
And a lot more...
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Oct 2 17:06:03 CEST 2009 - trenn@suse.de
|
||||
|
||||
|
103
mcelog.service
Normal file
103
mcelog.service
Normal file
@ -0,0 +1,103 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2009 by Thomas Renninger <trenn@suse.de>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 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.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: mcelog
|
||||
# Required-Start:
|
||||
# Should-Start: $remote_fs $network $syslog
|
||||
# Required-Stop:
|
||||
# Should-Stop: $remote_fs $network $syslog
|
||||
# Default-Start: 2 3 5
|
||||
# Default-Stop:
|
||||
# Short-Description: Machine Check Architecture/Error (MCA/MCE) implementations
|
||||
# Description: Depending on the configuration, the mcelog service will log
|
||||
# HW initiated Machine Check Excpetions or also react on them intelligently
|
||||
### END INIT INFO
|
||||
|
||||
. /etc/rc.status
|
||||
#. /etc/sysconfig/mcelog
|
||||
|
||||
# Shell functions sourced from /etc/rc.status:
|
||||
# rc_check check and set local and overall rc status
|
||||
# rc_status check and set local and overall rc status
|
||||
# rc_status -v ditto but be verbose in local rc status
|
||||
# rc_status -v -r ditto and clear the local rc status
|
||||
# rc_failed set local and overall rc status to failed
|
||||
# rc_reset clear local rc status (overall remains)
|
||||
# rc_exit exit appropriate to overall rc status
|
||||
|
||||
# First reset status of this service
|
||||
rc_reset
|
||||
|
||||
mcelog="/usr/sbin/mcelog"
|
||||
mcelog_params=" --daemon "
|
||||
mcedev=/dev/mcelog
|
||||
mcelog_pid="/var/run/mcelog.pid"
|
||||
|
||||
check="checkproc -p ${mcelog_pid} ${mcelog}"
|
||||
kill="killproc -p ${mcelog_pid} ${mcelog}"
|
||||
start="startproc -p ${mcelog_pid} ${mcelog} ${mcelog_params}"
|
||||
|
||||
test_kernel_support()
|
||||
{
|
||||
if [ ! -c ${mcedev} ];then
|
||||
echo -n "$mcedev not found - no kernel or HW support "
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting mcelog... "
|
||||
if ! test_kernel_support; then
|
||||
rc_status -u
|
||||
elif ${check};then
|
||||
echo -n "already running"
|
||||
else
|
||||
${start}
|
||||
fi
|
||||
rc_status -v
|
||||
;;
|
||||
stop)
|
||||
echo -n "Shutting down mcelog... "
|
||||
${kill}
|
||||
rc_status -v
|
||||
;;
|
||||
reload|restart)
|
||||
/etc/init.d/mcelog stop
|
||||
/etc/init.d/mcelog start
|
||||
;;
|
||||
status)
|
||||
echo -n "Checking for service mcelog... "
|
||||
if ! test_kernel_support; then
|
||||
rc_status -u
|
||||
else
|
||||
${check}
|
||||
rc_status -v
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
rc_exit
|
40
mcelog.spec
40
mcelog.spec
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package mcelog (Version 0.9pre)
|
||||
# spec file for package mcelog (Version 1.0pre1)
|
||||
#
|
||||
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -19,13 +19,16 @@
|
||||
|
||||
|
||||
Name: mcelog
|
||||
License: GPL v2 or later
|
||||
License: GPLv2+
|
||||
Summary: Log Machine Check Events
|
||||
Version: 0.9pre
|
||||
Version: 1.0pre1
|
||||
Release: 1
|
||||
AutoReqProv: on
|
||||
ExclusiveArch: x86_64
|
||||
PreReq: %insserv_prereq
|
||||
Source: mcelog-%{version}.tar.bz2
|
||||
Source1: mcelog.service
|
||||
Patch0: mcelog_daemon_create_pid_file.patch
|
||||
Group: System/Monitoring
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
|
||||
@ -47,28 +50,43 @@ Authors:
|
||||
|
||||
%prep
|
||||
%setup
|
||||
%patch0 -p1
|
||||
|
||||
%build
|
||||
make CFLAGS="$RPM_OPT_FLAGS"
|
||||
|
||||
%install
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/sbin/
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/cron.hourly/
|
||||
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man8
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d/
|
||||
cp mcelog $RPM_BUILD_ROOT/usr/sbin
|
||||
cp mcelog.cron $RPM_BUILD_ROOT/etc/cron.hourly/mcelog
|
||||
cp mcelog.8 $RPM_BUILD_ROOT/%{_mandir}/man8
|
||||
cp mcelog.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/mcelog
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/init.d
|
||||
install -m755 %SOURCE1 $RPM_BUILD_ROOT/etc/init.d/mcelog
|
||||
ln -s /etc/init.d/mcelog $RPM_BUILD_ROOT/usr/sbin/rcmcelog
|
||||
install -m755 mcelog $RPM_BUILD_ROOT/usr/sbin
|
||||
install -m644 mcelog.8 $RPM_BUILD_ROOT/%{_mandir}/man8
|
||||
install -m644 mcelog.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/mcelog
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%post
|
||||
if [ -c /dev/mcelog ];then
|
||||
%{insserv_force_if_yast mcelog}
|
||||
fi
|
||||
|
||||
%preun
|
||||
%stop_on_removal mcelog
|
||||
|
||||
%postun
|
||||
%restart_on_update
|
||||
%insserv_cleanup
|
||||
|
||||
%files
|
||||
%defattr (-,root,root,755)
|
||||
%{_mandir}/man8/*
|
||||
/usr/sbin/mcelog
|
||||
/etc/cron.hourly/mcelog
|
||||
/etc/logrotate.d/mcelog
|
||||
%config /etc/logrotate.d/mcelog
|
||||
/etc/init.d/mcelog
|
||||
/usr/sbin/rcmcelog
|
||||
|
||||
%changelog
|
||||
|
85
mcelog_daemon_create_pid_file.patch
Normal file
85
mcelog_daemon_create_pid_file.patch
Normal file
@ -0,0 +1,85 @@
|
||||
mcelog daemon: Add pid file handling
|
||||
|
||||
Signed-off-by: Thomas Renninger <trenn@suse.de>
|
||||
|
||||
---
|
||||
mcelog.c | 41 +++++++++++++++++++++++++++++++++++++++--
|
||||
paths.h | 2 ++
|
||||
2 files changed, 41 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/mcelog.c b/mcelog.c
|
||||
index e166f57..a556664 100644
|
||||
--- a/mcelog.c
|
||||
+++ b/mcelog.c
|
||||
@@ -35,6 +35,8 @@
|
||||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
#include <pwd.h>
|
||||
+#include <signal.h>
|
||||
+
|
||||
#include "mcelog.h"
|
||||
#include "paths.h"
|
||||
#include "k8.h"
|
||||
@@ -977,6 +979,37 @@ static void process_mcefd(struct pollfd *pfd, void *data)
|
||||
process(pfd->fd, d->recordlen, d->loglen, d->buf);
|
||||
}
|
||||
|
||||
+void exit_handler (int signal)
|
||||
+{
|
||||
+ remove(DAEMON_PID_PATH);
|
||||
+}
|
||||
+
|
||||
+static int daemonize(int foreground)
|
||||
+{
|
||||
+ int ret;
|
||||
+ pid_t pid;
|
||||
+ FILE *fd;
|
||||
+
|
||||
+ fd = fopen(DAEMON_PID_PATH, "r");
|
||||
+ if (!fd) {
|
||||
+ if (!foreground) {
|
||||
+ ret = daemon(0, need_stdout());
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ }
|
||||
+ fd = fopen(DAEMON_PID_PATH, "w+");
|
||||
+ if (!fd)
|
||||
+ return -1;
|
||||
+ pid = getpid();
|
||||
+ fprintf(fd, "%d\n", pid);
|
||||
+ fclose(fd);
|
||||
+ signal(SIGKILL, exit_handler);
|
||||
+ signal(SIGTERM, exit_handler);
|
||||
+ return 0;
|
||||
+ } else
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
struct mcefd_data d = {};
|
||||
@@ -1031,8 +1064,12 @@ int main(int ac, char **av)
|
||||
page_setup();
|
||||
drop_cred();
|
||||
register_pollcb(fd, POLLIN, process_mcefd, &d);
|
||||
- if (!foreground && daemon(0, need_stdout()) < 0)
|
||||
- err("daemon");
|
||||
+ if (daemonize(foreground) < 0) {
|
||||
+ fprintf(stderr, "Could not run in background or create"
|
||||
+ " pidfile: " DAEMON_PID_PATH "\n");
|
||||
+ fprintf(stderr, "Is the daemon already running?\n");
|
||||
+ exit(1);
|
||||
+ }
|
||||
eventloop();
|
||||
} else {
|
||||
process(fd, d.recordlen, d.loglen, d.buf);
|
||||
diff --git a/paths.h b/paths.h
|
||||
index 6780552..efda627 100644
|
||||
--- a/paths.h
|
||||
+++ b/paths.h
|
||||
@@ -5,3 +5,5 @@
|
||||
#define CONFIG_FILENAME PREFIX "/etc/mcelog/mcelog.conf"
|
||||
|
||||
#define SOCKET_PATH "/var/run/mcelog-client"
|
||||
+
|
||||
+#define DAEMON_PID_PATH "/var/run/mcelog.pid"
|
Loading…
Reference in New Issue
Block a user