灌溉梦想,记录脚步

How To Create A Cluster Testbed Using CentOS 5 Vir

  A. Overview
  This guide attempts to provide a Xen based test environment where you can practice setting up a two node cluster (cluster setup itself is not discussed here – I'm merely giving you what you need to set it up).
  XEN can host two type of guest systems para-virtualized and fully-virtualized:
  for para-virtualized guests you require the Red Hat Enterprise Linux 5 installation tree available over NFS, FTP or HTTP.
  for fully-virtualized guest installations you will require DVD or CD-ROM distribution media or a bootable .iso file and a network accessible installation tree
  For details, please refer to the RHEL5 Virtualization Manual.
  I'll be using para-virtualized guests here in my setup. There will be three systems involved here:
  node00 – physical system
  virtual IPs: 192.168.222.1 (public1 vlan)
  192.168.100.1 (private1 vlan)
  node01 – para-virtualized guest 1
  virtual IPs: 192.168.222.10 (public1 vlan)
  192.168.100.10 (private1 vlan)
  node02 – para-virtualized guest 1
  virtual IPs: 192.168.222.20 (public1 vlan)
  192.168.100.20 (private1 vlan)
  B. What I used
  an HP Blade bl25p machine with 4G of RAM (this is actually an AMD64 blade machine). A machine with decent amount of RAM and processing speed should do.
  Centos i386 5 update 1 www.centos.org DVD ISO downloaded HTTP, NFS and FTP installation sources were created from this iso. Also, the yum repository that can be used by host and guest systems will be generated from the centos iso image.
  logical volumes hosting the guests and the "virtual luns" via iscsi (you can also use disk partitions – please refer to the virtualization guide for details).
  1. My LVM setup
  The following is my LVM configuration. The lvLUN0* entries are the ones I used for iSCSI setup and will be shared by the two virtual guest systems.
  lvs
  LV VG Attr LSize origin Snap% Move Log Copy%
  lvLUN01 Virtual00VG -wi-ao 50.00G
  lvLUN02 Virtual00VG -wi-ao 50.00G
  lvNODE01 Virtual00VG -wi-ao 30.00G
  lvNODE02 Virtual00VG -wi-ao 30.00G
  lvNODE03 Virtual00VG -wi-ao 15.00G
  lvsys00 vg00 -wi-ao 512.00M
  lvsys01 vg00 -wi-ao 8.00G
  lvsys02 vg00 -wi-ao 8.00G
  lvsys03 vg00 -wi-ao 512.00M
  lvsys04 vg00 -wi-ao 128.00M
  lvsys05 vg00 -wi-ao 1.00G
  lvsys06 vg00 -wi-ao 256.00M
  C. Host Preparation
  I'm assuming that you know how to install CentOS or other RHEL based distributions and that you are familiar with rpm installation. Since I do a lot of setup for test/dev environments at work, I already have an installation server making it easy to do a network based install via PXE. The kickstart file for node00 is provided below. You can do a local media install (you have the ISO so you can burn it to a DVD) and just refer to the kickstart file for some of the configuration. The list of packages I used is in the %packages section of node00's kickstart file. You can install them manually using yum, like:
  # will list centos installation groups
  yum grouplist
  # will install Virtualization group
  yum groupinstall Virtualization
  1. ks file and installation
  1.a kickstart file I use for the host (node00)
  You'll have to modify the following to suit your setup.
  ## START node00_ks.cfg
  #modify for your own settings
  install
  nfs –server=remote_server –dir=/path/to/CENTOS5U1/i386
  lang en_US.UTF-8
  keyboard us
  skipx
  reboot
  network –device eth2 –bootproto static –ip a.b.c.1 –netmask 255.255.255.0 –gateway a.b.c.2 –nameserver x.y.z.n –hostname node00.example.com
  # grub and root password is a1s2d3f4g5
  rootpw –iscrypted $1$3CXK2$CG9WlX2PuPpp7nxYMQGwP0
  firewall –disabled
  authconfig –enableshadow
  selinux –disabled
  timezone Asia/Singapore
  bootloader –location=mbr –driveorder=cciss/c0d0 –append="rhgb quiet" –md5pass=$1$3CXK2$CG9WlX2PuPpp7nxYMQGwP0
  clearpart –all –initlabel –drives=cciss/c0d0
  part /boot –fstype ext3 –size=100 –ondisk=cciss/c0d0
  part pv.100000 –size=100 –grow –ondisk=cciss/c0d0 –asprimary
  volgroup vg00 –pesize=32768 pv.100000
  logvol /tmp –fstype ext3 –name=lvsys05 –vgname=vg00 –size=1024
  logvol /opt –fstype ext3 –name=lvsys04 –vgname=vg00 –size=128
  logvol /var –fstype ext3 –name=lvsys03 –vgname=vg00 –size=512
  logvol /usr –fstype ext3 –name=lvsys02 –vgname=vg00 –size=8192
  logvol swap –fstype swap –name=lvsys01 –vgname=vg00 –size=8192
  logvol /home –fstype ext3 –name=lvsys06 –vgname=vg00 –size=256
  logvol / –fstype ext3 –name=lvsys00 –vgname=vg00 –size=512
  %packages
  @development-libs
  @editors
  @system-tools
  @text-internet
  @x-software-development
  @virtualization
  @dns-server
  @core
  @base
  @ftp-server
  @network-server
  @legacy-software-development
  @base-x
  @web-server
  @printing
  @server-cfg
  @sql-server
  @admin-tools
  @development-tools
  lsscsi
  createrepo
  audit
  net-snmp-utils
  iptraf
  tftp
  lynx
  mesa-libGLU-devel
  kexec-tools
  bridge-utils
  device-mapper-multipath
  vnc-server
  xorg-x11-server-Xnest
  xorg-x11-server-Xvfb
  imake
  openmotif
  -vim-enhanced
  -zisofs-tools
  -zsh
  -bluez-hcidump
  -sysreport
  ## END of node00_ks.cfg
  2. Host configuration
  Setting up an HTTP, NFS and FTP installation server:
  2.a web server
  #/etc/httpd/conf.d/centos5u1.conf
  Alias /centos5u1 /var/ftp/pub/centos5u1
  
  Options Indexes FollowSymLinks MultiViews
  IndexOptions FancyIndexing
  Order deny,allow
  Deny from all
  Allow from 127.0.0.1 ::1 all
  
  Then start the httpd service and make sure it does during startup:
  service httpd start
  chkconfig httpd on
  2.b NFS server
  Edit /etc/exports and put the following into it:
  # /etc/exports
  /var/ftp/pub/centos5u1 192.168*(ro)
  service nfs start
  chkconfig nfs on
  2.c FTP server
  Since we already have the source in /var/ftp/pub/centos5u1, all that is needed is to start vsftpd:
  service vsftpd start
  chkconfig vsftpd on
  2.d YUM repository
  For this setup, I only use a local yum repository from the Centos DVD ISO I downloaded. First, I loopback mount it in /var/ftp/pub/centos5u1/i386/:
  cd /var/ftp/pub/centos5u1/
  mkdir temp
  mount -o loop CentOS-5.1-i386-bin-DVD.iso temp
  cp -pr temp i386
  umount temp
  createrepo -g i386
  (i386/repodata/ will then be updated.)
  For RHEL5, it's different:
  createrepo -g repodata/comps-rhel5-server-core.xml Server
  You need to do this inside the i386 directory (after loopback mounting and copying the whole directory structure).
  2.d.1 the yum repo configuration:
  I renamed the default repo files in /etc/yum.repos.d/ to *-repo (instead of *.repo) to disable them. I then created this file:
  #/etc/yum.repos.d/CentOS5.repo
  [centos5-Server]
  name=CentOS5 Server
  baseurl=http://node00/centos5u1/i386
  enabled=1
  gpgcheck=1
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  node00 needs to be defined in /etc/hosts for the above file to work. or just replace node00 with its IP address.
  2.e VNC server
  You won't be needing a vnc connection if you have local console access to the physical machine. All you need to do is switch into gui mode:
  telinit 5
  and open a gui terminal (like gnome-terminal or kde konsole). But since I do everything remotely, I use vncserver and vncviewer to do gui based stuff.
  2.e.1 run vncserver:
  This will bringvup a vncserver in node00 that is accessible via "vncviewer" at node00:1 (assuming node00 is resolveable from your vncviewer host).
  vncserver
  You will require a password to access your desktops.
  Password:
  Verify:
  xauth: creating new authority file /root/.Xauthority
  New 'node00.example.com:1 (root)' desktop is node00.example.com:1
  Creating default startup script /root/.vnc/xstartup
  Starting applications specified in /root/.vnc/xstartup
  Log file is /root/.vnc/node00.example.com:1.log
  How To Create A Cluster Testbed Using CentOS 5 Virtualization And iSCSI – Page 2
  How To Create A Cluster Testbed Using CentOS 5 Virtualization And iSCSI – Page 3
  next
  How To Create A Cluster Testbed Using CentOS 5 Virtualization And iSCSI – Page 2
  Copyright ? 2008 roderick tapang

Memcached的管理

  在以前写过了"搭建nginx + python + django +memcached+ mysql +fastcgi 环境"一文,有不少朋友问我关于memcached的管理的问题,比如查看memcached的运行情况等等,我们知道目前memcached没有直观的工具来查看整个运行情况,不过我们可以通过系统级--shell命令。
  1、数据存储(假设key为dbasky.net,value为88888)
  printf "set dbasky.net 0 0 5\r\n88888\r\n" | nc 127.0.0.1 11211
  STORED
  2、数据取回(假设key为dbasky.net)
  printf "get dbasky.net\r\n" | nc 127.0.0.1 11211
  VALUE dbasky.net 0 5
  88888
  END
  3、数值增加1(假设key为dbasky.net,并且value为正整数)
  printf "incr dbasky.net 1\r\n" | nc 127.0.0.1 11211
  88889
  4、数值减少3(假设key为dbasky.net,并且value为正整数)
  printf "decr dbasky.net 3\r\n" | nc 127.0.0.1 11211
  88886
  5、数据删除(假设key为dbasky.net)
  printf "delete dbasky.net\r\n" | nc 127.0.0.1 11211
  DeleteD
  6、查看Memcached状态
  [root@app3 ~]# printf "stats\r\n" | nc 127.0.0.1 11211
  STAT pid 20272
  STAT uptime 927901
  STAT time 1256541017
  STAT version 1.2.8
  STAT pointer_size 64
  STAT rusage_user 72323.142211
  STAT rusage_system 270758.303481
  STAT curr_items 2255461
  STAT total_items 2237096141
  STAT bytes 3865876133
  STAT curr_connections 156
  STAT total_connections 2662892830
  STAT connection_structures 2975
  STAT cmd_flush 0
  STAT cmd_get 7155551459
  STAT cmd_set 2237096141
  STAT get_hits 6275571127
  STAT get_misses 879980332
  STAT evictions 21174550
  STAT bytes_read 5936788593022
  STAT bytes_written 12278494693042
  STAT limit_maxbytes 4294967296
  STAT threads 9
  STAT accepting_conns 1
  STAT listen_disabled_num 0
  END
  7、模拟top命令,查看Memcached状态:
  watch "printf 'stats\r\n' | nc 127.0.0.1 11211"
  或者
  watch "echo stats | nc 127.0.0.1 11211"
  [root@app3 ~]# watch "printf 'stats\r\n' | nc 127.0.0.1 11211"
  Every 2.0s: printf 'stats\r\n' | nc 127.0.0.1 11211 Mon Oct 26 16:11:26 2009
  STAT pid 20272
  STAT uptime 927970
  STAT time 1256541086
  STAT version 1.2.8
  STAT pointer_size 64
  STAT rusage_user 72327.750510
  STAT rusage_system 270774.932953
  STAT curr_items 2255435
  STAT total_items 2237240981
  STAT bytes 3865771193
  STAT curr_connections 269
  STAT total_connections 2663066932
  STAT connection_structures 2975
  STAT cmd_flush 0
  STAT cmd_get 7156031867
  STAT cmd_set 2237240981
  STAT get_hits 6275980308
  STAT get_misses 880051559
  STAT evictions 21177694
  STAT bytes_read 5937174840056
  STAT bytes_written 12279303680177
  STAT limit_maxbytes 4294967296
  STAT threads 9
  STAT accepting_conns 1
  STAT listen_disabled_num 0
  END
  下面解释下各项的含意:
  uptime 是memcached运行的秒数,cmd_get是查询缓存的次数。这两个数据相除一下就能得到平均每秒请求缓存的次数,cmd_set 就是设置key=>value的次数。整个memcached是个大hash,用cmd_get没有找到的内容,就会调用一下cmd_set写进缓存里。紧跟着是get_hits,就是缓存命中的次数。缓存命中率 = get_hits/cmd_get *100%。get_misses的数字加上get_hits应该等于cmd_get。而total_itemscurr_items表示现在在缓存中的键值对个数,在图上total_items == cmd_set == get_misses,不过当可用最大内存用光时,memcached就会删掉一些内容,上面的等式就不成立了。

硬盘安装Ubuntu 9.10

  Ubuntu 9.10已正式发布,在Windows环境下通过硬盘安装Ubuntu 9.10。
  1.下载Grub4Dos(注意:如果你想尝试Ext4文件系统,一定要下载最新的支持Ext4文件系统Grub4Dos 0.4.4版本),解压至XP的C盘根下,修改menu.lst文件,在末尾添加如下内容:
  (注意:Ubuntu 9.10默认的文件系统格式是ext4,而不是ext3,格式分区的时候应注意选择。)
  title Install Ubuntu
  root (hd0,0)
  kernel (hd0,0)/vmlinuz boot=casper iso-scan/filename=/Ubuntu-9.10-desktop-i386.iso ro quiet
  splash locale=zh_CN.UTF-8
  initrd (hd0,0)/initrd.gz
  2.修改XP的boot.ini文件(该文件为系统文件,具有只读隐藏属性),在boot.ini末尾添加:
  C:\grldr=”GRUB”
  3.下载Ubuntu 9.10的desktopCD的镜像文件,下载地址参考Ubuntu 9.10官方衍生版本全集,然后将下载好的镜像文件直接放在C: ,将其中的.disk文件夹加压至C: , 将casper目录下的initrd.gz和vmlinuz这两个文件也解压至C:
  4.重启计算机,选择Grub,进入Grub引导程序,选择最后一项(Install Ubuntu),稍等即可进入ubuntu的liveCD模式,此时打开一个终端,在里面输入:
  sudo umount -l /iosdevice
  回车,然后点击桌面上的安装图标即可完成安装过程。

Ubuntu 官方正式发布 Ubuntu 9.10 ( Karmic Koala )

ubuntu 经过了漫长的等待,Ubuntu 官方在刚刚已经正式发布了被受期待的 Ubuntu 9.10 ( Karmic Koala ) !其实在这之前就可以在镜像服务器下载 Ubuntu 9.10 ( Karmic Koala ) 正式版的ISO镜像文件了,为了不影响 Ubuntu 9.10 正式版的ISO文件向各地镜像服务器分发的进度,OwnLinux 并没有公布下载链接。目前官方已经正式开放了 Ubuntu 9.10 正式版的ISO文件下载服务。 今天从世界各地涌入的巨大下载量也是对各个官方服务器一次严峻的考验。

  Ubuntu 首页宣布 Ubuntu 9.10 正式版发布:
  官方的下载界面已经从 Ubuntu 9.10 RC 更改为 Ubuntu 9.10 ( Karmic Koala ) 正式版了:
  Ubuntu 9.10 ( Karmic Koala ) 正式版的下载地址:
  http://cn.releases.ubuntu.com/9.10/
  http://tw.releases.ubuntu.com/9.10/
  http://releases.ubuntu.com/releases/9.10/
  Ubuntu 9.10 ( Karmic Koala ) 正式版ISO镜像文件MD5码列表
  836440698456aa2936a4347b5485fdd6 *ubuntu-9.10-alternate-amd64.iso
  3faa345d298deec3854e0e02410973dc *ubuntu-9.10-alternate-i386.iso
  dc51c1d7e3e173dcab4e0b9ad2be2bbf *ubuntu-9.10-desktop-amd64.iso
  d91659de6e945dbb96eb8970b2b4590a *ubuntu-9.10-desktop-armel+dove.img
  297875d2a7531824a0fb08f241d33e85 *ubuntu-9.10-desktop-armel+imx51.img
  8790491bfa9d00f283ed9dd2d77b3906 *ubuntu-9.10-desktop-i386.iso
  ed6e77587b87fe0d92a2f21855869f00 *ubuntu-9.10-netbook-remix-i386.iso
  14707e8847b9c9ba2dd1869fb5086e4f *ubuntu-9.10-server-amd64.iso
  55618ad5f180692f9dac20cbff352634 *ubuntu-9.10-server-i386.iso
  37a04db193b1a342f961f59aea2fada8 *wubi.exe
  友情提示: alternate 为文字界面的安装版本, desktop 为包含 Live CD 的图形界面安装版本, server为服务器版本, i386 为32位的系统版本, amd64 为64位的系统系统版本,请根据你自己的需要下载相应的版本。由于版本比较多,下载的时候不要下错版本了哟,做了又费带宽又费电又费精力的事就不好了:) 最后建议大家:使用P2P下载以减轻官方服务器的负担。

