利用shell脚本监控公司内网机器

简介:

   公司内网的一些服务器宕机或者出问题时,网络管理人员不能及时发现,利用sendmail+shell脚本可以及时告知网络管理人员。

  其中iplist.txt文件为监控的服务器ip地址列表。

1
2
3
4
[root@mail sh] # cat iplist.txt
192.168.1.1
192.168.1.100
192.168.1.200

   查看脚本:

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@mail sh] # cat check_ip_all.sh
#!/bin/bash
BASE= /root/sh
for  ip  in  ` cat  $BASE /iplist .txt`
do
ping  $ip -c 2 >  /dev/null  2>&1
         if  [ ! $? - eq  0 ]; then
                 echo  "The company server $ip down,please solved the problem as soon as possible!"  /root/sh/mail .txt
                 mail -s  "The server $ip is down now"   shifeng_zhang88@163.com  <  /root/sh/mail .txt
         fi
done
#添加crontab,每2分钟自动检测
* /5  * * * *  /bin/bash  /root/sh/check_ip_all .sh >  /dev/null  2>&1









本文转自 sfzhang 51CTO博客,原文链接:http://blog.51cto.com/sfzhang88/857716,如需转载请自行联系原作者

目录
相关文章
|
3天前
|
分布式计算 Hadoop Shell
使用shell脚本实现自动SSH互信功能
使用shell脚本实现自动SSH互信功能
10 1
|
4天前
|
Unix Shell Linux
轻松编写 AIX Shell 脚本
轻松编写 AIX Shell 脚本
12 1
|
5天前
|
监控 关系型数据库 Shell
Shell脚本入门:从基础到实践,轻松掌握Shell编程
Shell脚本入门:从基础到实践,轻松掌握Shell编程
|
5天前
|
关系型数据库 MySQL Shell
在Centos7中利用Shell脚本:实现MySQL的数据备份
在Centos7中利用Shell脚本:实现MySQL的数据备份
|
6天前
|
Shell Linux 编译器
C语言,Linux,静态库编写方法,makefile与shell脚本的关系。
总结:C语言在Linux上编写静态库时,通常会使用Makefile来管理编译和链接过程,以及Shell脚本来自动化构建任务。Makefile包含了编译规则和链接信息,而Shell脚本可以调用Makefile以及其他构建工具来构建项目。这种组合可以大大简化编译和构建过程,使代码更易于维护和分发。
24 5
|
Shell Perl
在shell中获取当前机器的ip地址
在shell中获取得到当前机器的ip地址 ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' 原文: http://www.
815 0
|
7天前
|
Shell 程序员 数据安全/隐私保护
shell 脚本 if-else判断 和流程控制 (基本语法|基础命令)
shell 脚本 if-else判断 和流程控制 (基本语法|基础命令)
|
7天前
|
存储 Shell C语言
shell脚本 编程 变量 基本入门(详解)
shell脚本 编程 变量 基本入门(详解)
|
7天前
|
Shell Linux 编译器
C语言,Linux,静态库编写方法,makefile与shell脚本的关系。
总结:C语言在Linux上编写静态库时,通常会使用Makefile来管理编译和链接过程,以及Shell脚本来自动化构建任务。Makefile包含了编译规则和链接信息,而Shell脚本可以调用Makefile以及其他构建工具来构建项目。这种组合可以大大简化编译和构建过程,使代码更易于维护和分发。
15 3
|
13天前
|
弹性计算 运维 监控