GithubHelp home page GithubHelp logo

node-haproxy-stat's Introduction

Simplify getting info and stats from a local haproxy stat file socket.

build status

Install

npm install haproxy-stat

Module Usage

var haproxystat = require('haproxy-stat');
var hastat = haproxystat({ socketPath: '/tmp/haproxy.sock' });

Show Info

Get basic info from HAProxy.

hastat.showInfo(function (err, data) {
	console.log(data);
});

data is an object with the following properties:

{
	name: 'HAProxy',
	version: '1.4.18',
	release_data: '2011/09/16',
	nbproc: '1',
	process_num: '1',
	pid: '30984',
	uptime: '0d 2h01m42s',
	uptime_sec: '7302',
	mem_max_mb: '0',
	ulimit_n: '8210',
	max_sock: '8210',
	max_conn: '4096',
	max_pipes: '0',
	current_conns: '2',
	pipes_used: '0',
	pipes_free: '0',
	tasks: '5',
	run_queue: '1',
	node: 'haproxyserver-0',
	development: '' 
}	

Show Stats

Get data from HAProxy stats via show stats command. Detailed date described here.

hastat.showStat(function (err, data) {
	console.log(data);
});

data is an array of objects like the following:

[ 
	{ 
	  	pxname: 'ldap',
	    svname: 'FRONTEND',
	    qcur: '',
	    qmax: '',
	    scur: '0',
	    smax: '0',
	    slim: '2000',
	    stot: '0',
	    bin: '0',
	    bout: '0',
	    dreq: '0',
	    dresp: '0',
	    ereq: '0',
	    econ: '',
	    eresp: '',
	    wretr: '',
	    wredis: '',
	    status: 'OPEN',
	    weight: '',
	    act: '',
	    bck: '',
	    chkfail: '',
	    chkdown: '',
	    lastchg: '',
	    downtime: '',
	    qlimit: '',
	    pid: '1',
	    iid: '2',
	    sid: '0',
	    throttle: '',
	    lbtot: '',
	    tracked: '',
	    type: 'frontend',
	    rate: '0',
	    rate_lim: '0',
	    rate_max: '0',
	    check_status: { 
	    	code: '', 
	    	description: '' 
	    },
	    check_code: '',
	    check_duration: '',
	    hrsp_1xx: '',
	    hrsp_2xx: '',
	    hrsp_3xx: '',
	    hrsp_4xx: '',
	    hrsp_5xx: '',
	    hrsp_other: '',
	    hanafail: '',
	    req_rate: '0',
	    req_rate_max: '0',
	    req_tot: '0',
	    cli_abrt: '',
	    srv_abrt: '' 
	},
	{ 
	  	pxname: 'agent',
	    svname: 'agent_10.10.2.125:8080',
	    qcur: '0',
	    qmax: '0',
	    scur: '0',
	    smax: '0',
	    slim: '',
	    stot: '0',
	    bin: '0',
	    bout: '0',
	    dreq: '',
	    dresp: '0',
	    ereq: '',
	    econ: '0',
	    eresp: '0',
	    wretr: '0',
	    wredis: '0',
	    status: 'UP',
	    weight: '1',
	    act: '1',
	    bck: '0',
	    chkfail: '0',
	    chkdown: '0',
	    lastchg: '99',
	    downtime: '0',
	    qlimit: '',
	    pid: '1',
	    iid: '5',
	    sid: '2',
	    throttle: '',
	    lbtot: '0',
	    tracked: '',
	    type: 'server',
	    rate: '0',
	    rate_lim: '',
	    rate_max: '0',
	    check_status: { 
	    	code: 'L4OK',
	    	description: 'check passed on layer 4, no upper layers testing enabled' 
	    },
	    check_code: '',
	    check_duration: '0',
	    hrsp_1xx: '0',
	    hrsp_2xx: '0',
	    hrsp_3xx: '0',
	    hrsp_4xx: '0',
	    hrsp_5xx: '0',
	    hrsp_other: '0',
	    hanafail: '0',
	    req_rate: '',
	    req_rate_max: '',
	    req_tot: '',
	    cli_abrt: '0',
	    srv_abrt: '0' 
	},
	{ 
	  	pxname: 'agent',
	    svname: 'BACKEND',
	    qcur: '0',
	    qmax: '0',
	    scur: '0',
	    smax: '0',
	    slim: '0',
	    stot: '0',
	    bin: '0',
	    bout: '0',
	    dreq: '0',
	    dresp: '0',
	    ereq: '',
	    econ: '0',
	    eresp: '0',
	    wretr: '0',
	    wredis: '0',
	    status: 'UP',
	    weight: '2',
	    act: '2',
	    bck: '0',
	    chkfail: '',
	    chkdown: '0',
	    lastchg: '99',
	    downtime: '0',
	    qlimit: '',
	    pid: '1',
	    iid: '5',
	    sid: '0',
	    throttle: '',
	    lbtot: '0',
	    tracked: '',
	    type: 'backend',
	    rate: '0',
	    rate_lim: '',
	    rate_max: '0',
	    check_status: { 
	    	code: '', 
	    	description: '' 
	    },
	    check_code: '',
	    check_duration: '',
	    hrsp_1xx: '0',
	    hrsp_2xx: '0',
	    hrsp_3xx: '0',
	    hrsp_4xx: '0',
	    hrsp_5xx: '0',
	    hrsp_other: '0',
	    hanafail: '',
	    req_rate: '',
	    req_rate_max: '',
	    req_tot: '',
	    cli_abrt: '0',
	    srv_abrt: '0' 
	} 
]


var longDescrption = hastat.statDescription(property);

like:

var longDescrption = hastat.statDescription('rate');
console.log(longDescription);

results in:

number of sessions per second over last elapsed second

CLI

./node_modueles/.bin/haproxystat

Or if installed globally:

npm install -g haproxy-stat
haproxystat

Usage:

Usage:  node cli  <command> <socket_path> 
	command      ->   showInfo, showStat 
	socket_path  ->  /tmp/haproxy.sock (for example)

node-haproxy-stat's People

Contributors

mbrevoort avatar

Stargazers

Cecil Worsley avatar Pantelis Koukousoulas avatar Benjamin E. Coe avatar Niclas Hoyer avatar Arnout Kazemier avatar Damon Oehlman avatar  avatar

Watchers

 avatar James Cloos avatar

node-haproxy-stat's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.