diff --git a/.gitignore b/.gitignore index 9bd9c2fcb418b2879004759957099de8c1814ccf..8656a8abc99e4eb6a75bb80ce804710833bbf85c 100644 --- a/.gitignore +++ b/.gitignore @@ -122,6 +122,7 @@ /src/htools /src/hconfd /src/ganeti-confd +/src/ganeti-mond /src/rpc-test # automatically-built Haskell files diff --git a/Makefile.am b/Makefile.am index 47cca9fcab14d5a9a12db2e045ff06dd1fdccfd6..b43c18787c53467c2510be397e0405caeac851b0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,6 +71,7 @@ HS_DIRS = \ src/Ganeti/HTools/Program \ src/Ganeti/Hypervisor \ src/Ganeti/Hypervisor/Xen \ + src/Ganeti/Monitoring \ src/Ganeti/Query \ test/hs \ test/hs/Test \ @@ -193,6 +194,7 @@ CLEANFILES = \ $(HS_ALL_PROGS) $(HS_BUILT_SRCS) \ $(HS_BUILT_TEST_HELPERS) \ src/ganeti-confd \ + src/ganeti-mond \ .hpc/*.mix src/*.tix test/hs/*.tix \ doc/hs-lint.html @@ -207,6 +209,10 @@ HS_GENERATED_FILES += $(HS_PROGS) if ENABLE_CONFD HS_GENERATED_FILES += src/hconfd src/ganeti-confd endif + +if ENABLE_MOND +HS_GENERATED_FILES += src/ganeti-mond +endif endif built_base_sources = \ @@ -434,9 +440,9 @@ HS_BIN_PROGS=src/htools # Haskell programs to be installed in the MYEXECLIB dir HS_MYEXECLIB_PROGS=src/mon-collector -# Haskell programs to compiled but not installed automatically -# Usually they have their own specific installation rules +# Haskell programs to be compiled by "make really-all" HS_COMPILE_PROGS= \ + src/ganeti-mond \ src/hconfd \ src/rpc-test @@ -530,6 +536,7 @@ HS_LIB_SRCS = \ src/Ganeti/Jobs.hs \ src/Ganeti/Logging.hs \ src/Ganeti/Luxi.hs \ + src/Ganeti/Monitoring/Server.hs \ src/Ganeti/Network.hs \ src/Ganeti/Objects.hs \ src/Ganeti/OpCodes.hs \ @@ -828,6 +835,10 @@ src/ganeti-confd: src/hconfd nodist_sbin_SCRIPTS += src/ganeti-confd endif +if ENABLE_MOND +nodist_sbin_SCRIPTS += src/ganeti-mond +endif + python_scripts = \ tools/cfgshell \ tools/cfgupgrade \ @@ -933,6 +944,7 @@ man_MANS = \ man/ganeti-confd.8 \ man/ganeti-listrunner.8 \ man/ganeti-masterd.8 \ + man/ganeti-mond.8 \ man/ganeti-noded.8 \ man/ganeti-os-interface.7 \ man/ganeti-extstorage-interface.7 \ diff --git a/configure.ac b/configure.ac index 1a17cc13364314c870053bc2bec8d4ed2ff04765..dd1061290890441910edd9a96fd71c10569b7f4a 100644 --- a/configure.ac +++ b/configure.ac @@ -484,7 +484,7 @@ AC_ARG_ENABLE([confd], ENABLE_MOND= AC_ARG_ENABLE([monitoring], [AS_HELP_STRING([--enable-monitoring], - [enable the ganeti monitoring agent (default: check)])], + [enable the ganeti monitoring daemon (default: check)])], [], [enable_monitoring=check]) @@ -558,17 +558,19 @@ fi AC_SUBST(ENABLE_CONFD, $has_confd) AM_CONDITIONAL([ENABLE_CONFD], [test x$has_confd = xTrue]) -#extra modules for monitoring agent functionality +#extra modules for monitoring daemon functionality has_monitoring=False if test "$enable_monitoring" != no; then MONITORING_PKG= AC_GHC_PKG_CHECK([attoparsec], [], [MONITORING_PKG="$MONITORING_PKG attoparsec"]) + AC_GHC_PKG_CHECK([snap-server], [], + [MONITORING_PKG="$MONITORING_PKG snap-server"]) if test -z "$MONITORING_PKG"; then has_monitoring=True elif test "$enable_monitoring" = check; then AC_MSG_WARN(m4_normalize([The required extra libraries for the monitoring - agent were not found ($MONITORING_PKG), + daemon were not found ($MONITORING_PKG), monitoring disabled])) else AC_MSG_FAILURE(m4_normalize([The monitoring functionality was requested, but @@ -577,7 +579,7 @@ if test "$enable_monitoring" != no; then fi fi if test "$has_monitoring" = True; then - AC_MSG_NOTICE([Enabling the monitoring agent usage]) + AC_MSG_NOTICE([Enabling the monitoring daemon usage]) fi AC_SUBST(ENABLE_MOND, $has_monitoring) AM_CONDITIONAL([ENABLE_MOND], [test "$has_monitoring" = True]) diff --git a/daemons/daemon-util.in b/daemons/daemon-util.in index 786c4b003d95ae0742a62890efcc4a255d43abdc..fbabdfe470a531b8483e00459ad4d002fdcf851b 100644 --- a/daemons/daemon-util.in +++ b/daemons/daemon-util.in @@ -41,10 +41,19 @@ if _confd_enabled; then DAEMONS+=( ganeti-confd ) fi +_mond_enabled() { + [[ "@CUSTOM_ENABLE_MOND@" == True ]] +} + +if _mond_enabled; then + DAEMONS+=( ganeti-mond ) +fi + NODED_ARGS= MASTERD_ARGS= CONFD_ARGS= RAPI_ARGS= +MOND_ARGS= # Read defaults file if it exists if [[ -s $defaults_file ]]; then @@ -79,6 +88,9 @@ _daemon_usergroup() { noded) echo "@GNTNODEDUSER@:@GNTDAEMONSGROUP@" ;; + mond) + echo "@GNTMONDUSER@:@GNTMONDGROUP@" + ;; *) echo "root:@GNTDAEMONSGROUP@" ;; diff --git a/lib/constants.py b/lib/constants.py index e3be62efd77f05074984e7b99b7089bb35756b4d..3b03a0b24b70d9c12ffffedde488f65fdd4c0e76 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -171,12 +171,14 @@ DAEMONS_PORTS = { # daemon-name: ("proto", "default-port") NODED: ("tcp", 1811), CONFD: ("udp", 1814), + MOND: ("tcp", 1815), RAPI: ("tcp", 5080), SSH: ("tcp", 22), } DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1] DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1] +DEFAULT_MOND_PORT = DAEMONS_PORTS[MOND][1] DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1] FIRST_DRBD_PORT = 11000 diff --git a/man/ganeti-mond.rst b/man/ganeti-mond.rst new file mode 100644 index 0000000000000000000000000000000000000000..65c35db399475b3eaf9c2c9ec531a39dafe9d9ba --- /dev/null +++ b/man/ganeti-mond.rst @@ -0,0 +1,13 @@ +ganeti-mond(8) Ganeti | Version @GANETI_VERSION@ +================================================= + +Name +---- + +ganeti-mond - Ganeti monitoring daemon + +.. vim: set textwidth=72 : +.. Local Variables: +.. mode: rst +.. fill-column: 72 +.. End: diff --git a/src/Ganeti/Monitoring/Server.hs b/src/Ganeti/Monitoring/Server.hs new file mode 100644 index 0000000000000000000000000000000000000000..2448d8b052ca3295e9e963d1b94042089ffe05d7 --- /dev/null +++ b/src/Ganeti/Monitoring/Server.hs @@ -0,0 +1,57 @@ +{-# LANGUAGE OverloadedStrings #-} + +{-| Implementation of the Ganeti confd server functionality. + +-} + +{- + +Copyright (C) 2013 Google Inc. + +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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. + +-} + +module Ganeti.Monitoring.Server + ( main + , checkMain + , prepMain + ) where + +import Ganeti.Daemon + +-- * Types and constants definitions + +-- | Type alias for checkMain results. +type CheckResult = () + +-- | Type alias for prepMain results. +type PrepResult = () + +-- * Helper functions + +-- | Check function for the monitoring agent. +checkMain :: CheckFn CheckResult +checkMain _ = return $ Right () + +-- | Prepare function for monitoring agent. +prepMain :: PrepFn CheckResult PrepResult +prepMain _ _ = return () + +-- | Main function. +main :: MainFn CheckResult PrepResult +main _ _ _ = + return () diff --git a/src/ganeti-mond.hs b/src/ganeti-mond.hs new file mode 100644 index 0000000000000000000000000000000000000000..a7d554176cb4801cab4d93e8357b996f608996da --- /dev/null +++ b/src/ganeti-mond.hs @@ -0,0 +1,48 @@ +{-| Ganeti monitoring agent daemon + +-} + +{- + +Copyright (C) 2013 Google Inc. + +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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. + +-} + +module Main (main) where + +import qualified Ganeti.Monitoring.Server +import Ganeti.Daemon +import Ganeti.Runtime +import qualified Ganeti.Constants as C + +-- | Options list and functions. +options :: [OptType] +options = + [ oNoDaemonize + , oNoUserChecks + , oDebug + , oPort C.defaultMondPort + ] + +-- | Main function. +main :: IO () +main = + genericMain GanetiMond options + Ganeti.Monitoring.Server.checkMain + Ganeti.Monitoring.Server.prepMain + Ganeti.Monitoring.Server.main diff --git a/test/py/daemon-util_unittest.bash b/test/py/daemon-util_unittest.bash index aa3ededc04a5da1b7cfe628069de6d1692a0cbb8..75414ebeb23a79bdbba1f5923b550b6d6de668fd 100755 --- a/test/py/daemon-util_unittest.bash +++ b/test/py/daemon-util_unittest.bash @@ -32,14 +32,26 @@ if ! grep -q '^ENABLE_CONFD = ' lib/_autoconf.py; then err "Please update $0, confd enable feature is missing" fi +if ! grep -q '^ENABLE_MOND = ' lib/_autoconf.py; then + err "Please update $0, mond enable feature is missing" +fi + +DAEMONS_LIST="noded masterd rapi" +STOPDAEMONS_LIST="rapi masterd noded" + if grep -q '^ENABLE_CONFD = True' lib/_autoconf.py; then - DAEMONS="$(echo ganeti-{noded,masterd,rapi,confd})" - STOPDAEMONS="$(echo ganeti-{confd,rapi,masterd,noded})" -else - DAEMONS="$(echo ganeti-{noded,masterd,rapi})" - STOPDAEMONS="$(echo ganeti-{rapi,masterd,noded})" + DAEMONS_LIST="$DAEMONS_LIST confd" + STOPDAEMONS_LIST="confd $STOPDAEMONS_LIST" fi +if grep -q '^ENABLE_MOND = True' lib/_autoconf.py; then + DAEMONS_LIST="$DAEMONS_LIST mond" + STOPDAEMONS_LIST="mond $STOPDAEMONS_LIST" +fi + +DAEMONS=$(echo $(for d in $DAEMONS_LIST; do echo "ganeti-$d"; done)) +STOPDAEMONS=$(echo $(for d in $STOPDAEMONS_LIST; do echo "ganeti-$d"; done)) + $daemon_util >/dev/null 2>&1 && err "daemon-util succeeded without command"