2009年9月29日 星期二

xhprof安裝

升級php5.2.11
更新yum

#additional packages that extend functionality of existing packages
[c5plus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5


#yum update php

#cd /usr/local/src
#wget http://pecl.php.net/get/xhprof-0.9.1.tgz
#tar -zxvf xhprof-0.9.1.tgz
#cd xhprof-0.9.1/extension
#phpize
#./configure --with-php-config=/usr/bin/php-config
#make
#make install
#make test
#vi /etc/php.ini

[xhprof]
extension=xhprof.so
;
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;
xhprof.output_dir=


#vi graphviz-rhel.repo

//http://graphviz.org/graphviz-rhel.repo
[graphviz-stable]
name=Graphviz - RHEL $releasever - $basearch
baseurl=http://www.graphviz.org/pub/graphviz/stable/redhat/el$releasever/$basearch/os/
enabled=1
gpgcheck=0

[graphviz-stable-source]
name=Graphviz - RHEL $releasever - Source
baseurl=http://www.graphviz.org/pub/graphviz/stable/SRPMS/
enabled=0
gpgcheck=0

[graphviz-stable-debuginfo]
name=Graphviz - RHEL - Debug
baseurl=http://www.graphviz.org/pub/graphviz/stable/redhat/el$releasever/$basearch/debug/
enabled=0
gpgcheck=0

[graphviz-snapshot]
name=Graphviz - RHEL $releasever - $basearch
baseurl=http://www.graphviz.org/pub/graphviz/development/redhat/el$releasever/$basearch/os/
enabled=0
gpgcheck=0

[graphviz-snapshot-source]
name=Graphviz - RHEL $releasever - Source
baseurl=http://www.graphviz.org/pub/graphviz/development/SRPMS/
enabled=0
gpgcheck=0

[graphviz-snapshot-debuginfo]
name=Graphviz - RHEL - Debug
baseurl=http://www.graphviz.org/pub/graphviz/development/redhat/el$releasever/$basearch/debug/
enabled=0
gpgcheck=0


#rpm -e graphviz-php
#yum update graphviz

2009年9月24日 星期四

【JavaScript】slice()、substring()、substr()的區別

stringObject.slice(startIndex,endIndex)
  返回字串 stringObject 從 startIndex 開始(包括 startIndex )到 endIndex 結束(不包括 endIndex )為止的所有字元。
  1)參數 endIndex 可選,如果沒有指定,則預設為字串的長度 stringObject.length 。
 var stringObject = "hello world!";
 alert(stringObject.slice(3)); // lo world!
 alert(stringObject.slice(3,stringObject.length)); // lo world!
  【注1】字串中第一個字元的位置是從【0】開始的,最後一個字元的位置為【stringObject.length-1】,所以slice()方法返回的字串不包括endIndex位置的字元。
  2)startIndex 、endIndex 可以是負數。如果為負,則表示從字串尾部開始算起。即-1表示字串最後一個字元。
 var stringObject = "hello world!";
 alert(stringObject.slice(-3)); // ld!
 alert(stringObject.slice(-3,stringObject.length)); // ld!
 alert(stringObject.slice(-3,-1)); // ld
  【注2】合理運用負數可以簡化代碼
  3)startIndex、endIndex 都是可選的,如果都不填則返回字串 stringObject 的全部,等同於slice(0)
 var stringObject = "hello world!";
 alert(stringObject.slice()); // hello world!
 alert(stringObject.slice(0)); // hello world!
  4)如果startIndex、endIndex 相等,則返回空串
  【注3】String.slice() 與 Array.slice() 相似
