]> granicus.if.org Git - sysstat/commitdiff
systemd support added.
authorseb <seb@kluane.home>
Mon, 3 Sep 2012 19:23:20 +0000 (21:23 +0200)
committerseb <seb@kluane.home>
Mon, 3 Sep 2012 19:23:20 +0000 (21:23 +0200)
Sysstat service unit file has been added to replace init script
for systems with systemd support.

Mail from Peter Schiffer <pschiffe@redhat.com> 24/08/2012:

I am sending you a patch which adds support for systemd to sysstat. With this patch, configure script detects whether the system uses systemd, and if yes, it installs the unit file and enables the sysstat service. Then, init script is not used.

Systemd is default since Fedora 15, and many more distributions are slowly converting to it. For more information about it, see it's home page [1], man pages about unit files and integration into autotools can be found at [2 - 6]. General information about systemd can be found at [7].

What do you think?

CHANGES
Makefile.in
README
configure
configure.in
sysstat.service.in [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index df98806166845337a8e344f074afb034523f4701..aa165d2a8554e9ac3e4a916912aee881af8a9917 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,7 @@
 Changes:
 
 xxxx/xx/xx: Version 10.1.2 - Sebastien Godard (sysstat <at> orange.fr)
+       * [Peter Schiffer]: systemd support added.
        * [Peter Schiffer]: Sysstat init script updated to make it
          more conforming to LSB.
        * sar and sadf manual pages updated.
index b09a832f408893fc08b1560f31e15a6f70f431ac..e7f78a5a6e2184397b51cff1838c04165a42cd95 100644 (file)
@@ -122,6 +122,10 @@ ifndef INSTALL_DOC
 INSTALL_DOC = @INSTALL_DOC@
 endif
 
+# Systemd
+SYSTEMCTL = @SYSTEMCTL@
+SYSTEMD_UNIT_DIR = @SYSTEMD_UNIT_DIR@
+
 # Run-command directories
 ifndef RC_DIR
 RC_DIR = @RC_DIR@
@@ -356,7 +360,10 @@ install_all: install_base cron/crontab sysstat \
           echo "USER'S PREVIOUS CRONTAB SAVED IN CURRENT DIRECTORY (USING .save SUFFIX)."; \
           su $(CRON_OWNER) -c "crontab cron/crontab"; \
        fi
-       if [ -d $(DESTDIR)$(INIT_DIR) ]; then \
+       if [ -x $(SYSTEMCTL) -a -d "$(SYSTEMD_UNIT_DIR)" ]; then \
+           $(INSTALL_DATA) sysstat.service $(SYSTEMD_UNIT_DIR); \
+           $(SYSTEMCTL) enable sysstat.service; \
+       elif [ -d $(DESTDIR)$(INIT_DIR) ]; then \
           $(INSTALL_BIN) sysstat $(DESTDIR)$(INIT_DIR)/sysstat; \
           if [ -x $(CHKCONFIG) ]; then \
              cd $(DESTDIR)$(INIT_DIR) && $(CHKCONFIG) --add sysstat; \
@@ -456,6 +463,10 @@ uninstall_all: uninstall_base
        -$(CP) -a /tmp/crontab-$(CRON_OWNER).old ./crontab-$(CRON_OWNER).`date '+%Y%m%d.%H%M%S'`.old
        @echo "USER CRONTAB SAVED IN CURRENT DIRECTORY (WITH .old SUFFIX)."
        -su $(CRON_OWNER) -c "crontab -r"
+       if [ -x $(SYSTEMCTL) -a -d "$(SYSTEMD_UNIT_DIR)" ]; then \
+           $(SYSTEMCTL) disable sysstat.service; \
+           rm -f $(SYSTEMD_UNIT_DIR)/sysstat.service; \
+       fi
 
 ifeq ($(INSTALL_CRON),y)
 uninstall: uninstall_all
@@ -481,7 +492,7 @@ clean:
 
 almost-distclean: clean nls/sysstat.pot
        rm -f sa1 sa2 sysstat cron/crontab version.h sysconfig.h
-       rm -f sysstat.sysconfig cron/sysstat.crond cron/sysstat.cron.daily
+       rm -f sysstat.sysconfig cron/sysstat.crond cron/sysstat.cron.daily sysstat.service
        rm -f cron/sysstat.cron.hourly cron/sysstat.crond.sample cron/sysstat.crond.sample.in
        rm -f contrib/isag/isag
        rm -f man/sa1.8 man/sa2.8 man/sadc.8 man/sadf.1 man/sar.1 man/iostat.1 man/sysstat.5
diff --git a/README b/README
index 657c46cf4c3d73a91b820b248f6e32665ec33182..beabe7d6055dc91474d4f31cb6cfc5aa1e90ad40 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 sysstat: System performance tools for the Linux operating system...
 --
-(C) 1999-2011 Sebastien Godard (sysstat <at> orange.fr)
+(C) 1999-2012 Sebastien GODARD (sysstat <at> orange.fr)
 
 The latest version of sysstat can always be found on my web site at:
 
@@ -88,6 +88,7 @@ ${PREFIX}/share/locale/*/LC_MESSAGES/sysstat.mo
 ${PREFIX}/share/doc/sysstat-x.y.z/*
 /var/log/sa
 ${INIT_DIR}/sysstat
+/lib/systemd/system/sysstat.service            if OS uses systemd
 /etc/sysconfig/sysstat
 /etc/sysconfig/sysstat.ioconf
 /etc/cron.d/sysstat
@@ -127,5 +128,5 @@ Anyway you are welcome if you want to make other translations available ;-)
 Please read the README-nls file in the nls directory before.
 
 --
-Sebastien Godard (sysstat <at> orange.fr)
+Sebastien GODARD (sysstat <at> orange.fr)
 
index 51ab1b098ba52f9fd526356111f32460ca34d22c..75171813ce496826ee1ee764287f153c9f531795 100755 (executable)
--- a/configure
+++ b/configure
@@ -641,6 +641,11 @@ rcdir
 DFSENSORS
 LFSENSORS
 HAVE_SENSORS
+SYSTEMD_UNIT_DIR
+SYSTEMCTL
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 PATH_CHKCONFIG
 PATH_CP
 INSTALL_BIN
@@ -705,6 +710,7 @@ SHELL'
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
+with_systemdsystemunitdir
 enable_sensors
 enable_largefile
 enable_nls
@@ -728,6 +734,9 @@ LDFLAGS
 LIBS
 CPPFLAGS
 CPP
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
 rcdir
 sa_lib_dir
 sa_dir
@@ -1362,6 +1371,12 @@ Optional Features:
   --enable-debuginfo      enable debug output (--debuginfo option)
   --disable-stripping     do not strip object files
 
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-systemdsystemunitdir=DIR
+                          Directory for systemd service files
+
 Some influential environment variables:
   CC          C compiler command
   CFLAGS      C compiler flags
@@ -1371,6 +1386,11 @@ Some influential environment variables:
   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
   rcdir       run-commands directory
   sa_lib_dir  sadc directory
   sa_dir      system activity directory
@@ -3893,6 +3913,185 @@ done
 test -n "$PATH_CHKCONFIG" || PATH_CHKCONFIG="chkconfig"
 
 
+# Check for systemd
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+       if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+       _pkg_min_version=0.9.0
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+       if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       else
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+               PKG_CONFIG=""
+       fi
+fi
+for ac_prog in systemctl
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_SYSTEMCTL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $SYSTEMCTL in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_SYSTEMCTL="$SYSTEMCTL" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin /etc /sbin /usr/bin /usr/etc /usr/sbin /usr/ucb /usr/local/bin /usr/local/etc /usr/local/sbin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_SYSTEMCTL="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+SYSTEMCTL=$ac_cv_path_SYSTEMCTL
+if test -n "$SYSTEMCTL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SYSTEMCTL" >&5
+$as_echo "$SYSTEMCTL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$SYSTEMCTL" && break
+done
+test -n "$SYSTEMCTL" || SYSTEMCTL="systemctl"
+
+
+# Check whether --with-systemdsystemunitdir was given.
+if test "${with_systemdsystemunitdir+set}" = set; then :
+  withval=$with_systemdsystemunitdir;
+else
+  with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
+fi
+
+if test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ; then
+    SYSTEMD_UNIT_DIR=$with_systemdsystemunitdir
+
+fi
+
 # Check libraries
 
 # Check header files
@@ -5240,6 +5439,8 @@ ac_config_files="$ac_config_files cron/sysstat.crond.sample.in:cron/sysstat.cron
 
 ac_config_files="$ac_config_files sysstat"
        # Permissions must be changed
+ac_config_files="$ac_config_files sysstat.service"
+
 ac_config_files="$ac_config_files man/sa1.8:man/sa1.in"
                # File must be renamed
 ac_config_files="$ac_config_files man/sa2.8:man/sa2.in"
@@ -5991,6 +6192,7 @@ do
     "cron/sysstat.crond") CONFIG_FILES="$CONFIG_FILES cron/sysstat.crond" ;;
     "cron/sysstat.crond.sample.in") CONFIG_FILES="$CONFIG_FILES cron/sysstat.crond.sample.in:cron/sysstat.crond.in" ;;
     "sysstat") CONFIG_FILES="$CONFIG_FILES sysstat" ;;
+    "sysstat.service") CONFIG_FILES="$CONFIG_FILES sysstat.service" ;;
     "man/sa1.8") CONFIG_FILES="$CONFIG_FILES man/sa1.8:man/sa1.in" ;;
     "man/sa2.8") CONFIG_FILES="$CONFIG_FILES man/sa2.8:man/sa2.in" ;;
     "man/sadc.8") CONFIG_FILES="$CONFIG_FILES man/sadc.8:man/sadc.in" ;;
@@ -6466,6 +6668,7 @@ echo "
    Installation prefix:                $prefix
    rc directory:               ${RC_DIR}
    Init directory:             ${INIT_DIR}
+   Systemd unit dir:           ${with_systemdsystemunitdir}
    Configuration directory:    ${SYSCONFIG_DIR}
    Man pages directory:                $mandir
    Compiler:                   $CC
index 85b1cdfed758452920f43308304803b234967777..7e66c302fb904d4ee6124d15ce24d0e6116ea35b 100644 (file)
@@ -39,6 +39,16 @@ AC_SUBST(INSTALL_BIN)
 AC_PATH_PROGS(PATH_CP, cp, cp, /bin /etc /sbin /usr/bin /usr/etc /usr/sbin /usr/ucb /usr/local/bin /usr/local/etc /usr/local/sbin)
 AC_PATH_PROGS(PATH_CHKCONFIG, chkconfig, chkconfig, /bin /etc /sbin /usr/bin /usr/etc /usr/sbin /usr/ucb /usr/local/bin /usr/local/etc /usr/local/sbin)
 
+# Check for systemd
+PKG_PROG_PKG_CONFIG
+AC_PATH_PROGS(SYSTEMCTL, systemctl, systemctl, /bin /etc /sbin /usr/bin /usr/etc /usr/sbin /usr/ucb /usr/local/bin /usr/local/etc /usr/local/sbin)
+AC_ARG_WITH([systemdsystemunitdir],
+    AS_HELP_STRING([--with-systemdsystemunitdir=DIR],[Directory for systemd service files]),
+    [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
+if test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ; then
+    AC_SUBST([SYSTEMD_UNIT_DIR], [$with_systemdsystemunitdir])
+fi
+
 # Check libraries
 
 # Check header files
@@ -557,6 +567,7 @@ AC_CONFIG_FILES([cron/sysstat.cron.hourly])
 AC_CONFIG_FILES([cron/sysstat.crond])
 AC_CONFIG_FILES([cron/sysstat.crond.sample.in:cron/sysstat.crond.in], [sed s/^/#/ cron/sysstat.crond.sample.in > cron/sysstat.crond.sample])
 AC_CONFIG_FILES([sysstat], [chmod +x sysstat]) # Permissions must be changed
+AC_CONFIG_FILES([sysstat.service])
 AC_CONFIG_FILES([man/sa1.8:man/sa1.in])                # File must be renamed
 AC_CONFIG_FILES([man/sa2.8:man/sa2.in])                # File must be renamed
 AC_CONFIG_FILES([man/sadc.8:man/sadc.in])      # File must be renamed
@@ -575,6 +586,7 @@ echo "
    Installation prefix:                $prefix
    rc directory:               ${RC_DIR}
    Init directory:             ${INIT_DIR}
+   Systemd unit dir:           ${with_systemdsystemunitdir}
    Configuration directory:    ${SYSCONFIG_DIR}
    Man pages directory:                $mandir
    Compiler:                   $CC
diff --git a/sysstat.service.in b/sysstat.service.in
new file mode 100644 (file)
index 0000000..cbeab69
--- /dev/null
@@ -0,0 +1,19 @@
+# @SYSTEMD_UNIT_DIR@/sysstat.service
+# (C) 2012 Peter Schiffer (pschiffe <at> redhat.com)
+#
+# @PACKAGE_NAME@-@PACKAGE_VERSION@ systemd unit file:
+#       Insert a dummy record in current daily data file.
+#       This indicates that the counters have restarted from 0.
+
+[Unit]
+Description=Resets System Activity Logs
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+User=@CRON_OWNER@
+ExecStart=@SA_LIB_DIR@/sa1 --boot
+
+[Install]
+WantedBy=multi-user.target
+