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

io-overwatch

v1.0.0-beta.11

Published

io-event-reactor based daemon for monitoring changes within one or more directories; then reacting by making directories, copying, moving, extracting files or inserting audit records into a database

Downloads

5

Readme

io-overwatch

io-event-reactor based daemon for monitoring changes within one or more directories; then reacting by making directories, copying, moving, extracting files or inserting audit records into a database.

NPM

Usage

Method 1

>$ git clone https://github.com/bitsofinfo/io-overwatch.git
>$ cd io-overwatch/
>$ npm install .
>$ node overwatch.js

Method 2

>$ mkdir overwatch
>$ cd overwatch/
>$ npm install io-overwatch
>$ node node_modules/io-overwatch/overwatch.js
Usage: overwatch.js <command> [options]

Commands:
  dir  Monitor a directory and react to changes

Options:
  --logging.file                Full path to log file                 [required]
  --logging.level               Logging level
         [choices: "error", "warn", "info", "verbose", "info", "debug", "silly"]
                                                              [default: "debug"]
  --logging.maxsize             Max size before rotation, in bytes
                                                                [default: 10485760]
  --logging.maxfiles            Max rotated files to retain          [default: 20]
  --monitor.dir                 Directory to monitor                  [required]
  --monitor.stabilityThreshold   Milliseconds for file sizes to remain constant
                                 before reacting.               [default: 30000]
  --evaluator.events            Space separated list of relevant event types
  [array] [required] [choices: "add", "addDir", "change", "unlink", "unlinkDir"]
  --evaluator.regex             Regex to apply to ioEvent.fullPath to trigger
                                reactors                              [required]
  --evaluator.reactors          Ordered list of reactors
	[array] [required] [choices: "mkdir", "copyFile", "moveFile", "copyAll",
                                          "moveAll", "extractFile", "sqlInsert"]
  --reactor.mkdir.dir           Target dir create. Variables apply.
                                                                 [default: null]
  --reactor.copyAll.target      Target dir to copy all files in monitored dir
                                TO. Variables apply.             [default: null]
  --reactor.moveAll.target      Target dir to move all files in monitored dir
                                TO. Variables apply.             [default: null]
  --reactor.copyFile.target     Target dir to copy evaluated file TO. Variables
                                apply.                           [default: null]
  --reactor.moveFile.target     Target dir to move evaluated file TO. Variables
                                apply.                           [default: null]
  --reactor.extractFile.target  Target dir to extract evaluated file TO.
                                Variables apply.                 [default: null]
  --reactor.sqlInsert.table     Table name for sql insert        [default: null]
  --reactor.sqlInsert.columns   Space separated list of target table columns.
                                                         [array] [default: null]
  --reactor.sqlInsert.values    Space separated list of column values. Variables
                                apply.                   [array] [default: null]
  --reactor.shell.uid           uid to run shell commands as
                                                           [default: 2146091417]
  --reactor.shell.gid           gid to run shell commands as
                                                           [default: 1028219364]
  --reactor.db.host             database host                         [required]
  --reactor.db.port             database port                    [default: 3306]
  --reactor.db.user             database user                         [required]
  --reactor.db.pw               database pw                           [required]
  --reactor.db.name             database name                         [required]

For certain options you can use the following variables:
 {{{ioEvent.context.timestamp}}}
 {{{ioEvent.eventType}}}
 {{{ioEvent.fullPath}}}
 {{{ioEvent.parentPath}}}
 {{{ioEvent.parentName}}}
 {{{ioEvent.filename}}}
 {{{ioEvent.uuid}}}
 {{{ioEvent.context.[copyAll | copyFile | moveAll | moveFile | extractFileTo].target}}}

Usage samples table: (mysql)

