Class: LogStash::Instrument::PeriodicPoller::Cgroup
- Inherits:
-
Object
- Object
- LogStash::Instrument::PeriodicPoller::Cgroup
- Includes:
- Util::Loggable
- Defined in:
- lib/logstash/instrument/periodic_poller/cgroup.rb
Defined Under Namespace
Modules: ControllerResource Classes: CGroupResources, CpuAcctResource, CpuResource, CpuStats, Override, UnimplementedResource
Constant Summary collapse
- CGROUP_FILE =
‘/proc/self/cgroup` contents look like this 5:cpu,cpuacct:/ 4:cpuset:/ 2:net_cls,net_prio:/ 0::/user.slice/user-1000.slice/session-932.scope e.g. N:controller:/path-to-info we find the controller and path we skip the line without a controller e.g. 0::/path we assume there are these symlinks: `/sys/fs/cgroup/cpu` -> `/sys/fs/cgroup/cpu,cpuacct `/sys/fs/cgroup/cpuacct` -> `/sys/fs/cgroup/cpu,cpuacct
"/proc/self/cgroup"
- CPUACCT_DIR =
"/sys/fs/cgroup/cpuacct"
- CPU_DIR =
"/sys/fs/cgroup/cpu"
- CRITICAL_PATHS =
[CGROUP_FILE, CPUACCT_DIR, CPU_DIR]
- CONTROLLER_CPUACCT_LABEL =
"cpuacct"
- CONTROLLER_CPU_LABEL =
"cpu"
- CGROUP_RESOURCES =
CGroupResources.new
Class Method Summary collapse
Class Method Details
.get ⇒ Object
214 215 216 |
# File 'lib/logstash/instrument/periodic_poller/cgroup.rb', line 214 def get get_all end |
.get_all ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/logstash/instrument/periodic_poller/cgroup.rb', line 190 def get_all unless CGROUP_RESOURCES.cgroup_available? logger.debug("One or more required cgroup files or directories not found: #{CRITICAL_PATHS.join(', ')}") return end groups = CGROUP_RESOURCES.controller_groups if groups.empty? logger.debug("The main cgroup file did not have any controllers: #{CGROUP_FILE}") return end cgroups_stats = {} groups.each do |name, controller| next unless controller.implemented? cgroups_stats[name.to_sym] = controller.to_hash end cgroups_stats rescue => e logger.debug("Error, cannot retrieve cgroups information", :exception => e.class.name, :message => e., :backtrace => e.backtrace.take(4)) if logger.debug? nil end |