Esempio n. 1
0
    def __init__(self, argv=(), env=None, debug=False):
        """
        Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('container', '^\w+$')
        self._username = self.envGet('username')
        self._api_key = self.envGet('api_key')
        self._region = self.envGet('region')
        self._servicenet = self.envCheckFlag('servicenet', False)
        self._category = 'Rackspace'

        self._fileInfo = CloudFilesInfo(username=self._username,
                                        api_key=self._api_key,
                                        region=self._region,
                                        servicenet=self._servicenet)
        self._fileContList = [
            name for name in self._fileInfo.getContainerList()
            if self.containerIncluded(name)
        ]

        if self.graphEnabled('rackspace_cloudfiles_container_size'):
            graph = MuninGraph(
                'Rackspace Cloud Files - Container Size (bytes)',
                self._category,
                info=
                'The total size of files for each Rackspace Cloud Files container.',
                args='--base 1024 --lower-limit 0',
                autoFixNames=True)
            for contname in self._fileContList:
                graph.addField(contname,
                               contname,
                               draw='AREASTACK',
                               type='GAUGE')
            self.appendGraph('rackspace_cloudfiles_container_size', graph)

        if self.graphEnabled('rackspace_cloudfiles_container_count'):
            graph = MuninGraph(
                'Rackspace Cloud Files - Container Object Count',
                self._category,
                info=
                'The total number of files for each Rackspace Cloud Files container.',
                args='--base 1024 --lower-limit 0',
                autoFixNames=True)
            for contname in self._fileContList:
                graph.addField(contname,
                               contname,
                               draw='AREASTACK',
                               type='GAUGE')
            self.appendGraph('rackspace_cloudfiles_container_count', graph)
Esempio n. 2
0
 def __init__(self, argv=(), env=None, debug=False):
     """
     Populate Munin Plugin with MuninGraph instances.
     
     @param argv:  List of command line arguments.
     @param env:   Dictionary of environment variables.
     @param debug: Print debugging messages if True. (Default: False)
     
     """
     MuninPlugin.__init__(self, argv, env, debug)
     
     self.envRegisterFilter('container', '^\w+$')
     self._username = self.envGet('username')
     self._api_key = self.envGet('api_key')
     self._region = self.envGet('region')
     self._servicenet = self.envCheckFlag('servicenet', False)
     self._category = 'Rackspace'
     
     self._fileInfo = CloudFilesInfo(username=self._username,
                                     api_key=self._api_key,
                                     region=self._region,
                                     servicenet=self._servicenet)
     self._fileContList = [name for name in self._fileInfo.getContainerList()
                                if self.containerIncluded(name)]
     
     if self.graphEnabled('rackspace_cloudfiles_container_size'):
         graph = MuninGraph('Rackspace Cloud Files - Container Size (bytes)', 
                            self._category,
             info='The total size of files for each Rackspace Cloud Files container.',
             args='--base 1024 --lower-limit 0', autoFixNames=True)
         for contname in self._fileContList:
                 graph.addField(contname, contname, draw='AREASTACK', 
                                type='GAUGE')
         self.appendGraph('rackspace_cloudfiles_container_size', graph)
     
     if self.graphEnabled('rackspace_cloudfiles_container_count'):
         graph = MuninGraph('Rackspace Cloud Files - Container Object Count', 
                            self._category,
             info='The total number of files for each Rackspace Cloud Files container.',
             args='--base 1024 --lower-limit 0', autoFixNames=True)
         for contname in self._fileContList:
                 graph.addField(contname, contname, draw='AREASTACK', 
                                type='GAUGE')
         self.appendGraph('rackspace_cloudfiles_container_count', graph)
Esempio n. 3
0
class MuninRackspacePlugin(MuninPlugin):
    """Multigraph Munin Plugin for monitoring Rackspace Cloud Usage.
    
    """
    plugin_name = 'rackspacestats'
    isMultigraph = True
    isMultiInstance = True
    
    def __init__(self, argv=(), env=None, debug=False):
        """
        Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)
        
        self.envRegisterFilter('container', '^\w+$')
        self._username = self.envGet('username')
        self._api_key = self.envGet('api_key')
        self._region = self.envGet('region')
        self._servicenet = self.envCheckFlag('servicenet', False)
        self._category = 'Rackspace'
        
        self._fileInfo = CloudFilesInfo(username=self._username,
                                        api_key=self._api_key,
                                        region=self._region,
                                        servicenet=self._servicenet)
        self._fileContList = [name for name in self._fileInfo.getContainerList()
                                   if self.containerIncluded(name)]
        
        if self.graphEnabled('rackspace_cloudfiles_container_size'):
            graph = MuninGraph('Rackspace Cloud Files - Container Size (bytes)', 
                               self._category,
                info='The total size of files for each Rackspace Cloud Files container.',
                args='--base 1024 --lower-limit 0', autoFixNames=True)
            for contname in self._fileContList:
                    graph.addField(contname, contname, draw='AREASTACK', 
                                   type='GAUGE')
            self.appendGraph('rackspace_cloudfiles_container_size', graph)
        
        if self.graphEnabled('rackspace_cloudfiles_container_count'):
            graph = MuninGraph('Rackspace Cloud Files - Container Object Count', 
                               self._category,
                info='The total number of files for each Rackspace Cloud Files container.',
                args='--base 1024 --lower-limit 0', autoFixNames=True)
            for contname in self._fileContList:
                    graph.addField(contname, contname, draw='AREASTACK', 
                                   type='GAUGE')
            self.appendGraph('rackspace_cloudfiles_container_count', graph)

    def retrieveVals(self):
        """Retrieve values for graphs."""
        file_stats = self._fileInfo.getContainerStats()
        for contname in self._fileContList:
            stats = file_stats.get(contname)
            if stats is not None:
                if self.hasGraph('rackspace_cloudfiles_container_size'):
                    self.setGraphVal('rackspace_cloudfiles_container_size', contname,
                                     stats.get('size'))
                if self.hasGraph('rackspace_cloudfiles_container_count'):
                    self.setGraphVal('rackspace_cloudfiles_container_count', contname,
                                     stats.get('count'))
    
    def containerIncluded(self, name):
        """Utility method to check if database is included in graphs.
        
        @param name: Name of container.
        @return:     Returns True if included in graphs, False otherwise.
            
        """
        return self.envCheckFilter('container', name)
