예제 #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)