stringObject.substring(startIndex、endIndex)
  返回字串 stringObject 從 startIndex 開始(包括 startIndex )到 endIndex 結束(不包括 endIndex )為止的所有字元。
  1)startIndex 是一個非負的整數,必須填寫。endIndex 是一個非負整數,可選。如果沒有,則預設為字串的長度stringObject.length 。
 var stringObject = "hello world!";
 alert(stringObject.substring(3)); // lo world!
 alert(stringObject.substring(3,stringObject.length)); // lo world!
 alert(stringObject.substring(3,7)); // lo w,空格也算在內[l][o][ ][w]
  2)如果startIndex、endIndex 相等,則返回空串。如果startIndex 比 endIndex 大,則提取子串之前,調換兩個參數。即stringObject.substring(startIndex,endIndex)等同於stringObject.substring(endIndex,startIndex)
 var stringObject = "hello world!";
 alert(stringObject.substring(3,3)); // 空串
 alert(stringObject.substring(3,7)); // lo w
 alert(stringObject.substring(7,3)); // lo w
  【注4】與substring()相比,slice()更靈活,可以接收負參數。
  stringObject.substr(startIndex,length)
  返回字串 stringObject 從 startIndex 開始(包括 startIndex )指定數目(length)的字元字元。
  1)startIndex 必須填寫,可以是負數。如果為負,則表示從字串尾部開始算起。即-1表示字串最後一個字元。
  2)參數 length 可選,如果沒有指定,則預設為字串的長度 stringObject.length 。
 var stringObject = "hello world!";
 alert(stringObject.substr(3)); // lo world!
 alert(stringObject.substr(3,stringObject.length)); // lo world!
 alert(stringObject.substr(3,4)); // lo w
  3)substr()可以代替slice()和substring()來使用,從上面代碼看出 stringObject.substr(3,4) 等同於stringObject.substring(3,7)
  【注5】ECMAscript 沒有對該方法進行標準化,因此儘量少使用該方法。

JQuery How to check if an element exists

A common question comes up very frequently - "how do I know if XXX exists". The XXX could be a particular DIV with a class, or it might be an ID. The issue is common enough that it has been listed in the jQuery FAQs (http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_test_whether_...).

Some people attempt to just check the jQuery object for the specified selector:


//This will not work

if ( $("#myid") ) {

//do something

}


This will fail. The jQuery object will ALWAYS return something. When we say $( ) we are asking for a jQuery object. So we get one back. The above code will always equate to TRUE.

The jQuery object contains a list/array of the elements that match our selector. So we can ask for the length of this internal list. The jQuery kindly exposes this length for us as the .length property. If the length is greater than zero then we have at least one object that matches our selector.


if ( $("#myid").length > 0 ) {

//do something

}


So now the only question is what we are testing. This is defined by the selector we use. If we want to know if a particular ID exists, we would use a selector of "#theID". If we were trying to determine if a DIV with a particular class existed, we would use the selector of "div.theClass".


if ( $("#theID").length > 0 ) { alert("The ID exists"); }

if ( $("div.theClass").length > 0 ) { alert("The DIV exists"); }


In this way we can check to see if ANY element exists.

2009年9月23日 星期三

吴迪西羽毛球技术入门

http://v.youku.com/v_show/id_XMTUxOTcwNDQ=.html

2009年9月22日 星期二

javascript for loop json


var json = { "glossary": { "title": "example glossary" } };
alert(json);
alert(json.glossary.title);
for (var x in json) { alert(x); alert(json[x].title); }

用YUM升级CentOS系统中PHP和MySQL

用上umVPS后,很多时候在虚拟主机不用自己动手的事情都要自己搞定了,例如:PHP和MySQL的升级。因为不用自己动手,也动不了,所以冰古不太清楚虚拟主机的PHP和MySQL是不是会及时地更新。但用VPS,可以动手玩一下也保证安全,冰古是很乐意进行更新的。以下就是用YUM升级CentOS系统中PHP和MySQL的过程:

yum是CentOS系统自带的用于方便地添加/删除/更新RPM包的工具,它能自动解决包的倚赖性问题。
用yum更新PHP,只需用一条命令就可以搞定:

#yum update php
但问题来了,使用此命令后,系统告诉我,没有发现可更新的包。而当前的PHP版本只是5.2.1,PHP官方已经更新到5.2.6了。
经过一番询问,才知道原来CentOS系统的源里PHP仍旧是5.2.1,需要额外的源才能升级PHP。
根据外国网友的介绍,冰古添加了额外的源:
登录SSH后依次运行下列命令:

#rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
#vi /etc/yum.repos.d/utterramblings.repo #文中这里是使用nano,但VPS不能启动nano,用vi代替也是可以的
在打开的文档中加入下面内容:

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
保存。
再次运行下面的命令就可以完成php的升级了

#yum update php
同理,运行下面命令,升级mysql

#yum update mysql

摘自:http://bingu.net/508/upgrade-php-mysql-of-centos-system-use-yum-command/

[Debug]Cannot load libphp5.so No such file or directory

#locate libphp5.so
/usr/lib/httpd/modules/libphp5.so

#cp -a /usr/lib/httpd/modules/libphp5.so /opt/httpd/modules/

即可

2009年9月15日 星期二

重新開機後Apache未能自動啟動

預設並不啟動Apache,可執行「chkconfig httpd on」,則重開機時亦會自動啟動Apache。

2009年9月13日 星期日

自己寫了一個開心網安撫奴隸的小外掛

開心網(kaixin001的那個)我每天必上,9個奴隸從頭到尾安撫一次,感覺很費勁,早上上班來無聊就寫了一個安撫的小程式,放上來。
功能比較簡單,只完成了安撫操作,其他操作原理一樣,工作比較忙就沒時間弄了....
我用的是 curl_http_client.php (curl的包裝類)
下載地址:http://www.phpclasses.org/browse/file/15747.html
我的代碼是:

set_time_limit(0);
require("curl_http_client.php");
echo "start";
$curl = new Curl_HTTP_Client(0);
$curl->store_cookies("c:\\cookies.txt");
$post_data = array("url"=>"/home/",
"invisible_mode"=>"0",
"email"=>"luobo525@163.com",
"password"=>"********",
"remember"=>"1");
//登陸
$loginhtml=$curl->send_post_data("http://www.kaixin001.com/login/login.php", st_data);
if(preg_match("/登錄開心網/",$loginhtml))
{
echo "
登陸失敗!";
exit;
}

echo "
登陸成功...";
sleep(1);
//獲得買賣列表
echo "
獲得奴隸列表...";
$html=$curl->fetch_url("http://www.kaixin001.com/app/app.php?aid=1028");
$allNuLi=array();
preg_match_all("/comfortslave\((.*?)\)/",$html,$nuliArr);
preg_match_all('/class="sl2">(.*?)<\/a><\/strong> <\/div>/',$html,$nuliNameArr);
$nuliCnt=count($nuliArr[1]);
echo "
獲得奴隸數:{$nuliCnt}
";
if($nuliCnt==0)exit;

for($i=0;$i<$nuliCnt;$i++)
{
$allNuLi[$nuliArr[1][$i]]=$nuliNameArr[1][$i];
echo $nuliNameArr[1][$i]." ";
}
//獲取隨機碼
preg_match('/var g_verify = "(.*)";/',$html,$verCode);

foreach ($allNuLi as $nl=>$nlname)
{
if(emptyempty($nl))break;
echo "

奴隸:".$nlname;
sleep(1);
$url="http://www.kaixin001.com/slave/comfort_dialog.php?slaveuid=".$nl."&verify=".$verCode[1];
//echo $url;
$afhtml= $curl->fetch_url($url);
if(preg_match('/\$\("error141"\)\.style\.display/',$afhtml))
{
echo "
【{$nlname}】已經安撫過了...";
continue;
}

//獲得最高級安撫
preg_match('/name="comforttype" value="(\d*)"/',$afhtml,$afArr);
preg_match('/name="verify" value="(.*?)"/',$afhtml,$verify);

sleep(1);
//進行安撫
echo "
進行安撫...";
$url="http://www.kaixin001.com/slave/comfort1.php";
$post_data = array("verify"=>$verify[1],"slaveuid"=>$nl,"comforttype"=>$afArr[1]);
//print_r($post_data);
$curl->send_post_data($url, $post_data);

echo "
【".$nlname."】 安撫完成";

}
echo "
end";



摘自:http://blog.csdn.net/luobo525/archive/2009/02/04/3861436.aspx

2009年9月8日 星期二

