scanner {
  
# Extract memory usage information
  "/proc/meminfo" {
    MemTotal. = "^MemTotal:[\t ]*([0-9]+)[\t ]"
    MemFree.= "^MemFree:[\t ]*([0-9]+)[\t ]"
    MemCache.= "^Cached:[\t ]*([0-9]+)[\t ]"
    MemBuff.= "^Buffers:[\t ]*([0-9]+)[\t ]"
  }

# Add up total and used swap capacity across all partitions
  "/proc/swaps" {
    SwapTotal.add = "[\t ]([0-9]+)"
    SwapUsed.add = "[\t ][0-9]+[\t ]([0-9]+)"
  }

# Add up CPU utilization stats across all CPUs
  "/proc/stat" {
    CpuUser.add = "^cpu [\\t ]*([0-9]+)","flag"
    CpuNice.add = "^cpu [\\t ]*[0-9]+ ([0-9]+)"
    CpuSystem.add = "^cpu [\\t ]*[0-9]+ [0-9]+ ([0-9]+)"
    CpuIdle.add = "^cpu [\\t ]*[0-9]+ [0-9]+ [0-9]+ ([0-9]+)"
  }
}

layout {
  # add a sub-grid to house scales
  pbars {
    type = grid
    style = scales
    children {
  # add a scale to display CPU utilization
      Cpu { 
        type = scale
        css = "progressbar progress { background-color: #0000ff;}"
        value = "(CpuUser-CpuUser.pval)/(CpuUser+CpuNice+CpuSystem+CpuIdle-CpuUser.pval-CpuNice.pval-CpuSystem.pval-CpuIdle.pval)"
      }
      Mem { 
        type = scale
        css = "progressbar progress { background-color: #00ff00;}"
        value= "(MemTotal-MemFree-MemCache-MemBuff)/MemTotal" 
      }
      Swap { 
        type = scale
        css = "progressbar progress { background-color: #ff0000;}"
        value = "SwapUsed/SwapTotal"
      }
    }
  }
}
