Revision 332b1340
b/.gitignore | ||
---|---|---|
115 | 115 |
/htools/.hpc |
116 | 116 |
/htools/coverage |
117 | 117 |
|
118 |
/htools/mon-collector |
|
118 | 119 |
/htools/htools |
119 | 120 |
/htools/hconfd |
120 | 121 |
/htools/ganeti-confd |
b/Makefile.am | ||
---|---|---|
60 | 60 |
htools/Ganeti/Block \ |
61 | 61 |
htools/Ganeti/Block/Drbd \ |
62 | 62 |
htools/Ganeti/Confd \ |
63 |
htools/Ganeti/DataCollectors \ |
|
63 | 64 |
htools/Ganeti/HTools \ |
64 | 65 |
htools/Ganeti/HTools/Backend \ |
65 | 66 |
htools/Ganeti/HTools/Program \ |
... | ... | |
113 | 114 |
$(APIDOC_HS_DIR)/Ganeti/Block \ |
114 | 115 |
$(APIDOC_HS_DIR)/Ganeti/Block/Drbd \ |
115 | 116 |
$(APIDOC_HS_DIR)/Ganeti/Confd \ |
117 |
$(APIDOC_HS_DIR)/Ganeti/DataCollectors \ |
|
116 | 118 |
$(APIDOC_HS_DIR)/Ganeti/HTools \ |
117 | 119 |
$(APIDOC_HS_DIR)/Ganeti/HTools/Backend \ |
118 | 120 |
$(APIDOC_HS_DIR)/Ganeti/HTools/Program \ |
... | ... | |
404 | 406 |
doc/virtual-cluster.rst \ |
405 | 407 |
doc/walkthrough.rst |
406 | 408 |
|
407 |
HS_PROGS = htools/htools |
|
409 |
HS_PROGS = htools/htools htools/mon-collector
|
|
408 | 410 |
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck |
409 | 411 |
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail |
410 | 412 |
|
... | ... | |
452 | 454 |
htools/Ganeti/Confd/Utils.hs \ |
453 | 455 |
htools/Ganeti/Config.hs \ |
454 | 456 |
htools/Ganeti/Daemon.hs \ |
457 |
htools/Ganeti/DataCollectors/Drbd.hs \ |
|
458 |
htools/Ganeti/DataCollectors/Program.hs \ |
|
455 | 459 |
htools/Ganeti/Errors.hs \ |
456 | 460 |
htools/Ganeti/HTools/Backend/IAlloc.hs \ |
457 | 461 |
htools/Ganeti/HTools/Backend/Luxi.hs \ |
... | ... | |
743 | 747 |
myexeclib_SCRIPTS = \ |
744 | 748 |
daemons/daemon-util \ |
745 | 749 |
tools/kvm-ifup \ |
746 |
$(pkglib_python_scripts) |
|
750 |
$(pkglib_python_scripts) \ |
|
751 |
htools/mon-collector |
|
747 | 752 |
|
748 | 753 |
nodist_myexeclib_SCRIPTS = \ |
749 | 754 |
$(nodist_pkglib_python_scripts) |
... | ... | |
829 | 834 |
man/hinfo.1 \ |
830 | 835 |
man/hscan.1 \ |
831 | 836 |
man/hspace.1 \ |
832 |
man/htools.1 |
|
837 |
man/htools.1 \ |
|
838 |
man/mon-collector.7 |
|
833 | 839 |
|
834 | 840 |
manrst = $(patsubst %.1,%.rst,$(patsubst %.7,%.rst,$(patsubst %.8,%.rst,$(man_MANS)))) |
835 | 841 |
manhtml = $(patsubst %.rst,%.html,$(manrst)) |
b/htools/Ganeti/DataCollectors/Drbd.hs | ||
---|---|---|
1 |
{-| DRBD data collector. |
|
2 |
|
|
3 |
-} |
|
4 |
|
|
5 |
{- |
|
6 |
|
|
7 |
Copyright (C) 2012 Google Inc. |
|
8 |
|
|
9 |
This program is free software; you can redistribute it and/or modify |
|
10 |
it under the terms of the GNU General Public License as published by |
|
11 |
the Free Software Foundation; either version 2 of the License, or |
|
12 |
(at your option) any later version. |
|
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, but |
|
15 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
17 |
General Public License for more details. |
|
18 |
|
|
19 |
You should have received a copy of the GNU General Public License |
|
20 |
along with this program; if not, write to the Free Software |
|
21 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
22 |
02110-1301, USA. |
|
23 |
|
|
24 |
-} |
|
25 |
|
|
26 |
module Ganeti.DataCollectors.Drbd |
|
27 |
( main |
|
28 |
, options |
|
29 |
, arguments |
|
30 |
) where |
|
31 |
|
|
32 |
|
|
33 |
import qualified Control.Exception as E |
|
34 |
import Data.Attoparsec.Text.Lazy as A |
|
35 |
import Data.Text.Lazy (pack, unpack) |
|
36 |
import Text.JSON |
|
37 |
|
|
38 |
import qualified Ganeti.BasicTypes as BT |
|
39 |
import qualified Ganeti.Constants as C |
|
40 |
import Ganeti.Block.Drbd.Parser(drbdStatusParser) |
|
41 |
import Ganeti.Common |
|
42 |
import Ganeti.HTools.CLI |
|
43 |
import Ganeti.Utils |
|
44 |
|
|
45 |
|
|
46 |
-- | The default path of the DRBD status file. |
|
47 |
-- It is hardcoded because it is not likely to change. |
|
48 |
defaultFile :: FilePath |
|
49 |
defaultFile = C.drbdStatusFile |
|
50 |
|
|
51 |
-- | The default setting for the maximum amount of not parsed character to |
|
52 |
-- print in case of error. |
|
53 |
-- It is set to use most of the screen estate on a standard 80x25 terminal. |
|
54 |
-- TODO: add the possibility to set this with a command line parameter. |
|
55 |
defaultCharNum :: Int |
|
56 |
defaultCharNum = 80*20 |
|
57 |
|
|
58 |
options :: IO [OptType] |
|
59 |
options = return [] |
|
60 |
|
|
61 |
-- | The list of arguments supported by the program. |
|
62 |
arguments :: [ArgCompletion] |
|
63 |
arguments = [ArgCompletion OptComplFile 0 (Just 1)] |
|
64 |
|
|
65 |
|
|
66 |
-- * Command line options |
|
67 |
|
|
68 |
-- | Main function. |
|
69 |
main :: Options -> [String] -> IO () |
|
70 |
main _ args = do |
|
71 |
contents <- |
|
72 |
((E.try . readFile $ getInputPath args) :: IO (Either IOError String)) >>= |
|
73 |
exitIfBad "Error reading from file" . either (BT.Bad . show) BT.Ok |
|
74 |
output <- |
|
75 |
case A.parse drbdStatusParser $ pack contents of |
|
76 |
A.Fail unparsedText contexts errorMessage -> exitErr $ |
|
77 |
show (Prelude.take defaultCharNum $ unpack unparsedText) ++ "\n" |
|
78 |
++ show contexts ++ "\n" ++ errorMessage |
|
79 |
A.Done _ drbdStatus -> return $ encode drbdStatus |
|
80 |
putStrLn output |
|
81 |
where getInputPath a = |
|
82 |
if null a |
|
83 |
then defaultFile |
|
84 |
else head a |
b/htools/Ganeti/DataCollectors/Program.hs | ||
---|---|---|
1 |
{-| Small module holding program definitions for data collectors. |
|
2 |
|
|
3 |
-} |
|
4 |
|
|
5 |
{- |
|
6 |
|
|
7 |
Copyright (C) 2012 Google Inc. |
|
8 |
|
|
9 |
This program is free software; you can redistribute it and/or modify |
|
10 |
it under the terms of the GNU General Public License as published by |
|
11 |
the Free Software Foundation; either version 2 of the License, or |
|
12 |
(at your option) any later version. |
|
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, but |
|
15 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
17 |
General Public License for more details. |
|
18 |
|
|
19 |
You should have received a copy of the GNU General Public License |
|
20 |
along with this program; if not, write to the Free Software |
|
21 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
22 |
02110-1301, USA. |
|
23 |
|
|
24 |
-} |
|
25 |
|
|
26 |
module Ganeti.DataCollectors.Program (personalities) where |
|
27 |
|
|
28 |
import Ganeti.Common (ArgCompletion) |
|
29 |
import Ganeti.HTools.CLI (OptType, Options) |
|
30 |
|
|
31 |
import qualified Ganeti.DataCollectors.Drbd as Drbd |
|
32 |
|
|
33 |
-- | Supported binaries. |
|
34 |
personalities :: [(String, |
|
35 |
(Options -> [String] -> IO (), IO [OptType], |
|
36 |
[ArgCompletion]))] |
|
37 |
personalities = [ ("drbd", (Drbd.main, Drbd.options, Drbd.arguments)) |
|
38 |
] |
b/htools/mon-collector.hs | ||
---|---|---|
1 |
{-| Main binary for all stand-alone data collectors |
|
2 |
|
|
3 |
-} |
|
4 |
|
|
5 |
{- |
|
6 |
|
|
7 |
Copyright (C) 2012 Google Inc. |
|
8 |
|
|
9 |
This program is free software; you can redistribute it and/or modify |
|
10 |
it under the terms of the GNU General Public License as published by |
|
11 |
the Free Software Foundation; either version 2 of the License, or |
|
12 |
(at your option) any later version. |
|
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, but |
|
15 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
17 |
General Public License for more details. |
|
18 |
|
|
19 |
You should have received a copy of the GNU General Public License |
|
20 |
along with this program; if not, write to the Free Software |
|
21 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
22 |
02110-1301, USA. |
|
23 |
|
|
24 |
-} |
|
25 |
|
|
26 |
module Main (main) where |
|
27 |
|
|
28 |
import Data.Char (toLower) |
|
29 |
import System.Environment |
|
30 |
import System.IO |
|
31 |
|
|
32 |
import Ganeti.Utils |
|
33 |
import Ganeti.HTools.CLI (parseOpts, genericOpts) |
|
34 |
import Ganeti.DataCollectors.Program (personalities) |
|
35 |
|
|
36 |
-- | Display usage and exit. |
|
37 |
usage :: String -> IO () |
|
38 |
usage name = do |
|
39 |
hPutStrLn stderr $ "Unrecognised personality '" ++ name ++ "'." |
|
40 |
hPutStrLn stderr "This program must be executed specifying one of the \ |
|
41 |
\following names as the first parameter:" |
|
42 |
mapM_ (hPutStrLn stderr . (" - " ++) . fst) personalities |
|
43 |
exitErr "Please specify the desired role." |
|
44 |
|
|
45 |
main :: IO () |
|
46 |
main = do |
|
47 |
cmd_args <- getArgs |
|
48 |
let binary = |
|
49 |
if null cmd_args |
|
50 |
then "" |
|
51 |
else head cmd_args |
|
52 |
name = map toLower binary |
|
53 |
boolnames = map (\(x, y) -> (x == name, Just y)) personalities |
|
54 |
case select Nothing boolnames of |
|
55 |
Nothing -> usage name |
|
56 |
Just (fn, options, arguments) -> do |
|
57 |
let actual_args = tail cmd_args |
|
58 |
real_options <- options |
|
59 |
(opts, args) <- parseOpts actual_args name (real_options ++ |
|
60 |
genericOpts) arguments |
|
61 |
fn opts args |
b/man/footer.rst | ||
---|---|---|
26 | 26 |
Ganeti htools: **htools**(1) (generic binary), **hbal**(1) (cluster |
27 | 27 |
balancer), **hspace**(1) (capacity calculation), **hail**(1) (IAllocator |
28 | 28 |
plugin), **hscan**(1) (data gatherer from remote clusters), **hinfo**(1) |
29 |
(cluster information printer). |
|
29 |
(cluster information printer), **mon-collector**(7) (data collectors |
|
30 |
interface). |
|
30 | 31 |
|
31 | 32 |
COPYRIGHT |
32 | 33 |
--------- |
b/man/mon-collector.rst | ||
---|---|---|
1 |
mon-collector(7) Ganeti | Version @GANETI_VERSION@ |
|
2 |
================================================== |
|
3 |
|
|
4 |
NAME |
|
5 |
---- |
|
6 |
|
|
7 |
mon-collector - Command line interface for the data collectors of the |
|
8 |
monitoring system |
|
9 |
|
|
10 |
SYNOPSIS |
|
11 |
-------- |
|
12 |
|
|
13 |
**mon-collector** {collector} |
|
14 |
|
|
15 |
DESCRIPTION |
|
16 |
----------- |
|
17 |
|
|
18 |
``mon-collector`` is a suite of tools designed to provide a command line |
|
19 |
interface to the data collectors implemented by the ganeti monitoring system. |
|
20 |
``mon-collector`` is also the generic binary that must be invoked specifying, |
|
21 |
as the first command line parameter, the name of the actual desired data |
|
22 |
collector to be run. |
|
23 |
|
|
24 |
When executed, ``mon-collector`` will run the specified collector and will |
|
25 |
print its output to stdout, in JSON format. |
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
COLLECTORS |
|
31 |
---------- |
|
32 |
|
|
33 |
DRBD |
|
34 |
~~~~ |
|
35 |
|
|
36 |
| drbd [*status-file*] |
|
37 |
|
|
38 |
Collects the information about the version and status of the DRBD kernel |
|
39 |
module, and of the disks it is managing. |
|
40 |
|
|
41 |
If *status-file* is specified, the status will be read from that file. |
|
42 |
Otherwise, the collector will read it from /proc/drbd. |
Also available in: Unified diff