// getAgentStatus return overall agent status + status of the plugins
// the method takes into account non-fatal plugin settings
12157
func (p *Plugin) getAgentStatus() ExposedStatus {

	exposedStatus := ExposedStatus{
		AgentStatus:     p.StatusCheck.GetAgentStatus(),
		PluginStatus:    p.StatusCheck.GetAllPluginStatus(),
		NonFatalPlugins: p.NonFatalPlugins,
	}

	// check whether error is caused by one of the plugins in NonFatalPlugin list
	if exposedStatus.AgentStatus.State == status.OperationalState_ERROR && len(p.NonFatalPlugins) > 0 {
		for k, v := range exposedStatus.PluginStatus {
			if v.State == status.OperationalState_ERROR {
				if isInSlice(p.NonFatalPlugins, k) {
					// treat error reported by this plugin as non fatal
					exposedStatus.AgentStatus.State = status.OperationalState_OK
				} else {
					exposedStatus.AgentStatus.State = status.OperationalState_ERROR
					break
				}
			}

		}
	}

	return exposedStatus
}
1246753
func (s *Server) ModifyStatus(ctx context.Context,
	in *ModifyStatusRequest) (*ModifyStatusResponse, error) {

	log.Debugf("Setting agent enabled=%v", in.Enable)

	var err error
	if in.Enable {
		err = s.manager.StartAgent()
	} else {
		err = s.manager.StopAgent()
	}
	return &ModifyStatusResponse{}, err
}
180496
func (r Monitoring_Agent) GetStatusName() (resp string, err error) {
	err = r.Session.DoRequest("SoftLayer_Monitoring_Agent", "getStatusName", nil, &r.Options, &resp)
	return
}
1165726
func (a API) SetAgentStatus(args params.SetStatus) error {
	var result params.ErrorResults
	err := a.facade.FacadeCall("SetAgentStatus", args, &result)
	if err != nil {
		return err
	}
	return result.Combine()
}
647893
func (a *Agent) UpdateTaskStatus(ctx context.Context, taskID string, status *api.TaskStatus) error {
	log.G(ctx).WithField("task.id", taskID).Debug("(*Agent).UpdateTaskStatus")
	ctx, cancel := context.WithCancel(ctx)
	defer cancel()

	errs := make(chan error, 1)
	if err := a.withSession(ctx, func(session *session) error {
		go func() {
			err := session.sendTaskStatus(ctx, taskID, status)
			if err != nil {
				if err == errTaskUnknown {
					err = nil // dispatcher no longer cares about this task.
				} else {
					log.G(ctx).WithError(err).Error("closing session after fatal error")
					session.sendError(err)
				}
			} else {
				log.G(ctx).Debug("task status reported")
			}

			errs <- err
		}()

		return nil
	}); err != nil {
		return err
	}

	select {
	case err := <-errs:
		return err
	case <-ctx.Done():
		return ctx.Err()
	}
}
345102
func (r Account_Agreement) GetStatus() (resp datatypes.Account_Agreement_Status, err error) {
	err = r.Session.DoRequest("SoftLayer_Account_Agreement", "getStatus", nil, &r.Options, &resp)
	return
}
941370
func (u *Unit) AgentStatus() (status.StatusInfo, error) {
	agent := newUnitAgent(u.st, u.Tag(), u.Name())
	return agent.Status()
}
543932
func (u *UnitAgent) Status() (status.StatusInfo, error) {
	info, err := getStatus(u.st.db(), u.globalKey(), "agent")
	if err != nil {
		return status.StatusInfo{}, errors.Trace(err)
	}
	// The current health spec says when a hook error occurs, the workload should
	// be in error state, but the state model more correctly records the agent
	// itself as being in error. So we'll do that model translation here.
	// TODO(fwereade): this should absolutely not be happpening in the model.
	// TODO: when fixed, also fix code in status.go for UnitAgent.
	if info.Status == status.Error {
		return status.StatusInfo{
			Status:  status.Idle,
			Message: "",
			Data:    map[string]interface{}{},
			Since:   info.Since,
		}, nil
	}
	return info, nil
}
516949
func (c *SessionContext) GetAgent() (agent.Agent, *ssh.Certificate, error) {
	pub, _, _, _, err := ssh.ParseAuthorizedKey(c.sess.GetPub())
	if err != nil {
		return nil, nil, trace.Wrap(err)
	}
	cert, ok := pub.(*ssh.Certificate)
	if !ok {
		return nil, nil, trace.BadParameter("expected certificate, got %T", pub)
	}
	if len(cert.ValidPrincipals) == 0 {
		return nil, nil, trace.BadParameter("expected at least valid principal in certificate")
	}
	privateKey, err := ssh.ParseRawPrivateKey(c.sess.GetPriv())
	if err != nil {
		return nil, nil, trace.Wrap(err, "failed to parse SSH private key")
	}

	keyring := agent.NewKeyring()
	err = keyring.Add(agent.AddedKey{
		PrivateKey:  privateKey,
		Certificate: cert,
	})
	if err != nil {
		return nil, nil, trace.Wrap(err)
	}
	return keyring, cert, nil
}
118393
func agentDoing(agentStatus statusInfoContents) string {
	if agentStatus.Current != status.Executing {
		return ""
	}
	// First see if we can determine a hook name.
	var hookNames []string
	for _, h := range hooks.UnitHooks() {
		hookNames = append(hookNames, string(h))
	}
	for _, h := range hooks.RelationHooks() {
		hookNames = append(hookNames, string(h))
	}
	hookExp := regexp.MustCompile(fmt.Sprintf(`running (?P<hook>%s?) hook`, strings.Join(hookNames, "|")))
	match := hookExp.FindStringSubmatch(agentStatus.Message)
	if len(match) > 0 {
		return match[1]
	}
	// Now try for an action name.
	actionExp := regexp.MustCompile(`running action (?P<action>.*)`)
	match = actionExp.FindStringSubmatch(agentStatus.Message)
	if len(match) > 0 {
		return match[1]
	}
	return ""
}
1324454
func (c *statusContext) processUnitAndAgentStatus(unit *state.Unit, expectWorkload bool) (agentStatus, workloadStatus params.DetailedStatus) {
	wrapped := &contextUnit{unit, expectWorkload, c}
	agent, workload := c.presence.UnitStatus(wrapped)
	populateStatusFromStatusInfoAndErr(&agentStatus, agent.Status, agent.Err)
	populateStatusFromStatusInfoAndErr(&workloadStatus, workload.Status, workload.Err)

	agentStatus.Life = processLife(unit)

	if t, err := unit.AgentTools(); err == nil {
		agentStatus.Version = t.Version.Number.String()
	}
	return
}
869383
func (l *ListCheckRunsOptions) GetStatus() string {
	if l == nil || l.Status == nil {
		return ""
	}
	return *l.Status
}
352216
func (d *PendingDeployment) GetStatus() (string, <-chan struct{}) {
	// mutex lock not necessary; d.status.Get is protected
	status, notify := d.status.Get()
	return status.(string), notify
}
414040
func (r Network_ContentDelivery_Account) GetStatus() (resp datatypes.Network_ContentDelivery_Account_Status, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_ContentDelivery_Account", "getStatus", nil, &r.Options, &resp)
	return
}
887023
func (r Product_Upgrade_Request) GetStatus() (resp datatypes.Product_Upgrade_Request_Status, err error) {
	err = r.Session.DoRequest("SoftLayer_Product_Upgrade_Request", "getStatus", nil, &r.Options, &resp)
	return
}
607762
func (c *CreateCheckRunOptions) GetStatus() string {
	if c == nil || c.Status == nil {
		return ""
	}
	return *c.Status
}
405484
func (s *StartDataCollectionByAgentIdsOutput) SetAgentsConfigurationStatus(v []*AgentConfigurationStatus) *StartDataCollectionByAgentIdsOutput {
	s.AgentsConfigurationStatus = v
	return s
}