func (c *Client) List() ([]*Agent, error) {
	sudo := "sudo"
	if c.noSudo {
		sudo = ""
	}

	list := []*Agent{}

	listCmd := strings.TrimSpace(
		fmt.Sprintf(
			"%s %s -l",
			sudo,
			c.manageExec,
		),
	)

	s, err := c.run(listCmd)
	if err != nil {
		return nil, err
	}

	if c.debug {
		fmt.Printf("-- Start Raw Response --\n%s\n-- End Raw Response--\n", s)
	}

	for _, item := range strings.Split(s, "\n") {
		matches := entryRx.FindAllStringSubmatch(item, -1)
		if len(matches) == 0 {
			continue
		}

		list = append(list, &Agent{
			ID:   matches[0][1],
			Name: matches[0][2],
			IP:   matches[0][3],
		})
	}

	return list, nil
}
// List lists all ossec agents
List lists all ossec agents
// List lists all ossec agents
func (c *Client) List() ([]*Agent, error) {
	sudo := "sudo"
	if c.noSudo {
		sudo = ""
	}
	list := []*Agent{}
	listCmd := strings.TrimSpace(
		fmt.Sprintf(
			"%s %s -l",
			sudo,
			c.manageExec,
		),
	)
	s, err := c.run(listCmd)
	if err != nil {
		return nil, err
	}
	if c.debug {
		fmt.Printf("-- Start Raw Response --\n%s\n-- End Raw Response--\n", s)
	}
	for _, item := range strings.Split(s, "\n") {
		matches := entryRx.FindAllStringSubmatch(item, -1)
		if len(matches) == 0 {
			continue
		}
		list = append(list, &Agent{
			ID:   matches[0][1],
			Name: matches[0][2],
			IP:   matches[0][3],
		})
	}
	return list, nil
}
func ( c * Client ) List ( ) ( [ ] * Agent , error ) { sudo := " " if c . noSudo { sudo = " " } list := [ ] * Agent { } listCmd := strings . TrimSpace ( fmt . Sprintf ( " " , sudo , c . manageExec , ) , ) s , err := c . run ( listCmd ) if err != nil { return nil , err } if c . debug { fmt . Printf ( " \n \n \n " , s ) } for _ , item := range strings . Split ( s , " \n " ) { matches := entryRx . FindAllStringSubmatch ( item , - 1 ) if len ( matches ) == 0 { continue } list = append ( list , & Agent { ID : matches [ 0 ] [ 1 ] , Name : matches [ 0 ] [ 2 ] , IP : matches [ 0 ] [ 3 ] , } ) } return list , nil }
List lists all ossec agents
List lists all ossec agents