Class: Cloudscale::Plugins::MongoDbStatus
- Defined in:
- lib/cloudscale/plugins/mongo/mongo_db_status.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Attributes inherited from Plugin
Instance Method Summary collapse
- #collect(agentInstanceId) ⇒ Object
-
#initialize ⇒ MongoDbStatus
constructor
A new instance of MongoDbStatus.
- #is_enabled ⇒ Object
Methods inherited from Plugin
Constructor Details
#initialize ⇒ MongoDbStatus
Returns a new instance of MongoDbStatus.
18 19 20 21 22 23 |
# File 'lib/cloudscale/plugins/mongo/mongo_db_status.rb', line 18 def initialize super if is_enabled @client = Preops::MongodbPreop.instance.client end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
12 13 14 |
# File 'lib/cloudscale/plugins/mongo/mongo_db_status.rb', line 12 def client @client end |
Instance Method Details
#collect(agentInstanceId) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cloudscale/plugins/mongo/mongo_db_status.rb', line 25 def collect(agentInstanceId) registry = Monitor::Registry.instance metrics = Metrics::Agent.new log.info("Calling Collect on MongoDbStatus") stats = @client.database.command({:dbstats => 1}).first registry.metrics["mongo.status.objects"] = metrics.gauge :status_objects do { :value => stats['objects'] } end registry.metrics["mongo.status.indexes"] = metrics.gauge :status_indexes do { :value => stats['indexes'] } end registry.metrics["mongo.status.indexes"] = metrics.gauge :status_indexes do { :value => stats['indexes'] } end registry.metrics["mongo.status.dataSize"] = metrics.gauge :status_dataSize do { :value => stats['dataSize'] } end registry.metrics["mongo.status.storageSize"] = metrics.gauge :status_storageSize do { :value => stats['storageSize'] } end registry.metrics["mongo.status.collections"] = metrics.gauge :status_collections do { :value => stats['collections'] } end registry.metrics["mongo.status.avgObjSize"] = metrics.gauge :status_avgObjSize do { :value => stats['avgObjSize'] } end end |
#is_enabled ⇒ Object
14 15 16 |
# File 'lib/cloudscale/plugins/mongo/mongo_db_status.rb', line 14 def is_enabled Preops::MongodbPreop.instance.is_enabled end |