Documentation ¶
Overview ¶
Package service is a package that provides methods for manipulating host informations
Index ¶
- type AlertService
- func (as *AlertService) AlertInsertion(alr model.Alert) utils.AdvancedErrorInterface
- func (as *AlertService) DiffHostDataMapAndGenerateAlert(oldData model.HostDataBE, newData model.HostDataBE) utils.AdvancedErrorInterface
- func (as *AlertService) HostDataInsertion(id primitive.ObjectID) utils.AdvancedErrorInterface
- func (as *AlertService) Init(wg *sync.WaitGroup)
- func (as *AlertService) ProcessAlertInsertion(params hub.Fields)
- func (as *AlertService) ProcessHostDataInsertion(params hub.Fields)
- func (as *AlertService) ProcessMsg(msg hub.Message)
- func (as *AlertService) ThrowActivatedFeaturesAlert(dbname string, hostname string, activatedFeatures []string) utils.AdvancedErrorInterface
- func (as *AlertService) ThrowNewAlert(alert model.Alert) utils.AdvancedErrorInterface
- func (as *AlertService) ThrowNewDatabaseAlert(dbname string, hostname string) utils.AdvancedErrorInterface
- func (as *AlertService) ThrowNewEnterpriseLicenseAlert(hostname string) utils.AdvancedErrorInterface
- func (as *AlertService) ThrowNewServerAlert(hostname string) utils.AdvancedErrorInterface
- func (as *AlertService) ThrowNoDataAlert(hostname string, freshnessThreshold int) utils.AdvancedErrorInterface
- func (as *AlertService) ThrowUnlistedRunningDatabasesAlert(dbname string, hostname string) utils.AdvancedErrorInterface
- type AlertServiceInterface
- type Emailer
- type FreshnessCheckJob
- type SMTPEmailer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertService ¶
type AlertService struct { // Config contains the dataservice global configuration Config config.Configuration // Queue that contains all messages to be processed Queue *hub.Hub // Database contains the database layer Database database.MongoDatabaseInterface // TimeNow contains a function that return the current time TimeNow func() time.Time // Log contains logger formatted Log *logrus.Logger // Emailer contains the emailer layer Emailer Emailer }
AlertService is the concrete implementation of HostDataServiceInterface. It saves data to a MongoDB database
func (*AlertService) AlertInsertion ¶
func (as *AlertService) AlertInsertion(alr model.Alert) utils.AdvancedErrorInterface
AlertInsertion inserts an alert insertion in the queue
func (*AlertService) DiffHostDataMapAndGenerateAlert ¶
func (as *AlertService) DiffHostDataMapAndGenerateAlert(oldData model.HostDataBE, newData model.HostDataBE) utils.AdvancedErrorInterface
DiffHostDataMapAndGenerateAlert find the difference between the data and generate eventually alerts for such difference
func (*AlertService) HostDataInsertion ¶
func (as *AlertService) HostDataInsertion(id primitive.ObjectID) utils.AdvancedErrorInterface
HostDataInsertion inserts the host data insertion in the queue
func (*AlertService) Init ¶
func (as *AlertService) Init(wg *sync.WaitGroup)
Init initializes the service and database
func (*AlertService) ProcessAlertInsertion ¶
func (as *AlertService) ProcessAlertInsertion(params hub.Fields)
ProcessAlertInsertion processes the alert insertion event
func (*AlertService) ProcessHostDataInsertion ¶
func (as *AlertService) ProcessHostDataInsertion(params hub.Fields)
ProcessHostDataInsertion processes the host data insertion event
func (*AlertService) ProcessMsg ¶
func (as *AlertService) ProcessMsg(msg hub.Message)
ProcessMsg processes the message msg
func (*AlertService) ThrowActivatedFeaturesAlert ¶
func (as *AlertService) ThrowActivatedFeaturesAlert(dbname string, hostname string, activatedFeatures []string) utils.AdvancedErrorInterface
ThrowActivatedFeaturesAlert create and insert in the database a new NEW_OPTION alert
func (*AlertService) ThrowNewAlert ¶
func (as *AlertService) ThrowNewAlert(alert model.Alert) utils.AdvancedErrorInterface
ThrowNewAlert create and insert in the database a new NEW_DATABASE alert
func (*AlertService) ThrowNewDatabaseAlert ¶
func (as *AlertService) ThrowNewDatabaseAlert(dbname string, hostname string) utils.AdvancedErrorInterface
ThrowNewDatabaseAlert create and insert in the database a new NEW_DATABASE alert
func (*AlertService) ThrowNewEnterpriseLicenseAlert ¶
func (as *AlertService) ThrowNewEnterpriseLicenseAlert(hostname string) utils.AdvancedErrorInterface
ThrowNewEnterpriseLicenseAlert create and insert in the database a new NEW_DATABASE alert
func (*AlertService) ThrowNewServerAlert ¶
func (as *AlertService) ThrowNewServerAlert(hostname string) utils.AdvancedErrorInterface
ThrowNewServerAlert create and insert in the database a new NEW_SERVER alert
func (*AlertService) ThrowNoDataAlert ¶
func (as *AlertService) ThrowNoDataAlert(hostname string, freshnessThreshold int) utils.AdvancedErrorInterface
ThrowNoDataAlert create and insert in the database a new NO_DATA alert
func (*AlertService) ThrowUnlistedRunningDatabasesAlert ¶
func (as *AlertService) ThrowUnlistedRunningDatabasesAlert(dbname string, hostname string) utils.AdvancedErrorInterface
ThrowUnlistedRunningDatabasesAlert create and insert in the database a new UNLISTED_RUNNING_DATABASE alert
type AlertServiceInterface ¶
type AlertServiceInterface interface { // Init initializes the service Init(wg *sync.WaitGroup) // HostDataInsertion inserts the host data insertion in the queue HostDataInsertion(id primitive.ObjectID) utils.AdvancedErrorInterface // ProcessMsg processes the message msg ProcessMsg(msg hub.Message) ThrowNewAlert(alert model.Alert) utils.AdvancedErrorInterface // ThrowNewDatabaseAlert create and insert in the database a new NEW_DATABASE alert ThrowNewDatabaseAlert(dbname string, hostname string) utils.AdvancedErrorInterface // ThrowNewServerAlert create and insert in the database a new NEW_SERVER alert ThrowNewServerAlert(hostname string) utils.AdvancedErrorInterface // ThrowNewEnterpriseLicenseAlert create and insert in the database a new NEW_DATABASE alert ThrowNewEnterpriseLicenseAlert(hostname string) utils.AdvancedErrorInterface // ThrowActivatedFeaturesAlert create and insert in the database a new NEW_OPTION alert ThrowActivatedFeaturesAlert(dbname string, hostname string, activatedFeatures []string) utils.AdvancedErrorInterface // ThrowNoDataAlert create and insert in the database a new NO_DATA alert ThrowNoDataAlert(hostname string, freshnessThreshold int) utils.AdvancedErrorInterface }
AlertServiceInterface is a interface that wrap methods used to insert and process alert messages
type Emailer ¶
type Emailer interface { // SendEmail send a email SendEmail(subject string, text string, to []string) utils.AdvancedErrorInterface }
Emailer contains the interface of a email senders
type FreshnessCheckJob ¶
type FreshnessCheckJob struct { // TimeNow contains a function that return the current time TimeNow func() time.Time // Database contains the database layer Database database.MongoDatabaseInterface // Config contains the dataservice global configuration Config config.Configuration // Log contains logger formatted Log *logrus.Logger // contains filtered or unexported fields }
FreshnessCheckJob is the job used to check the freshness of the current hosts
func (*FreshnessCheckJob) Run ¶
func (job *FreshnessCheckJob) Run()
Run throws NO_DATA alert for each hosts that haven't sent a hostdata withing the FreshnessCheck.DaysThreshold
type SMTPEmailer ¶
type SMTPEmailer struct { // Config contains the dataservice global configuration Config config.Configuration }
func (*SMTPEmailer) SendEmail ¶
func (this *SMTPEmailer) SendEmail(subject string, text string, to []string) utils.AdvancedErrorInterface