cPanel破解版下载与简介

市场价:每台服务器每月55美元
对国际主机市场了解的朋友一定听说过cPanel,它是世界上功能最强大,最容易使用,因而最受用户欢迎的虚拟主机控制系统。不过国内真正领略过cPanel非凡功能的站长很少,大部分人从不同渠道听说过cPanel却无缘享用。
相信做过网站的都能体会,想使用某个功能时却发现还要联系服务商开通功能是件最烦恼的事。想要调整功能,又不得不与主机商来来往往联系半天,实在浪费时间精力。更不要提一些重要功能在不少主机系统上根本不能提供。
在cPanel主机上,您可以自如控制一切,无需联系服务商开通或调整任何功能,所有你想得到的功能都可以在控制界面自助完成。在cPanel做不到的功能,99%的可能性是根本不适合在虚拟主机环境。
一个简单的道理,cPanel之所以成为世界上最受欢迎的控制面板一定有它的原因,是用户的喜爱造就了cPanel的地位。
cPanel功能
用户可以通过cPanel轻松完成所有虚拟主机功能操作,包括:
* 电子邮件管理 – – 新建,删除邮件账户,修改密码,自动回复,邮件转发,垃圾邮件过滤等
* Webmail – – Web邮箱,通过浏览器Web界面收发Email
* 域名管理 – – 多域名绑定,二级域名设置
* FTP管理 – – 新建,删除FTP账户,权限设置,FTP进程管理
* 文件管理器 – – 通过浏览器Web界面文件管理器新建,删除,编辑,管理文件夹(目录)和文件
* 空间使用统计 – – 显示账户空间使用情况
* 备份管理 – – 生成,下载和管理账户备份,数据库备份
* 数据库管理 – – 建立,删除,管理数据库及数据库用户,phpMyAdmin数据库管理工具
* 流量统计工具 – – 图形显示网站流量统计,原始日志文件管理,错误日志
* 预装程序 – – 预装常用博客,论坛,购物车等程序
* 其他功能 – – 如密码保护目录,URL转向,自定义错误页面,Cron Jobs,防盗链等。
cPanel和WHM(WebHost Manager)是一整套软件包,安装它必须在一个干净的Linux环境下,也就是说cPanel将会负责整个网络服务环境的构建,甚至需要删除机器上可能安装过的apache、MySQL、PHP、exim等组件。
控制面板架构:
WebHost Manager (WHM) [服务器管理员控制面板]:
利用WHM,系统管理员可以定义用户权限、修改服务器安全设置、安装插件等等。
WebHost Manager(WHM) [分销商控制面板]:
分销商也可以进入WHM进行创建用户、备份用户等操作,不过他的权限是由服务器管理员决定的。
cPanel [域名拥有者的控制面板]:
在cPanel里,用户可以找到建立一个优秀网站所必备的所有工具。你能够创建电子邮件账户、进行文件管理、添加子域名、查看访问日志统计、管理数据库、设置文件夹保护密码、防盗链管理等等。
Mail [电子邮件用户登陆接口]:
只要拥有cPanel的邮件账户,每个人都可以随时随地登陆自己的网络邮箱、设置自己的垃圾邮件过滤器、管理信息过滤等等。
cPanel 安装先前准备:
1. 要先安装好一台机器。
2. 你的机器必须高于以下的最低需求
CPU:Pentium 3 500 MHz以上
HDD:10 GB以上
Ram:256 MB以上
4. 安装cPanel的HDD建议分割方式:
001 GB /
050 MB /boot
001 GB /tmp
010 GB /usr
007 GB /var
001 GB swap
剩余的空间划分给 /home
注意:上面的分割建议是以40GBHDD来范例,如果你有更大的HDD,建议你应该相对增加 /usr & /var 的空间。假使你没依照上述的建议来分割,建议重新分割并且格式化,避免未来使用上会有操作上的问题。
cPanel 安装指引:
安装cPanel必须要为你的机器选择正确的档案,你应该到这里,用右键来复制适合你的作业系统的捷径(例如:cpanel-install.sea 适合 Red Hat 9)。
当你完成上述手续后,用root帐号登入你的机器,并且执行下面的指令:
cd /home
wget (paste shortcut here)
nohup sh cpanel-* &
tail -f nohup.out
此时安装程序会开始执行,整个安装过程需要花费30~60分钟时间,安装期间不需要输入任何东西。安装完成以后荧幕会停止并且显示一个”Done”的字样,此时你应该输入”Ctrl+c”来继续。
注意:如果cPanel安装失败。 你可以用指令”sh cpanel-*”重新安装一次,但我们建议你重新格式化HDD,然后 安装一次,以确保机器可以正确无误的安装。
cPanel组态设定:
当安装成功以后,你应该要尽快地的重新设定cPanel。为了要完成整个安装程序,你应该要登入主IP位置(eth0/fxp0)。在浏览器中输入的格式如下:
https://xxx.xxx.xxx.xxx:2087
注意:你应该把上面的xxx.xxx.xxx.xxx取代为你实际的IP位置。
安装后默认管理员帐号:root 密码:password
下载地址:http://cn.ziddu.com/download/414700/WHM_Nulled.rar.html

