Revision 34be621a

b/src/Ganeti/Monitoring/Server.hs
51 51
import qualified Ganeti.DataCollectors.Lv as Lv
52 52
import Ganeti.DataCollectors.Types
53 53
import qualified Ganeti.Constants as C
54
import Ganeti.Runtime
54 55

  
55 56
-- * Types and constants definitions
56 57

  
......
99 100
-- * Configuration handling
100 101

  
101 102
-- | The default configuration for the HTTP server.
102
defaultHttpConf :: Config Snap ()
103
defaultHttpConf =
104
  setAccessLog (ConfigFileLog C.daemonsExtraLogfilesGanetiMondAccess) .
103
defaultHttpConf :: FilePath -> FilePath -> Config Snap ()
104
defaultHttpConf accessLog errorLog =
105
  setAccessLog (ConfigFileLog accessLog) .
105 106
  setCompression False .
106
  setErrorLog (ConfigFileLog C.daemonsExtraLogfilesGanetiMondError) $
107
  setErrorLog (ConfigFileLog errorLog) $
107 108
  setVerbose False
108 109
  emptyConfig
109 110

  
......
115 116

  
116 117
-- | Prepare function for monitoring agent.
117 118
prepMain :: PrepFn CheckResult PrepResult
118
prepMain opts _ =
119
  return $
120
    setPort (maybe C.defaultMondPort fromIntegral (optPort opts))
121
      defaultHttpConf
119
prepMain opts _ = do
120
  mAccessLog <- daemonsExtraLogFile GanetiMond AccessLog
121
  mErrorLog <- daemonsExtraLogFile GanetiMond ErrorLog
122
  case (mAccessLog, mErrorLog) of
123
    (Just accessLog, Just errorLog) ->
124
      return $
125
        setPort
126
          (maybe C.defaultMondPort fromIntegral (optPort opts))
127
          (defaultHttpConf accessLog errorLog)
128
    _ -> fail "Failed to retrieve extra log filepaths for the monitoring daemon"
122 129

  
123 130
-- * Query answers
124 131

  
b/src/Ganeti/Runtime.hs
32 32
  , daemonOnlyOnMaster
33 33
  , daemonUser
34 34
  , daemonGroup
35
  , ExtraLogReason(..)
35 36
  , daemonLogFile
37
  , daemonsExtraLogFile
36 38
  , daemonPidFile
37 39
  , getEnts
38 40
  , verifyDaemonUser
......
118 120
daemonGroup (ExtraGroup  DaemonsGroup)  = C.daemonsGroup
119 121
daemonGroup (ExtraGroup  AdminGroup)    = C.adminGroup
120 122

  
123
data ExtraLogReason = AccessLog | ErrorLog
124

  
125
daemonsExtraLogbase :: GanetiDaemon -> ExtraLogReason -> Maybe String
126
daemonsExtraLogbase GanetiMond AccessLog =
127
  Just C.daemonsExtraLogbaseGanetiMondAccess
128

  
129
daemonsExtraLogbase GanetiMond ErrorLog =
130
  Just C.daemonsExtraLogbaseGanetiMondError
131

  
132
daemonsExtraLogbase _ _ = Nothing
133

  
121 134
-- | Returns the log file for a daemon.
122 135
daemonLogFile :: GanetiDaemon -> IO FilePath
123 136
daemonLogFile daemon = do
124 137
  logDir <- Path.logDir
125 138
  return $ logDir </> daemonLogBase daemon <.> "log"
126 139

  
140
daemonsExtraLogFile :: GanetiDaemon -> ExtraLogReason -> IO (Maybe FilePath)
141
daemonsExtraLogFile daemon logreason = do
142
  logDir <- Path.logDir
143
  case daemonsExtraLogbase daemon logreason of
144
    Nothing -> return Nothing
145
    Just logbase -> return . Just $ logDir </> logbase <.> "log"
146

  
127 147
-- | Returns the pid file name for a daemon.
128 148
daemonPidFile :: GanetiDaemon -> IO FilePath
129 149
daemonPidFile daemon = do

Also available in: Unified diff