CREATE TABLE `io_event` (
  `eventType` varchar(256) NOT NULL,
  `fullPath` varchar(256) DEFAULT NULL,
  `stats` varchar(512) DEFAULT NULL,
  `timestamp` varchar(256) DEFAULT NULL,
  `filename` varchar(256) DEFAULT NULL,
  `uuid` varchar(256) DEFAULT NULL,
  `parentPath` varchar(256) DEFAULT NULL,
  `parentName` varchar(256) DEFAULT NULL,
  `target` varchar(256) DEFAULT NULL,
  `context` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Usage sample one:

Monitor one dir, when any file matching *test1* is changed make a new target directory, move all files in the same directory as triggering file to the target dir, and then insert a sql record of the event.

mkdir /tmp/bitsofinfo
pm2 start sample1.pm2.json

OR

mkdir /tmp/bitsofinfo

node overwatch.js dir  \
	--logging.file=./overwatch.log \
	--monitor.dir=/tmp/bitsofinfo \
	--monitor.stabilityThreshold=1000 \
	--evaluator.events=change \
	--evaluator.regex=".*test1.*" \
	--evaluator.reactors=mkdir moveAll sqlInsert \
	--reactor.mkdir.target=/tmp/{{{ioEvent.context.timestamp}}}/bitsofinfo_target \
	--reactor.moveAll.target=/tmp/{{{ioEvent.context.timestamp}}}/bitsofinfo_target \
	--reactor.sqlInsert.table=io_event \
	--reactor.sqlInsert.columns=context eventType fullPath filename parentPath timestamp uuid parentName target \
	--reactor.sqlInsert.values=moveAllToContext "{{{ioEvent.eventType}}}" "{{{ioEvent.fullPath}}}" "{{{ioEvent.filename}}}" "{{{ioEvent.parentPath}}}" "{{{ioEvent.context.timestamp}}}" "{{{ioEvent.uuid}}}" "{{{ioEvent.parentName}}}" "{{{ioEvent.context.moveAll.target}}}" \
	--reactor.db.host=localhost \
	--reactor.db.user=root \
	--reactor.db.pw=root \
	--reactor.db.name=io_event_reactor

Usage sample two:

Monitor one dir, when any file matching zip/tgz/gz is changed make a new target directory, extract the zip/tgz to the target dir, then move all files in the same directory as triggering file to the target dir, and then insert a sql record of the event.

mkdir /tmp/bitsofinfo
pm2 start sample2.pm2.json

OR

mkdir /tmp/bitsofinfo

node overwatch.js dir  \
	--logging.file=./overwatch.log \
	--monitor.dir=/tmp/bitsofinfo \
	--monitor.stabilityThreshold=1000 \
	--evaluator.events=add change \
	--evaluator.regex="(.+\.zip$|.+\.gz$|.+\.tgz$)" \
	--evaluator.reactors=mkdir extractFileTo moveAll sqlInsert \
	--reactor.mkdir.target=/tmp/{{{ioEvent.context.timestamp}}}/{{{ioEvent.parentName}}}/bitsofinfo_target \
	--reactor.extractFileTo.target=/tmp/{{{ioEvent.context.timestamp}}}/{{{ioEvent.parentName}}}/bitsofinfo_target \
	--reactor.moveAll.target=/tmp/{{{ioEvent.context.timestamp}}}/{{{ioEvent.parentName}}}/bitsofinfo_target \
	--reactor.sqlInsert.table=io_event \
	--reactor.sqlInsert.columns=context eventType fullPath filename parentPath timestamp uuid parentName target \
	--reactor.sqlInsert.values=extractFileToContext "{{{ioEvent.eventType}}}" "{{{ioEvent.fullPath}}}" "{{{ioEvent.filename}}}" "{{{ioEvent.parentPath}}}" "{{{ioEvent.context.timestamp}}}" "{{{ioEvent.uuid}}}" "{{{ioEvent.parentName}}}" "{{{ioEvent.context.extractFileTo.target}}}" \
	--reactor.db.host=localhost \
	--reactor.db.user=root \
	--reactor.db.pw=root \
	--reactor.db.name=io_event_reactor