Documentation ¶
Overview ¶
Package core contains the main functionality of Statping. 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/statping
Index ¶
- Variables
- func CheckHash(password, hash string) bool
- func CloseDB()
- func CountFailures() uint64
- func CountUsers() int64
- 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 ExportSettings() ([]byte, error)
- func GetLocalIP() string
- func InitApp()
- func InsertLargeSampleData() error
- func InsertNotifierDB() error
- func InsertSampleData() error
- func InsertSampleHits() error
- func SampleData() error
- func Services() []types.ServiceInterface
- type Checkin
- func (c *Checkin) AfterFind() (err error)
- func (c *Checkin) AllFailures() []*types.Failure
- func (c *Checkin) AllHits() []*types.CheckinHit
- 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) Last() *CheckinHit
- func (c *Checkin) LimitedFailures(amount int64) []types.FailureInterface
- func (c *Checkin) LimitedHits(amount int64) []*types.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) Select() *types.Checkin
- func (c *Checkin) Service() *Service
- func (c *Checkin) String() string
- func (c *Checkin) Update() (int64, error)
- type CheckinHit
- type Core
- func (c *Core) AfterFind() (err error)
- 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) Messages() []*Message
- func (c Core) MobileSASS() string
- func (c Core) SassVars() string
- func (c *Core) SelectAllServices(start bool) ([]*Service, error)
- func (c *Core) ToCore() *types.Core
- func (c Core) UsingAssets() bool
- type DateScan
- type DateScanObj
- type DbConfig
- 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 ExportData
- type Failure
- type Group
- type GroupOrder
- type Hit
- type Incident
- type IncidentUpdate
- type Message
- type PluginJSON
- type PluginRepos
- type Service
- func (s *Service) ActiveMessages() []*Message
- func (s *Service) AfterFind() (err error)
- func (s *Service) AllCheckins() []*Checkin
- func (s *Service) AllFailures() []*Failure
- func (s *Service) AvgTime() string
- func (s *Service) AvgUptime(ago time.Time) string
- func (s *Service) AvgUptime24() string
- func (s *Service) Check(record bool)
- func (s *Service) CheckQueue(record bool)
- func (s *Service) CheckinProcess()
- 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) FailuresDaysAgo(days int) uint64
- func (s *Service) Hits() ([]*types.Hit, error)
- func (s *Service) HitsBetween(t1, t2 time.Time, group string, column string) *gorm.DB
- func (s *Service) Incidents() []*Incident
- func (s *Service) LimitedCheckinFailures(amount int64) []*Failure
- func (s *Service) LimitedFailures(amount int64) []*Failure
- func (s *Service) LimitedHits(amount int64) ([]*types.Hit, error)
- func (s *Service) Messages() []*Message
- func (s *Service) OnlineDaysPercent(days int) float32
- func (s *Service) OnlineSince(ago time.Time) float32
- func (s *Service) Select() *types.Service
- func (s *Service) SmallText() string
- func (s *Service) SparklineDayFailures(days int) string
- func (s *Service) SparklineHourResponse(hours int, method string) string
- func (s *Service) Sum() float64
- func (s *Service) TotalFailures() (uint64, error)
- func (s *Service) TotalFailures24() (uint64, error)
- func (s *Service) TotalFailuresOnDate(ago time.Time) (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
- type ServiceOrder
- type User
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 Statping does not have a database connection VERSION string // VERSION is set on build automatically by setting a -ldflag )
var ( // DbSession stores the Statping database session DbSession *gorm.DB DbModels []interface{} )
var (
SampleHits = 9900.
)
Functions ¶
func CloseDB ¶ added in v0.79.1
func CloseDB()
CloseDB will close the database connection if available
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 ¶ added in v0.79.1
Dbtimestamp will return a SQL query for grouping by date
func DefaultPort ¶ added in v0.79.1
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 ¶ added in v0.79.1
func ExportChartsJs() string
ExportChartsJs renders the charts for the index page
func ExportSettings ¶ added in v0.79.9
ExportSettings will export a JSON file containing all of the settings below: - Core - Notifiers - Checkins - Users - Services - Groups - Messages
func GetLocalIP ¶ added in v0.79.9
func GetLocalIP() string
GetLocalIP returns the non loopback local IP of the host
func InsertLargeSampleData ¶ added in v0.79.1
func InsertLargeSampleData() error
InsertLargeSampleData will create the example/dummy services for testing the Statping server
func InsertNotifierDB ¶ added in v0.79.1
func InsertNotifierDB() error
InsertNotifierDB inject the Statping database instance to the Notifier package
func InsertSampleData ¶ added in v0.79.1
func InsertSampleData() error
InsertSampleData will create the example/dummy services for a brand new Statping installation
func InsertSampleHits ¶ added in v0.79.1
func InsertSampleHits() error
InsertSampleHits will create a couple new hits for the sample services
func SampleData ¶ added in v0.79.1
func SampleData() error
SampleData runs all the sample data for a new Statping installation
func Services ¶ added in v0.79.1
func Services() []types.ServiceInterface
Types ¶
type Checkin ¶
func AllCheckins ¶ added in v0.79.9
func AllCheckins() []*Checkin
AllCheckins returns all checkin in system
func ReturnCheckin ¶ added in v0.79.1
ReturnCheckin converts *types.Checking to *core.Checkin
func SelectCheckin ¶ added in v0.79.1
SelectCheckin will find a Checkin based on the API supplied
func (*Checkin) AllFailures ¶ added in v0.79.9
Hits returns all of the CheckinHits for a given Checkin
func (*Checkin) AllHits ¶ added in v0.79.9
func (c *Checkin) AllHits() []*types.CheckinHit
AllHits returns all of the CheckinHits for a given Checkin
func (*Checkin) CreateFailure ¶
func (*Checkin) Expected ¶ added in v0.79.1
Expected returns the duration of when the serviec should receive a Checkin
func (*Checkin) Grace ¶ added in v0.79.1
Grace will return the duration of the Checkin Grace Period (after service hasn't responded, wait a bit for a response)
func (*Checkin) Last ¶ added in v0.79.1
func (c *Checkin) Last() *CheckinHit
Last returns the last checkinHit for a Checkin
func (*Checkin) LimitedFailures ¶ added in v0.79.98
func (c *Checkin) LimitedFailures(amount int64) []types.FailureInterface
Hits returns all of the CheckinHits for a given Checkin
func (*Checkin) LimitedHits ¶ added in v0.79.98
func (c *Checkin) LimitedHits(amount int64) []*types.CheckinHit
LimitedHits will return the last amount of successful hits from a checkin
func (*Checkin) RecheckCheckinFailure ¶
func (c *Checkin) RecheckCheckinFailure(guard chan struct{})
RecheckCheckinFailure will check if a Service Checkin has been reported yet
func (*Checkin) Routine ¶ added in v0.79.1
func (c *Checkin) Routine()
Routine for checking if the last Checkin was within its interval
type CheckinHit ¶ added in v0.79.9
type CheckinHit struct {
*types.CheckinHit
}
func ReturnCheckinHit ¶ added in v0.79.1
func ReturnCheckinHit(c *types.CheckinHit) *CheckinHit
ReturnCheckinHit converts *types.checkinHit to *core.checkinHit
func (*CheckinHit) AfterFind ¶ added in v0.79.9
func (c *CheckinHit) AfterFind() (err error)
AfterFind for checkinHit will set the timezone
func (*CheckinHit) Ago ¶ added in v0.79.9
func (c *CheckinHit) Ago() string
Ago returns the duration of time between now and the last successful checkinHit
func (*CheckinHit) Create ¶ added in v0.79.9
func (c *CheckinHit) Create() (int64, error)
Create will create a new successful checkinHit
type Core ¶
func SelectCore ¶
SelectCore will return the CoreApp global variable and the settings/configs for Statping
func UpdateCore ¶ added in v0.79.1
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 ¶ added in v0.79.1
Count24HFailures returns the amount of failures for a service within the last 24 hours
func (*Core) CountOnline ¶ added in v0.79.1
CountOnline returns the amount of services online
func (Core) CurrentTime ¶ added in v0.79.1
CurrentTime will return the current local time
func (Core) MobileSASS ¶ added in v0.28.5
MobileSASS is the -webkit responsive custom css designs. This opens the file /assets/scss/mobile.scss to be edited in Theme
func (*Core) SelectAllServices ¶ added in v0.79.1
SelectAllServices returns a slice of *core.Service to be store on []*core.Services, should only be called once on startup.
func (Core) UsingAssets ¶
UsingAssets will return true if /assets folder is present
type DateScanObj ¶ added in v0.79.1
type DateScanObj struct {
Array []DateScan `json:"data"`
}
DateScanObj struct is for creating the charts.js graph JSON array
func GraphDataRaw ¶ added in v0.79.1
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 ¶ added in v0.79.1
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 ¶ added in v0.79.1
EnvToConfig converts environment variables to a DbConfig variable
func LoadConfigFile ¶ added in v0.79.1
LoadConfigFile will attempt to load the 'config.yml' file in a specific directory
func LoadUsingEnv ¶ added in v0.29.7
LoadUsingEnv will attempt to load database configs based on environment variables. If DB_CONN is set if will force this function.
func (*DbConfig) Connect ¶ added in v0.79.1
Connect will attempt to connect to the sqlite, postgres, or mysql database
func (*DbConfig) CreateCore ¶ added in v0.79.1
CreateCore will initialize the global variable 'CoreApp". This global variable contains most of Statping app.
func (*DbConfig) CreateDatabase ¶ added in v0.79.1
CreateDatabase will CREATE TABLES for each of the Statping elements
func (*DbConfig) DropDatabase ¶ added in v0.79.1
DropDatabase will DROP each table Statping created
func (*DbConfig) InsertCore ¶ added in v0.79.1
InsertCore create the single row for the Core settings in Statping
func (*DbConfig) MigrateDatabase ¶ added in v0.79.1
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 ExportData ¶ added in v0.79.9
type ExportData struct { Core *types.Core `json:"core"` Services []types.ServiceInterface `json:"services"` Messages []*Message `json:"messages"` Checkins []*Checkin `json:"checkins"` Users []*User `json:"users"` Groups []*Group `json:"groups"` Notifiers []types.AllNotifiers `json:"notifiers"` }
type Failure ¶
func (*Failure) ParseError ¶
ParseError returns a human readable error for a Failure
type Group ¶ added in v0.80.5
func SelectGroup ¶ added in v0.80.5
SelectGroup returns a *core.Group
func SelectGroups ¶ added in v0.80.5
SelectGroups returns all groups
func (*Group) VisibleServices ¶ added in v0.80.56
VisibleServices returns all services based on authentication
type GroupOrder ¶ added in v0.80.5
type GroupOrder []*Group
GroupOrder will reorder the groups based on 'order_id' (Order)
func (GroupOrder) Len ¶ added in v0.80.5
func (c GroupOrder) Len() int
Sort interface for resorting the Groups in order
func (GroupOrder) Less ¶ added in v0.80.5
func (c GroupOrder) Less(i, j int) bool
func (GroupOrder) Swap ¶ added in v0.80.5
func (c GroupOrder) Swap(i, j int)
type Incident ¶ added in v0.80.63
func AllIncidents ¶ added in v0.80.63
func AllIncidents() []*Incident
AllIncidents will return all incidents and updates recorded
func (*Incident) AllUpdates ¶ added in v0.80.63
func (i *Incident) AllUpdates() []*IncidentUpdate
AllUpdates will return the all updates for an incident
func (*Incident) Create ¶ added in v0.80.63
Create will create a incident and insert it into the database
type IncidentUpdate ¶ added in v0.80.63
type IncidentUpdate struct {
*types.IncidentUpdate
}
func (*IncidentUpdate) Create ¶ added in v0.80.63
func (i *IncidentUpdate) Create() (int64, error)
Create will create a incident update and insert it into the database
func (*IncidentUpdate) Delete ¶ added in v0.80.63
func (i *IncidentUpdate) Delete() error
Delete will remove a incident update
type Message ¶ added in v0.79.4
func ReturnMessage ¶ added in v0.79.4
ReturnMessage will convert *types.Message to *core.Message
func SelectMessage ¶ added in v0.79.4
SelectMessage returns a Message based on the ID passed
func SelectMessages ¶ added in v0.79.4
SelectMessages returns all messages
func SelectServiceMessages ¶ added in v0.79.4
SelectServiceMessages returns all messages for a service
func (*Message) Create ¶ added in v0.79.4
Create will create a Message and insert it into the database
type PluginJSON ¶
type PluginJSON types.PluginJSON
type PluginRepos ¶
type PluginRepos types.PluginRepos
type Service ¶
func ReturnService ¶ added in v0.79.1
ReturnService will convert *types.Service to *core.Service
func SelectService ¶
SelectService returns a *core.Service from in memory
func SelectServiceLink ¶ added in v0.80.5
SelectServiceLink returns a *core.Service from the service permalink
func SelectServices ¶ added in v0.80.56
func (*Service) ActiveMessages ¶ added in v0.79.4
ActiveMessages returns all service messages that are available based on the current time
func (*Service) AllCheckins ¶ added in v0.79.98
AllCheckins will return a slice of AllCheckins for a Service
func (*Service) AllFailures ¶ added in v0.79.1
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 ¶ added in v0.79.1
AvgUptime24 returns a service's average online status for last 24 hours
func (*Service) Check ¶
Check will run checkHttp for HTTP services and checkTcp for TCP services if record param is set to true, it will add a record into the database.
func (*Service) CheckQueue ¶
CheckQueue is the main go routine for checking a service
func (*Service) CheckinProcess ¶ added in v0.79.1
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) Downtime ¶ added in v0.79.1
Downtime returns the amount of time of a offline service
func (*Service) DowntimeText ¶ added in v0.79.1
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) FailuresDaysAgo ¶ added in v0.80.5
FailuresDaysAgo returns the amount of failures since days ago
func (*Service) HitsBetween ¶ added in v0.79.1
HitsBetween returns the gorm database query for a collection of service hits between a time range
func (*Service) LimitedCheckinFailures ¶ added in v0.79.91
LimitedFailures will return the last amount of failures from 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) OnlineDaysPercent ¶ added in v0.80.5
OnlineDaysPercent returns the service's uptime percent within last 24 hours
func (*Service) OnlineSince ¶ added in v0.79.1
OnlineSince accepts a time since parameter to return the percent of a service's uptime.
func (*Service) SmallText ¶ added in v0.27.9
SmallText returns a short description about a services status
service.SmallText() // Online since Monday 3:04:05PM, Jan _2 2006
func (*Service) SparklineDayFailures ¶ added in v0.80.5
SparklineDayFailures returns a string array of daily service failures
func (*Service) SparklineHourResponse ¶ added in v0.80.5
SparklineHourResponse returns a string array for the average response or ping time for a service
func (*Service) TotalFailures ¶
TotalFailures returns the total amount of failures for a service
func (*Service) TotalFailures24 ¶ added in v0.79.1
TotalFailures24 returns the amount of failures for a service within the last 24 hours
func (*Service) TotalFailuresOnDate ¶ added in v0.80.5
TotalFailuresOnDate returns the total amount of failures for a service on a specific time/date
func (*Service) TotalFailuresSince ¶ added in v0.79.1
TotalFailuresSince returns the total amount of failures for a service since a specific time/date
func (*Service) TotalHitsSince ¶ added in v0.79.1
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
type ServiceOrder ¶ added in v0.79.1
type ServiceOrder []types.ServiceInterface
ServiceOrder will reorder the services based on 'order_id' (Order)
func (ServiceOrder) Len ¶ added in v0.79.1
func (c ServiceOrder) Len() int
Sort interface for resroting the Services in order
func (ServiceOrder) Less ¶ added in v0.79.1
func (c ServiceOrder) Less(i, j int) bool
func (ServiceOrder) Swap ¶ added in v0.79.1
func (c ServiceOrder) Swap(i, j int)
type User ¶
func AuthUser ¶
AuthUser will return the User and a boolean if authentication was correct. AuthUser accepts username, and password as a string
func ReturnUser ¶ added in v0.79.1
ReturnUser returns *core.User based off a *types.User
func SelectUser ¶
SelectUser returns the User based on the User's ID.
func SelectUsername ¶
SelectUsername returns the User based on the User's username
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package notifier contains the main functionality for the Statping 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 Statping Notification system Example Notifier Below is an example of a Notifier with multiple Form values to custom your inputs. |