GithubHelp home page GithubHelp logo

cuts's Introduction

Common Unix Task Server

Some things are just easier if you run standard unix tools. It might be the easiest way to get visibility on disc usage, for example.

So this is a little server that runs unix commands frequently and lets us know the result.

Using as a server

 $ npm install -g cuts
 $ node cuts

the server will present an HTTP interface and start doing some default commands every 15 minutes.

Use as a module

 $ npm install cuts

You can write a module which will make the server available and heavily customize it:

const cutsServer = require("cuts");

cutsServer.boot(8001, {
  appCallback: function (app) {
     app.get("/service-status", (req, res) => {
        res.json({
           up: true,
           lastQueryedDate: new Date()
         });
     });
  }
});

Included in the repository is demo.js which is an example server with cuts as a module.

Options to pass to boot

  • runInterval - the time in seconds to run the commands.
  • appCallback - a function, called with the express app so you can configure routes.
  • listenerCallback - a function, called with the listener address so you can enquire of the listener.
  • logDir - a string indicating the path of the log directory where the output of the commands is collected; by default this is "logdir".
  • commands - an object describing the keys to run.
  • shell - a name to exec (either a bare name or a full filename) of the shell to use; bash by default.

commands

An example commands:


{ 
  "du_of_home_dir": "du -h ~/",
  "disc_free": "df -h",
  "uptime": "uptime"
  }

The keys are descriptions but also must be capable of being directory names.

The values are unix commands expressed as a string. These are passed to bash directly as a script.

Other customizations

When used as a program the PORT environment variable is examined for the listener port.

If nothing is in PORT then 8001 is used as a default.

What is cuts for?

We have a lot of monitoring tools for cloud environments but in a situation where you have lots of cattle like servers sometimes the quickest way to get a job done is to use a unix command.

cuts let's you specify those unix commands, run them frequently and capture the output.

This gives you an extra layer of monitoring.

cuts's People

Contributors

nicferrier avatar pengdavin avatar owenfreyberg avatar

Watchers

 avatar

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.