// GetServerMetrics fetches all metrics for each server and returns them in a map
// with the servers' names as keys.
GetServerMetrics fetches all metrics for each server and returns them in a map
with the servers' names as keys.
// GetServerMetrics fetches all metrics for each server and returns them in a map // with the servers ' names as keys .
func (c *PlexClient) GetServerMetrics() map[string]ServerMetric {
	serverMap := map[string]ServerMetric{}
	for _, server := range c.Servers {
		logger := c.Logger.WithFields(log.Fields{"server": server.Name})
		serverMetric := ServerMetric{
			ID:       server.ID,
			Name:     server.Name,
			Version:  server.Version,
			Platform: server.Platform,
		}
		activeSessions, err := server.GetSessionCount()
		if err != nil {
			logger.Errorf("Could not get metrics for server \"%s\"", server.Name)
			logger.Debugf("Could not get session count: %s", err)
			continue
		}
		serverMetric.ActiveSessions = activeSessions
		library, err := server.GetLibrary()
		if err != nil {
			logger.Errorf("Could not get metrics for server \"%s\"", server.Name)
			logger.Debugf("Could not get library: %s", err)
			continue
		}
		for _, section := range library.Sections {
			id, err := strconv.Atoi(section.ID)
			if err != nil {
				logger.Debugf("Could not convert sections ID to int. (%s)", section.ID)
			}
			size, err := server.GetSectionSize(id)
			if err != nil {
				logger.Debugf("Could not get section size for \"%s\": %s", section.Name, err)
				continue
			}
			libraryMetric := LibraryMetric{
				Name: section.Name,
				Type: section.Type,
				Size: size,
			}
			serverMetric.Libraries = append(serverMetric.Libraries, libraryMetric)
		}
		serverMap[server.Name] = serverMetric
	}
	return serverMap
}
func ( c * PlexClient ) GetServerMetrics ( ) map [ string ] ServerMetric { serverMap := map [ string ] ServerMetric { } for _ , server := range c . Servers { logger := c . Logger . WithFields ( log . Fields { " " : server . Name } ) serverMetric := ServerMetric { ID : server . ID , Name : server . Name , Version : server . Version , Platform : server . Platform , } activeSessions , err := server . GetSessionCount ( ) if err != nil { logger . Errorf ( " \" \" " , server . Name ) logger . Debugf ( " " , err ) continue } serverMetric . ActiveSessions = activeSessions library , err := server . GetLibrary ( ) if err != nil { logger . Errorf ( " \" \" " , server . Name ) logger . Debugf ( " " , err ) continue } for _ , section := range library . Sections { id , err := strconv . Atoi ( section . ID ) if err != nil { logger . Debugf ( " " , section . ID ) } size , err := server . GetSectionSize ( id ) if err != nil { logger . Debugf ( " \" \" " , section . Name , err ) continue } libraryMetric := LibraryMetric { Name : section . Name , Type : section . Type , Size : size , } serverMetric . Libraries = append ( serverMetric . Libraries , libraryMetric ) } serverMap [ server . Name ] = serverMetric } return serverMap }
GetServerMetrics fetches all metrics for each server and returns them in a map
with the servers' names as keys.
GetServerMetrics fetches all metrics for each server and returns them in a map with the servers ' names as keys .
// Get active sessions // Get library metrics