Skip to main content

Hosts

Sentinel automatically registers hosts when the agent starts. Monitor CPU, memory, disk, and network across your entire fleet.

Host Status

hosts = BrainzLab::Sentinel.hosts

hosts.each do |host|
  puts "#{host.name}: #{host.status}"
  puts "  CPU: #{host.cpu_percent}%"
  puts "  Memory: #{host.memory_percent}%"
  puts "  Disk: #{host.disk_percent}%"
  puts "  Load: #{host.load_average}"
end

Health Status

Hosts are classified by health:
StatusCondition
healthyAll metrics within thresholds
warningOne or more metrics above warning threshold
criticalOne or more metrics above critical threshold
offlineNo heartbeat for 60+ seconds

CPU Metrics

cpu = BrainzLab::Sentinel.host("web-1").cpu

puts cpu.usage_percent    # Overall CPU usage
puts cpu.user_percent     # User-space CPU
puts cpu.system_percent   # Kernel CPU
puts cpu.iowait_percent   # I/O wait
puts cpu.load_1m          # 1-minute load average
puts cpu.load_5m          # 5-minute load average
puts cpu.load_15m         # 15-minute load average
puts cpu.cores            # Number of cores

Memory Metrics

memory = BrainzLab::Sentinel.host("web-1").memory

puts memory.total_gb        # Total RAM
puts memory.used_gb         # Used RAM
puts memory.available_gb    # Available RAM
puts memory.used_percent    # Usage percentage
puts memory.swap_total_gb   # Swap size
puts memory.swap_used_gb    # Swap used
puts memory.cached_gb       # Cached memory
puts memory.buffers_gb      # Buffers

Disk Metrics

disks = BrainzLab::Sentinel.host("web-1").disks

disks.each do |disk|
  puts "#{disk.mount_point}:"
  puts "  Total: #{disk.total_gb}GB"
  puts "  Used: #{disk.used_gb}GB (#{disk.used_percent}%)"
  puts "  Available: #{disk.available_gb}GB"
  puts "  Read: #{disk.read_mb_s}MB/s"
  puts "  Write: #{disk.write_mb_s}MB/s"
  puts "  IOPS: #{disk.iops}"
end

Network Metrics

network = BrainzLab::Sentinel.host("web-1").network

network.interfaces.each do |iface|
  puts "#{iface.name}:"
  puts "  Bandwidth In: #{iface.bytes_in_mb_s}MB/s"
  puts "  Bandwidth Out: #{iface.bytes_out_mb_s}MB/s"
  puts "  Packets In: #{iface.packets_in}/s"
  puts "  Packets Out: #{iface.packets_out}/s"
  puts "  Errors: #{iface.errors}"
end

Historical Data

View metrics over time:
history = BrainzLab::Sentinel.host("web-1").metrics_history(
  period: :day,
  resolution: :hour
)

history.each do |point|
  puts "#{point.timestamp}: CPU=#{point.cpu}%, MEM=#{point.memory}%"
end

Host Comparison

Compare metrics across hosts:
comparison = BrainzLab::Sentinel.compare_hosts(["web-1", "web-2", "api-1"])

comparison.each do |host_name, stats|
  puts "#{host_name}:"
  puts "  Avg CPU: #{stats.avg_cpu}%"
  puts "  Max Memory: #{stats.max_memory}%"
  puts "  Disk Usage: #{stats.disk_percent}%"
end

Host Groups

Organize hosts into groups:
BrainzLab::Sentinel.create_group("web-servers", ["web-1", "web-2"])
BrainzLab::Sentinel.create_group("workers", ["worker-1", "worker-2"])

group = BrainzLab::Sentinel.group("web-servers")
puts group.avg_cpu
puts group.total_memory_used