summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Munin.hs
diff options
context:
space:
mode:
authorJoey Hess2016-01-03 16:26:16 -0400
committerJoey Hess2016-01-03 16:26:16 -0400
commit3f5cc046915a9f64c31a6d48aaef5254f5eb7598 (patch)
tree110bd5acac6adf0c08111efb9f9cd2dc07701b30 /src/Propellor/Property/Munin.hs
parent299d478dfd96037c660109c4f0519fd1cc37a887 (diff)
parent93ee9e6966783368fa41fb75c7e287bee04f9c16 (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/Munin.hs')
-rw-r--r--src/Propellor/Property/Munin.hs57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/Propellor/Property/Munin.hs b/src/Propellor/Property/Munin.hs
new file mode 100644
index 00000000..43112a6c
--- /dev/null
+++ b/src/Propellor/Property/Munin.hs
@@ -0,0 +1,57 @@
+-- | Maintainer: Jelmer Vernooij <jelmer@jelmer.uk>
+--
+module Propellor.Property.Munin (
+ hostListFragment,
+ hostListFragment',
+ nodePort,
+ nodeInstalled,
+ nodeRestarted,
+ nodeConfPath,
+ masterInstalled,
+ masterRestarted,
+ masterConfPath,
+) where
+
+import Propellor
+import qualified Propellor.Property.Apt as Apt
+import qualified Propellor.Property.Service as Service
+
+nodePort :: Integer
+nodePort = 4949
+
+nodeInstalled :: Property NoInfo
+nodeInstalled = Apt.serviceInstalledRunning "munin-node"
+
+nodeRestarted :: Property NoInfo
+nodeRestarted = Service.restarted "munin-node"
+
+nodeConfPath :: FilePath
+nodeConfPath = "/etc/munin/munin-node.conf"
+
+masterInstalled :: Property NoInfo
+masterInstalled = Apt.serviceInstalledRunning "munin"
+
+masterRestarted :: Property NoInfo
+masterRestarted = Service.restarted "munin"
+
+masterConfPath :: FilePath
+masterConfPath = "/etc/munin/munin.conf"
+
+
+-- | Create the host list fragment for master config.
+-- Takes an optional override list for hosts that are accessible on a non-standard host/port.
+-- TODO(jelmer): Only do this on hosts where munin is present (in other words, with Munin.installedNode)
+hostListFragment' :: [Host] -> [(HostName, (IPAddr, Port))] -> [String]
+hostListFragment' hs os = concatMap muninHost hs
+ where
+ muninHost :: Host -> [String]
+ muninHost h = [ "[" ++ (hostName h) ++ "]"
+ , " address " ++ maybe (hostName h) (fromIPAddr . fst) (hOverride h)
+ ] ++ (maybe [] (\x -> [" port " ++ (show $ fromPort $ snd x)]) (hOverride h)) ++ [""]
+ hOverride :: Host -> Maybe (IPAddr, Port)
+ hOverride h = lookup (hostName h) os
+ fromPort (Port p) = p
+
+-- | Create the host list fragment for master config.
+hostListFragment :: [Host] -> [String]
+hostListFragment hs = hostListFragment' hs []