博文

目前显示的是 九月, 2006的博文

维护Postfix的一些脚本、程序集锦

作为一名Postfix的管理员,维护Postfix的正常运行,并随时排除故障,这是最基本的任务。本文提供了一些我自己写及平时搜集到的脚本和程序,以便实现自动化的维护和操作。包括自动清理日志,分析日志,自动增加用户等等。 分析拒收邮件的日志分析程序 作者:Wietse Venema Message 6 in thread 寄件者:Wietse Venema ([email protected]) 主旨:Re: Freebsd Postifx Daily messages View this article only 新闻群组:mailing.postfix.users 日期:2002-12-01 10:48:47 PST Here's my own /etc/periodic/daily/460.status-mail-rejects script, and yes it needs updating when logging formats change. This script will not show rejected mail when the client never returned after a soft (450) error code from the server. I use 450 for non-FQDN HELO hostnames, so that I can whitelist mis-configured sites that aren't spammers. Wietse #!/bin/sh # echo ""; echo "Scanning maillog for rejections:" zcat -fc /var/log/maillog.0* /var/log/maillog | egrep reject: | cut -d : -f 5- | sort | uniq -c | sort -nr | grep -v '^ *[1-2] *[^ ]* [^ ]* from [^ ]*: 450 ' echo ""; echo "Scanning maillog for warnings:" zcat -f

Squid2.5+自定义日记

Squid2.6由于不能自由定义不同源的虚拟主机,所以只好使用2.5,可惜2.5的日志不能自定义。 补丁下载的网址: http://devel.squid-cache.org/customlog/ 可以生成Apache combined日志补丁 下载回来放到源码目录,运行 patch -p0 < customlog-2.5.patch 然后重新编译: ./configure --prefix=/usr/local/squid --enable-delay-pools --enable-useragent-log --enable-referer-log --enable-default-err-language=Simplify_Chinese --enable-x-accelerator-vary --enable-kill-parent-hack --enable-err-languages="Simplif y_Chinese English" --with-pthreads --with-aio --enable-cache-digests --with-large-files 编译结束后, 在  squid.conf 中添加:  logformat combined %>a - %un [%{%d/%b/%Y:%H:%M:%S +0800}tl] "%rm %ru HTTP/%rv" %Hs % h" "%{User-agent}>h" cache_access_log /var/squid/logs/access.log combined 一个支持 combined 日志模式的 Squid 即告完成。  注意, 这里用了 +0800 ,绕过了使用 tl 的 %z 或者 %Z 的问题,用 z% ,将显示为 25%z ,可能是 patch 有问题。  Squid custom log format Basic syntax: %...field where ... is an optional field width. On numeric fields the output will be 0 padded if the field width starts with

squid中的cachemgr.cgi使用(原创)

图片
下载回来squid的tar.gz包,如果要使用cachemgr.cgi的网页管理功能. 请编译时加入: --enable-cachemgr-hostname --enable-cachemgr-port 这样就可以不仅仅查看本机的squid运行情况了,当然还能指定端口. 如图: 然后修改你的--prefix=/path 中的/etc下的cachemgr.conf文件,加入对你所要控制的IP地址和端口,格式是:IP:PORT,或者是:*.* 把libexec/cachemrg.cgi拷到apache下的cgi-bin下. 关于这里的密码验证我还没有研究,是通过squid.conf下的cachegr_passwdg来控制. 当然你要在这里加入如下文字,以防止cachemrg对别人使用. acl Manager proto cache_object acl Localhost src 127.0.0.1/255.255.255.255 http_access allow Manager Localhost http_access deny Manager

squid中的refresh_pattern详解

图片
refresh_pattern 大概是 squid 最有意思但最不好懂的配置参数了,经过看书,大概明白如何使用,写出来贡献。 记住refresh_pattern 只对后端没设置Expires过期时间的页面起作用,比如论坛页面;而对类似apache mod_expires 设置过的页面不起作用。 说明之前,先将个概念LM,LM就是页面Header里时间(Date)和Last-Modified时间的差。Date一般是Squid从后面取页面的时间,Last-Modified 一般是页面生成时间。 refresh_pattern 的语法是refresh_pattern [-i] regexp min percent max [options]regexp 就不讲了,大家都明白的;) min, max的单位是分钟,percent就是百分比。 refresh_pattern 的算法如下:(当前时间定义为CURRENT_DATE) 1) If ((CURRENT_DATE-DATE(就是LM里定义的时间)) < min),cache是新鲜的 2) else if ((CURRENT_DATE-DATE) < (min + (max-min)*percent),cache是新鲜的 3) else cache是过期的 cache过期就需要从后面server取新鲜内容。 如果希望页面一进入cache就不删除,直到被主动purge掉为止,可以加上ignore-reload选项 一般情况可以使用 reload-into-ims。 举例: refresh_pattern -i \.gif$ 1440 50% 2880 ignore-reload refresh_pattern -i \.jpg$ 1440 50% 2880 ignore-reload refresh_pattern -i \.png$ 1440 50% 2880 ignore-reload refresh_pattern -i \.mp3$ 1440 50% 2880 ignore-reload refresh_pattern -i \.wmv$ 1440 50% 2880

