Documentation ¶
Index ¶
- Constants
- Variables
- func GetAccessLogWriter(cfg Config) (io.WriteCloser, error)
- type Config
- func (c Config) AccessLog() log.LogLocation
- func (c Config) DebugLog() log.LogLocation
- func (c Config) ErrorLog() log.LogLocation
- func (c Config) EventLog() log.LogLocation
- func (c Config) InfoLog() log.LogLocation
- func (c *Config) MarshalJSON() ([]byte, error)
- func (c *Config) UnmarshalJSON(data []byte) error
- func (c Config) WarningLog() log.LogLocation
- type LogLocation
- type PollingProtocol
- type StaticAppData
Constants ¶
const ( // LogLocationStdout indicates the stdout IO stream LogLocationStdout = "stdout" // LogLocationStderr indicates the stderr IO stream LogLocationStderr = "stderr" // LogLocationNull indicates the null IO stream (/dev/null) LogLocationNull = "null" //StaticFileDir is the directory that contains static html and js files. StaticFileDir = "/opt/traffic_monitor/static/" //CrConfigBackupFile is the default file name to store the last crconfig CRConfigBackupFile = "/opt/traffic_monitor/crconfig.backup" //TmConfigBackupFile is the default file name to store the last tmconfig TMConfigBackupFile = "/opt/traffic_monitor/tmconfig.backup" //HTTPPollingFormat is the default accept encoding for stats from caches HTTPPollingFormat = "text/json" )
const ( IPv4Only = PollingProtocol("ipv4only") IPv6Only = PollingProtocol("ipv6only") Both = PollingProtocol("both") InvalidPollingProtocol = PollingProtocol("invalid_polling_protocol") )
Variables ¶
var DefaultConfig = Config{ CachePollingProtocol: Both, CRConfigBackupFile: CRConfigBackupFile, CRConfigHistoryCount: 100, HealthFlushInterval: 200 * time.Millisecond, HTTPPollingFormat: HTTPPollingFormat, HTTPTimeout: 2 * time.Second, LogLocationAccess: LogLocationNull, LogLocationDebug: LogLocationNull, LogLocationError: LogLocationStderr, LogLocationEvent: LogLocationStdout, LogLocationInfo: LogLocationNull, LogLocationWarning: LogLocationStdout, MaxEvents: 200, MonitorConfigPollingInterval: 5 * time.Second, PeerOptimisticQuorumMin: 0, ServeReadTimeout: 10 * time.Second, ServeWriteTimeout: 10 * time.Second, ShortHostnameOverride: "", StatBufferInterval: 0, StatFlushInterval: 200 * time.Millisecond, StaticFileDir: StaticFileDir, StatPolling: true, TMConfigBackupFile: TMConfigBackupFile, TrafficOpsDiskRetryMax: 2, TrafficOpsMaxRetryInterval: 60000 * time.Millisecond, TrafficOpsMinRetryInterval: 100 * time.Millisecond, }
DefaultConfig is the default configuration for the application, if no configuration file is given, or if a given config setting doesn't exist in the config file.
Functions ¶
func GetAccessLogWriter ¶
func GetAccessLogWriter(cfg Config) (io.WriteCloser, error)
Types ¶
type Config ¶
type Config struct { // Sets the Internet Protocol version used for polling cache servers. CachePollingProtocol PollingProtocol `json:"cache_polling_protocol"` // A path to a file where CDN Snapshot backups are written. CRConfigBackupFile string `json:"crconfig_backup_file"` // The number of historical CDN Snapshots to store. CRConfigHistoryCount uint64 `json:"crconfig_history_count"` // Controls whether Distributed Polling is enabled. DistributedPolling bool `json:"distributed_polling"` // Defines an interval on which Traffic Monitor will flush its collected // health data such that it is made available through the API. HealthFlushInterval time.Duration `json:"-"` // A MIME-Type that will be sent in the Accept HTTP header in requests to // cache servers for health and stats data. HTTPPollingFormat string `json:"http_polling_format"` // Sets the timeout duration for all HTTP operations - peer-polling and // health data polling. HTTPTimeout time.Duration `json:"-"` // A "lib/go-log"-compliant string defining the logging of Access-level // logs. LogLocationAccess string `json:"log_location_access"` // A "lib/go-log"-compliant string defining the logging of Debug-level logs. LogLocationDebug string `json:"log_location_debug"` // A "lib/go-log"-compliant string defining the logging of Error-level logs. LogLocationError string `json:"log_location_error"` // A "lib/go-log"-compliant string defining the logging of Event-level logs. LogLocationEvent string `json:"log_location_event"` // A "lib/go-log"-compliant string defining the logging of Info-level logs. LogLocationInfo string `json:"log_location_info"` // A "lib/go-log"-compliant string defining the logging of Warning-level // logs. LogLocationWarning string `json:"log_location_warning"` // The maximum number of events to keep in TM's buffer to be served via its // API. MaxEvents uint64 `json:"max_events"` // The interval on which to poll for this TM's CDN's "monitoring config". MonitorConfigPollingInterval time.Duration `json:"-"` // Specifies the minimum number of peers that must be available in order to // participate in the optimistic health protocol. PeerOptimisticQuorumMin int `json:"peer_optimistic_quorum_min"` // The timeout for the API server for reading requests. ServeReadTimeout time.Duration `json:"-"` // The timeout for the API server for writing responses. ServeWriteTimeout time.Duration `json:"-"` // ShortHostnameOverride is for explicitly setting a hostname rather than using the output of `hostname -s`. ShortHostnameOverride string `json:"short_hostname_override"` // The interval for which to buffer stats data before processing it. StatBufferInterval time.Duration `json:"-"` // The interval on which Traffic Monitor will flush its collected stats data // such that it is made available through the API. StatFlushInterval time.Duration `json:"-"` // The directory in which Traffic Monitor will look for the static files for // its web UI. StaticFileDir string `json:"static_file_dir"` // Controls whether stats data is polled. StatPolling bool `json:"stat_polling"` // A file location to which a backup of the "monitoring configuration" // currently in use by Traffic Monitor will be written. TMConfigBackupFile string `json:"tmconfig_backup_file"` // The number of times Traffic Monitor should attempt to log in to Traffic // Ops before using its backup monitoring configuration and CDN Snapshot (if // those exist). TrafficOpsDiskRetryMax uint64 `json:"traffic_ops_disk_retry_max"` // The maximum exponential backoff duration for logging in to Traffic Ops. TrafficOpsMaxRetryInterval time.Duration `json:"-"` // The minimum exponential backoff duration for logging in to Traffic Ops. TrafficOpsMinRetryInterval time.Duration `json:"-"` }
Config is the configuration for the application. It includes myriad data, such as polling intervals and log locations.
func Load ¶
Load loads the given config file. If an empty string is passed, the default config is returned.
func (*Config) MarshalJSON ¶
MarshalJSON marshals custom millisecond durations. Aliasing inspired by http://choly.ca/post/go-json-marshalling/
func (*Config) UnmarshalJSON ¶
UnmarshalJSON populates this config object from given JSON bytes.
func (Config) WarningLog ¶
func (c Config) WarningLog() log.LogLocation
type LogLocation ¶
type LogLocation string
LogLocation is a location to log to. This may be stdout, stderr, null (/dev/null), or a valid file path.
type PollingProtocol ¶
type PollingProtocol string
PollingProtocol is a string value indicating whether to use IPv4, IPv6, or both.
func PollingProtocolFromString ¶
func PollingProtocolFromString(s string) PollingProtocol
PollingProtocolFromString returns a PollingProtocol based on the string input.
func (PollingProtocol) String ¶
func (t PollingProtocol) String() string
String returns a string representation of this PollingProtocol.
func (*PollingProtocol) UnmarshalJSON ¶
func (t *PollingProtocol) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaller interface
type StaticAppData ¶
type StaticAppData struct { StartTime time.Time GitRevision string FreeMemoryMB uint64 Version string WorkingDir string Name string BuildTimestamp string Hostname string UserAgent string }
StaticAppData encapsulates data about the app available at startup
func GetStaticAppData ¶
func GetStaticAppData(version, gitRevision, buildTimestamp string) (StaticAppData, error)
getStaticAppData returns app data available at start time. This should be called immediately, as it includes calculating when the app was started.