npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

console-agent

v0.1.0

Published

<p align=center> <h1>console-agent</h1> <a href="https://github.com/kaola-fed/kagent"> <img src="https://img.shields.io/npm/v/kagent.svg?style=for-the-badge"/> </a> <a href="https://travis-ci.org/kaola-fed/kagent"> <img src

Downloads

2

Readme

架构图

console-agent

特性

  • Leader/Follower 进程模型,保障监控模块高可用;
  • 内置进程监控探针,采集进程信息;
  • 与 connection 模块维持长连接,上报监控信息与执行远程端命令

快速开始

注册应用

1. 进入系统

2. 创建应用

3. 记录 app_id 与 app_secret

安装依赖

$ npm i -S console-agent

创建 .kagentrc.js

module.exports = {
  "server": "http://127.0.0.1:7009",                // connection 模块暴露的地址
  "appid": "5",                                     // appid
  "secret": "84fe6510-1340-11e9-94fa-d9a76a880c81", // secret
  "cluster": "localjd"                              // 集群名
}

预加载

$ node index.js --require ./node_modules/console-agent/index.js

使用

模块引入

const agent = require('console-agent');

ready

Leader/Follower 模型建立以及与 Connection 的对接是异步过程。本地埋探针的操作应当使用 ready 函数确保流程启动完毕。

const getMysqlConnections = () => {};

agent.ready(() => {
    agent.guage('connections', () => {
        return getMysqlConnections()
    })
});

埋入探针 API

agent.guage

const getMysqlConnections = () => {};
agent.guage('connections', () => {
    return getMysqlConnections()
})

agent.counter

该操作用来统计某一时刻的数量,常用于统计连接数

const redisCounter = agent.counter('redis');

redisCounter.inc();
redisCounter.dec();

agent.histogram

该操作用来统计某一操作的数据分布,如 MIN/MAX/AVG

const redisRT = agent.histogram('redis-rt');

redisRT.update(35);
redisRT.update(34);
redisRT.update(33);

agent.meter

该操作用来统计某一操作的触发频率,如 QPS

const redisQPS = agent.meter('redis-qps');

redisRT.mark();
redisRT.mark();
redisRT.mark();

agent.timer

timermeterhistogram 的封装。

const http = require('http');

http.createServer((req, res) => {
    const end = res.end;
    const url = URL.parse(req.url)
    const path = url.pathname;
    const timer = kagent.timer('http');
    timer.start();

    res.end = function(...args1) {
      timer.close();
      kagent.meter('app/url/' + res.statusCode + '/' + path).mark();
      return Reflect.apply(end, this, args1);
    }
});

LICENSE

MIT