Documentation ¶
Index ¶
- Constants
- Variables
- func AddAlert(alert *Alert) error
- func AddAlertConf(conf *AlertConf) error
- func AddAlertUser(clusterId int, alertName string, users []string) error
- func AddReadAlertId(userName string) error
- func AddSession(userInfo *UserInfo)
- func AddSystemLog(log *Log) error
- func CheckSession(s string, expireSec int) (bool, int)
- func CreateUser(name, passwd, email string, permission int) error
- func DeleteAlert(clusterId int, expirationMs int64) error
- func DeleteAlertUser(clusterId int, alertName string, users []string) error
- func DeleteSystemLog(expirationMs int64) error
- func DeleteUser(name string) error
- func GetAlertUser(clusterId int, alertName string) ([]string, error)
- func GetLoginUserByToken(token string) string
- func GetLoginWriteUser() string
- func GetNewPassWord() string
- func GetReadAlertId(userName string) (int64, error)
- func GetUnreadAlertNum(clusterId int, readId int64) (int64, error)
- func GetUserEmail(name string) (string, error)
- func GetUserPassword(name string) (string, error)
- func Init(cfg *pigeon.Configure) error
- func ListUser(userName string) (*[]UserInfo, error)
- func ListUserWithEmail() ([]string, error)
- func Logout(name string)
- func SendAlert(clusterId int, alert *Alert) error
- func UpdateAlertConf(conf *AlertConf) error
- func UpdateReadAlertId(id int64, userName string) error
- func UpdateUserEmail(name, email string) error
- func UpdateUserPassWord(name, passwd string) error
- func UpdateUserPermission(name string, perm int) error
- type Alert
- type AlertConf
- type AlertInfo
- type Log
- type LogInfo
- type UserInfo
Constants ¶
View Source
const ( ALERT_CRITICAL = 1 ALERT_WARNING = 2 CRITICAL = "critical" WARNING = "warning" INVALID = "invalid" )
View Source
const ( USER_ADMIN_NAME = "admin" USER_ADMIN_PASSWORD = "curve" ADMIN_PERM = 7 WRITE_PERM = 2 NEW_PASSWORD_LENGTH = 8 )
View Source
const (
SQLITE_DB_FILE = "db.sqlite.filepath"
)
Variables ¶
View Source
var ( // user table CREATE_USER_TABLE = `` /* 154-byte string literal not displayed */ // system log table CREATE_SYSTEM_LOG_TABLE = `` /* 227-byte string literal not displayed */ // alert conf table CREATE_ALERT_CONF_TABLE = `` /* 243-byte string literal not displayed */ // alert user table CREATE_ALERT_USER_TABLE = `` /* 150-byte string literal not displayed */ // alert table CREATE_ALERT_TABLE = `` /* 196-byte string literal not displayed */ // read alert table CREATE_READ_ALERT_TABLE = ` CREATE TABLE IF NOT EXISTS read_alert ( username TEXT PRIMARY KEY, id INTEGER ) ` // user CREATE_ADMIN = `INSERT OR IGNORE INTO user(username, password, email, permission) VALUES(?, ?, ?, ?)` CREATE_USER = `INSERT INTO user(username, password, email, permission) VALUES(?, ?, ?, ?)` DELETE_USER = `DELETE FROM user WHERE username=?` GET_USER = `SELECT * FROM user WHERE username=?` GET_USER_EMAIL = `SELECT email FROM user WHERE username=?` GET_USER_PASSWORD = `SELECT password FROM user WHERE username=?` LIST_USER = `SELECT * FROM user WHERE username!=?` LIST_USER_WITH_EMAIL = `SELECT username FROM user WHERE email!=?` UPDATE_USER_PASSWORD = `UPDATE user SET password=? WHERE username=?` UPDATE_USER_EMAIL = `UPDATE user SET email=? WHERE username=?` UPDATE_USER_PERMISSION = `UPDATE user SET permission=? WHERE username=?` // system log ADD_SYSTEM_LOG = `` /* 134-byte string literal not displayed */ GET_SYSTEM_LOG_NUM = `` /* 137-byte string literal not displayed */ GET_SYSTEM_LOG = `` /* 171-byte string literal not displayed */ GET_SYSTEM_LOG_NUM_OF_USER = `` /* 148-byte string literal not displayed */ GET_SYSTEM_LOG_OF_USER = `` /* 184-byte string literal not displayed */ DELETE_SYSTEM_LOG = `DELETE FROM system_log WHERE timestamp<?` // alert conf ADD_ALERT_CONF = `INSERT OR IGNORE INTO alert_conf(cluster, name, level, interval, times, enable, rule, desc) VALUES(?, ?, ?, ?, ?, ?, ?, ?)` UPDATE_ALERT_CONF = `UPDATE alert_conf SET interval=?, times=?, enable=?, rule=? WHERE cluster=? AND name=?` GET_ALERT_CONF = `SELECT * FROM alert_conf WHERE cluster=? ORDER BY name ASC` // alert user ADD_ALERT_USER = `INSERT OR IGNORE INTO alert_user(cluster, alert, user) VALUES(?, ?, ?)` DELETE_ALERT_USER = `DELETE FROM alert_user WHERE cluster=? AND alert=? AND user=?` GET_ALERT_USER = `SELECT user FROM alert_user WHERE cluster=? AND alert=?` // alert ADD_SYSTEM_ALERT = `INSERT OR IGNORE INTO alert(cluster, timestamp, level, name, duration, summary) VALUES(?, ?, ?, ?, ?, ?)` GET_SYSTEM_ALERT_NUM = `SELECT COUNT(*) FROM alert WHERE timestamp>=? AND timestamp<=? AND cluster=?` GET_SYSTEM_ALERT = `SELECT * FROM alert WHERE timestamp>=? AND timestamp<=? AND cluster=?` DELETE_SYSTEM_ALERT = `DELETE FROM alert WHERE cluster=? AND timestamp<?` GET_UNREAD_SYSTEM_ALERT_NUM = `SELECT COUNT(*) FROM alert WHERE id>? AND cluster=?` // read alert ADD_READ_ALERT_ID = `INSERT OR IGNORE INTO read_alert(username, id) VALUES(?, ?)` GET_READ_ALERT_ID = `SELECT id FROM read_alert WHERE username=?` UPDATE_READ_ALERT_ID = `UPDATE read_alert SET id=? WHERE username=?` )
Functions ¶
func AddAlertConf ¶
func AddReadAlertId ¶
func AddSession ¶
func AddSession(userInfo *UserInfo)
func AddSystemLog ¶
func CreateUser ¶
func DeleteAlert ¶
func DeleteSystemLog ¶
func DeleteUser ¶
func GetLoginUserByToken ¶
func GetLoginWriteUser ¶
func GetLoginWriteUser() string
func GetNewPassWord ¶
func GetNewPassWord() string
func GetReadAlertId ¶
func GetUserEmail ¶
func GetUserPassword ¶
func ListUserWithEmail ¶
func UpdateAlertConf ¶
func UpdateReadAlertId ¶
func UpdateUserEmail ¶
func UpdateUserPassWord ¶
func UpdateUserPermission ¶
Types ¶
type AlertConf ¶
type AlertConf struct { ClusterId int Name string Level int LevelStr string Interval uint32 Times uint32 Enable int EnableBool bool Rule string Desc string }
func GetAlertConf ¶
type Log ¶
type Log struct { TimeMs int64 `json:"-"` IP string `json:"ip"` Time string `json:"time"` User string `json:"user"` Module string `json:"module"` Method string `json:"method"` ErrorCode int `json:"errorCode"` ErrorMsg string `json:"errorMsg"` Content string `json:"content"` // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.