使用ESX修复Linux虚拟机重启只读模式
来源:优易学  2011-4-1 14:27:22   【优易学:中国教育考试门户网】   资料下载   IT书店

 

  选项3:Email通知
  如果Linux虚拟机不受VMware补丁的支持,你也不太愿意修改内核源的话,你至少应该配置虚拟机,以便发生问题时你能知道。一种方法是创建一个脚本,每10分钟运行一次或随你所选。下面是一个脚本例子:
  #!/bin/bash
  #
  # use the first argument to this script as the
  # email address to send notifications to
  TO="$1"
  #
  # get the output from the mount command
  #
  MOUNT_OUT=`mount`
  #
  # see if the string 'ro' exists in the
  # output of the mount command. be careful,
  # if there is a CD-ROM inserted into the
  # server this will always be true and you
  # will get a lot of false positives
  echo $MOUNT_OUT | grep \(ro\)
  #
  # get the return code for the grep
  # operation.
  #
  RO=$?
  #
  # grep returns an exit code
  # of 0 if there is a match
  #
  if [ "$RO" = "0" ]
  then
  #
  # send an e-mail notification saying
  # that there is a file-system that
  # has been mounted as read-only
  #
  BODY=$MOUNT_OUT
  echo read-only file systems found
  echo $BODY
  `which sendmail` -f root@`hostname --fqdn` -t << FooBar
  From: root@`hostname --fqdn`
  To: $TO
  Subject: `hostname` has read-only file systems $BODY
  FooBar
  #
  # exit with a status code of 1 if
  # read-only file systems were found
  #
  exit 1
  fi
  #
  # exit with a status code of 0 if no
  # read-only file systems were found
  #
  exit 0
  安装这个脚本,不要忘记给它一个邮箱地址。如果虚拟机的一个文件系统重启为只读时,它会提醒你,给你忽略这个问题的机会。记住,这个脚本假定你运行的是本地邮件服务器,不过也可以修改成通过中继主机发送邮件。

上一页  [1] [2] 

责任编辑:小草

文章搜索:
 相关文章
热点资讯
热门课程培训