diff options
author | Matt Spinler <spinler@us.ibm.com> | 2017-06-02 12:15:59 -0500 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2017-06-02 13:29:43 -0500 |
commit | 62b36bd882b12c7eea4e24e2438da05a719c8d97 (patch) | |
tree | 531cad5631214ac77bb82e8e2a9bc3c795d325cf | |
parent | a33fbf51b5133d9e984aa9863b75896ee220ef1a (diff) | |
download | phosphor-objmgr-62b36bd882b12c7eea4e24e2438da05a719c8d97.tar.gz phosphor-objmgr-62b36bd882b12c7eea4e24e2438da05a719c8d97.zip |
Add phosphor-unit-failure-monitor framework
This application is designed to be called from the
OnFailure directive in a systemd unit file. It will
stop or start another unit when the current unit
fails enough times to exceed its restart policy so
it isn't restarted again.
To do this, this application will check the ActiveState
property of the failing unit. When it is 'failed', the
target unit will be started (or stopped).
The failing unit name, the target unit name, and if the
target should be stopped or started are all passed in
on the command line.
Change-Id: I93ecccaf1c091abddb769ddad8f43ecd9902210b
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | fail-monitor/Makefile.am | 7 | ||||
-rw-r--r-- | fail-monitor/main.cpp | 30 |
4 files changed, 44 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index 7f99e00..d373416 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,3 +34,5 @@ uninstall-hook: | $(AWK) '{print "$(DESTDIR)"$$1}' | xargs rm -fv endif + +SUBDIRS = fail-monitor diff --git a/configure.ac b/configure.ac index bd80240..10ea4af 100644 --- a/configure.ac +++ b/configure.ac @@ -5,6 +5,7 @@ AC_CONFIG_HEADERS([libmapper/config.h]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) AM_SILENT_RULES([yes]) +AC_LANG([C++]) # Modify header template AH_TOP([#pragma once]) @@ -12,6 +13,7 @@ AH_BOTTOM([#include "libmapper/workaround/systemd.h"]) # Checks for programs. AC_PROG_CC +AC_PROG_CXX AM_PROG_AR AC_PROG_INSTALL AC_PROG_MAKE_SET @@ -29,7 +31,8 @@ PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221]) AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd development package required])]) # Checks for typedefs, structures, and compiler characteristics. -AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CFLAGS]) +AX_CXX_COMPILE_STDCXX_14([noext]) +AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CFLAGS CXXFLAGS]) # Checks for library functions. LT_INIT([disable-static shared]) @@ -72,5 +75,5 @@ AS_IF([test "x$enable_unpatched_systemd" == "xyes"], ) # Create configured output -AC_CONFIG_FILES([Makefile setup.py]) +AC_CONFIG_FILES([Makefile setup.py fail-monitor/Makefile]) AC_OUTPUT diff --git a/fail-monitor/Makefile.am b/fail-monitor/Makefile.am new file mode 100644 index 0000000..1976be1 --- /dev/null +++ b/fail-monitor/Makefile.am @@ -0,0 +1,7 @@ +AM_DEFAULT_SOURCE_EXT = .cpp + +sbin_PROGRAMS = \ + phosphor-unit-failure-monitor + +phosphor_unit_failure_monitor_SOURCES = \ + main.cpp diff --git a/fail-monitor/main.cpp b/fail-monitor/main.cpp new file mode 100644 index 0000000..b13dc7f --- /dev/null +++ b/fail-monitor/main.cpp @@ -0,0 +1,30 @@ +/** + * Copyright © 2017 IBM Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This application will check the ActiveState property + * on the source unit passed in. If that state is 'failed', + * then it will either stop or start the target unit, depending + * on the command line arguments. + */ + + +int main(int argc, char** argv) +{ + + + return 0; +} |