Documentation ¶
Index ¶
- Variables
- type AgentService
- func (as *AgentService) GetAgentInfo(ip string, formDB bool) (*models.AgentInfo, error)
- func (as *AgentService) GetOnlineAgent(ip string, backupIPs ...string) *models.AgentInfo
- func (as *AgentService) HTTPDoRequest(agent *models.AgentInfo, method string, path string, data ...interface{}) (*web.Response, error)
- func (as *AgentService) UpdateAgent(agent models.AgentInfo, online bool) error
- func (as *AgentService) UpdateAgentStatus(ip string, status models.AgentStatus) error
- type CommandService
- type OptCheckService
- type TaskService
- func (t TaskService) CheckTaskResult()
- func (t *TaskService) GetTaskInfo(taskID interface{}) (*models.Task, error)
- func (t *TaskService) NewTask(task *models.Task) error
- func (t *TaskService) PushLog(taskID bson.ObjectId, content interface{})
- func (t *TaskService) PushTaskProcess(msg *models.Msg) error
- func (t *TaskService) StartTask(taskID bson.ObjectId) error
- func (t *TaskService) UpdateTaskStatus(taskID bson.ObjectId, to models.TaskStatus) error
- Bugs
Constants ¶
This section is empty.
Variables ¶
var AgentMgt = &AgentService{ AgentStore: make(map[string]*models.AgentInfo), }
AgentMgt Agent管理
var CommandMgt = &CommandService{}
CommandMgt 命令信息管理实例
var OptCheck = &OptCheckService{}
OptCheck 三班操作检查项
var ( //SuportCmdCategory 所支持的命令类型 SuportCmdCategory = []string{ "cmd", "ps", "mssql", } )
var TaskMgt = &TaskService{}
TaskMgt 任务工作服务
Functions ¶
This section is empty.
Types ¶
type AgentService ¶
AgentService Agent管理器
func (*AgentService) GetAgentInfo ¶
GetAgentInfo 获取Agent信息,可选择从数据库获取,否则从内存中获取.
如果 fromDB 为 true,则从数据库中根据IP查询匹配的Agent信息,否则直接从内存中获取. 但是当内存中不存在此Ageng信息时将强制从数据库中查找.
func (*AgentService) GetOnlineAgent ¶
func (as *AgentService) GetOnlineAgent(ip string, backupIPs ...string) *models.AgentInfo
GetOnlineAgent 返回在线的Agent. 优先根据ip检查内存中在线的Agent,否则依次从backupIP 列表中检查,直到得到在线的Agent.
func (*AgentService) HTTPDoRequest ¶
func (as *AgentService) HTTPDoRequest(agent *models.AgentInfo, method string, path string, data ...interface{}) (*web.Response, error)
HTTPDoRequest 用HTTP提交数据到指定Agent. 返回请求结果数据
func (*AgentService) UpdateAgent ¶
func (as *AgentService) UpdateAgent(agent models.AgentInfo, online bool) error
UpdateAgent 依据IP更新Agent,同步更新内存和数据库. 更新数据库时仅仅更新:name,url,description,status,updated字段.
func (*AgentService) UpdateAgentStatus ¶
func (as *AgentService) UpdateAgentStatus(ip string, status models.AgentStatus) error
UpdateAgentStatus 更新 Agent状态.
type CommandService ¶
type CommandService struct { }
CommandService 命令信息管理.
func (*CommandService) GetCommandByName ¶
func (c *CommandService) GetCommandByName(name string) (cmd *models.CmdInfo, err error)
GetCommandByName 按名称查询Command信息.
func (*CommandService) NewCommand ¶
func (c *CommandService) NewCommand(cmd *models.CmdInfo) error
NewCommand 保存新的命令
type OptCheckService ¶
type OptCheckService struct { }
OptCheckService 三班操作检查项
func (*OptCheckService) GetAllCheckItems ¶
func (o *OptCheckService) GetAllCheckItems() []models.CheckItem
GetAllCheckItems 获取全部检查项
func (*OptCheckService) GetCheckItemByID ¶
func (o *OptCheckService) GetCheckItemByID(id string) (item *models.CheckItem, err error)
GetCheckItemByID 根据ID获取检查项
func (*OptCheckService) RunOrStopCheckItem ¶
func (o *OptCheckService) RunOrStopCheckItem(id string, goRun bool, operator string) error
RunOrStopCheckItem 启动或停止检查项
type TaskService ¶
type TaskService struct {
// contains filtered or unexported fields
}
TaskService 任务工作服务
func (TaskService) CheckTaskResult ¶
func (t TaskService) CheckTaskResult()
func (*TaskService) GetTaskInfo ¶
func (t *TaskService) GetTaskInfo(taskID interface{}) (*models.Task, error)
GetTaskInfo 获取Task信息
func (*TaskService) NewTask ¶
func (t *TaskService) NewTask(task *models.Task) error
NewTask 返回新建任务处理结果。 新建任务时,将再Command信息中记录TaskID
func (*TaskService) PushLog ¶
func (t *TaskService) PushLog(taskID bson.ObjectId, content interface{})
PushLog 推送日志
func (*TaskService) PushTaskProcess ¶
func (t *TaskService) PushTaskProcess(msg *models.Msg) error
PushTaskProcess 推送任务处理进度信息
func (*TaskService) StartTask ¶
func (t *TaskService) StartTask(taskID bson.ObjectId) error
StartTask 开启任务
func (*TaskService) UpdateTaskStatus ¶
func (t *TaskService) UpdateTaskStatus(taskID bson.ObjectId, to models.TaskStatus) error
UpdateTaskStatus 更新任务状态
Notes ¶
Bugs ¶
将时间周期设置为可配置. 每5分钟执行一次=5*60