How to monitor a file?

I want my program to monitor a file or directory. whenever the file or the directory is modificated, it will send an event to my program.
I use a thread to check the last modification time ever 5 seconds, but i don't think this is a good design.

This should help ....
class FileChangeEventManager extends Thread
     List<FileChangeEventListener> lst = new ArrayList<FileChangeEventListener>();
     List<String> lstFiles = new ArrayList<String>();
     public void fileToMonitor(String file)
          lstFiles.add(file);
     public void addListener()
          // add to list
     public void removeListener()
          // add to list
     public void run()
          while(true)
               try
                    Thread.sleep(2000);
               catch(InterruptedException e)
               // if filechanged
                     * 1. create file change event object
                     * 2. set filename
                     * 3. loop through all the listener
                     * 4. inovke filechanged(filechangeevent obj) on all listeners
class FileChangeEvent
     String fileName;
     public FileChangeEvent()
     public String getFileName() {
          return fileName;
     public void setFileName(String fileName) {
          this.fileName = fileName;
class FileChangeEventListener
     public void fileChanged(FileChangeEvent e)
}you event listeners should extends FileChangeEventListener to handle events..
enjoy !

Similar Messages

  • How to monitor Alert file large in EM Grid

    Hello,
    In Enterprise Manager 9 we used to monitor Alert File Large.
    I am not able find this in Grid Control.
    Can anybody tell me how to monitor this metric in OEM 10 GRid?
    Best regards,
    Jvries

    You must to select the host target and metric and policy issues
    Select all metrics and search File or Directory size MB
    You can to add the file when you want to monitor the size and
    you must to enable a response action when the critical theshold appear
    The response action must be a shell script like this
    #/bin/ksh
    #if you want backup
    cp /directory/file.log /backup_destination/file.log.bak
    #for clean the file and his size was empth
    /directory/file.logRemember that you want enable the credentials for host and the owner of agent had rights of read and write in the location of file
    Regards

  • How to monitor a file in oracle

    Hi,
    I am running a job using DBMS_job package where the job should look for a file.If the file exists only job should run.Can i use these dependencies in dbms_job package??
    What is the syntax for utl_file to monitor a file wehter it exists or not
    Thanks

    What you want is to resubmit the job by adding n number of seconds to the original job.
    Let us say your job starts at 1 AM and the file is not there yet, so the job should reschedule itself
    to run at 1:30 and then at 1:30 it will check the existence of file, if the file is not there it should further reschedule itself.
    There is a way to do it. Search in metalink forums .

  • How to monitor specific file size in SCOM 2012

    Dear Experts,
    In our environment we need to SCOM have monitor profile of NTuser.dat file growth in all citrix servers, This file is presented in the path of  “C:\Documents and Settings\ctx_cpsvcuser\NTuser.dat”. when this profile is reached 10 MB
    size then SCOM has to trigger the alert, So can you please help me out to achieve this Task. I have tried many scripts and no luck.. So please provide me step by steps to configure this.
    Saravana Raja

    Hi Yan,
    I have followed with Kevin steps with below model scripts and does not work it seems.Also I didn,t get any errors also.. I don't understand whats wrong there...
    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    Set objFile = objFSO.GetFile(“C:\Documents and Settings\ctx_cpsvcuser\ntuser.dat”)
    varSize = objFile.Size
    Dim oAPI, oBag
    If varSize > 52428800 Then
    Set oAPI = CreateObject(“MOM.ScriptAPI”)
    Set oBag = oAPI.CreatePropertyBag()
    Call oBag.AddValue(“Status”,”Bad”)
    Call oBag.AddValue(“Size”, varSize)
    Call oAPI.Return(oBag)
    Else
    Set oAPI = CreateObject(“MOM.ScriptAPI”)
    Set oBag = oAPI.CreatePropertyBag()
    Call oBag.AddValue(“Status”,”Ok”)
    Call oAPI.Return(oBag)
    End If
    Saravana Raja

  • How to monitor user logs,security logs,trace file,and performance monitori

    Hi guys,
    pls tel me how to monitor user logs,security logs,trace file,and performance monitoring.
    thanks
    regards
    kamal

    Hi,
    you can have a look in the Netweaver administration :
    http://<portal>:<port>/nwa
    Go to monitoring, Java system reports, etc..., you will find what you want.
    Fabien.

  • How do I transfer files from my PC to mini Mac if I only have one monitor?

    I'm going to be purchasing a Mac mini. I have a Windows PC running XP. I only have one display monitor, so I was wondering how do I transfer files from my XP to my mini Mac with only one monitor?
    Thanks

    You'd have to give us some more information in regard to the inputs of your display.
    Generally, you should be able to plug your current PC into one input (DVI most likely) and then the Mac mini into another (HDMI) then flip between the inputs on the monitor via the on-screen menu.

  • How to use thread to monitor a file

    Hi
    I have a situation where i want to monitor a file while current java process is running, for example
    The process would be like below,i have to do it using Java 1.4
    1 Start Main Java Class
    2 Start Another thread to monitor a file, from this main Java Class
    3 Return control back to main java class to do future processing
    4 When the process in this class is done, kill the monitor process.
    5 If the file is modified by external process, do some processing in the thread,
    What i did was as below, the main java class
    Thread t = new Thread(new TestOptimizationThreadWorker());
    t.run();
    // continue doing the process
    t.stop();the other thread class is as below
    public class TestOptimizationThreadWorker implements Runnable
         public void run()
              // monitor the external file here
    }But some how the control does not come back to main program after i run the thread,
    Any suggestions
    Ashish
    Edited by: kulkarni_ash on Sep 26, 2007 10:06 AM
    Edited by: kulkarni_ash on Sep 26, 2007 10:53 AM

    Hi
    Yes after changing, t.run() to t.start(), it works, but what are the issues you see,
    i have attached the whole code below
    Java Main Class
    public class TestOptimizationThread
         public TestOptimizationThread()
         public String doMessage()
              TestOptimizationThreadWorker tt =     new TestOptimizationThreadWorker();
              Thread t = new Thread(tt);
              System.out.println ("In Do message");
              try
                   System.out.println ("Before starting thread");
                   t.start();
                   System.out.println ("After starting thread");
              catch(Exception exc)
              finally
                   System.out.println ("in finally");
                   tt.changeB();
              return "";
         public static void main(String args[])
             new TestOptimizationThread().doMessage();
    }Java Thread class
    public class TestOptimizationThreadWorker implements Runnable
         private boolean b = true;
         public TestOptimizationThreadWorker()
              System.out.println ("Creating this class ");     
         public void run()
              System.out.println ("In Run Method");
              int i =0;
              while(b)
                   System.out.println ("int "+ i);     
                   i++;
         public void changeB()
              b = false;     
    }Ashish

  • How to monitor file changes

    all experts.........
    i'm wondering if it is possible to monitor the file changes and load updated file contents dynamically for a java application. i have some simple txt file. i'm taking my input data from these files for the simulation. during the sim some of these data will be changed and i need to take these new data as a input for the next step. any idea would help me a lot. thanksssssssss in advance.
    arun

    There's a few ideas in [url http://forum.java.sun.com/thread.jsp?forum=4&thread=431288]this thread

  • How do I share files between a PowerPC 8100 OS 7.6.1 and an iMac OS 10.7.4 over ethernet

    How do I share files between a PowerPC 8100 OS 7.6.1 and an iMac OS 10.7.4 over peer to peer ethernet connection? I'm trying to get data off the old machine so I can retire it for good. Can I just save the data and worry about file conversion later?

    Addendum
    There is a relatively simple server-based way of avoiding difficulties with incompatible system versions et cetera. It could possibly be of some interest.
    I tested the following between a System 7.5.3 PowerBook 540 and a Windows XP PC. It ought to work with a System 7.6.1 Power Macintosh 8100 and a MacOS X 10.7.4 iMac as well.
    a) Download and install Microsoft Personal Web Server 1.0 for Macintosh onto the 8100. If the 8100 does not have a direct Internet connection, carry out the download on another computer, and then try to transfer the hqx file (as it is) on a CD-R (burn at a low speed) or a 1.44 MB floppy (use StuffIt Expander to decode the hqx on the 8100). Do not change or add anything after the installation; just leave the files as they are.
    http://support.microsoft.com/kb/164571
    b) Drag a compressed example archive (we can call it example_file.sit) to the folder My Personal Web Site (there are other files inside this folder; do not worry about them). Ensure that the compression format is compatible with a decompression tool on the receiving computer.
    c) Many people have access to a router (wired or wireless) with a built-in Ethernet switch (usually something like four LAN ports). If applicable, disconnect any incoming Internet (the WAN port). If possible/necessary, switch off the wireless (see the router manual for details about this).
    d) Switch off both computers (and the router).
    e) Connect an AAUI to RJ-45 transceiver (such as the aforementioned Apple Ethernet Twisted-Pair Transceiver) to the AAUI port of the 8100.
    f) Connect an Ethernet cable from the transceiver to the first LAN port of the router.
    g) Connect an Ethernet cable from the second LAN port of the router to the iMac.
    h) Switch on the router.
    i) Start the computers.
    j) The TCP/IP control panel on the 8100 is set to connect via Ethernet. DHCP Server is used in this case.
    k) Open the Microsoft Personal Web Server control panel.
    l) Click on the Start button.
    m) Wait (can take a while).
    n) Notice the exact address at My URL (under Monitor Web Site). Could be something like http://192.168.1.2 (depends on the router).
    o) Launch a web browser on the iMac (I did the testing on the PC with Firefox and Safari).
    p) Enter the exact address (see n above) in the browser's address field (http://192.168.1.2 in my example). Press Return. A standard web page should appear. Disregard this page for now.
    q) Add the exact file name (example_file.sit) to the address shown in the field. The result would be http://192.168.1.2/example_file.sit in my case. Press Return.
    r) The file should start to download to the modern computer.
    All the above is intended for a local connection only (otherwise security settings become of importance), and should be considered purely experimental. There are further possibilities (including an FTP plug-in), but it also makes everything more complicated. I have not tested the behaviour with large files or with various files types. Sometimes the server may crash. If so, try a restart. Make sure that you have backup copies of important files already at the 8100 before you begin.
    Good luck!
    Jan

  • How to run .exe files with Virtual PC for Mac

    Hey Guys, I'm new around here and with mac technology as well. Anyway, I have an iMac OS X 10.5.1 Leopard and I've recently purchased the Virtual PC for Mac 7.0.2 software. So I'd like to know how to use this program properly, because I need to run some executable files in my computer. It is confusing for me because I don't know how to get started, and I only get to the part when it says "OS not found, Install an OS on this hard drive".
    Honestly I've no idea of what an OS is or where do I get that. So I'd really appreciate if one of you guys could tell me, step by step, what to do to use Virtual PC properly, and finally learn how to run .exe files on mac.
    Thanks in advance!
    Have a nice day!

    Always nice to see new faces
    Honestly I've no idea of what an OS is or where do I get that.
    This brings up the second part of your problem. The first part is setting up either a proper Virtual Machine program like Parallels or VMfusion, or setting up a Boot Camp partition on your drive.
    http://www.parallels.com/
    http://www.vmware.com/products/fusion/
    OS stands for Operating System. You are running Leopard 10.5.7 as an operating system on your Mac (MacOS X).
    The second part of your problem - You will need a copy of Windows XP or Vista if you want to run Windows on your Mac.
    There is at least one other solution for running Windows programs on a Mac. It's called "CrossOver" by a company named 'Codeweavers'. It's based on a project for "Wine" to be able to run PC programs on a Mac or Linux, without having to buy or install Windows. It works with a narrow subset of Windows programs so you would want to make sure the program you want to run is compatible with CrossOver before you buy it.
    http://www.codeweavers.com/products/cxmac/
    In addition to all the above information, you need to upgrade your Mac to the latest 10.5.7 from 10.5.1. "Software Update" is located under the black Apple icon in the Menu Bar at the top left corner of your monitor. After you are updated you will want to update your Profile here so that it shows the proper OS version.
    With your level of experience with MacOS X and the Windows OS's you should probably get some help from a local Apple store. They have an appointment system and do offer many types of help and training, and they can offer assistance with choosing the proper programs for you to purchase for your machine.
    You are also welcome to continue to ask questions here, of course. You will want to ask your questions with different issues that come up in different threads so that the answers stay focused on the title of the thread.
    Message was edited by: dechamp to try to be more accurate with a fairly complicated issue...

  • How to load flat files to BI

    Hi All,
    I am new to SAP BI. PLease tell me how to load excel files to BI.

    hi,
    For BI 7.0 basic step to laod data from flat (excel files) files for this follow the beloww step-by step directions ....
    Uploading of master data
    Log on to your SAP
    Transaction code RSA1u2014LEAD YOU TO MODELLING
    1. Creation of Info Objects
    u2022 In left panel select info object
    u2022 Create info area
    u2022 Create info object catalog ( characteristics & Key figures ) by right clicking the created info area
    u2022 Create new characteristics and key figures under respective catalogs according to the project requirement
    u2022 Create required info objects and Activate.
    2. Creation of Data Source
    u2022 In the left panel select data sources
    u2022 Create application component(AC)
    u2022 Right click AC and create datasource
    u2022 Specify data source name, source system, and data type ( master data attributes, text, hierarchies)
    u2022 In general tab give short, medium, and long description.
    u2022 In extraction tab specify file path, header rows to be ignored, data format(csv) and data separator( , )
    u2022 In proposal tab load example data and verify it.
    u2022 In field tab you can you can give the technical name of info objects in the template and you not have to map during the transformation the server will automatically map accordingly. If you are not mapping in this field tab you have to manually map during the transformation in Info providers.
    u2022 Activate data source and read preview data under preview tab.
    u2022 Create info package by right clicking data source and in schedule tab click star to load data to PSA.( make sure to close the flat file during loading )
    3. Creation of data targets
    u2022 In left panel select info provider
    u2022 Select created info area and right click to select Insert Characteristics as info provider
    u2022 Select required info object ( Ex : Employee ID)
    u2022 Under that info object select attributes
    u2022 Right click on attributes and select create transformation.
    u2022 In source of transformation , select object type( data source) and specify its name and source system Note: Source system will be a temporary folder or package into which data is getting stored
    u2022 Activate created transformation
    u2022 Create Data transfer process (DTP) by right clicking the master data attributes
    u2022 In extraction tab specify extraction mode ( full)
    u2022 In update tab specify error handling ( request green)
    u2022 Activate DTP and in execute tab click execute button to load data in data targets.
    4. Monitor
    Right Click data targets and select manage and in contents tab select contents to view the loaded data. Alternatively monitor icon can be used.
    BW 7.0
    Uploading of Transaction data
    Log on to your SAP
    Transaction code RSA1u2014LEAD YOU TO MODELLING
    5. Creation of Info Objects
    u2022 In left panel select info object
    u2022 Create info area
    u2022 Create info object catalog ( characteristics & Key figures ) by right clicking the created info area
    u2022 Create new characteristics and key figures under respective catalogs according to the project requirement
    u2022 Create required info objects and Activate.
    6. Creation of Data Source
    u2022 In the left panel select data sources
    u2022 Create application component(AC)
    u2022 Right click AC and create datasource
    u2022 Specify data source name, source system, and data type ( Transaction data )
    u2022 In general tab give short, medium, and long description.
    u2022 In extraction tab specify file path, header rows to be ignored, data format(csv) and data separator( , )
    u2022 In proposal tab load example data and verify it.
    u2022 In field tab you can you can give the technical name of info objects in the template and you not have to map during the transformation the server will automatically map accordingly. If you are not mapping in this field tab you have to manually map during the transformation in Info providers.
    u2022 Activate data source and read preview data under preview tab.
    u2022 Create info package by right clicking data source and in schedule tab click star to load data to PSA.( make sure to close the flat file during loading )
    7. Creation of data targets
    u2022 In left panel select info provider
    u2022 Select created info area and right click to create ODS( Data store object ) or Cube.
    u2022 Specify name fro the ODS or cube and click create
    u2022 From the template window select the required characteristics and key figures and drag and drop it into the DATA FIELD and KEY FIELDS
    u2022 Click Activate.
    u2022 Right click on ODS or Cube and select create transformation.
    u2022 In source of transformation , select object type( data source) and specify its name and source system Note: Source system will be a temporary folder or package into which data is getting stored
    u2022 Activate created transformation
    u2022 Create Data transfer process (DTP) by right clicking the master data attributes
    u2022 In extraction tab specify extraction mode ( full)
    u2022 In update tab specify error handling ( request green)
    u2022 Activate DTP and in execute tab click execute button to load data in data targets.
    8. Monitor
    Right Click data targets and select manage and in contents tab select contents to view the loaded data. There are two tables in ODS new table and active table to load data from new table to active table you have to activate after selecting the loaded data . Alternatively monitor icon can be used
    Regards,
    ANI

  • How to monitor background jobs automatically

    Hello,
    How to monitor background jobs automatically
    (we have more then 100+ jobs in a month and some jobs are repeating 4 - 5 times in a same day )  Now i am searching any salutation for monitor background jobs automatically
    Let me know the  options
    Thanks,
    Suresh

    Hi,
    If your batch job is creating a file in SAP and sending it to another system. These are some things you could do, if you have tools and resources available.
    1) When the job ( SAP program ) runs to create the file, ensure there is no file already existing in the landing zone ( AL11), if it does then do not over write, just throw an error, because the last file created did not leave the landing zone, because the other system or middle were did not pick it up. Usually when the middleware or third party system picks up your file from the landing zone, it may delete the file, so next time fresh file can be picked up. It is always good to have date and time stamp on the file that you create on the landing zone, so we could uniquely track which files were creates, when it was created and transmitted.
    2) Lets say your job created the file in the landing zone, the FTP program or what ever service or tool that you use to pick the file, if it is running as per design, then it should pick it up, if not you need to see why it is not running, usually the FTP softwars like GIS will throw an error if no file is found, and we could track them.
    I am sure there are many other ways to handle if the file really left the landing zone or not. Something to think about. thanks

  • How to monitor DFS shares disk usage/free space?

    How to monitor DFS shares disk usage/free space?
    Using Netapp filer shares to which DFS points. Looking for powershell script to send report.

    Hi,
    How about using Disk Quota function in FSRM (File Server Resource Manager)?
    Please see:
    Quota Management
    http://technet.microsoft.com/en-us/library/cc755917(v=ws.10).aspx
    In your case you can setup a soft quota with a specific size so that when it runs out of space you set, you will get an email or warning according to your setup. 
    If you have any feedback on our support, please send to [email protected]

  • How to monitor SQL Apply for 10.2.0.3 logical standby database

    We have a logical standby database setup for reporting purposes. Users want to monitor whether sql apply is working or failed closely as it has reporting repercations.
    In case of 9i databases , there was "Data Not Applied (logs)" metric which we used for alerting and paging, in case a backlog of more than 5 log files developed.
    With 10.2.0.3 onwards, the metric no more exists.
    I would like to learn from other, how to monitor the setup, so that if the backlog in logs shipping or applying develops, we get page.
    Regards.

    regather the statistics on the table with method_opt=>for all columns or for all indexed columns or whatever size 1
    The 'size 1' directive will remove the histogram statistics.
    Sorry, didn't read ur post in a hurry. Below article (http://www.freelists.org/post/oracle-l/Any-quick-way-to-remove-histograms,13) removes histogram without re-analyzing the table. Hope that helps!!!
    On 3/16/07, Wolfgang Breitling <breitliw@xxxxxxxxxxxxx> wrote:
    I also did a quick check and just using
    exec
    dbms_stats.set_column_stats(user,'table_name',colname=>'column_name',d
    istcnt=>
    <num_distinct>);
    will remove the histogram without removing the low_value andhigh_value.
    At 01:40 PM 3/16/2007, Alberto Dell'Era wrote:
    On 3/16/07, Allen, Brandon <Brandon.Allen@xxxxxxxxxxx> wrote:
    Is there any faster way to remove histograms other than
    re-analyzing
    >
    the table? I want to keep the existing table, index & columnstats,
    >
    but with only 1 bucket (i.e. no histograms).You might try the attached script, that reads the stats using
    dbms_stats.get_column_stats and re-sets them, minus the histogram,
    using dbms_stats.set_column_stats.
    I haven't fully tested it - it's only 10 minutes old, even if Ihave
    slightly modified for you another script I've used for quite some
    time - and the spool on 10.2.0.3 seems to confirmthat the histogram
    is, indeed, removed, while all the other statistics are preserved.I
    have also reset density to 1/num_distinct, that is the value youget
    if no histogram is collected.regards,
    naren
    Edited by: fuzzydba on Oct 25, 2010 10:52 AM

  • How to clear hidden files from hd

    My son upgraded iphoto and it disassociated all the files.  I thought it deleted all the files so I reloaded everything from an external drive.  My system will not run due to the fact that it says, not enought space.  My harddrive is completely full.  I'm thinking I have multiple copies of files and have not been erased. I went to iphoto and deleleted ALL the files and it still says that I have no space available.  I don't know how to find the files that are hidden or disassociated.
    Does anyone know how to find files outside of the program???

    If your sure you have a copy of your files off the machine, the open the Pictures/iPhoto Library and right click "show package contents" and the Originals folder should have a copy there, or they are all in your Trash can and you need to Empty Trash and reboot the machine.
    Open Activity monitor and look at your space remaining.
    Why is my computer slow?
    https://discussions.apple.com/community/notebooks/macbook_pro?view=documents

