Documentation ¶
Overview ¶
Package core contains the main functionality of Statup. This includes everything for Services, Hits, Failures, Users, service checking mechanisms, databases, and notifiers in the notifier package
More info on: https://github.com/hunterlong/statup
Index ¶
- Variables
- func AuthUser(username, password string) (*user, bool)
- func CheckHash(password, hash string) bool
- func CloseDB()
- func CountFailures() uint64
- func DatabaseMaintence()
- func Dbtimestamp(group string, column string) string
- func DefaultPort(db string) int64
- func DeleteAllSince(table string, date time.Time)
- func DeleteConfig() error
- func ExportChartsJs() string
- func ExportIndexHTML() string
- func InitApp()
- func InsertLargeSampleData() error
- func InsertNotifierDB() error
- func InsertSampleData() error
- func InsertSampleHits() error
- func ReturnCheckinHit(c *types.CheckinHit) *checkinHit
- func ReturnUser(u *types.User) *user
- func SampleData() error
- func SelectAllUsers() ([]*user, error)
- func SelectServicer(id int64) types.ServiceInterface
- func SelectUser(id int64) (*user, error)
- func SelectUsername(username string) (*user, error)
- func Services() []types.ServiceInterface
- type Checkin
- func (c *Checkin) AfterFind() (err error)
- func (c *Checkin) BeforeCreate() (err error)
- func (c *Checkin) Create() (int64, error)
- func (c *Checkin) CreateFailure() (int64, error)
- func (c *Checkin) Delete() error
- func (c *Checkin) Expected() time.Duration
- func (c *Checkin) Grace() time.Duration
- func (c *Checkin) Hits() []*checkinHit
- func (c *Checkin) Last() *checkinHit
- func (c *Checkin) Link() string
- func (c *Checkin) Period() time.Duration
- func (c *Checkin) RecheckCheckinFailure(guard chan struct{})
- func (c *Checkin) Routine()
- func (c *Checkin) Service() *Service
- func (c *Checkin) String() string
- func (c *Checkin) Update() (int64, error)
- type Core
- func (c Core) AllOnline() bool
- func (c Core) BaseSASS() string
- func (c *Core) Count24HFailures() uint64
- func (c *Core) CountOnline() int
- func (c Core) CurrentTime() string
- func (c Core) MobileSASS() string
- func (c Core) SassVars() string
- func (c *Core) SelectAllServices(start bool) ([]*Service, error)
- func (c *Core) ServicesCount() int
- func (c *Core) ToCore() *types.Core
- func (c Core) UsingAssets() bool
- type DateScan
- type DateScanObj
- type DbConfig
- func (db *DbConfig) Close() error
- func (db *DbConfig) Connect(retry bool, location string) error
- func (c *DbConfig) CreateCore() *Core
- func (db *DbConfig) CreateDatabase() error
- func (db *DbConfig) DropDatabase() error
- func (db *DbConfig) InsertCore() (*Core, error)
- func (db *DbConfig) MigrateDatabase() error
- func (db *DbConfig) Save() (*DbConfig, error)
- func (db *DbConfig) Update() error
- type ErrorResponse
- type Hit
- type Message
- type PluginJSON
- type PluginRepos
- type Service
- func (s *Service) ActiveMessages() []*Message
- func (s *Service) AfterFind() (err error)
- func (s *Service) AllFailures() []*failure
- func (s *Service) AvgTime() float64
- func (s *Service) AvgUptime(ago time.Time) string
- func (s *Service) AvgUptime24() string
- func (s *Service) BeforeCreate() (err error)
- func (s *Service) Check(record bool)
- func (s *Service) CheckQueue(record bool)
- func (s *Service) CheckinProcess()
- func (s *Service) Checkins() []*Checkin
- func (s *Service) CountHits() (int64, error)
- func (s *Service) Create(check bool) (int64, error)
- func (s *Service) CreateFailure(fail types.FailureInterface) (int64, error)
- func (s *Service) CreateHit(h *types.Hit) (int64, error)
- func (s *Service) Delete() error
- func (s *Service) DeleteFailures()
- func (s *Service) Downtime() time.Duration
- func (s *Service) DowntimeText() string
- func (s *Service) Hits() ([]*types.Hit, error)
- func (s *Service) HitsBetween(t1, t2 time.Time, group string, column string) *gorm.DB
- func (s *Service) LimitedCheckins() []*Checkin
- func (s *Service) LimitedFailures(amount int64) []*failure
- func (s *Service) LimitedHits() ([]*types.Hit, error)
- func (s *Service) Messages() []*Message
- func (s *Service) Online24() float32
- func (s *Service) OnlineSince(ago time.Time) float32
- func (s *Service) Select() *types.Service
- func (s *Service) SmallText() string
- func (s *Service) Sum() (float64, error)
- func (s *Service) ToJSON() string
- func (s *Service) TotalFailures() (uint64, error)
- func (s *Service) TotalFailures24() (uint64, error)
- func (s *Service) TotalFailuresSince(ago time.Time) (uint64, error)
- func (s *Service) TotalHits() (uint64, error)
- func (s *Service) TotalHitsSince(ago time.Time) (uint64, error)
- func (s *Service) TotalUptime() string
- func (s *Service) Update(restart bool) error
- func (s *Service) UpdateSingle(attr ...interface{}) error
- type ServiceOrder
Constants ¶
This section is empty.
Variables ¶
var ( Configs *DbConfig // Configs holds all of the config.yml and database info CoreApp *Core // CoreApp is a global variable that contains many elements SetupMode bool // SetupMode will be true if Statup does not have a database connection VERSION string // VERSION is set on build automatically by setting a -ldflag )
var ( // DbSession stores the Statup database session DbSession *gorm.DB )
Functions ¶
func AuthUser ¶
AuthUser will return the user and a boolean if authentication was correct. AuthUser accepts username, and password as a string
func CountFailures ¶
func CountFailures() uint64
CountFailures returns the total count of failures for all services
func DatabaseMaintence ¶
func DatabaseMaintence()
DatabaseMaintence will automatically delete old records from 'failures' and 'hits' this function is currently set to delete records 7+ days old every 60 minutes
func Dbtimestamp ¶
Dbtimestamp will return a SQL query for grouping by date
func DefaultPort ¶
DefaultPort accepts a database type and returns its default port
func DeleteAllSince ¶
DeleteAllSince will delete a specific table's records based on a time.
func ExportChartsJs ¶
func ExportChartsJs() string
ExportChartsJs renders the charts for the index page
func ExportIndexHTML ¶
func ExportIndexHTML() string
ExportIndexHTML returns the HTML of the index page as a string
func InsertLargeSampleData ¶
func InsertLargeSampleData() error
InsertLargeSampleData will create the example/dummy services for testing the Statup server
func InsertNotifierDB ¶
func InsertNotifierDB() error
InsertNotifierDB inject the Statup database instance to the Notifier package
func InsertSampleData ¶
func InsertSampleData() error
InsertSampleData will create the example/dummy services for a brand new Statup installation
func InsertSampleHits ¶
func InsertSampleHits() error
InsertSampleHits will create a couple new hits for the sample services
func ReturnCheckinHit ¶
func ReturnCheckinHit(c *types.CheckinHit) *checkinHit
ReturnCheckinHit converts *types.checkinHit to *core.checkinHit
func ReturnUser ¶
ReturnUser returns *core.user based off a *types.user
func SampleData ¶
func SampleData() error
SampleData runs all the sample data for a new Statup installation
func SelectServicer ¶
func SelectServicer(id int64) types.ServiceInterface
SelectServicer returns a types.ServiceInterface from in memory
func SelectUser ¶
SelectUser returns the user based on the user's ID.
func SelectUsername ¶
SelectUsername returns the user based on the user's username
func Services ¶
func Services() []types.ServiceInterface
Types ¶
type Checkin ¶
func ReturnCheckin ¶
ReturnCheckin converts *types.Checking to *core.Checkin
func SelectCheckin ¶
SelectCheckin will find a Checkin based on the API supplied
func SelectCheckinId ¶
SelectCheckin will find a Checkin based on the API supplied
func (*Checkin) BeforeCreate ¶
BeforeCreate for Checkin will set CreatedAt to UTC
func (*Checkin) CreateFailure ¶
func (*Checkin) Expected ¶
Expected returns the duration of when the serviec should receive a Checkin
func (*Checkin) Grace ¶
Grace will return the duration of the Checkin Grace Period (after service hasn't responded, wait a bit for a response)
func (*Checkin) Hits ¶
func (c *Checkin) Hits() []*checkinHit
Hits returns all of the CheckinHits for a given Checkin
func (*Checkin) Last ¶
func (c *Checkin) Last() *checkinHit
Last returns the last checkinHit for a Checkin
func (*Checkin) RecheckCheckinFailure ¶
func (c *Checkin) RecheckCheckinFailure(guard chan struct{})
RecheckCheckinFailure will check if a Service Checkin has been reported yet
type Core ¶
func SelectCore ¶
SelectCore will return the CoreApp global variable and the settings/configs for Statup
func UpdateCore ¶
UpdateCore will update the CoreApp variable inside of the 'core' table in database
func (Core) BaseSASS ¶
BaseSASS is the base design , this opens the file /assets/scss/base.scss to be edited in Theme
func (*Core) Count24HFailures ¶
Count24HFailures returns the amount of failures for a service within the last 24 hours
func (Core) CurrentTime ¶
CurrentTime will return the current local time
func (Core) MobileSASS ¶
MobileSASS is the -webkit responsive custom css designs. This opens the file /assets/scss/mobile.scss to be edited in Theme
func (*Core) SelectAllServices ¶
SelectAllServices returns a slice of *core.Service to be store on []*core.Services, should only be called once on startup.
func (*Core) ServicesCount ¶
ServicesCount returns the amount of services inside the []*core.Services slice
func (Core) UsingAssets ¶
UsingAssets will return true if /assets folder is present
type DateScanObj ¶
type DateScanObj struct {
Array []DateScan `json:"data"`
}
DateScanObj struct is for creating the charts.js graph JSON array
func GraphDataRaw ¶
func GraphDataRaw(service types.ServiceInterface, start, end time.Time, group string, column string) *DateScanObj
GraphDataRaw will return all the hits between 2 times for a Service
func (*DateScanObj) ToString ¶
func (d *DateScanObj) ToString() string
ToString will convert the DateScanObj into a JSON string for the charts to render
type DbConfig ¶
DbConfig stores the config.yml file for the statup configuration
func EnvToConfig ¶
func EnvToConfig() *DbConfig
EnvToConfig converts environment variables to a DbConfig variable
func LoadConfigFile ¶
LoadConfigFile will attempt to load the 'config.yml' file in a specific directory
func LoadUsingEnv ¶
LoadUsingEnv will attempt to load database configs based on environment variables. If DB_CONN is set if will force this function.
func (*DbConfig) Connect ¶
Connect will attempt to connect to the sqlite, postgres, or mysql database
func (*DbConfig) CreateCore ¶
CreateCore will initialize the global variable 'CoreApp". This global variable contains most of Statup app.
func (*DbConfig) CreateDatabase ¶
CreateDatabase will CREATE TABLES for each of the Statup elements
func (*DbConfig) DropDatabase ¶
DropDatabase will DROP each table Statup created
func (*DbConfig) InsertCore ¶
InsertCore create the single row for the Core settings in Statup
func (*DbConfig) MigrateDatabase ¶
MigrateDatabase will migrate the database structure to current version. This function will NOT remove previous records, tables or columns from the database. If this function has an issue, it will ROLLBACK to the previous state.
type ErrorResponse ¶
type ErrorResponse struct {
Error string
}
ErrorResponse is used for HTTP errors to show to user
type Hit ¶
func (*Hit) BeforeCreate ¶
BeforeCreate for Hit will set CreatedAt to UTC
type Message ¶
func ReturnMessage ¶
ReturnMessage will convert *types.Message to *core.Message
func SelectMessage ¶
SelectMessage returns a Message based on the ID passed
func SelectServiceMessages ¶
SelectServiceMessages returns all messages for a service
type PluginJSON ¶
type PluginJSON types.PluginJSON
type PluginRepos ¶
type PluginRepos types.PluginRepos
type Service ¶
func ReturnService ¶
ReturnService will convert *types.Service to *core.Service
func SelectService ¶
SelectService returns a *core.Service from in memory
func (*Service) ActiveMessages ¶
ActiveMessages returns all Messages for a Service
func (*Service) AllFailures ¶
func (s *Service) AllFailures() []*failure
AllFailures will return all failures attached to a service
func (*Service) AvgTime ¶
AvgTime will return the average amount of time for a service to response back successfully
func (*Service) AvgUptime24 ¶
AvgUptime24 returns a service's average online status for last 24 hours
func (*Service) BeforeCreate ¶
BeforeCreate for Service will set CreatedAt to UTC
func (*Service) CheckQueue ¶
CheckQueue is the main go routine for checking a service
func (*Service) CheckinProcess ¶
func (s *Service) CheckinProcess()
CheckinProcess runs the checkin routine for each checkin attached to service
func (*Service) CreateFailure ¶
func (s *Service) CreateFailure(fail types.FailureInterface) (int64, error)
CreateFailure will create a new failure record for a service
func (*Service) CreateHit ¶
CreateHit will create a new 'hit' record in the database for a successful/online service
func (*Service) Delete ¶
Delete will remove a service from the database, it will also end the service checking go routine
func (*Service) DeleteFailures ¶
func (s *Service) DeleteFailures()
DeleteFailures will delete all failures for a service
func (*Service) DowntimeText ¶
DowntimeText will return the amount of downtime for a service based on the duration
service.DowntimeText() // Service has been offline for 15 minutes
func (*Service) HitsBetween ¶
HitsBetween returns the gorm database query for a collection of service hits between a time range
func (*Service) LimitedCheckins ¶
LimitedCheckins will return a slice of Checkins for a Service
func (*Service) LimitedFailures ¶
LimitedFailures will return the last amount of failures from a service
func (*Service) LimitedHits ¶
LimitedHits returns the last 1024 successful/online 'hit' records for a service
func (*Service) OnlineSince ¶
OnlineSince accepts a time since parameter to return the percent of a service's uptime.
func (*Service) SmallText ¶
SmallText returns a short description about a services status
service.SmallText() // Online since Monday 3:04:05PM, Jan _2 2006
func (*Service) TotalFailures ¶
TotalFailures returns the total amount of failures for a service
func (*Service) TotalFailures24 ¶
TotalFailures24 returns the amount of failures for a service within the last 24 hours
func (*Service) TotalFailuresSince ¶
TotalFailuresSince returns the total amount of failures for a service since a specific time/date
func (*Service) TotalHitsSince ¶
TotalHitsSince returns the total amount of hits based on a specific time/date
func (*Service) TotalUptime ¶
TotalUptime returns the total uptime percent of a service
func (*Service) Update ¶
Update will update a service in the database, the service's checking routine can be restarted by passing true
func (*Service) UpdateSingle ¶
UpdateSingle will update a single column for a service
type ServiceOrder ¶
type ServiceOrder []types.ServiceInterface
ServiceOrder will reorder the services based on 'order_id' (Order)
func (ServiceOrder) Len ¶
func (c ServiceOrder) Len() int
Sort interface for resroting the Services in order
func (ServiceOrder) Less ¶
func (c ServiceOrder) Less(i, j int) bool
func (ServiceOrder) Swap ¶
func (c ServiceOrder) Swap(i, j int)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package notifier contains the main functionality for the Statup Notification system Example Notifier Below is an example of a Notifier with multiple Form values to custom your inputs.
|
Package notifier contains the main functionality for the Statup Notification system Example Notifier Below is an example of a Notifier with multiple Form values to custom your inputs. |