Esempio n. 4
0
class MuninRackspacePlugin(MuninPlugin):
    """Multigraph Munin Plugin for monitoring Rackspace Cloud Usage.
    
    """
    plugin_name = 'rackspacestats'
    isMultigraph = True
    isMultiInstance = True

    def __init__(self, argv=(), env=None, debug=False):
        """
        Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('container', '^\w+$')
        self._username = self.envGet('username')
        self._api_key = self.envGet('api_key')
        self._region = self.envGet('region')
        self._servicenet = self.envCheckFlag('servicenet', False)
        self._category = 'Rackspace'

        self._fileInfo = CloudFilesInfo(username=self._username,
                                        api_key=self._api_key,
                                        region=self._region,
                                        servicenet=self._servicenet)
        self._fileContList = [
            name for name in self._fileInfo.getContainerList()
            if self.containerIncluded(name)
        ]

        if self.graphEnabled('rackspace_cloudfiles_container_size'):
            graph = MuninGraph(
                'Rackspace Cloud Files - Container Size (bytes)',
                self._category,
                info=
                'The total size of files for each Rackspace Cloud Files container.',
                args='--base 1024 --lower-limit 0',
                autoFixNames=True)
            for contname in self._fileContList:
                graph.addField(contname,
                               contname,
                               draw='AREASTACK',
                               type='GAUGE')
            self.appendGraph('rackspace_cloudfiles_container_size', graph)

        if self.graphEnabled('rackspace_cloudfiles_container_count'):
            graph = MuninGraph(
                'Rackspace Cloud Files - Container Object Count',
                self._category,
                info=
                'The total number of files for each Rackspace Cloud Files container.',
                args='--base 1024 --lower-limit 0',
                autoFixNames=True)
            for contname in self._fileContList:
                graph.addField(contname,
                               contname,
                               draw='AREASTACK',
                               type='GAUGE')
            self.appendGraph('rackspace_cloudfiles_container_count', graph)

    def retrieveVals(self):
        """Retrieve values for graphs."""
        file_stats = self._fileInfo.getContainerStats()
        for contname in self._fileContList:
            stats = file_stats.get(contname)
            if stats is not None:
                if self.hasGraph('rackspace_cloudfiles_container_size'):
                    self.setGraphVal('rackspace_cloudfiles_container_size',
                                     contname, stats.get('size'))
                if self.hasGraph('rackspace_cloudfiles_container_count'):
                    self.setGraphVal('rackspace_cloudfiles_container_count',
                                     contname, stats.get('count'))

    def containerIncluded(self, name):
        """Utility method to check if database is included in graphs.
        
        @param name: Name of container.
        @return:     Returns True if included in graphs, False otherwise.
            
        """
        return self.envCheckFilter('container', name)