Haproxy Statistics Report

try to take over the world!

2016-10-26 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Haproxy Statistics Report 
// @namespace    tossp.com
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http://*/*
// @grant        none
// @require      https://cdn.bootcss.com/jquery/1.2.3/jquery.min.js
// ==/UserScript==

function size(kb){
    var tmp = kb;
    if (tmp.indexOf('Response bytes')!=-1){
        tmp = tmp.substr(0,tmp.indexOf('Response bytes'));
    }
    if (!isNaN(tmp)&&parseInt(tmp)>0){
        if (tmp < 1024 ) {
            tmp = parseFloat(tmp).toFixed(2) + ' B';
        } else if ( tmp >= 1024 && tmp < 1048576 ) {
            tmp = parseFloat(tmp / 1024).toFixed(2) + ' Kb';
        }        else if ( tmp >= 1048576 && tmp < 1073741824 )        {
            tmp = parseFloat(tmp / (1024 * 1024)).toFixed(2) + ' Mb';
        }        else        {
            tmp = parseFloat(tmp / (1024 * 1024 * 1024)).toFixed(2) + ' Gb';
        }
    }else{
         return kb;
    }
    return tmp;


}
(function() {
    'use strict';
    if ($('h1 a').attr('href')=='http://www.haproxy.org/'){
        console.debug("init");
        
        $('table:gt(3) tbody tr td span.rls').each(function(k,v) {
            var inElem,outElem;
            if ($(v).parent().parent().children("td:eq(2)").attr('colspan')){
                inElem=$(v).parent().parent().children("td:eq(12)");
                outElem=$(v).parent().parent().children("td:eq(13)");
            }else{
                inElem=$(v).parent().parent().children("td:eq(14)");
                outElem=$(v).parent().parent().children("td:eq(15)");
            }
            //.css('background-color', '#20a0ff')
            inElem.html(size(inElem.text()));
            outElem.html(size(outElem.text()));
            //console.debug(size(inElem.text()),size(outElem.text()));
        });
        
    }
    
})();