Home   →   Blog   →   File Activity Monitoring on Linux OS

File Activity Monitoring on Linux OS

There are many tasks within web development, that actively interact with the file system in order to monitor chages of files and catalogs. In order to solve these tasks it is necessary to provide the processing of the immediate file changes that should be perfomed with the minimal resource consumption. The DropBox service might be a nice example of such type of applications. It has to process all the changes inside the assigned catalog – immediately and consuming the minimum of resources.

Lets imagine we need to develop an application (or a website) like DropBox that should be running on Linux OS. Traditionally this kind of the project consists of two subsystems – server and client subsystem.

Server subsystem regularly tracks and authorizes users, provides synchronization of file changes, conflict solution or file exporting, etc.

Client subsystem provides a limited way to access file information, tracks user interaction and informs the server about them. The key problem of the this application is to provide immediate way to inform client subsystem about file changes.

 Requirements for this subsystem:

- Immediate processing of changes.

- Minimum of resources consumed.

- Monitoring of such operations as file movement and renaming, and others that do not lead to data modification in certain files but change the structure.

Initial approach is the checking of the file system with the using file checksums. In order to do this we have to visit every element in the targeted catalog, then to find out its data (attribute, checksum, etc.) and to make a conclusion about the change in the required catalog. At first, when an application is beeing developed such an operation might be worthwhile, but then such polling consumes too much resources and might complicate server administration. That is why it is necessary to use some automated solution that would operate only in the case of available changes. For the Linux OS it would be Inotify.

Inotify is the subsystem of the Linux kernel which monitors file system changes and sends associated events to necessary applications instantly (data deletion, reading, recording, and even unmount). Among others it is also possible to monitor start and end moving points.

Inotify raises events:

  1. IN_ACCESS The most minimal file event
  2. IN_ATTRIB Metadata change
  3. IN_CLOSE_WRITE A file that was opened for recording — closed
  4. IN_CLOSE_NOWRITE A file that was opened not for recording — closed
  5. IN_CREATE Creating a file/directory
  6. IN_DELETE Deleting a file/directory
  7. IN_DELETE_SELF Deleting a file/directory that is a “viewpoint”
  8. IN_MODIFY Changing a file
  9. IN_MOVE_SELF Changing a file/directory that is a “viewpoint”
  10. IN_MOVED_FROM File movement from a monitor catalog out of a certain monitoring area
  11. IN_MOVED_TO File movement from a certain area to the monitor catalog
  12. IN_OPEN Opening a file

We suggest using this approach to resolve such kind of issues. 

Please follow us on:

If you have any questions or would like to contact us about possible request on design or mobile friendly websites/mobile apps development please use Contact form.

comments powered by Disqus
Cf68cdaaf75f9cd1417267c6b1cafb3813c488a1 Virtual Reality Applications
Augmented reality apps are widely used – from geolocalization to using it in gaming industry. Augmented reality app is a new way to access data determined by environment conditions.
754d17aa02f8c56a0e0b671d45bf2455f6177062 Agile Methodology (Scrum)
Scrum is the very popular agile methodology for managing product development and project delivery. Scrum is the framework that could be applied for the development of product use cases, different projects or entire products.
1a1b621bfd24aba09a56bb25cf18719ad46ef190 News App Development
Smartphones are regularly used everywhere & anytime: in cars, on the way to the office, during the rest on holidays or weekends. That’s very convenient way for users to access important or just fun information with the help of news mobile app.
D63ac21dfd17c4acc93d52d9bdc72fea10e84edd Geolocation Services in Mobile Tracking Software
Geolocation services are used by many mobile apps, websites, mobile operators etc.