Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Parses Apache Extended Server Status pages and converts them to CSV. Great in combination with
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'csv'
if ARGV.length < 1
puts "Error: Please supply a URL pointing to an Apache Extended Server Status page"
page = Nokogiri::HTML(open(ARGV.first))
table = page.css('table').first
csv_options = {
headers: true
out = CSV.generate(csv_options) do |csv|
csv << table.css('tr').first.css('th').map {|h| h.text.strip}
table.css('tr')[1..-1].each do |row|
csv << row.css('td').map {|r| r.text.strip}
puts out

This comment has been minimized.

Copy link
Owner Author

lillesvin commented Mar 15, 2019


csvize-server-status.rb "<URL of status page>" | xsv sort -s CPU -NR | xsv slice -l 10 | xsv table

to get the 10 most CPU intensive requests currently being served.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.