tracking / monitoring system [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have been developing an application which will track the work history of employees in the office.
Hence I need to track the following details of my users Ubuntu users.
Applications opened.
Duration for which application was running.
If the application is like a text editor/video codec like VLC – what files were opened and for what duration.
Also I want to track the copy/paste history of files/folders on removable media.
Could anyone help me to suggest the header files and functions in C/shell/Perl which would help me to track this?
Please Note: I am not expecting the keystrokes to be monitored for the sake of privacy.
It may be that some of these requirements can't be fulfilled, however suggestions on possible features will be appreciated.

Take a look at the man page for 'proc'. The procfs is a filesystem mounted on /proc. Under that directory is a folder for each process by process ID. Of interest to you will be the fd folder for each process. For example, for a process with a PID of 5, the fd folder is
/proc/5/fd
The fd folder contains a symbolic link for each file handle open by the process. To listen for changes(new processes being launched, new files being opened) on the proc filesystem, I suggest inotify. However, it does have limitations with respect to procfs.

Related

Build a File Monitoring System [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have just started programming and would like to implement a file monitoring system from scratch in C.
I have used the Watch Service API in java but I would like to learn how to build one from scratch. I would really appreciate some assistance and guidance.
Thanks.
You can:
either rely on existing system calls that will push you notifications on file system modifications (eg: inotify)
implement your own kernel module that will intercept file system modification and notify you (if you really want to reimplement the wheel)
use a polling-approach, rebuild the filesystem tree in-memory and compare it every second or so. This will be very cpu/io/memory consuming, but it can be instructive.

Getting the available free space on a directory in linux [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Using a C program how to get the free size available in a directory ?
What are the library functions that i can use to achieve this.
A given directory does not have free space, it is the file system (containing that directory) which has free space.
You can query that using the df(1) command (you might popen(3) "/bin/df .", but I don't recommend doing that) and the statfs(2) (and some other) syscall(s).
See syscalls(2) and read Advanced Linux Programming
Perhaps the limit is quota related, see repquota(8), or resource-limit related, see ulimit builtin of bash and getrlimit(2). Maybe use /proc/ pseudo-files, see proc(5)
BTW, that limit is in fact only indicative: other programs and processes are also able to fill the directory (e.g. between the moment your program is querying it and the moment it is writing data).

can we know when a file is succesfully transfer in SFTP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am about to read the whole ietf spec for sftp but was wondering if someone has been through this before at all. Is it possible that sftp provides a mechanism that can be used to figure out if a file has been succesfully transferred (something like last byte out) or by design this is not possible?
Use scp instead. According to the appropriate manual page (man scp):
DIAGNOSTICS
scp exits with 0 on success or >0 if an error occurred.
So, check the exit code of scp, and that should be what you need. sftp is really intended to be more of an interactive experience (although you can in fact call it in a batch-oriented sort of way, but it doesn't seem to provide as much useful information).
It seems that there is no guaranteed way to know it.
SFTP protocol doesn't have the concept of "file transfer". It has operations like "open file", "write to file at position X" (random access is supported) and "close file".
Potentially the SFTP server knows when the file is closed by the client and this can be treated as "upload complete". But in most cases there are no hooks for this. On the client side it's the same.

Data destruction [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
There are many file shredders programs that one can use in order to delete permanently one file. What I want to know is some implementation details. For example, considering Gutmann algorithm, how it should work with file and file system? Should an application iterate over all hdd cluster in order to overwrite them? Or it will be enough to open one file, change it content in some way and after that to delete it?
Vice versa, how to restore deleted file? I have not found a lot of information for these topics.
I will be very thankful for your replies.
You could look at the source code of the shred utility which is a part of the GNU core utils found on Linux.The basic idea is to make multiple passes over the disk blocks.There are also some assumptions made about the way the underlying files system commits these writes. See info coreutils 'shred invocation' for more information.
Restoring deleted files are done best when you know the internal layout of the file system in question and how the delete operation is implemented on it. For example, many drivers for the FAT file system just mark the directory entry as deleted but leave the file's content in tact. (Until and unless it is over-written by new files that you create). So you could just take a dump of the disk and scan through the raw data looking for what you want.

Best way to instantly mirror/sync files from Windows to Linux server [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a directory on a Windows machine with a large number of files and folders that I need to watch and have the files mirrored/synced instantly (or as near to as possible), to a Linux machine over the local network.
I've investigated:
- Rsync, not realtime enough
- WinSCP 'Keep directories up to date' feature, which was OK but limited to 500 directories and the performance was pretty slow.
There are a bunch of results of shareware-style apps that claim to do this, but they are all pretty dubious looking. It seems there must be a good FOSS solution somewhere?
UPDATE: I'd be happy with a one-way transfer rather than a full sync, as long as it's instant and automatic.
I second eneset's proposal of the Unison software. Also if you care of looking for some alternatives Lifehacker has an interesting article on this subject http://lifehacker.com/372175/free-ways-to-synchronize-folders-between-computers
titel
It seems that what you want is to actually deal with the files on the linux server as if they were local files on your computer.
Did you consider looking for a tool to mount a remote ssh folder as a local drive?
Have a look at Unison (http://www.cis.upenn.edu/~bcpierce/unison/). I successfully used it for Linux/Windows home directory mirroring.
Have you considered using Samba? It will let you mount windows shares under linux as well as accessing linux directorys from windows if you set them up as shares.

Resources