Permalink
Browse files

added dom element count to nagios performance data

  • Loading branch information...
1 parent 5d82987 commit 54a734ec95afed9ba2fad44ae3084389dbe3c470 @hggh committed Aug 17, 2012
Showing with 8 additions and 3 deletions.
  1. +2 −1 check_http_load_time.rb
  2. +6 −2 netsniff.js
@@ -71,11 +71,12 @@
request_global_time_end = Time.iso8601(hash['log']['pages'][0]['endedDateTime'])
request_size = hash['log']['pages'][0]['size']
request_count = hash['log']['pages'][0]['resourcesCount']
+dom_element_count = hash['log']['pages'][0]['domElementsCount']
website_load_time = '%.2f' % (request_global_time_end - request_global_time_start)
website_load_time_ms = (request_global_time_end - request_global_time_start) * 1000
-performance_data = " | load_time=#{website_load_time_ms.to_s}ms size=#{request_size} requests=#{request_count.to_s}"
+performance_data = " | load_time=#{website_load_time_ms.to_s}ms size=#{request_size} requests=#{request_count.to_s} dom_elements=#{dom_element_count}"
website_url_info = website_url.to_s
if options[:html]
View
@@ -12,7 +12,7 @@ if (!Date.prototype.toISOString) {
}
}
-function createHAR(address, title, startTime, resources, endTime)
+function createHAR(address, title, startTime, resources, endTime, dom_element_count)
{
var bodySize = 0;
resources.forEach(function (resource) {
@@ -38,6 +38,7 @@ function createHAR(address, title, startTime, resources, endTime)
id: address,
size: bodySize,
resourcesCount: resources.length,
+ domElementsCount: dom_element_count,
title: title,
pageTimings: {}
}],
@@ -85,7 +86,10 @@ else {
page.onLoadFinished = function (status) {
var har;
- har = createHAR(page.address, page.title, page.startTime, page.resources, new Date());
+ var dom_element_count = page.evaluate(function (s) {
+ return document.getElementsByTagName('*').length;
+ });
+ har = createHAR(page.address, page.title, page.startTime, page.resources, new Date(), dom_element_count);
console.log(JSON.stringify(har, undefined, 4));
phantom.exit();
};

0 comments on commit 54a734e

Please sign in to comment.