Linux/hp unix/AIX日常巡检脚本(转)
以下为Linux/hp unix/AIX日常巡检脚本,大家可以参考着进行改写,用于自己的服务器。
#!/usr/bin/ksh
syserrdate=`date +"%m/%d"`
errcount=0
STATUS=
HOSTS=`hostname`
SCRIPT=`basename $0`
REPORT="/tmp/report.txt"
#FS percent
FILESYSTEM_CHECK() {
FS=`df -k|sed '1d'|awk 'sub("%","",$4) {if ($4 > 80) print $7}'|xargs`
for i in $FS
do
echo "The $i filesystem percent more than %80 n"
done
}
#Active VG
VG_CHECK() {
echo "****************************ACTIVE VG****************************n"
ACVG=`lsvg -o|xargs`
echo "Active VG is: $ACVGn"
#LV_CHECK
echo "***************************PROBLEM LV****************************n"
BLV=`lsvg -l rootvg|grep -E "jfs|jfs2|raw"|grep -v 'N/A'|awk '{if ($6~/closed/ || $6~/stale/) print $1}'|xargs`
for i in $BLV
do
echo "The $i filesystem has a problem!!!n"
done
}
#Problem disk
DISK_CHECK() {
echo "***************************Problem disk***************************n"
disk=`lsvg -o|lsvg -ip|awk '$1~/hdisk/ && $2!~/active/ {print $1}'|xargs`
if [ "$disk" != "" ]
then
for i in $disk
do
echo "The $disk in $i has a problem!!!n"
done
fi
}
#error report
ERROR_CHECK() {
echo "***************************error report***************************n"
errdate=`errpt |grep -v IDENTIFIER |awk '{print $2}' |cut -c 1-4 |xargs`
for syserrFor1 in $errdate
do
if [ "$syserrFor1" = "$syserrdate" ]
then
newerrcount=`expr $errcount + 1`
errcount=$newerrcount
fi
done
if [ "$errcount" -eq 0 ]
then
echo "Today error is add $errcount yesterdayn"
else
echo "Today errors is add $errcount than yesterdayn"
fi
#error detail
errors=`errpt -dH -TPERM`
if [ -z "$errors" ]
then
echo "The Hardware is ${STATUS:-NORMAL}.n"
else
echo "The permanent error of Hardware as fllow:n`errpt -dH -TPERM`"
fi
}
#Check Database
DB_CHECK() {
su - oracle -c "lsnrctl status"|grep -i "no listener"
if [ $? = 1 ]
then
echo "The listener status is ${STATUS:-NORMAL}n"
else
echo "The listener has a problem!!!n"
fi
#echo "The listener status is :`su - oracle -c "lsnrctl status"`n"
#echo "Database status is:"
#su - oracle -c "sqlplus -s /nolog"<<EOF|sed '/^$/d'
#conn /as sysdba
#select log_mode,name,open_mode from v$database;
#quit
#EOF
su - oracle -c "sqlplus -s /nolog"<<EOF|sed '/^$/d' 2>/dev/null|grep -i "ORACLE not avail
able"
conn /as sysdba
select log_mode,name,open_mode from v$database;
quit
EOF
if [ $? = 0 ]
then
echo "The database not available!!!n"
else
echo "The database is NORMALn"
fi
}
#HBA card link
HARDWARE_CHECK() {
fget_config -Av|grep -i dacnone>>/dev/null
if [ $? -eq 0 ]
then
echo "The storage link has problem!!!"
else
echo "The storage link NORMAL!"
fi
}
#HACMP CHECK
HA_CHECK() {
echo "The HACMP status is: `lssrc -g cluster|sed '1d'`"
}
#CHECK SNA
SNA_CHECK() {
echo "The SNA LINK STATUS is:`sna -d l`"
echo "The SNA SESSION has problem as fllows:n"
sna -d sl|tail +4|awk 'BEGIN { OFS="t"; print "name","tactsess","actconw"}{if ($7 == 0 && $8 == 0) print $1, $7,$8}'
}
#CHECK CICS
CICS_CHECK() {
echo "The not active CICS is as fllows:n"
lssrc -a|grep cics|awk '$3!~/active/ {print $1}'
}
echo $SCRIPT >$REPORT
echo $HOSTS >> $REPORT
echo "IP ADDRESS:`ifconfig -a|grep -w inet|grep -v 127.0.0.1|awk '{print $2}'`" >> $REPORT
netstat -v|grep -E "STAT|Link" >>$REPORT
oslevel >> $REPORT
FILESYSTEM_CHECK >>$REPORT 2>&1
VG_CHECK >>$REPORT 2>&1
DISK_CHECK >>$REPORT 2>&1
ERROR_CHECK >>$REPORT 2>&1
DB_CHECK >>$REPORT 2>&1
HARDWARE_CHECK >>$REPORT 2>&1
lslpp -L|grep cluster >/dev/null
if [ $? -eq 0 ]
then
HA_CHECK >>$REPORT 2>&1
else
echo "This machine not install HACMP" >> $REPORT
fi
lslpp -L|grep "sna.rte" >/dev/null
if [ $? -eq 0 ]
then
SNA_CHECK >>$REPORT 2>&1
else
echo "This machine not install sna" >> $REPORT
fi
lslpp -L|grep -i cics >/dev/null
if [ $? -eq 0 ]
then
CICS_CHECK >>$REPORT 2>&1
else
echo "This machine not install cics" >> $REPORT
fi
========================================================
#! /bin/sh
cd /home/check
logname=check.`hostname`.`date +"%y%m%d%H%M"`.txt
echo "system log starting......" >$logname
echo "Filesystem disk use checking started" >>$logname
echo "#df -h" >>$logname
df -h >>$logname 2>&1
echo "filesystem disk ustage checking completed" >>$logname
echo "VG checking started." >>$logname
echo "check vg status" >>$logname
echo "# vgdisplay -v" >>$logname
vgdisplay -v >>$logname
echo "VG checking completed." >>$logname
echo "System log checking started.....">>$logname
echo "# tail -n 50 /var/log/messages" >>$logname
tail -n 50 /var/log/messages >>$logname
echo " showing root's mail" >>$logname
cat /var/spool/mail/root >mail.now
diff -e mail.ref mail.now |awk 'NR>1 {print $0}'>>$logname
mv mail.now mail.ref
echo "showing user login history since last day" >>$logname
last >last.now
diff -e last.ref last.now |awk 'NR>1 {print $0}'>>$logname
mv last.now last.ref >>$logname
echo "Crontab using and error log starting..">>$logname
crontab -l >>$logname
tail -n 30 /var/log/cron >>$logname
echo "#########################">>$logname
echo " System process checking started " >>$logname
echo "#dmesg">>$logname
dmesg >>$logname
echo "#ps -ef |grep defunc">>$logname
ps -ef |grep defunc >>$logname
echo "#service named status">>$logname
service named status >>$logname
echo " #uptime" >>$logname
uptime >>$logname
echo " System process checking completed ">>$logname
echo "#########################">>$logname
echo " networking checking Start.">>$logname
echo "#service network status " >>$logname
service network status >>$logname
echo "#netstat -in " >>$logname
netstat -in >>$logname
echo "#netstat -rn " >>$logname
netstat -rn >>$logname
echo "#netstat -ntapl " >>$logname
netstat -ntapl >>$logname
echo " networking checking completed " >>$logname
#echo "#########################">>$logname
#echo "performance and paging space checking start..." >>$logname
#top >top.now
#cat top.now>>$logname
echo "performance and paging space checking started" >>$logname
echo "#vmstat 1 10 " >>$logname
vmstat 1 10 >>$logname
echo "#free -l ">>$logname
free -l >>$logname
echo "performance and paging space checking completed" >>$logname
echo " showing command used history since last day " >>$logname
cat /.sh_history >sh_history.now
diff -e sh_history.ref sh_history.now |awk 'NR>1 {print $0}' >>$logname
mv sh_history.now sh_history.ref
echo " system logging completed " >>$logname
# now ftp to the log server
ftp -i -n <<EOF
open 10.0.99.5
user root vmware
lcd /home/check
put $logname
bye
EOF
cd /home/check
mv $logname /home/check/syslog/
Linux/hp unix/AIX日常巡检脚本(转)的更多相关文章
- linux日常巡检脚本
######################以下是脚本内容开始部分###################################### #!/bin/bash #set -x2012-02-2 ...
- 企业日常巡检shell脚本
Linux内部查看系统信息 $INTERNET192忽略 [root@ mysql-master ~]# ip a|grep eth0|grep inet|cut -d' ' -f6|cut -d'/ ...
- Linux 编写安全巡检脚本
Linux 编写安全巡检脚本 检测/etc/passwd,/etc/shadow文件是否锁定 检测/etc/login.defs配置文件中密码有效期设置是否得当 检查所有用户账户(非系统账户)中是否存 ...
- 双机倒换(NewStartHA,SKYbility,hacmp,hp unix双机)
1.Suse linux (NewStartHA): # cli cli:~>service-migrate Select service to migrate: ...
- 从Linux 与 Unix 异同,看开源世界的发展!
从Linux 与 Unix 异同,看开源世界的发展! 如果你是一名20多岁或30多岁的软件开发人员,那么你已成长在一个由Linux主导的世界中.数十年来,它一直是数据中心的重要参与者,尽管很难找到明确 ...
- Linux 与 Unix 到底有什么不同?区别在哪?
Linux 与 Unix 到底有什么不同?区别在哪? 如果你是一名20多岁或30多岁的软件开发人员,那么你已成长在一个由Linux主导的世界中.数十年来,它一直是数据中心的重要参与者,尽管很难找到明确 ...
- 资料收集:学习 Linux/*BSD/Unix 的 30 个最佳在线文档
文章转自:https://linux.cn/article-10311-1.html 手册页(man)是由系统管理员和 IT 技术开发人员写的,更多的是为了作为参考而不是教你如何使用.手册页对于已经熟 ...
- linux基础-linux和unix的区别
有时候我们对天天使用的Linux指令,只知道怎么用,却分不清概念用法区别,我觉得很有必要整理整理大家熟视无睹的一些linux概念区别. 首先说说unix和linux的区别: linux和unix的最大 ...
- 1.Linux和Unix区别
整理来源于网络:http://blog.csdn.net/xiaojianpitt/article/details/6377419 有很多初学Linux的人比较关心Linux和windows的区别,这 ...
随机推荐
- Android OpenGL ES(二)OpenGL ES管道(Pipeline) .
大部分图形系统都可以比作工厂中的装配线(Assemble line)或者称为管道(Pipeline).前一道的输出作为下道工序的输入.主CPU发出一个绘图指令,然后可能由硬件部件完成坐标变换,裁剪,添 ...
- Spring Boot 系列教程13-注解定时任务
注解 @Scheduled(cron = "0/5 * * * * ?") 相当于原来的xml版本的如下配置 <task:scheduled ref="schedu ...
- 转:浏览器与WEB服务器工作过程举例
用户通过“浏览器”访问因特网上的WEB服务器,浏览器和服务器之间的信息交换使用超文本传输协议(HTTP--HyperText Transfer Protocol). 例:用户访问东南大学主页 Http ...
- 转:LoadRunner常用函数列表
Web相关函数 函 数 功 能 描 述 web_custom_request 用户可以通过该函数自行创建一个HTTP请求的函数 web_image 模拟用户单击图片操作的函数 web_link ...
- Hibernate 乐观锁(Optimistic Locking)
1.hibernate基于数据版本(Version)记录机制实现.为数据增加一个版本标识,一般是通过为数据库表增加一个"version"字段来实现. 读取出数据时,将此版本号一同读 ...
- Windows下MongoDB安装及创建用户名和密码
下载MongoDB的安装文件https://www.mongodb.com/download-center#community,选择合适的版本(注:本人选择的是3.2.6) 下载完MongoDB.ms ...
- index.do为后缀的是什么开发语言? 有什么技术特点?
@Override 重写父类的方法.@Nullable 表示定义的字段可以为空. 一般情况下扩展名可以体现出一个网站使用的技术,***.html?id=***,这个就是普通的html页面,然后通过ja ...
- hdu_5110_Alexandra and COS(DP+分块思想)
题目连接:hdu_5110_Alexandra and COS 题意: 给你一个图,X代表宝藏,然后有一个船,它的声纳的频率为D,定船到宝藏的距离为Dis=max(abs(x1-x2),abs(y1- ...
- 11、组合模式(Composite)
组合模式有时又叫部分-整体模式在处理类似树形结构的问题时比较方便,看看关系图: 直接来看代码: [java] view plaincopy public class TreeNode { privat ...
- ural1701 Ostap and Partners
Ostap and Partners Time limit: 2.0 secondMemory limit: 64 MB Workman Ivan lost his job. Not because ...