Monday, June 29, 2009
Sunday, June 21, 2009
Free online file conversion: Zamzar
很多人為了轉換檔案格式,總是會在電腦上裝載各種轉換的軟體,甚至有時收到了不能讀取的檔案時就更是令人感到心煩了,比如Office 2007的docx,像我的Linux與OSX都沒辦法讀取docx的文件,偏偏有人就是很喜歡寄給我但也總不能去請人家去轉換好再寄給我吧,此時只好自己開啟Windows的office 2007來看,挺浪費時間,嘿嘿~不過今天真是個好日子,讓我發現了一個能解決我這種困擾的服務,Zamzar!
Zamzar它是一個免費的線上格式轉換的服務,不論您使用那種OS(事實上跟OS一點關係都沒有),只要將檔案透過Web browser上傳後,選擇想轉換成的檔案格式,它就會幫你將檔案轉換好並透過mail告訴你檔案下載的連結,真的是非常之方便呀!目前檔案的上限為100MB,而能轉換的格式真是包山包海呀!
Wednesday, June 10, 2009
[Shell script] Remote Services watchdog
以下的script是針對偵測到對方的service沒有正常運作時則發mail給所指定的使用者,請參考:
#!/bin/bash
SRVLIST='192.168.0.100:80
192.168.0.100:53'
MAILACCOUNT="root@server1.example.com"
for SRV in `echo $SRVLIST`
do
IP=`echo $SRV | cut -d: -f1`
PORT=`echo $SRV | cut -d: -f2`
nc -w 1 $IP $PORT > /dev/null 2>&1 || echo "Port $PORT on Server $IP is failed" | mail -s "Error: Service failed" $MAILACCOUNT
done
Monday, June 08, 2009
Install AWstats on CentOS 5.x
What's AWstats?
AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. It uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers.
http://awstats.sourceforge.net/
安裝步驟:
1. 於rpmfind.net 搜尋並下載awstat*rpm for RHEL5.x (awstats-6.9-2.el5.rf.noarch.rpm)
AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. It uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers.
http://awstats.sourceforge.net/
安裝步驟:
1. 於rpmfind.net 搜尋並下載awstat*rpm for RHEL5.x (awstats-6.9-2.el5.rf.noarch.rpm)
2. # rpm -ivh awstat*rpm
3. 修改/etc/httpd/conf/httpd.conf:
AddHandler cgi-script .cgi .pl
4. 修改/etc/httpd/conf.d/awstats.conf :
Alias /awstats/icon/ /var/www/awstats/icon/
ScriptAlias /awstats/ /var/www/awstats/
DirectoryIndex awstats.pl
Options ExecCGI
Order allow,deny
Allow from all
# order deny,allow
# deny from all
# allow from 127.0.0.1
5. 將/etc/awstats/awstats.localhost.localdomain.conf改成/etc/awstats/awstats.IPADDRESS.conf (e.g., IPADDRESS=192.168.0.1)
6.手動執行/etc/cron.hourly/00awstats
如此一來就馬上有資料產生了,之後就交給system crontable更新吧!
7. 開啟瀏覽器並輸入 http://192.168.0.1/awstats/awstats.pl,成功的話應該會看到以下的畫面:
Note: awstats.IPADDRESS.conf 有許多參數可調整,請參考裡面的說明。
Sunday, June 07, 2009
Saturday, June 06, 2009
[Shell script] Services watchdog
這隻script的功能就是當偵測到所指定的port於本機沒有啟動的話,就會將它自動重啟,放在cron table裡定時檢查吧!
#!/bin/bash
SRVLIST='80:/etc/init.d/httpd
25:/etc/init.d/postfix
22:/etc/init.d/sshd
110:/etc/init.d/dovecot'
for SRV in `echo $SRVLIST`
do
nc -w 1 localhost `echo $SRV | cut -d: -f1` > /dev/null 2>&1 && echo "Port $SRV fine" || `echo $SRV|cut -d: -f2` restart
done
[Shell script] Monitor process cpu loading and count
1. 當process CPU loading超過90%, 就先行刪除:
#!/bin/bash
CPULOADING=90
ps auxh | \
while read pro
do
set -- $pro
if [ `echo $3 | cut -d"." -f1` -gt $CPULOADING ]; then
kill $2
fi
done
2.當process數目超過50時, 就先行刪除:
#!/bin/bash
PSCOUNT=50
ps axh -o "cmd" | sort | uniq -d -c | \
while read ps
do
set -- $ps
if [ $1 -gt $PSCOUNT ]; then
killall $2
fi
done
Reference: Linux網路安全管理與監控
#!/bin/bash
CPULOADING=90
ps auxh | \
while read pro
do
set -- $pro
if [ `echo $3 | cut -d"." -f1` -gt $CPULOADING ]; then
kill $2
fi
done
2.當process數目超過50時, 就先行刪除:
#!/bin/bash
PSCOUNT=50
ps axh -o "cmd" | sort | uniq -d -c | \
while read ps
do
set -- $ps
if [ $1 -gt $PSCOUNT ]; then
killall $2
fi
done
Reference: Linux網路安全管理與監控
Friday, June 05, 2009
[Shell script] Monitor Disk space
#!/bin/bash
USAGE_SPACE=20
USAGE_SPACE=20
df | grep '[0-9]%' | egrep 'sd|hd' | \
while read line
do
# if [ `echo $line | awk -F" " '{ print $5 }' | cut -d% -f1` -gt "$USAGE_SPACE" ]; then
# echo "Disk space of `echo $line | awk -F" " '{ print $6}'` belongs to `hostname` is over $USAGE_SPACE%" | mail -s "HD DISK is not enough" $USER
# fi
set -- $line
if [ `echo $5 | cut -d% -f1` -gt $USAGE_SPACE ]; then
echo "Disk space of `echo $6` belongs to `hostname` is over $USAGE_SPACE%" | mail -s "HD DISK is not enough" $USER
fi
done
Subscribe to:
Posts (Atom)