RHEL Ramdisk安裝教學

Introduction

What is a RAM disk? A RAM disk is a portion of RAM which is being used as if it were a disk drive. RAM disks have fixed sizes, and act like regular disk partitions. Access time is much faster for a RAM disk than for a real, physical disk. However, any data stored on a RAM disk is lost when the system is shut down or powered off. RAM disks can be a great place to store temporary data.

The Linux kernel version 2.4 has built-in support for ramdisks. Ramdisks are useful for a number of things, including:

Working with the unencrypted data from encrypted documents
Serving certain types of web content
Mounting Loopback file systems (such as run-from-floppy/CD distributions)
Why did I write this document? Because I needed to setup a 16 MB ramdisk for viewing and creating encrypted documents. I did not want the unencrypted documents to be written to any physical media on my workstation. I also found it amazing that I could easily create a "virtual disk" in RAM that is larger than my first hard drive, a 20 MB Winchester disk. At the time, that disk was so large that I never even considered filling it up, and I never did!

This document should take you step-by-step through the process of creating and using RAM disks.

Assumptions/Setup

I was using Red Hat 9 for this test, but it should work with other GNU/Linux distributions running 2.4.x kernels. I am also assuming that the distribution you are using already has ramdisk support compiled into the kernel. My test machine was a Pentium 4 and had 256 MB of RAM. The exact version of the kernel that I used was: 2.4.20-20.9

Step 1: Take a look at what has already been created by your system

Red Hat creates 16 ramdisks by default, although they are not "active" or using any RAM. It lists devices ram0 - ram 19, but only ram0 - ram15 are usable by default. To check these block devices out, use the following command:

[root]# ls -l /dev/ram*
lrwxrwxrwx 1 root root 4 Jun 12 00:31 /dev/ram -> ram1
brw-rw---- 1 root disk 1, 0 Jan 30 2003 /dev/ram0
brw-rw---- 1 root disk 1, 1 Jan 30 2003 /dev/ram1
brw-rw---- 1 root disk 1, 10 Jan 30 2003 /dev/ram10
brw-rw---- 1 root disk 1, 11 Jan 30 2003 /dev/ram11
brw-rw---- 1 root disk 1, 12 Jan 30 2003 /dev/ram12
brw-rw---- 1 root disk 1, 13 Jan 30 2003 /dev/ram13
brw-rw---- 1 root disk 1, 14 Jan 30 2003 /dev/ram14
brw-rw---- 1 root disk 1, 15 Jan 30 2003 /dev/ram15
brw-rw---- 1 root disk 1, 16 Jan 30 2003 /dev/ram16
brw-rw---- 1 root disk 1, 17 Jan 30 2003 /dev/ram17
brw-rw---- 1 root disk 1, 18 Jan 30 2003 /dev/ram18
brw-rw---- 1 root disk 1, 19 Jan 30 2003 /dev/ram19
brw-rw---- 1 root disk 1, 2 Jan 30 2003 /dev/ram2
brw-rw---- 1 root disk 1, 3 Jan 30 2003 /dev/ram3
brw-rw---- 1 root disk 1, 4 Jan 30 2003 /dev/ram4
brw-rw---- 1 root disk 1, 5 Jan 30 2003 /dev/ram5
brw-rw---- 1 root disk 1, 6 Jan 30 2003 /dev/ram6
brw-rw---- 1 root disk 1, 7 Jan 30 2003 /dev/ram7
brw-rw---- 1 root disk 1, 8 Jan 30 2003 /dev/ram8
brw-rw---- 1 root disk 1, 9 Jan 30 2003 /dev/ram9
lrwxrwxrwx 1 root root 4 Jun 12 00:31 /dev/ramdisk -> ram0
Now, grep through dmesg output to find out what size the ramdisks are:

[root]# dmesg | grep RAMDISK
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
RAMDISK: Compressed image found at block 0
As you can see, the default ramdisk size is 4 MB. I want a 16 MB ramdisk, so the next step will be to configure Linux to use a larger ramdisk size during boot.

Step 2: Increase ramdisk size

Ramdisk size is controlled by a command-line option that is passed to the kernel during boot. Since GRUB is the default bootloader for Red Hat 9, I will modify /etc/grub.conf with the new kernel option. The kernel option for ramdisk size is: ramdisk_size=xxxxx, where xxxxx is the size expressed in 1024-byte blocks. Here is what I will add to /etc/grub.conf to configure 16 MB ramdisks:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda5
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.20-20.9)
root (hd0,0)
kernel /vmlinuz-2.4.20-20.9 ro root=LABEL=/ hdc=ide-scsi ramdisk_size=16000
initrd /initrd-2.4.20-20.9.img
Once you save the file, you will need to reboot your system. After the reboot, a look at the dmesg output should confirm the change has taken effect:

[root]# dmesg | grep RAMDISK
RAMDISK driver initialized: 16 RAM disks of 16000K size 1024 blocksize
RAMDISK: Compressed image found at block 0
Step 3: Format the ramdisk

There is no need to format the ramdisk as a journaling file system, so we will simply use the ubiquitous ext2 file system. I only want to use one ramdisk, so I will only format /dev/ram0:

[root]# mke2fs -m 0 /dev/ram0
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
4000 inodes, 16000 blocks
0 blocks (0.00%) reserved for the super user
First data block=1
2 block groups
8192 blocks per group, 8192 fragments per group
2000 inodes per group
Superblock backups stored on blocks:
8193

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
The -m 0 option keeps mke2fs from reserving any space on the file system for the root user, which is the default behavior. I want all of the ramdisk space available to a regular user for working with encrypted files.

Step 4: Create a mount point and mount the ramdisk

Now that you have formatted the ramdisk, you must create a mount point for it. Then you can mount your ramdisk and use it. We will use the directory /mnt/rd for this operation.

[root]# mkdir /mnt/rd
[root]# mount /dev/ram0 /mnt/rd
Now verify the new ramdisk mount:

[root]# mount | grep ram0
/dev/ram0 on /mnt/rd type ext2 (rw)
[root]# df -h | grep ram0
/dev/ram0 16M 13K 16M 1% /mnt/rd
You can even take a detailed look at the new ramdisk with the tune2fs command:

[root]# tune2fs -l /dev/ram0
tune2fs 1.32 (09-Nov-2002)
Filesystem volume name: none
Last mounted on: not available
Filesystem UUID: fbb80e9a-8e7c-4bd4-b3d9-37c29813a5f5
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: filetype sparse_super
Default mount options: (none)
Filesystem state: not clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 4000
Block count: 16000
Reserved block count: 0
Free blocks: 15478
Free inodes: 3989
First block: 1
Block size: 1024
Fragment size: 1024
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 2000
Inode blocks per group: 250
Filesystem created: Mon Dec 8 14:33:57 2003
Last mount time: Mon Dec 8 14:35:39 2003
Last write time: Mon Dec 8 14:35:39 2003
Mount count: 1
Maximum mount count: 22
Last checked: Mon Dec 8 14:33:57 2003
Check interval: 15552000 (6 months)
Next check after: Sat Jun 5 14:33:57 2004
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
In my case, I need the user "van" to be able to read and write to the ramdisk, so I must change the ownership and permissions of the /mnt/rd directory:

[root]# chown van:root /mnt/rd
[root]# chmod 0770 /mnt/rd
[root]# ls -ald /mnt/rd
drwxrwx--- 2 van root 4096 Dec 8 11:09 /mnt/rd
The ownership and permissions on the ramdisk filesystem/directory should be tailored to your particular needs.

Step 5: Use the ramdisk

Now that it has been created, you can copy, move, delete, edit, and list files on the ramdisk exactly as if they were on a physical disk partiton. This is a great place to view decrypted GPG or OpenSSL files, as well as a good place to create files that will be encrypted. After your host is powered down, all traces of files created on the ramdisk are gone.

To unmount the ramdisk, simply enter the following:

