Documentation
¶
Index ¶
- Variables
- func CheckPluginDependencies() []string
- func CreateMarkdownTable[T any](headers []string, valuesArray [][]T) string
- func CreateOrUpdateCronInterval(name string)
- func CreateRedmineIssue(issue Issue) error
- func CreateRedmineNews(news News) error
- func EnsureShutdownNotifierService(logger zerolog.Logger)
- func HandleCommonPluginArgs(args []string, version string, configFiles []string)
- func HandleShutdownNotifier(args []string, logger zerolog.Logger)
- func InitConfig(configFiles ...string) error
- func InitLogger() (zerolog.Logger, error)
- func InitializeDatabase() error
- func IsTestMode() bool
- func RunPlugin(pluginName string, args []string) error
- func RunTUI(version string) error
- func SendZulipAlarm(message string, service string, module string, status string) error
- type CronInterval
- type DBConfigType
- type Dependencies
- type FetchPluginsMsg
- type GlobalConfigType
- type Issue
- type News
- type OsHealthConfigType
- type PluginInfo
- type ProgressMsg
- type RedmineAPIObject
- type RedmineDate
- type RedmineIssue
- type RedmineNews
- type RemotePlugin
- type SystemdUnit
- type TUIModel
- type UIState
- type UfwApplyConfigType
- type UpdateResult
- type Version
- type ZulipAlarm
Constants ¶
This section is empty.
Variables ¶
var DB *gorm.DB
var DbDir string
var IssuePriority = struct { Default int Low int Normal int High int Urgent int }{ Default: 5, Low: 4, Normal: 3, High: 2, Urgent: 1, }
var IssueStatus = struct { Working int // in progress InBreak int // in break time Feedback int // waiting for employee Feedback2 int // waiting for customer Resolved int Closed int }{ Working: 2, InBreak: 7, Feedback: 8, Feedback2: 4, Resolved: 3, Closed: 5, }
Working = in progress
InBreak = in break time
Feedback = waiting for employee
Feedback2 = waiting for customer
var LogDir string
var (
Logger zerolog.Logger
)
var PluginsDir string
Functions ¶
func CheckPluginDependencies ¶
func CheckPluginDependencies() []string
func CreateMarkdownTable ¶
func CreateOrUpdateCronInterval ¶
func CreateOrUpdateCronInterval(name string)
func CreateRedmineIssue ¶
issue.Service = plugin name, issue.Module = specific module in the plugin, issue.Status = alarm status like "up" or "down"
service, module name and status can be nil if not applicable
instead of directly giving them as string, giving them as pointer to string
Example input:
issue := lib.Issue{
ProjectIdentifier: lib.GlobalConfig.ProjectIdentifier,
Hostname: lib.GlobalConfig.Hostname,
Subject: fmt.Sprintf("%s için sistem yükü %.2f üstüne çıktı", lib.GlobalConfig.Hostname, loadLimit),
Description: alarmMessage,
Service: &pluginName,
Module: &moduleName,
Status: &down
}
func CreateRedmineNews ¶
func HandleCommonPluginArgs ¶
func HandleShutdownNotifier ¶
func InitConfig ¶
func InitLogger ¶
default configured logger for the application
logger, err := InitLogger() or lib.InitLogger()
func InitializeDatabase ¶
func InitializeDatabase() error
func IsTestMode ¶
func IsTestMode() bool
func SendZulipAlarm ¶
service = plugin name, module = specific module in the plugin, status = alarm status like "up" or "down"
service, module name and status can be nil if not applicable
instead of directly giving them as string, giving them as pointer to string
Types ¶
type CronInterval ¶
type CronInterval struct {
gorm.Model
Id uint `gorm:"primaryKey;autoIncrement"`
Name string `gorm:"text,unique" json:"name"`
LastRun *time.Time `gorm:"int" json:"last_run"`
}
CronInterval keeps track of the last run time of various cron jobs
func GetLastCronInterval ¶
func GetLastCronInterval(name string) CronInterval
type DBConfigType ¶
type DBConfigType struct {
Mysql struct {
ProcessLimit int `yaml:"process-limit"`
Credentials struct {
User string `yaml:"user"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port int `yaml:"port"`
DBName string `yaml:"dbname"`
Network string `yaml:"network"`
Socket string `yaml:"socket"`
AllowNativePasswords bool `yaml:"allow-native-passwords"`
} `yaml:"credentials"`
AutoRepair struct {
Enabled bool `yaml:"enabled"`
Day string `yaml:"day"` // Mon Tue Wed Thu Fri Sat Sun
Hour string `yaml:"hour"` // 24h format, e.g. 05:00, 17:00
} `yaml:"auto-repair"`
// Not implemented yet, but will be used for future cluster monitoring features
Cluster struct {
Enabled bool `yaml:"enabled"`
ClusterType string `yaml:"cluster-type"` // ndb, xtradb
Size int `yaml:"size"`
ReceiveQueueLimit int `yaml:"receive-queue-limit"`
FlowControlLimit float64 `yaml:"flow-control-limit"`
} `yaml:"cluster"`
Alarm struct {
Enabled bool `yaml:"enabled"`
} `yaml:"alarm"`
} `yaml:"mysql"`
MariaDB struct {
ProcessLimit int `yaml:"process-limit"`
Credentials struct {
User string `yaml:"user"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port int `yaml:"port"`
DBName string `yaml:"dbname"`
Network string `yaml:"network"`
Socket string `yaml:"socket"`
AllowNativePasswords bool `yaml:"allow-native-passwords"`
} `yaml:"credentials"`
Cluster struct {
Enabled bool `yaml:"enabled"`
ClusterType string `yaml:"cluster-type"` // galera
Size int `yaml:"size"`
ReceiveQueueLimit int `yaml:"receive-queue-limit"`
FlowControlLimit float64 `yaml:"flow-control-limit"`
} `yaml:"cluster"`
AutoRepair struct {
Enabled bool `yaml:"enabled"`
Day string `yaml:"day"` // Mon Tue Wed Thu Fri Sat Sun
Hour string `yaml:"hour"` // 24h format, e.g. 05:00, 17:00
} `yaml:"auto-repair"`
PMMAgent struct {
Enabled bool `yaml:"enabled"`
} `yaml:"pmm-agent"`
Alarm struct {
Enabled bool `yaml:"enabled"`
} `yaml:"alarm"`
} `yaml:"mariadb"`
}
var DBConfig DBConfigType
type Dependencies ¶
type Dependencies struct {
ConfigFiles []string `json:"configFiles"`
}
type FetchPluginsMsg ¶
type FetchPluginsMsg struct {
Plugins []RemotePlugin
Error error
}
type GlobalConfigType ¶
type GlobalConfigType struct {
ProjectIdentifier string `yaml:"project-identifier"`
Hostname string `yaml:"hostname"`
LogLocation string `yaml:"log-location"`
SqliteLocation string `yaml:"sqlite-location"`
PluginsLocation string `yaml:"plugins-location"`
ZulipAlarm struct {
Enabled bool `yaml:"enabled"`
Interval int `yaml:"interval"`
WebhookUrls []string `yaml:"webhook-urls"`
Limit int `yaml:"limit"`
BotApi struct {
Enabled bool `yaml:"enabled"`
AlarmUrl string `yaml:"alarm-urls"`
Email string `yaml:"email"`
ApiKey string `yaml:"api-key"`
UserEmails []string `yaml:"user-emails"`
}
} `yaml:"zulip-alarm"`
Redmine struct {
Enabled bool `yaml:"enabled"`
ApiKey string `yaml:"api-key"`
Url string `yaml:"url"`
Interval int `yaml:"interval"`
Limit int `yaml:"limit"`
} `yaml:"redmine"`
AutoUpdate struct {
Enabled bool `yaml:"enabled"`
Interval int `yaml:"interval"`
} `yaml:"auto-update"`
}
var GlobalConfig GlobalConfigType
type Issue ¶
type Issue struct {
gorm.Model
TableId uint `gorm:"primaryKey;autoIncrement"`
Id int `gorm:"int" json:"id,omitempty"`
Notes string `gorm:"text" json:"notes,omitempty"`
ProjectId string `gorm:"text" json:"project_id,omitempty"`
TrackerId int `gorm:"int" json:"tracker_id,omitempty"`
Description string `gorm:"text" json:"description,omitempty"`
Subject string `gorm:"text" json:"subject,omitempty"`
PriorityId int `gorm:"int" json:"priority_id,omitempty"`
StatusId int `gorm:"int" json:"status_id,omitempty"`
AssignedToId string `gorm:"text" json:"assigned_to_id,omitempty"`
Project RedmineAPIObject `gorm:"text" json:"project,omitempty"`
Tracker RedmineAPIObject `gorm:"text" json:"tracker,omitempty"`
IssueStatus RedmineAPIObject `gorm:"text" json:"status,omitempty"`
Priority RedmineAPIObject `gorm:"text" json:"priority,omitempty"`
Author RedmineAPIObject `gorm:"text" json:"author,omitempty"`
AssignedTo *RedmineAPIObject `gorm:"text" json:"assigned_to,omitempty"`
StartDate RedmineDate `gorm:"time" json:"start_date,omitempty"`
DueDate *RedmineDate `gorm:"time" json:"due_date,omitempty"`
DoneRatio int `gorm:"int" json:"done_ratio,omitempty"`
IsPrivate bool `gorm:"bool" json:"is_private,omitempty"`
EstimatedHours *time.Time `gorm:"time" json:"estimated_hours,omitempty"`
TotalEstimatedHours *time.Time `gorm:"time" json:"total_estimated_hours,omitempty"`
SpentHours float64 `gorm:"float" json:"spent_hours,omitempty"`
TotalSpentHours float64 `gorm:"float" json:"total_spent_hours,omitempty"`
CreatedOn time.Time `gorm:"time" json:"created_on,omitempty"`
UpdatedOn time.Time `gorm:"time" json:"updated_on,omitempty"`
ClosedOn *time.Time `gorm:"time" json:"closed_on,omitempty"`
ProjectIdentifier string `gorm:"text"` // internal use
Hostname string `gorm:"text"` // internal use
Status string `gorm:"text" json:"-"` // down or up
Service string `gorm:"text" json:"-"` // plugin name
Module string `gorm:"text" json:"-"` // plugin's module name
}
type News ¶
type News struct {
gorm.Model
TableId uint `gorm:"primaryKey;autoIncrement"`
Id int `gorm:"int" json:"id,omitempty"`
Title string `gorm:"text" json:"title,omitempty"`
Description string `gorm:"text" json:"description,omitempty"`
ProjectIdentifier string `gorm:"text" json:"-"` // internal use
Hostname string `gorm:"text" json:"-"` // internal use
}
type OsHealthConfigType ¶
type OsHealthConfigType struct {
SystemLoadAlarm struct {
Enabled bool `yaml:"enabled"`
LimitMultiplier float64 `yaml:"limit-multiplier"`
TopProcesses struct {
Enabled bool `yaml:"enabled"`
Processes int `yaml:"processes"`
} `yaml:"top-processes"`
} `yaml:"system-load-alarm"`
RamUsageAlarm struct {
Enabled bool `yaml:"enabled"`
Limit int `yaml:"limit"`
TopProcesses struct {
Enabled bool `yaml:"enabled"`
Processes int `yaml:"processes"`
} `yaml:"top-processes"`
} `yaml:"ram-usage-alarm"`
DiskUsageAlarm struct {
Enabled bool `yaml:"enabled"`
Limit int `yaml:"limit"`
} `yaml:"disk-usage-alarm"`
VersionAlarm struct {
Enabled bool `yaml:"enabled"`
} `yaml:"version-alarm"`
ServiceHealthAlarm struct {
Enabled bool `yaml:"enabled"`
Services []string `yaml:"services"`
} `yaml:"service-health-alarm"`
PowerAlarm struct {
Enabled bool `yaml:"enabled"`
} `yaml:"power-alarm"`
}
var OsHealthConfig OsHealthConfigType
type PluginInfo ¶
func ListPlugins ¶
func ListPlugins() ([]PluginInfo, error)
type RedmineAPIObject ¶
type RedmineAPIObject struct {
Id int `json:"id"`
Name string `json:"name"`
IsClosed *bool `json:"is_closed"`
}
func (*RedmineAPIObject) Scan ¶
func (r *RedmineAPIObject) Scan(value interface{}) error
type RedmineDate ¶
func (RedmineDate) MarshalJSON ¶
func (d RedmineDate) MarshalJSON() ([]byte, error)
func (*RedmineDate) Scan ¶
func (d *RedmineDate) Scan(value interface{}) error
func (*RedmineDate) UnmarshalJSON ¶
func (d *RedmineDate) UnmarshalJSON(b []byte) error
Convert redmine date formatting to golang and database compatible format
type RedmineIssue ¶
type RedmineIssue struct {
Issue Issue `json:"issue"`
}
func GetIssueFromRedmine ¶
func GetIssueFromRedmine(id int) (RedmineIssue, error)
type RedmineNews ¶
type RedmineNews struct {
News News `json:"news"`
}
type RemotePlugin ¶
type SystemdUnit ¶
type SystemdUnit struct {
gorm.Model
ProjectIdentifier string `gorm:"text"` // internal use
Hostname string `gorm:"text"` // internal use
Name string `gorm:"text,unique"`
LoadState string `gorm:"text"`
ActiveState string `gorm:"text"`
SubState string `gorm:"text"`
Uptime int64 `gorm:"int"`
Description string `gorm:"text"`
// contains filtered or unexported fields
}
type TUIModel ¶
type TUIModel struct {
// contains filtered or unexported fields
}
func NewTUIModel ¶
type UfwApplyConfigType ¶
type UfwApplyConfigType struct {
RuleSources []struct {
Url string `yaml:"url"`
Protocol string `yaml:"protocol"`
Port string `yaml:"port"`
Comment string `yaml:"comment"`
} `yaml:"rule-sources"`
StaticRules []struct {
IP string `yaml:"ip"`
Protocol string `yaml:"protocol"`
Port string `yaml:"port"`
Comment string `yaml:"comment"`
} `yaml:"static-rules"`
RulesetDir string `yaml:"ruleset-dir"`
}
var UfwApplyConfig UfwApplyConfigType
type UpdateResult ¶
type UpdateResult struct {
Name string
OldVersion string
NewVersion string
Updated bool
Error error
}
func UpdateMonokit2 ¶
func UpdateMonokit2(currentVersion string, forceUpdate bool) (*UpdateResult, error)
UpdateMonokit2 updates the monokit2 binary to the latest version It backs up the current binary, downloads the new one, and restores on failure
func UpdatePlugins ¶
func UpdatePlugins(currentMonokitVersion string, forceUpdate bool) ([]UpdateResult, error)
UpdatePlugins updates all plugins to the latest version It backs up current plugins, downloads new ones, and restores on failure
type Version ¶
type Version struct {
gorm.Model
Id uint `gorm:"primaryKey;autoIncrement"`
Name string `gorm:"text,unique" json:"name"`
Version string `gorm:"text" json:"version"` // direct version
VersionMulti string `gorm:"text" json:"version_multi"` // version in json format for software with multiple components
Status string `gorm:"text" json:"status"` // installed, not-installed
}
type ZulipAlarm ¶
type ZulipAlarm struct {
gorm.Model
Id uint `gorm:"primaryKey"`
ProjectIdentifier string `gorm:"text"` // internal use
Hostname string `gorm:"text"` // internal use
Content string `gorm:"text"`
Status string `gorm:"text"` // down or up
Service string `gorm:"text"` // plugin name
Module string `gorm:"text"` // plugin's module name
}
func GetLastZulipAlarm ¶
func GetLastZulipAlarm(service string, module string) (ZulipAlarm, error)
func GetLastZulipAlarms ¶
func GetLastZulipAlarms(service string, module string) ([]ZulipAlarm, error)