osx - Java DTrace bridge on OS X -


i trying grab filesystem events on os / kernel level on os x. there 2 requirements have follow. first 1 in java whole project im developing written in java. second 1 have find out when document opened.

for linux used inotify-java, can't find equivalent on os x. jna doesn't provide helpful binding. i'm avoiding catching events calling lsof program. this, however, bad solution.

thanks help.

you can use dtrace on osx, since needs root privileges it's not you'd want put runtime of system.

in case, won't able in pure java (any java api wrapper around lower level c introspection, , if you're doing kernel-wide, need done root).

if want track when program opening files (as opposed other files on same system) can install own security manager , implement checkread() family of methods, should give idea of when accesses happening.

import java.io.*;  public class demo {   public static void main(string args[]) throws exception {     system.setsecuritymanager(new sniffer());     file f = new file("/tmp/file");     new fileinputstream(f);   } } class sniffer extends securitymanager {   public void checkread(string name) {     system.out.println("opening " + name);   } } 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -