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

node-red-contrib-inotify

v1.1.0

Published

node-red inotify node

Downloads

6

Readme

node-red-contrib-inotify

Inotify can be used to monitor individual files, or to monitor directories. When a directory is monitored, inotify will return events for the directory itself, and for files inside the directory. (ref: GNU/Linux Manual)

By default it's in persistent mode. You can specify false to use the non persistent mode.

The events send will contain the following fields in payload: type and event

Installation

[NodeJS][nodejs_dev] versions 0.10.x, 0.12.x, 4.x.x, 5.x.x and IO.js 1.x, 2.x, 3.x are currently supported and tested.

Message payload object structure is:

msg.payload: {
    type: Resource type watched (file or directory)
    event: { watch: Watch descriptor,
             mask: Mask of events,
             cookie: Cookie that permits to associate events,
             name: Optional name of the object being watched
    }
}

The event.name property is only present when an event is returned for a file inside a watched directory; it identifies the file path name relative to the watched director

Inotify Events

Watch for:

  • Inotify.IN_ACCESS: File was accessed (read)
  • Inotify.IN_ATTRIB: Metadata changed, e.g., permissions, timestamps, extended attributes, link count (since Linux 2.6.25), UID, GID, etc.
  • Inotify.IN_CLOSE_WRITE: File opened for writing was closed
  • Inotify.IN_CLOSE_NOWRITE: File not opened for writing was closed
  • Inotify.IN_CREATE: File/directory created in the watched directory
  • Inotify.IN_DELETE: File/directory deleted from the watched directory
  • Inotify.IN_DELETE_SELF: Watched file/directory was deleted
  • Inotify.IN_MODIFY: File was modified
  • Inotify.IN_MOVE_SELF: Watched file/directory was moved
  • Inotify.IN_MOVED_FROM: File moved out of the watched directory
  • Inotify.IN_MOVED_TO: File moved into watched directory
  • Inotify.IN_OPEN: File was opened
  • Inotify.IN_ALL_EVENTS: Watch for all kind of events
  • Inotify.IN_CLOSE: (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) Close
  • Inotify.IN_MOVE: (IN_MOVED_FROM | IN_MOVED_TO) Moves

Additional Flags:

  • Inotify.IN_ONLYDIR: Only watch the path if it is a directory.
  • Inotify.IN_DONT_FOLLOW: Do not follow symbolics links
  • Inotify.IN_ONESHOT: Only send events once
  • Inotify.IN_MASK_ADD: Add (OR) events to watch mask for this pathname if it already exists (instead of replacing the mask).

The following bits may be set in the event.mask property returned in the callback

  • Inotify.IN_IGNORED: Watch was removed explicitly with inotify.removeWatch(watch_descriptor) or automatically (the file was deleted, or the file system was unmounted)
  • Inotify.IN_ISDIR: Subject of this event is a directory
  • Inotify.IN_Q_OVERFLOW: Event queue overflowed (wd is -1 for this event)
  • Inotify.IN_UNMOUNT: File system containing the watched object was unmounted

Example

Upload a file from a FTP service to a shared folder watched from inotify node-red node. The debug obtained is:

8/1/2017 12:29:073d8ea7a0.d0cef8
msg.payload : Object
{ "type": "file", "event": { "watch": 1, "mask": 32, "cookie": 0, "name": "Declaracion.png" } }
28/1/2017 12:29:073d8ea7a0.d0cef8
msg.payload : Object
{ "type": "file", "event": { "watch": 1, "mask": 8, "cookie": 0, "name": "Declaracion.png" } }
28/1/2017 12:29:073d8ea7a0.d0cef8
msg.payload : Object
{ "type": "directory", "event": { "watch": 1, "mask": 1073741856, "cookie": 0 } }
28/1/2017 12:29:073d8ea7a0.d0cef8
msg.payload : Object
{ "type": "directory", "event": { "watch": 1, "mask": 1073741840, "cookie": 0 } }
28/1/2017 12:29:103d8ea7a0.d0cef8
msg.payload : Object
{ "type": "file", "event": { "watch": 1, "mask": 32, "cookie": 0, "name": "Declaracion.png" } }
28/1/2017 12:29:103d8ea7a0.d0cef8
msg.payload : Object
{ "type": "file", "event": { "watch": 1, "mask": 16, "cookie": 0, "name": "Declaracion.png" } }

Sample Node-RED flow capture

inotify

Thanks

Thanks to c4milo for this great node package inotify