`

分享一个linux的流量监测工具!!!(2)

阅读更多

[root@server146 monitoring]# ls -l /var/www/html/monitoring
总计 28
-rw-r--r-- 1 munin munin 2555 07-22 15:15 definitions.html
-rw-r--r-- 1 munin munin 1584 07-23 17:00 index.html
drwxr-xr-x 2 munin munin 12288 07-22 15:15 localhost
-rw-r--r-- 1 munin munin 473 07-22 15:15 logo.png
-rw-r--r-- 1 munin munin 3538 07-22 15:15 style.css

通过http://ip/monitoring/ 就可以查看到主机的监控信息http:#192.168.1.146/monitoring/localhost/localhost.html#Network图:Munin监控信息

图:Munin监控信息每天


图:Munin监控信息每周
安装和配置monit
执行yum 完成安装
yum install monit
设置monit的启动脚本
chkconfig --levels 235 monit on
默认的/etc/monit.conf文件中是注释的示例配置文件,http:#mmonit.com/wiki/Monit/ConfigurationExamples这里是官方提供的配置文件参考。
http:#mmonit.com/monit/documentation/monit.html 这里是详尽的配置文件的语法格式信息。
大家注意到/etc/monit.conf文件末尾的信息。
###############################################################################
## Includes
###############################################################################
##
## It is possible to include additional configuration parts from other files or
## directories.
#
include /etc/monit.d/*
#
#

此处的信息的作用是与apache的配置文件类似,在/etc/monit.d/中的每个文件都是一个独立的配置文件,便于配置文件的结构化和维护操作。
创建一个简单的配置文件
vi /etc/monit.d/monitrc
set daemon 60 #2分钟检查一次
set logfile syslog facility log_daemon #monit的日志文件
set mailserver localhost #设置邮件服务器
set mail-format { from: monit@192.168.1.149 } #出现错误的时候发报警邮件到指定的邮箱
set alert lvsheat@qq.com
set httpd port 2812 and use address 192.168.1.149 #设置http监控页面的端口和ip
SSL ENABLE
PEMFILE /var/certs/monit.pem
allow admin:test #认证的用户名和密码

#平均负载.内存使用率,cpu使用率
check system 192.168.1.149 
if loadavg (1min) > 4 then alert
if loadavg (5min) > 2 then alert
if memory usage > 75% then alert
if cpu usage (user) > 70% then alert
if cpu usage (system) > 30% then alert
if cpu usage (wait) > 20% then alert
# 磁盘空间使用率
check device data with path /dev/sda2
if space usage > 90% then alert
if inode usage > 85% then alert
check device home with path /dev/sda3
if space usage > 85% then alert
if inode usage > 85% then alert
#监控vsftpd服务
check process vsftpd with pidfile /var/run/vsftpd.pid
start program = "/etc/init.d/vsftpd start"
stop program = "/etc/init.d/vsftpd stop"
if failed port 21 protocol ftp then restart
if 5 restarts within 5 cycles then timeout

#监控ssh服务
check process sshd with pidfile /var/run/sshd.pid 
start program "/etc/init.d/sshd start"
stop program "/etc/init.d/sshd stop"
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
#监控mysql服务
check process mysql with pidfile /var/run/mysqld/mysqld.pid
group database
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed host 127.0.0.1 port 3306 then restart
if 5 restarts within 5 cycles then timeout
#监控apache服务
check process apache with pidfile /var/run/httpd.pid
group www
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host 192.168.1.149 port 80 protocol http
and request "/monit/testok" then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 500 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout
#监控postfix 邮件服务
check process postfix with pidfile /var/spool/postfix/pid/master.pid
group mail
start program = "/etc/init.d/postfix start"
stop program = "/etc/init.d/postfix stop"
if failed port 25 protocol smtp then restart
if 5 restarts within 5 cycles then timeout
#监控自定义服务
check process web_lb with pidfile /opt/server/web_lb/httpd.pid
start program = "/opt/bin/lb.sh" #启动脚本
stop program = "/opt/bin/lb_stop.sh" #停止脚本
if failed host 192.168.1.149 port 6101 proto http then restart
if failed host 192.168.1.149 port 6101 proto http for 5 times within 5 cycles then exec "/opt/bin/lb_pay.sh"
if failed host 192.168.1.149 port 6102 type TCPSSL proto http then restart
if failed host 192.168.1.149 port 6102 type TCPSSL proto http for 5 times within 5 cycles then exec "/opt/bin/lb_pay.sh

分享到:
评论

相关推荐

    Linux 流量监控工具

    以上介绍的知识点涉及Linux流量监控工具iftop的安装、配置、运行和使用。iftop作为一个功能强大的工具,对于有需要进行网络流量分析和管理的用户来说,是不可或缺的。通过iftop的使用,可以有效地监控、分析和诊断...

    Linux下的MRTG流量监控的设计与实现

    MRTG(Multi Router Traffic Grapher)是一个用于监控网络流量和性能的开源工具,尤其在Linux环境下广泛使用。本文将详细介绍如何在Linux系统上利用MRTG来实施网络流量监控。 1. **引言** 在信息化社会中,网络...

    Linux Mrtg监控主机流量的安装方法

    Linux MRTG(Multi Router Traffic Grapher)是一种网络监控工具,专门用于收集和展示网络设备的流量数据。它通过SNMP(Simple Network Management Protocol)协议与网络设备交互,收集网络接口的流入和流出流量,...

    iftop是一个实时流量监控工具,类似于Linux系统中的top命令,用于监控IP网络流量

    iftop是一个实时流量监控工具,类似于Linux系统中的top命令,用于监控IP网络流量。它提供了一个实时更新的界面,展示了网络接口上的流量统计,包括发送和接收的数据包。iftop的主要功能包括监控网卡的实时流量(可以...

    linux 流量监控 iptraf

    Linux流量监控工具IPtraf是Linux系统管理员用来实时监测网络流量和网络性能的重要软件。IPtraf是一款基于命令行的工具,它提供了丰富的界面来显示网络接口的各种统计信息,包括带宽使用、数据包计数、TCP/UDP连接...

    Linux运维监控工具,支持系统硬件信息,内存,cpu,温度,磁盘空间及IO,硬盘smart,系统负载,网络流量等监控,服务接口

    今天给大家介绍一款Linux运维监控工具 ——wgcloud,功能非常强大,完全开源! wgcloud支持显示CPU利用率、CPU温度、内存利用率、磁盘容量、磁盘IO、硬盘智能健康状态、系统负载、连接数、网卡流量、硬件系统信息等...

    网络流量监测工具.rar

    本压缩包文件"网络流量监测工具.rar"包含一个名为"网络流量监测工具.exe"的应用程序,这可能是一款简易易用的网络流量监控软件。 网络流量监测工具的主要功能包括: 1. **实时流量显示**:工具能够实时显示当前...

    Linux运维监控工具(支持系统硬件信息,内存,cpu,温度).zip

    Linux运维监控工具(支持系统硬件信息,内存,cpu,温度,磁盘空间及IO,硬盘smart,系统负载,网络流量等监控,服务接口,大屏展示,拓扑图,进程监控,端口监控,docker监控,文件防篡改,日志监控,数据可视化,...

    Linux下实现流量监测源代码

    该资源中的"bd-2.0.1"可能是一个流量监测软件的版本号,这可能包含了一个用C或Python等编程语言编写的源代码库。对于初学者来说,通过阅读和理解这些源代码,可以了解到如何利用`libpcap`库进行数据包捕获,以及如何...

    linux主机流量实时监控脚本

    `iftop`是一个实时流量监控工具,它以类似top命令的界面展示当前网络带宽使用情况。它能按进程显示流量信息,便于定位哪个进程占用了大量带宽。要安装`iftop`,可以使用以下命令(根据不同的Linux发行版可能会有所...

    linux流量监控脚本

    本文将详细介绍一个简单的Linux流量监控脚本的实现原理和具体步骤。 #### 二、脚本结构分析 该脚本主要用于监控Linux系统中eth0网卡的接收和发送流量,并记录最高传输速率。 ##### 2.1 初始化变量与获取当前流量值...

    linux下流量检测工具iftop和nethogs 实时流量监控工具 统计网络带宽使用率

    nethogs则是一个轻量级的网络流量监控工具,它的主要特点是按进程划分流量,可以显示哪个进程正在占用最多的网络带宽。`nethogs-0.8.5-1.el7.x86_64.rpm`包安装后,执行`nethogs`命令即可查看。nethogs的输出清晰...

    流量监控工具

    在Linux和Solaris系统中,`nicstat`是一个常用的流量监控工具。`nicstat-1.92`是这个工具的一个版本号,它可能包含了对多个网络接口的统计功能,以及一些性能改进和错误修复。`nicstat`通过收集网络接口控制器(NIC...

    Linux网络监控工具nicstat-src-1.95.tar.gz(源码)

    在Linux系统管理中,了解和使用网络监控工具是至关重要的,因为这有助于管理员实时了解网络性能,及时发现并解决问题。`nicstat`是一款强大的网络监控工具,尤其适用于Solaris和Linux环境。它提供了丰富的功能,可以...

    Linux命令行下的网络流量监控:工具与实践

    本文将详细介绍如何在Linux环境下使用命令行工具进行网络流量监控,包括常用的监控工具和一些实用的监控技巧。 Linux命令行提供了多种工具来监控网络流量,从简单的实时监控到复杂的数据包分析。通过合理选择和使用...

    Cacti for LinuxUnix(网络流量监测图形分析工具) v1.2.24.gz

    Cacti是一款基于Web的网络监控和图形生成工具,专为Linux和Unix系统设计,用于实时监控...对于有经验的Linux用户和系统管理员来说,这是一个强大的工具,而对于初学者,这将是一个学习网络监控和系统管理的宝贵机会。

    linux资源监控工具

    nmon是Linux下的一款非常强大的资源监控工具,由Nigel Cunningham开发,旨在提供一个简洁易用的界面来显示系统性能数据。它能够实时监控CPU、内存、磁盘I/O和网络流量,并且可以记录数据以便后续分析。nmon支持多种...

    服务器流量监控5.0(网络流量观测专用工具)

    "服务器流量监控5.0"是一款专为网络流量观测设计的专业工具,它提供了全面的监控解决方案,以确保企业级网络环境的健康运行。 这款工具的核心功能包括: 1. **实时监控**:能够实时显示网络进出流量,帮助用户即时...

    4个Linux下网络流量实时监控工具.pdf

    SAR(System Activity Reporter)是一个综合性的系统性能监控工具,它不仅可以监控网络流量,还可以显示CPU、磁盘I/O、内存等多个方面的性能数据。 - **安装**: - 使用yum安装SAR:`$ yum -y install sysstat` - *...

    非常好用的LINUX流量监控软件.

    "非常好用的LINUX流量监控软件"指的是nload,这是一款轻量级的命令行工具,专用于实时监控网络带宽使用情况。它的安装过程简洁明了,非常适合对系统性能有高要求或不希望图形界面的用户。 nload的安装步骤正如描述...

Global site tag (gtag.js) - Google Analytics