import psutil
from checks import AgentCheck

class SystemCore(AgentCheck):

    def check(self, instance):
        cpu_times = psutil.cpu_times(percpu=True)

        for i, cpu in enumerate(cpu_times):
            for key, value in cpu._asdict().iteritems():
                self.rate(
                    "system.core.{0}".format(key), 
                    100.0 * value, 
                    tags=["core:{0}".format(i)]
                    )

import psutil
from checks import AgentCheck

class SystemCore(AgentCheck):

    def check(self, instance):
        cpu_times = psutil.cpu_times(percpu=True)
        self.gauge("system.core.count", len(cpu_times))

        for i, cpu in enumerate(cpu_times):
            for key, value in cpu._asdict().iteritems():
                self.rate(
                    "system.core.{0}".format(key), 
                    100.0 * value, 
                    tags=["core:{0}".format(i)]
                    )

Send the core count as a metric
Send the core count as a metric

  import psutil
  from checks import AgentCheck
  
  class SystemCore(AgentCheck):
  
      def check(self, instance):
          cpu_times = psutil.cpu_times(percpu=True)
+         self.gauge("system.core.count", len(cpu_times))
  
          for i, cpu in enumerate(cpu_times):
              for key, value in cpu._asdict().iteritems():
                  self.rate(
                      "system.core.{0}".format(key), 
                      100.0 * value, 
                      tags=["core:{0}".format(i)]
                      )
  
Send the core count as a metric
## Code Before:
import psutil
from checks import AgentCheck

class SystemCore(AgentCheck):

    def check(self, instance):
        cpu_times = psutil.cpu_times(percpu=True)

        for i, cpu in enumerate(cpu_times):
            for key, value in cpu._asdict().iteritems():
                self.rate(
                    "system.core.{0}".format(key), 
                    100.0 * value, 
                    tags=["core:{0}".format(i)]
                    )

## Instruction:
Send the core count as a metric
## Code After:
import psutil
from checks import AgentCheck

class SystemCore(AgentCheck):

    def check(self, instance):
        cpu_times = psutil.cpu_times(percpu=True)
        self.gauge("system.core.count", len(cpu_times))

        for i, cpu in enumerate(cpu_times):
            for key, value in cpu._asdict().iteritems():
                self.rate(
                    "system.core.{0}".format(key), 
                    100.0 * value, 
                    tags=["core:{0}".format(i)]
                    )