[root]# umount -v /mnt/rd
/dev/ram0 umounted
Note: If you remount the ramdisk, your data will still be there. Once memory has been allocated to the ramdisk, it is flagged so that the kernel will not try to reuse the memory later. Therefore, you cannot "reclaim" the RAM after you are done with using the ramdisk. For this reason, you will want to be careful not to allocate more memory to the ramdisk than is absolutely necessary. In my case, I am allocating < 10% of the physical RAM. You will have to tailor the ramdisk size to your needs. Of course, you can always free up the space with a reboot!

Automating Ramdisk Creation

If you need to create and mount a ramdisk every time your system boots, you can automate the process by adding some commands to your /etc/rc.local init script. Here are the lines that I added:

# Formats, mounts, and sets permissions on my 16MB ramdisk
/sbin/mke2fs -q -m 0 /dev/ram0
/bin/mount /dev/ram0 /mnt/rd
/bin/chown van:root /mnt/rd
/bin/chmod 0750 /mnt/rd


Conclusion

You have now seen how to setup and use a ramdisk on your GNU/Linux system. Hopefully, you will find this information to be interesting and useful!




摘自:http://www.vanemery.com/Linux/Ramdisk/ramdisk.html
參考:http://www.linuxfocus.org/English/November1999/article124.html

2009年9月7日 星期一

Update PHP to 5.2.9

#vi /etc/yum.repos.d/centos.repo

append below to file :
[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/5/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing

save file
#yum clean all
#yum info php
#yum update php*

Installing PHP 5.2.x or 5.3.x on RedHat ES5, CentOS 5, etc

I’ve had to follow this tutorial a few times myself now so decided I should share it with the world.

A few of our applications which make use of SOAP get a Segmentation Fault if run with PHP 5.1.x or lower. We believe this is due to a bug in PHP but can’t be sure, regardless it works fine in PHP 5.2.4 and above.

Problem is, RedHat ES5 does not have support at this time for anything higher than 5.1.6, and we didn’t want to break RPM dependancys etc by installing from source.

To install PHP 5.2.5 (Highest in repository at this time) you can make use of a RPM repository maintained by Remi. He has a repository for each distro, but to save you translating for the ES5 one I’ll give you the commands here. Run the following to get up and running:


wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm


You now have the Remi repository on your system, however it is disabled by default. Obviously you don’t want all of your packages been effected by this repository, however to enable it for a specific package, run the following:


yum --enablerepo=remi update php


摘自:http://bluhaloit.wordpress.com/2008/03/13/installing-php-52x-on-redhat-es5-centos-5-etc/

2009年9月5日 星期六

Uninstall mysql on Red Hat Enterprise Linux

List currently installed packages..
#rpm -qa | grep -i '^mysql-'

Then remove one-by-one

rpm --nodeps -ev MySQL-first-package
rpm --nodeps -ev MySQL-second-package

rpm --nodeps -ev MySQL-last-package

Once you remove all packages you download all MySQL 5.4.* packages into a dir and run below command

rpm -ivh MySQL-*.rpm

2009年9月1日 星期二

系統監控Shell Script


#!/bin/sh
status_squid_connection="$(ssh root@192.168.0.2 netstat -tun | grep '80' | wc -l)"
#echo $status_squid_connection

status_apache_connection="$(netstat -tun | grep '80' | wc -l)"
#echo $status_apache_connection

status_mysql_connection="$(netstat -tun | grep '3306' | wc -l)"
#echo $status_mysql_connection

LANG=C
for (( i=0;i<15;i=i+1 ))
do
date_regular_exp=`date --date="$i minutes ago" +\%a\ %b\ %d\ %H:%M`
if [ $i -gt 0 ]; then
str_pipe="|"
fi
str="${str}${str_pipe}${date_regular_exp}"
done
status_httpd_error_num="$(cat /var/log/httpd/httpd_urcosme/httpd-error.log | egrep "(${str})" | wc -l)"


/usr/bin/lynx --dump "http://DomainName/updateURL?status_squid_connection=$status_squid_connection&status_apache_connection=$status_apache_connection&status_mysql_connection=$status_mysql_connection&status_httpd_error_num=$status_httpd_error_num"

wibiya widget