- 浏览: 836006 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
zjhzwx1212:
为什么用threadLocal后,输出值是从20开始的,而定义 ...
j2ee的线程安全--threadlocal -
aeoluspu:
不错 mysql 测试部分感觉不详细
用sysbench(或者super-smack)测试mysql性能 -
nanPrivate:
有没有例子,只理论,实践起来还是不会啊
JMS可靠消息传送 -
lwclover:
一个网络工程师 装什么b
postfix 如何删除队列中的邮件 -
maimode:
我也欠缺不少啊
理想的计算机科学知识体系
http://www.linux.com/feature/124903
Applications can ask the Linux kernel to report changes to selected files and directories. I created the Kernel Filesystem Monitoring Daemon (kfsmd) to make monitoring filesystem changes simple.
There are packages available for both 32- and 64-bit Fedora 7 and 8 and Ubuntu 7.10 Gutsy, as well as 32-bit packages for openSUSE 10.3. You can also download a repo file, which can be used with Fedora 8 and yum. Placing the repo file into /etc/yum.repos.d allows you to install kfsmd and its dependencies with yum install kfsmd
on a Fedora 8 machine. You can also compile directly from source if that is your preference.
Command-line clients for kfsmd come in two categories: monitoring and logging. The monitoring client produces output on the console whenever something happens to a filesystem you are watching. You can log to either a Berkeley DB4 file or a PostgreSQL database.
The following session shows a simple directory monitoring session using kfsmd. It creates and populates a temporary directory, then starts kfsmd-cat to watch /tmp/k for any filesystem changes. The main command-line parameter is the watch
command, which takes the directory or file to watch as a single argument. While kfsmd-cat was running, I opened a second terminal and created the df5.txt file and then removed it. These actions were reported to the console by kfsmd.
What's that command again?
Although some of the command names shown in this article are quite long, the commands themselves are simple to use. In the article text I shorten command names from "kernel-filesystem-monitor-daemon-postgresql" to simply kfsmd-postgresql, but I show the full command names in code blocks. The command-line clients all have long names in order to be as descriptive as possible, and because common usage of kfsmd is generally through scripts and not directly on the command line.
$ mkdir /tmp/k $ cd /tmp/k $ date > df1.txt $ date > df2.txt $ kernel-filesystem-monitor-daemon-cat -v watch . setting up watch for:. setting up watches calling run event on wd:1 . filename:df5.txt CLOSE URL:./df5.txt event on wd:1 . filename:df5.txt DELETE_FILE URL:./df5.txt
If you specify a directory to monitor with a full filesystem path, then kfsmd also monitors existing and newly created subdirectories by default. You can use the ignorepfx
argument to limit these recursive monitors by explicitly telling kfsmd not to monitor some subdirectories. In the next example, which uses ignorepfx, I created two subdirectories inside /tmp/k: junk1 and subdir1. Both of the directory create and delete events were reported by kfsmd, and because of the ignorepfx argument, kfsmd did not monitor the /tmp/k/junk1 subdirectory itself, so files I created in that directory were not monitored and reported by kfsmd. Note that as ignorepfx is the prefix of a path, using just "junk" means that the subdirectory junk1 is not monitored.
$ kernel-filesystem-monitor-daemon-cat -v \ watch /tmp/k ignorepfx /tmp/k/junk event on wd:1 /tmp/k filename:junk1 CREATE URL:/tmp/k/junk1 event on wd:1 /tmp/k filename:subdir1 CREATE URL:/tmp/k/subdir1 should adding monitor for:subdir1 event on wd:2 /tmp/k/subdir1 filename:subfileA.txt CREATE URL:/tmp/k/subdir1/subfileA.txt event on wd:2 /tmp/k/subdir1 filename:subfileA.txt CLOSE URL:/tmp/k/subdir1/subfileA.txt event on wd:2 /tmp/k/subdir1 filename:subfileA.txt DELETE URL:/tmp/k/subdir1/subfileA.txt event on wd:1 /tmp/k filename:subdir1 DELETE URL:/tmp/k/subdir1 event on wd:1 /tmp/k filename:junk1 DELETE URL:/tmp/k/junk1
You can see that filesystem changes reported by kfsmd have a regular style. The primary report has the prefix "EVENT_TYPE URL:" where the event type is what happened to the file and the URL: string is used as a direct prefix to the file path being reported. This structure makes it convenient to use the kfsmd-cat command and pipe the output into a script that will perform some action for you automatically when files change.
The following script uses Perl to print the paths of files that are deleted in any monitored directory. It uses the pwd command on the first line of the command to make the paths reported by kfsmd absolute. The kfsmd-cat command will produce output similar to that shown above, and Perl code massages the output into a particular format, or can execute a command whenever a deletion happens. The script ignores all lines that do not start with DELET. Lines which report file deletion then have the prefix string "anything...URL:" stripped off so only the file path is printed to the console.
$ kernel-filesystem-monitor-daemon-cat watch `pwd` \ | perl -ne '{ if( /^DELET/ ) { s/.*URL://g; print; } }' /tmp/k/df5.txt
A second invocation of kfsmd-cat, shown below, sends an email message whenever a file is deleted in the current directory.
$ kernel-filesystem-monitor-daemon-cat watch `pwd` \ | kfsmd-sendemail.pl
The Perl script kfsmd-sendemail.pl
is shown below. The three lines which you might have to change to use this yourself are listed at the top of the script; the FromAddress and ToAddress should be modified to suit your local environment.
#!/usr/bin/perl -n $Mailer = "| /usr/sbin/sendmail -t"; $FromAddress = 'ben@localhost'; $ToAddress = 'ben@localhost'; if( /^DELETE_/ ) { s/.*URL://g; chomp; $url=$_; $now=`date`; open MAIL,"$Mailer"; print MAIL <<THE_EMAIL; From: $FromAddress To: $ToAddress Subject: KFSMD: A file was deleted The file: $url Was deleted at $now THE_EMAIL close MAIL; }
Logging with kfsmd
To log filesystem events into a PostgreSQL database, use the kfsmd-postgresql command. Before using this command you must set up the database with the postgresql-schema.sql script. This can be done using the first command shown below. Note that the the database setup command only needs to be run once. The kfsmd-postgresql daemon will run in the background by default. You can set up watches with it in the same manner as for the kfsmd-cat command, though you must specify the database host and database name.
$ cat postgresql-schema.sql | psql -h myPostgreSQLServer $ kernel-filesystem-monitor-daemon-postgresql \ -h myPostgreSQLServer \ -d kernel_filesystem_monitor_daemon_postgresql watch `pwd`
With the command above, filesystem changes are logged to the PostgreSQL database called kernel_filesystem_monitor_daemon_postgresql on the server myPostgreSQLServer. You can query the database using SQL as shown below.
$ psql -h myPostgreSQLServer # \c kernel_filesystem_monitor_daemon_postgresql # select * from dirs d, events e where d.pwd = e.pwd order by time; pwd | url | id | mask | pwd | time | name -----+--------+----+------+-----+----------------------------+---------- 1 | /tmp/k | 2 | 512 | 1 | 2008-01-03 13:26:39.913456 | df11.txt 1 | /tmp/k | 1 | 8 | 1 | 2008-01-03 13:26:39.913456 | df11.txt 1 | /tmp/k | 3 | 8 | 1 | 2008-01-03 13:26:41.917512 | df21.txt
There are many situations where kfsmd is the right tool for the job. For example, if you are editing a file and wish to automatically publish it to a remote server each time it is saved, you can use kfsmd-cat and when a CLOSED event is detected execute a little script to rsync the file to the server. If you have a long-running task and wish to know when it is completed, just monitor for a filesystem change that occurs at the end of the process, such as when a file download or a build completes.
The kfsmd-postgresql and kfsmd-stldb4 commands allow you to easily record filesystem changes in a database, which is great for auditing what happened and when.
发表评论
-
sysctl.conf
2011-07-06 14:54 1705fs.file-max=51200 net.core.net ... -
top的替代工具
2011-06-28 15:06 1428dstat -cgilpymn collectl and ... -
有用的小工具
2010-12-23 11:51 1296pv stream nessus Nikto ski ... -
调优linux i/o 行为
2010-11-25 11:27 2876http://www.westnet.com/~gsmith/ ... -
服务器部署工具
2010-11-12 16:32 2005http://www.linuxlinks.com/artic ... -
开源的配置管理工具
2010-11-12 16:24 1409最佳开源配置管理工具: Puppet / 提名:OpenQ ... -
优化ext3的mount选项
2010-11-12 10:24 1281defaults,commit=600,noatime,nod ... -
恢复r710biso 出厂设置
2010-11-10 10:30 1176ALT+E/F/B -
每进程io监控工具
2010-11-02 14:14 1613iodump iotop iopp pidstat b ... -
Intel Xeon 5500/5600系列 CPU服务器内存设置
2010-11-01 21:29 4770http://www.xasun.com/article/2a ... -
zabbix短信报警脚本文件
2010-10-21 14:28 2737附件 -
天外飞仙级别的Linux Shell命令
2010-10-16 09:59 1356本文编译自commandlinefu.com ( 应该是 Ca ... -
lenny+r710+lvm 重启问题解决方案
2010-10-15 14:22 1068ro rootdelay=10 quiet -
fai,debian 自动安装工具
2010-10-15 13:36 1074http://sys.firnow.com/linux/x80 ... -
十个服务器监控工具
2010-09-26 11:44 1784一位国外的技术博主在 ... -
restrict authorized_keys
2010-09-06 09:45 1208command="/home/someuser/rs ... -
sysctl优化设置
2010-09-05 11:25 1078sysctl 是一个用来在系统运作中查看及调整系统参数的工 ... -
proc文件系统
2010-09-05 11:22 1210什么是proc文件系统? proc文件系统是一个伪 ... -
nfs使用
2010-09-02 17:01 1111http://www.linuxhomenetworking. ... -
lsof example
2010-08-23 12:40 12271、查看文件系统阻塞 ...
相关推荐
需手动输入坐标,实现ECEF空间直角坐标系等四种坐标之间相互转换。 具体代码流程可见主页文章。 通过下拉框,自由选择输入输出坐标系后,在左侧文本框手动输入一组或多组坐标,可以实现ECEF空间直角坐标系,ECEF球面坐标系,ECEF椭球坐标系(大地坐标系),站心坐标系四个坐标系统之间的自由转换,共12种转换方式。然后将转换后的坐标结果输入到右边文本框。 适用于GNSS相关课程的编程作业,测绘、地信等专业实践。 ------------------------------------------------------------------------------------------------------------------------- 该代码可能存在部分不足与漏洞。实际运行时没有发生过错误。
基于matlab实现直角坐标系下的牛顿拉夫逊潮流计算MATLAB程序.rar
基于matlab实现麦克风阵列SRP-PHAT算法的二级空间快速声源定位,含模拟环境。.rar
Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。
dephi+sqlserver2000题库与试卷生成系统.zip
Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。
ASP+ACCESS网页设计辅导系统(源代码+设计说明书).zip
中考实验视频.zip
基于VB+access实现的学生成绩管理系统(开题报告+答辩PPT+论文+系统) 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。
基于matlab实现模拟退火程序。f(x,y) = 5sin(xy) + x^2 + y^2的最小值,对理解模拟退火算法是一个很好的程序示例.rar
Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。
ASP+access网上人才信息管理系统毕业设计(源代码+设计说明书).zip
Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。
Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。
污水处理计算书
ASP+ACCESS文学网站建设设计(源代码+设计说明书+系统).zip
http代理服务器的实现(程序).zip
Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。
JSP教学管理系统设计(源代码+设计说明书).zip
行业报告