在Vista中IE使用五笔

图片
昨天终于试着安装了下载回来的Vista RC1 5600,安装过程很顺利,似乎比XP还要快。 不过晚上试着在IE里使用五笔输入法弄了很长时间,几乎试了所有的输入法都不行。 还装上N多垃圾软件,受不了这些智能陈桥的作者了,垃圾作者,是软件员的败类。 后来,我试着在安全模式下关闭帐号的ACL控制,后来果然在IE里能用五笔了。

jdk5.0update8+jboss4.04.centos4.3安装过程.

首先从sun下载到jdk的安装包. 有两种包,分别是: jdk-1_5_0_08-linux-i586-rpm.bin(自解压,安装包) jdk-1_5_0_08-linux-i586.bin(自解压) 都是chmod +x filename 然后./filename 翻页到最后,输入Yes jdk就安装好了,jdk其实被安装到/usr/java/jdk1.5.0_08/bin 所以需要到 /etc/profile.d/下建立 java.sh文件 然后在这个文件里加入: export PATH=$PATH:/usr/java/jdk1.5.0_08/bin 这样java就可以用了,你可以试着用java -version来查看版本号,不知道这次的jdk为什么为1.4一下子跳到5.0了,其实是1.5. 然后就是下载jboss-4.0.4.GA.zip,到官方网站找一下吧. 然后unzip一下,把这个目录拷到/usr/local/jboss 然后到bin/运行./run.bat jboss就安装好了.

linux时间设置

date 查看,配置系统上的时间 clock 查看,配置系统硬件上的时间 clock --set --date="09/17/2003 13:26:00" tzselect 文本界面的时区设置 timeconfig 图形界面的时区设置 rdate -s time.nist.gov 和时间服务器同步. clock的帮助 [root@smtp02 ~]# clock --help hwclock - query and set the hardware clock (RTC) Usage: hwclock [function] [options...] Functions: --help show this help --show read hardware clock and print result --set set the rtc to the time given with --date --hctosys set the system time from the hardware clock --systohc set the hardware clock to the current system time --adjust adjust the rtc to account for systematic drift since the clock was last set or adjusted --getepoch print out the kernel's hardware clock epoch value --setepoch set the kernel's hardware clock epoch value to the value given with --epoch --version print out the version of hwclock to stdout Opt

RamDisk三种实现方式

  在Linux中可以将一部分内存mount为分区来使用,通常称之为RamDisk,分为:   Ramdisk, ramfs, tmpfs.   ① 第一种就是传统意义上的,可以格式化,然后加载。   这在Linux内核2.0/2.2就已经支持,其不足之处是大小固定,之后不能改变。   为了能够使用Ramdisk,我们在编译内核时须将block device中的Ramdisk支持选上,它下面还有两个选项,一个是设定Ramdisk的大小,默认是4096k;另一个是initrd的支持。   如果对Ramdisk的支持已经编译进内核,我们就可以使用它了:   首先查看一下可用的RamDisk,使用ls /dev/ram*   首先创建一个目录,比如test,运行mkdir /mnt/test;   然后对/dev/ram0 创建文件系统,运行mke2fs /dev/ram0;   最后挂载 /dev/ram0,运行mount /dev/ram /mnt/test,就可以象对普通硬盘一样对它进行操作了。   ② 另两种则是内核2.4才支持的,通过Ramfs或者Tmpfs来实现:   它们不需经过格式化,用起来灵活,其大小随所需要的空间而增加或减少。   Ramfs顾名思义是内存文件系统,它处于虚拟文件系统(VFS)层,而不像ramdisk那样基于虚拟在内存中的其他文件系统(ex2fs)。   因而,它无需格式化,可以创建多个,只要内存足够,在创建时可以指定其最大能使用的内存大小。   如果你的Linux已经将Ramfs编译进内核,你就可以很容易地使用Ramfs了。创建一个目录,加载Ramfs到该目录即可:   # mkdir /testRam   # mount -t ramfs none /testRAM   缺省情况下,Ramfs被限制最多可使用内存大小的一半。可以通过maxsize(以kbyte为单位)选项来改变。    # mount -t ramfs none /testRAM -o maxsize=2000 (创建了一个限定最大使用内存为2M的ramdisk)   ③ Tmpfs是一个虚拟内存文件系统,它不同于传统的用块设备形式来实现的Ramdisk,也不同于针对物理内存的Ramfs。   Tmpfs可以使用物理内存,也可以使用交换分区。在Linux内核中,虚拟