Commit 13cc7b84 authored by Michele Tartara's avatar Michele Tartara

Add the core of the monitoring daemon

This commit adds the core infrastructure of the monitoring daemon,
and integrates it in the build and test systems.

The actual functionality of the monitoring daemon is still completely
missing.
Signed-off-by: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent cb44e3db
......@@ -122,6 +122,7 @@
/src/htools
/src/hconfd
/src/ganeti-confd
/src/ganeti-mond
/src/rpc-test
# automatically-built Haskell files
......
......@@ -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 \
......
......@@ -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])
......
......@@ -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@"
;;
......
......@@ -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
......
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:
{-# 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 ()
{-| 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
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment