Ejemplo n.º 1
0
func NewSlowLogWorker(logger *pct.Logger, name string) *SlowLogWorker {
	w := &SlowLogWorker{
		logger: logger,
		name:   name,
		status: pct.NewStatus([]string{name}),
	}
	return w
}
Ejemplo n.º 2
0
func NewMockServiceManager(name string, readyChan chan bool, traceChan chan string) *MockServiceManager {
	m := &MockServiceManager{
		name:      name,
		readyChan: readyChan,
		traceChan: traceChan,
		status:    pct.NewStatus([]string{name}),
	}
	return m
}
Ejemplo n.º 3
0
func NewManager(logger *pct.Logger, monitor Monitor) *Manager {
	m := &Manager{
		logger:  logger,
		monitor: monitor,
		// --
		status: pct.NewStatus([]string{SERVICE_NAME}),
	}
	return m
}
Ejemplo n.º 4
0
func NewSender(logger *pct.Logger, client pct.WebsocketClient) *Sender {
	s := &Sender{
		logger: logger,
		client: client,
		sync:   pct.NewSyncChan(),
		status: pct.NewStatus([]string{"data-sender"}),
	}
	return s
}
Ejemplo n.º 5
0
func NewManager(logger *pct.Logger) *Manager {
	m := &Manager{
		logger: logger,
		// --
		service: make(map[string]Service),
		status:  pct.NewStatus([]string{SERVICE_NAME}),
	}
	return m
}
Ejemplo n.º 6
0
func NewManager(client pct.WebsocketClient, logChan chan *proto.LogEntry) *Manager {
	m := &Manager{
		client:  client,
		logChan: logChan,
		// --
		status: pct.NewStatus([]string{"log"}),
		mux:    &sync.RWMutex{},
	}
	return m
}
Ejemplo n.º 7
0
func NewManager(logger *pct.Logger, instanceRepo *instance.Repo, connFactory mysql.ConnectionFactory) *Manager {
	m := &Manager{
		logger:       logger,
		instanceRepo: instanceRepo,
		connFactory:  connFactory,
		// --
		status: pct.NewStatus([]string{SERVICE_NAME}),
	}
	return m
}
Ejemplo n.º 8
0
func NewManager(logger *pct.Logger, configDir string, api pct.APIConnector) *Manager {
	repo := NewRepo(pct.NewLogger(logger.LogChan(), "instance-repo"), configDir, api)
	m := &Manager{
		logger:    logger,
		configDir: configDir,
		// --
		status: pct.NewStatus([]string{"instance", "instance-repo"}),
		repo:   repo,
	}
	return m
}
Ejemplo n.º 9
0
func NewSender(logger *pct.Logger, client pct.WebsocketClient) *Sender {
	s := &Sender{
		logger:     logger,
		client:     client,
		sync:       pct.NewSyncChan(),
		status:     pct.NewStatus([]string{"data-sender", "data-sender-last", "data-sender-1d"}),
		lastStats:  NewSenderStats(0),
		dailyStats: NewSenderStats(24 * time.Hour),
	}
	return s
}
Ejemplo n.º 10
0
func NewManager(logger *pct.Logger, dataDir string, hostname string, client pct.WebsocketClient) *Manager {
	m := &Manager{
		logger:   logger,
		dataDir:  dataDir,
		hostname: hostname,
		client:   client,
		// --
		status: pct.NewStatus([]string{"data"}),
		mux:    &sync.Mutex{},
	}
	return m
}
Ejemplo n.º 11
0
func NewMonitor(name string, config *Config, logger *pct.Logger, conn mysql.Connector) *Monitor {
	m := &Monitor{
		name:   name,
		config: config,
		logger: logger,
		conn:   conn,
		// --
		sync:   pct.NewSyncChan(),
		status: pct.NewStatus([]string{name, name + "-mysql"}),
	}
	return m
}
Ejemplo n.º 12
0
func NewDiskvSpooler(logger *pct.Logger, dataDir string, hostname string) *DiskvSpooler {
	s := &DiskvSpooler{
		logger:   logger,
		dataDir:  dataDir,
		hostname: hostname,
		// --
		dataChan: make(chan *proto.Data, WRITE_BUFFER),
		sync:     pct.NewSyncChan(),
		status:   pct.NewStatus([]string{"data-spooler"}),
		mux:      new(sync.Mutex),
	}
	return s
}
Ejemplo n.º 13
0
func NewMonitor(name string, config *Config, logger *pct.Logger) *Monitor {
	m := &Monitor{
		name:   name,
		config: config,
		logger: logger,
		// --
		prevCPUval: make(map[string][]float64),
		prevCPUsum: make(map[string]float64),
		status:     pct.NewStatus([]string{name}),
		sync:       pct.NewSyncChan(),
	}
	return m
}
Ejemplo n.º 14
0
func NewMonitor(logger *pct.Logger, mysqlConnFactory mysql.ConnectionFactory) mrms.Monitor {
	m := &Monitor{
		logger:           logger,
		mysqlConnFactory: mysqlConnFactory,
		// --
		mysqlInstances: make(map[string]*MysqlInstance),
		// --
		status:     pct.NewStatus([]string{MONITOR_NAME}),
		sync:       pct.NewSyncChan(),
		globalChan: make(chan string, 100),
	}
	return m
}
Ejemplo n.º 15
0
func NewManager(logger *pct.Logger, factory MonitorFactory, clock ticker.Manager, spool data.Spooler, im *instance.Repo) *Manager {
	m := &Manager{
		logger:  logger,
		factory: factory,
		clock:   clock,
		spool:   spool,
		im:      im,
		// --
		reportChan: make(chan *Report, 3),
		monitors:   make(map[string]Monitor),
		status:     pct.NewStatus([]string{"sysconfig", "sysconfig-spooler"}),
		mux:        &sync.RWMutex{},
	}
	return m
}
Ejemplo n.º 16
0
func NewManager(logger *pct.Logger, configDir string, api pct.APIConnector, mrm mrms.Monitor) *Manager {
	repo := NewRepo(pct.NewLogger(logger.LogChan(), "instance-repo"), configDir, api)
	m := &Manager{
		logger:    logger,
		configDir: configDir,
		api:       api,
		// --
		status:         pct.NewStatus([]string{"instance", "instance-repo", "instance-mrms"}),
		repo:           repo,
		mrm:            mrm,
		mrmChans:       make(map[string]<-chan bool),
		mrmsGlobalChan: make(chan string, 100), // monitor up to 100 instances
	}
	return m
}
Ejemplo n.º 17
0
func NewManager(logger *pct.Logger, factory MonitorFactory, clock ticker.Manager, spool data.Spooler, im *instance.Repo) *Manager {
	m := &Manager{
		logger:  logger,
		factory: factory,
		clock:   clock,
		spool:   spool,
		im:      im,
		// --
		monitors:    make(map[string]Monitor),
		status:      pct.NewStatus([]string{"mm"}),
		aggregators: make(map[uint]*Binding),
		mux:         &sync.RWMutex{},
	}
	return m
}
Ejemplo n.º 18
0
func NewMonitor(name string, config *Config, logger *pct.Logger, conn mysql.Connector, mrm mrms.Monitor) *Monitor {
	m := &Monitor{
		name:   name,
		config: config,
		logger: logger,
		conn:   conn,
		// --
		connectedChan: make(chan bool, 1),
		restartChan:   nil,
		status:        pct.NewStatus([]string{name, name + "-mysql"}),
		sync:          pct.NewSyncChan(),
		collectLimit:  float64(config.Collect) * 0.1, // 10% of Collect time
		mrm:           mrm,
	}
	return m
}
Ejemplo n.º 19
0
func NewDiskvSpooler(logger *pct.Logger, dataDir, trashDir, hostname string, limits proto.DataSpoolLimits) *DiskvSpooler {
	s := &DiskvSpooler{
		logger:   logger,
		dataDir:  dataDir,
		trashDir: trashDir,
		hostname: hostname,
		limits:   limits,
		// --
		dataChan: make(chan *proto.Data, DEFAULT_DATA_MAX_FILES),
		sync:     pct.NewSyncChan(),
		status:   pct.NewStatus([]string{"data-spooler", "data-spooler-count", "data-spooler-size", "data-spooler-oldest"}),
		mux:      new(sync.Mutex),
		fileSize: make(map[string]int),
	}
	return s
}
Ejemplo n.º 20
0
func NewAgent(config *Config, logger *pct.Logger, api pct.APIConnector, client pct.WebsocketClient, services map[string]pct.ServiceManager) *Agent {
	agent := &Agent{
		config:    config,
		api:       api,
		configMux: &sync.RWMutex{},
		logger:    logger,
		client:    client,
		services:  services,
		updater:   pct.NewUpdater(logger, api, pct.PublicKey, os.Args[0], VERSION),
		// --
		status:     pct.NewStatus([]string{"agent", "agent-cmd-handler"}),
		cmdChan:    make(chan *proto.Cmd, CMD_QUEUE_SIZE),
		statusChan: make(chan *proto.Cmd, STATUS_QUEUE_SIZE),
	}
	return agent
}
Ejemplo n.º 21
0
func NewManager(logger *pct.Logger, mysqlFactory mysql.ConnectionFactory, clock ticker.Manager, iterFactory IntervalIterFactory, workerFactory WorkerFactory, spool data.Spooler, im *instance.Repo) *Manager {
	m := &Manager{
		logger:        logger,
		mysqlFactory:  mysqlFactory,
		clock:         clock,
		iterFactory:   iterFactory,
		workerFactory: workerFactory,
		spool:         spool,
		im:            im,
		// --
		mux:            new(sync.RWMutex),
		tickChan:       make(chan time.Time),
		workers:        make(map[Worker]*Interval),
		workersMux:     new(sync.RWMutex),
		workerDoneChan: make(chan Worker, 2),
		status:         pct.NewStatus([]string{"qan", "qan-log-parser", "qan-last-interval", "qan-next-interval"}),
		sync:           pct.NewSyncChan(),
		oldSlowLogs:    make(map[string]int),
	}
	return m
}
Ejemplo n.º 22
0
func NewWebsocketClient(logger *pct.Logger, api pct.APIConnector, link string) (*WebsocketClient, error) {
	name := logger.Service()
	c := &WebsocketClient{
		logger: logger,
		api:    api,
		link:   link,
		// --
		conn:        nil,
		recvChan:    make(chan *proto.Cmd, RECV_BUFFER_SIZE),
		sendChan:    make(chan *proto.Reply, SEND_BUFFER_SIZE),
		connectChan: make(chan bool, 1),
		errChan:     make(chan error, 2),
		backoff:     pct.NewBackoff(5 * time.Minute),
		sendSync:    pct.NewSyncChan(),
		recvSync:    pct.NewSyncChan(),
		mux:         new(sync.Mutex),
		name:        name,
		status:      pct.NewStatus([]string{name, name + "-link"}),
	}
	return c, nil
}
Ejemplo n.º 23
0
func NewRealAnalyzer(logger *pct.Logger, config Config, iter IntervalIter, mysqlConn mysql.Connector, restartChan <-chan bool, worker Worker, clock ticker.Manager, spool data.Spooler) *RealAnalyzer {
	name := logger.Service()
	a := &RealAnalyzer{
		logger:      logger,
		config:      config,
		iter:        iter,
		mysqlConn:   mysqlConn,
		restartChan: restartChan,
		worker:      worker,
		clock:       clock,
		spool:       spool,
		// --
		name:                name,
		mysqlConfiguredChan: make(chan bool, 1),
		workerDoneChan:      make(chan *Interval, 1),
		status:              pct.NewStatus([]string{name, name + "-last-interval", name + "-next-interval"}),
		runSync:             pct.NewSyncChan(),
		configureMySQLSync:  pct.NewSyncChan(),
		mux:                 &sync.RWMutex{},
	}
	return a
}
Ejemplo n.º 24
0
func NewManager(
	logger *pct.Logger,
	clock ticker.Manager,
	im *instance.Repo,
	mrm mrms.Monitor,
	mysqlFactory mysql.ConnectionFactory,
	analyzerFactory AnalyzerFactory,
) *Manager {
	m := &Manager{
		logger:          logger,
		clock:           clock,
		im:              im,
		mrm:             mrm,
		mysqlFactory:    mysqlFactory,
		analyzerFactory: analyzerFactory,
		// --
		mux:       &sync.RWMutex{},
		analyzers: make(map[uint]AnalyzerInstance),
		status:    pct.NewStatus([]string{"qan"}),
	}
	return m
}
Ejemplo n.º 25
0
func NewRelay(client pct.WebsocketClient, logChan chan *proto.LogEntry, logFile string, logLevel byte, offline bool) *Relay {
	r := &Relay{
		client:   client,
		logChan:  logChan,
		logFile:  logFile,
		logLevel: logLevel,
		offline:  offline,
		// --
		logLevelChan: make(chan byte),
		logFileChan:  make(chan string),
		firstBuf:     make([]*proto.LogEntry, BUFFER_SIZE),
		secondBuf:    make([]*proto.LogEntry, BUFFER_SIZE),
		status: pct.NewStatus([]string{
			"log-relay",
			"log-file",
			"log-level",
			"log-chan",
			"log-buf1",
			"log-buf2",
		}),
	}
	return r
}