Maybe you are looking for

  • How to get mail accounts in all profiles?

    Hi, I setup 4 users in my imac, one for each family member. I setup the email accounts under my profile and when my wife logs in, the mail prog wants her to go thru the same process again. How do I copy the mail accounts from under my profile to all

  • Error while using copy function for position in IT 1001

    Hi All, I am getting the following error " For infotype 1001 in status 1, function COP is not allowed" when I am changing the Org unit relationship (A003) in IT 1001 for a position Steps followed: po13 -> choose position -> select relationship IT-> c

  • DirectAccess (2012 R2) Force Tunnel & Non-IE Browsers

    I'm setting up a DirectAccess solution with Force Tunneling enabled (don't ask why, the client demanded it). The solution is working flawlessly except for internet access for non-IE browsers. I have a proxy server entry in the nrpt for the '.' dnssuf

  • Using Time Machine in Corporate Environment

    Hi, I have a question regarding time machine in a corporate environment. Instead of purchasing a time capsule, I thought it would be straight forward to share a large drive and have our ten Mac Pro computers share that drive for a time machine. This

  • DLL import and Pointers to a function

    Hi, I am currently trying to get the ANT development kit working under LabView. For that i have imported the dllL (with the 8.2 version of LabView because of unknown reasons the import doesnt work under 8.5). everything seems to work fine except one