serv-u最新注册码

  serv-u最新注册码
  注册码:s0etK1+tklL+1jT+Lx4FIhL3eVHAOB+vbeBoEROE20epLX/fYhT81ie9TmxqTmuZWQK0XXbBB
  YEdYnb2pCTMWCvI+zyWt0GNSmxFWn+WED3uVnrb
  注册码:9dK4g4iPhvOsoEY9nprEiSsmW7OUqFaGuwHT1CtBn9K6hQVg0bd2
  okQ9ldel+1IGE9b4xDP0q2W+vE4vgZLA7unm6t3CxTI
  注册码: (7.0.02)s0etK1+tklL+1jT+Lx4………

linux主机常用监控脚本

  1、查看主机网卡流量
  #!/bin/bash
  #network
  #Mike.Xu
  while : ; do
  time='date +%m"-"%d" "%k":"%M'
  day='date +%m"-"%d'
  rx_before='ifconfig eth0|sed -n "8"p|awk '{print $2}'|cut -c7-'
  tx_before='ifconfig eth0|sed -n "8"p|awk '{print $6}'|cut -c7-'
  sleep 2
  rx_after='ifconfig eth0|sed -n "8"p|awk '{print $2}'|cut -c7-'
  tx_after='ifconfig eth0|sed -n "8"p|awk '{print $6}'|cut -c7-'
  rx_result=$[(rx_after-rx_before)/256]
  tx_result=$[(tx_after-tx_before)/256]
  echo "$time Now_In_Speed: "$rx_result"kbps Now_OUt_Speed: "$tx_result"kbps"
  sleep 2
  done
  2、系统状况监控
  #!/bin/sh
  #systemstat.sh
  #Mike.Xu
  IP=192.168.1.227
  top -n 2| grep "Cpu" >>./temp/cpu.txt
  free -m | grep "Mem" >> ./temp/mem.txt
  df -k | grep "sda1" >> ./temp/drive_sda1.txt
  #df -k | grep sda2 >> ./temp/drive_sda2.txt
  df -k | grep "/mnt/storage_0" >> ./temp/mnt_storage_0.txt
  df -k | grep "/mnt/storage_pic" >> ./temp/mnt_storage_pic.txt
  time=`date +%m"."%d" "%k":"%M`
  connect=`netstat -na | grep "219.238.148.30:80" | wc -l`
  echo "$time $connect" >> ./temp/connect_count.txt
  3、监控主机的磁盘空间,当使用空间超过90%就通过发mail来发警告
  #!/bin/bash
  #monitor available disk space
  SPACE='df | sed -n '/ \ / $ / p' | gawk '{print $5}' | sed 's/%//'
  if [ $SPACE -ge 90 ]
  then
  fty89@163.com
  fi
  4、 监控CPU和内存的使用情况
  #!/bin/bash
  #script to capture system statistics
  OUTFILE=/home/xu/capstats.csv
  DATE='date +%m/%d/%Y'
  TIME='date +%k:%m:%s'
  TIMEOUT='uptime'
  VMOUT='vmstat 1 2'
  USERS='echo $TIMEOUT | gawk '{print $4}' '
  LOAD='echo $TIMEOUT | gawk '{print $9}' | sed "s/,//' '
  FREE='echo $VMOUT | sed -n '/[0-9]/p' | sed -n '2p' | gawk '{print $4} ' '
  IDLE='echo $VMOUT | sed -n '/[0-9]/p' | sed -n '2p' |gawk '{print $15}' '
  echo "$DATE,$TIME,$USERS,$LOAD,$FREE,$IDLE" >> $OUTFILE
  5、全方位监控主机
  #!/bin/bash
  # check_xu.sh
  # 0 * * * * /home/check_xu.sh
  DAT="`date +%Y%m%d`"
  HOUR="`date +%H`"
  DIR="/home/oslog/host_${DAT}/${HOUR}"
  DELAY=60
  COUNT=60
  # whether the responsible directory exist
  if ! test -d ${DIR}
  then
  /bin/mkdir -p ${DIR}
  fi
  # general check
  export TERM=linux
  /usr/bin/top -b -d ${DELAY} -n ${COUNT} > ${DIR}/top_${DAT}.log 2>&1 &
  # cpu check
  /usr/bin/sar -u ${DELAY} ${COUNT} > ${DIR}/cpu_${DAT}.log 2>&1 &
  #/usr/bin/mpstat -P 0 ${DELAY} ${COUNT} > ${DIR}/cpu_0_${DAT}.log 2>&1 &
  #/usr/bin/mpstat -P 1 ${DELAY} ${COUNT} > ${DIR}/cpu_1_${DAT}.log 2>&1 &
  # memory check
  /usr/bin/vmstat ${DELAY} ${COUNT} > ${DIR}/vmstat_${DAT}.log 2>&1 &
  # I/O check
  /usr/bin/iostat ${DELAY} ${COUNT} > ${DIR}/iostat_${DAT}.log 2>&1 &
  # network check
  /usr/bin/sar -n DEV ${DELAY} ${COUNT} > ${DIR}/net_${DAT}.log 2>&1 &
  #/usr/bin/sar -n EDEV ${DELAY} ${COUNT} > ${DIR}/net_edev_${DAT}.log 2>&1 &
  放在crontab里每小时自动执行:
  0 * * * * /home/check_xu.sh
  这样会在/home/oslog/host_yyyymmdd/hh目录下生成各小时cpu、内存、网络,IO的统计数据。
  如果某个时间段产生问题了,就可以去看对应的日志信息,看看当时的主机性能如何。