升级内核的方法:
内核下载地址: www.kernel.org
L7的相关文件 http://l7-filter.clearfoundation.com/downloads/start
iptables http://www.netfilter.org
升级内核到2.6.28 并支持L7/string
解压源码包
tar xzf linux-2.6.28.tar.gz
tar xjf iptables-1.4.10.tar.bz2
tar xzf l7-protocols-2009-05-28.tar.gz
tar xzf netfilter-layer7-v2.22.tar.gz
cd linux-2.6.28
make mrproper 清理工作
patch -p1 < /usr/src/netfilter-layer7-v2.22/kernel-2.6.25-2.6.28-layer7-2.22.patch #打上L7补丁
make menuconfig
在
Networking--Networking options--Network packet filtering (replaces ipchains)--Core Netfilter Configuration
把L7和支持 string 等选上
make
make modules
make modules_install
make install
重启系统
#uname -a
Linux localhost.localdomain 2.6.28
编译iptables 支持layer7
cd /usr/src/netfilter-layer7-v2.22/iptables-1.4.3forward-for-kernel-2.6.20forward/
cp libxt_layer7.* /usr/src/iptables-1.4.10/extensions/
上面两步必须操作,这样iptables才能支持,因为新版本的iptables不用打补丁了,直接复制过去即可
cd /usr/src/iptables-1.4.10/
./configure --prefix=/ --with-ksource=/usr/src/linux-2.6.28
make
make install
#iptables -V
iptables v1.4.10
安装协议
cd /usr/src
cd l7-protocols-2009-05-28
make install
#iptables -t mangle -I PREROUTING -m layer7 --l7proto edonkey -j DROP
如没有提示 则无问题
第二种方法:我刚刚测试过
首先确认内核版本: uname -r
例如:[root@localhost iptables-1.4.10]# uname -r
2.6.18-194.el5
这样我从kernel上下载2.6.18的内核
linux-2.6.18.tar.bz2
下载:l7-protocols-2009-05-28 (L7的主程序)
netfilter-layer7-v2.6 (内核的补丁)
内核下载地址: www.kernel.org
L7的相关文件 http://l7-filter.clearfoundation.com/downloads/start
iptables http://www.netfilter.org
解压源码包
tar xzf linux-2.6.18.tar.bz2
tar xjf iptables-1.3.5.tar.bz2
tar xzf l7-protocols-2009-05-28.tar.gz
tar xzf netfilter-layer7-v2.6.tar.gz
cd linux-2.6.18
make mrproper 清理工作
patch -p1 <../netfilter-layer7-v2.6/kernel-2.6.18-layer7-2.6.patc #打上L7补丁(根据内核版本)
make menuconfig
在
Networking--Networking options--Network packet filtering (replaces ipchains)--Core Netfilter Configuration
把L7支持 string 等选上
make modules_prepa
2013年4月28日星期日
2013年4月16日星期二
如何杀死linux中zombie(僵死进程)
解决方法:
#ps -A -o stat,ppid,pid,cmd |grep -e "^[Zz]" //先查看具体进程:
#kill -9 pid号 //杀死z进程(这些动作是比较危险的,希望在真正的服务器上面慎用!!!)
2013年4月10日星期三
2013年4月9日星期二
nrpe标准设置
################################ edited by oyzjin
command[check_iftraffic]=/usr/lib64/nagios/plugins/check_iftraffic -i eth0 -w 80 -c 95 -b 10 -u m
command[check_iostat]=/usr/lib64/nagios/plugins/check_iostat -w 10 -c 15
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -e
command[check_mem]=/usr/lib64/nagios/plugins/check_mem -w 90,3 -c 95,5
2013年4月6日星期六
安装配置 NRPE
监控平台上的安装:
先安装 openssl-devel
yum install openssl-devel
Installing for dependencies: e2fsprogs-devel krb5-devel
再安装 NRPE:
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
在 objects/commands.cfg 中定义 check_nrpe 使用的命令:
复制代码
被监控主机的安装:
同样需要安装 openssl-devel
创建 nagios 用户和组
groupadd nagios
useradd -g nagios -d /usr/local/nagios -s /sbin/nologin nagios
先安装 nagios-plugin:
tar zxvf nagios-plugins-1.4.12.tar.gz
cd nagios-plugins-1.4.12
./configure --prefix=/usr/local/nagios
make
make install
再安装 NRPE:
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
chown -R nagios:nagios /usr/local/nagios
配置 NRPE:
vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,$Nagios监控平台的地址或域名
启动 NRPE 守护进程:
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
可以将此命令加入 /etc/rc.local ,以便开机自动启动。
检查 NRPE 是否正常:
在被监控主机上
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
在监控平台上
/usr/local/nagios/libexec/check_nrpe -H $目标主机地址
都应该可以输出 NRPE 的版本: NRPE v2.12
在被监控端的 nrpe.cfg 文件中,可以看到这样的配置:
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
这是用来检查 CPU 负载的。
这样,就可以在监控平台上定义如下服务来监控被监控端的 CPU 负载了:
复制代码
先安装 openssl-devel
yum install openssl-devel
Installing for dependencies: e2fsprogs-devel krb5-devel
再安装 NRPE:
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
在 objects/commands.cfg 中定义 check_nrpe 使用的命令:
- # 'check_nrpe' command definition
- define command{
- command_name check_nrpe
- command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
- }
同样需要安装 openssl-devel
创建 nagios 用户和组
groupadd nagios
useradd -g nagios -d /usr/local/nagios -s /sbin/nologin nagios
先安装 nagios-plugin:
tar zxvf nagios-plugins-1.4.12.tar.gz
cd nagios-plugins-1.4.12
./configure --prefix=/usr/local/nagios
make
make install
再安装 NRPE:
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
chown -R nagios:nagios /usr/local/nagios
配置 NRPE:
vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,$Nagios监控平台的地址或域名
启动 NRPE 守护进程:
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
可以将此命令加入 /etc/rc.local ,以便开机自动启动。
检查 NRPE 是否正常:
在被监控主机上
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
在监控平台上
/usr/local/nagios/libexec/check_nrpe -H $目标主机地址
都应该可以输出 NRPE 的版本: NRPE v2.12
在被监控端的 nrpe.cfg 文件中,可以看到这样的配置:
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
这是用来检查 CPU 负载的。
这样,就可以在监控平台上定义如下服务来监控被监控端的 CPU 负载了:
- define service{
- host_name remotehost
- service_description check_load
- ...
- check_command check_nrpe!check_load }
2013年4月4日星期四
Nagios 配置
主配置文件 nagios.cfg 需要更改的地方:
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
interval_length=1 ; 间隔时间基准由 60s 改为 1s
command_check_interval=10s ; 命令检查时间间隔,-1 表示尽可能频繁的进行检查
date_format=iso8601 ; 日期格式
objects/contacts.cfg 用来定义联系人:
复制代码
再定义联系人组
复制代码
主机监控的配置
复制代码
服务监控的配置
复制代码
服务监控的配置和主机监控的配置较为相似,就不一一说明了。
间隔时间的计算方法为:
normal_check_interval x interval_length 秒
retry_check_interval x interval_length 秒
notification_interval x interval_length 秒
主机监控配置的例子
复制代码
对主机 web1 进行 24x7 的监控,默认会每 10 秒检查一次状态,累计五次失败就发送提醒,并且不再重复发送提醒。
服务监控配置的例子
复制代码
配置解释: 24x7 监控 web1 主机上的 HTTP 服务,检查间隔为 30 秒, 检查失败后每 15 秒再进行一次检查,累计三次失败就认定是故障并发送提醒。
联系人组是 admins 。提醒后恢复到 30 秒一次的 normal_check_interval 检查。如果服务仍然没有被恢复,每个小时发送一次提醒。
如果要检测其他服务,例如,要检查 ssh 服务是否开启,更改如下两行:
service_description check_ssh
check_command check_ssh
为方便管理,对配置文件的分布做了如下修改:
nagios.cfg 中增加了:
cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/services
在 hosts 目录中,为不同类型的主机创建了配置文件,如: app.cfg cache.cfg mysql.cfg web.cfg
并创建了 hostgroup.cfg 文件对主机进行分组,如:
复制代码
在 services 目录中创建了各种服务的配置文件,如: disk.cfg http.cfg load.cfg mysql.cfg
并创建了 servicegroup.cfg 文件对服务进行分组,如:
复制代码
作者:Bluedata 来源: http://blog.bluedata.org/nagios-setup/
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
interval_length=1 ; 间隔时间基准由 60s 改为 1s
command_check_interval=10s ; 命令检查时间间隔,-1 表示尽可能频繁的进行检查
date_format=iso8601 ; 日期格式
objects/contacts.cfg 用来定义联系人:
- define contact {
- contact_name sa
- alias System Administrator
- service_notification_period 24x7
- host_notification_period 24x7
- service_notification_options w,u,c,r
- host_notification_options d,u,r
- service_notification_commands notify-service-by-email
- host_notification_commands notify-host-by-email
- email admin@test.com
- }
- define contactgroup {
- contactgroup_name admins
- alias Administrator Group
- members sa ; 添加其它联系人用 "," 分隔
- }
- define host {
- host_name host_name ; 简短的主机名称。
- alias alias ; 别名,可以更详细的说明主机。
- address address ; IP 地址,也可以写主机名。如果不定义这个值, nagio 将会用 host_name 去寻找主机。
- parents host_names ; 上一节点的名称,也就是指从 nagios 服务器到被监控主机之间经过的节点,可以是路由器、交换机、主机等等。
- hostgroups hostgroup_names ; 简短的主机组名称。
- check_command command_name ; 检查命令的简短名称,如果此项留空, nagios 将不会去判断主机是否 alive 。
- max_check_attempts 整数 ; 当检查命令的返回值不是 "OK" 时,重试的次数。
- check_interval 数字 ; 循环检查的间隔时间。
- active_checks_enabled [0/1] ; 是否启用 "active_checks"
- passive_checks_enabled [0/1] ; 是否启用 "passive_checks" ,及“被动检查”
- check_period timeperiod_name ; 检测时间段简短名称,这只是个名称,具体的时间段要写在其他的配置文件中。
- obsess_over_host [0/1] ; 是否启用主机操作系统探测。
- check_freshness [0/1] ; 是否启用 freshness 检查。freshness 检查是对于启用被动检查模式的主机而言的,其作用是定期检查主机报告的状态信息,如果该状态信息已经过期,freshness 将会强制做主机检查。
- freshness_threshold 数字 ; fressness 的临界值,单位为秒。 如果定义为 "0" ,则为自动定义。
- event_handler command_name ; 当主机发生状态改变时,采用的处理命令的简短的名字(可以在 commands.cfg 中对其定义)
- event_handler_enabled [0/1] ; 是否启用 event_handler
- low_flap_threshold 数字 ; 抖动的下限值。抖动,即在一段时间内,主机(或服务)的状态值频繁的发生变化。
- high_flap_threshold 数字 ; 抖动的上限值。
- flap_detection_enabled [0/1] ; 是否启用抖动检查。
- process_perf_data [0/1] ; 是否启用 processing of performance data
- retain_status_information [0/1] ; 程序重启时,是否保持主机状态相关的信息。
- retain_nonstatus_information [0/1] ; 程序重启时,是否保持主机状态无关的信息。
- contact_groups contact_groups ; 联系人组,在此组中的联系人都会收到主机的提醒信息。
- notification_interval 整数 ; 重复发送提醒信息的最短间隔时间。默认间隔时间是 "60" 分钟。如果这个值设置为 "0" ,将不会发送重复提醒。
- notification_period timeperiod_name ; 发送提醒的时间段。非常重要的主机(服务)定义为 24x7 ,一般的主机(服务)就定义为上班时间。如果不在定义的时间段内,无论发生什么问题,都不会发送提醒。
- notification_options [d,u,r,f] ; 发送提醒包括的情况: d = 状态为 DOWN , u = 状态为 UNREACHABLE , r = 状态恢复为 OK , f = flapping
- notifications_enabled [0/1] ; 是否开启提醒功能。"1" 为开启,"0" 为禁用。一般,这个选项会在主配置文件 (nagios.cfg) 中定义,效果相同。
- stalking_options [o,d,u] ; 持续状态检测参数,o = 持续的 UP 状态 , d = 持续的 DOWN 状态 , u = 持续的 UNREACHABLE 状态
- }
- define service {
- host_name host_name
- service_description service_description
- servicegroups servicegroup_names
- is_volatile [0/1]
- check_command command_name
- max_check_attempts
- normal_check_interval
- retry_check_interval
- active_checks_enabled [0/1]
- passive_checks_enabled [0/1]
- check_period timeperiod_name
- parallelize_check [0/1]
- obsess_over_service [0/1]
- check_freshness [0/1]
- freshness_threshold
- event_handler command_name
- event_handler_enabled [0/1]
- low_flap_threshold
- high_flap_threshold
- flap_detection_enabled [0/1]
- process_perf_data [0/1]
- retain_status_information [0/1]
- retain_nonstatus_information [0/1]
- notification_interval
- notification_period timeperiod_name n
- otification_options [w,u,c,r,f]
- notifications_enabled [0/1]
- contact_groups contact_groups
- stalking_options [o,w,u,c]
- }
间隔时间的计算方法为:
normal_check_interval x interval_length 秒
retry_check_interval x interval_length 秒
notification_interval x interval_length 秒
主机监控配置的例子
- define host {
- host_name web1
- alias web1
- address 192.168.0.101
- contact_groups admins
- check_command check-host-alive
- max_check_attempts 5
- notification_interval 0
- notification_period 24x7
- notification_options d,u,r
- }
服务监控配置的例子
- define service {
- host_name web1
- service_description check_http
- check_period 24x7
- max_check_attempts 3
- normal_check_interval 30
- contact_groups admins
- retry_check_interval 15
- notification_interval 3600
- notification_period 24x7
- notification_options w,u,c,r
- check_command check_http
- }
联系人组是 admins 。提醒后恢复到 30 秒一次的 normal_check_interval 检查。如果服务仍然没有被恢复,每个小时发送一次提醒。
如果要检测其他服务,例如,要检查 ssh 服务是否开启,更改如下两行:
service_description check_ssh
check_command check_ssh
为方便管理,对配置文件的分布做了如下修改:
nagios.cfg 中增加了:
cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/services
在 hosts 目录中,为不同类型的主机创建了配置文件,如: app.cfg cache.cfg mysql.cfg web.cfg
并创建了 hostgroup.cfg 文件对主机进行分组,如:
- define hostgroup {
- hostgroup_name app-hosts
- alias APP Hosts
- members app1,app2
- }
并创建了 servicegroup.cfg 文件对服务进行分组,如:
- define servicegroup {
- servicegroup_name disk
- alias DISK
- members cache1,check_disk,cache2,check_disk
- }
youtube的dns屏蔽方法
216.239.38.120 是 Google 提供的一个特殊 DNS 服务器,用于强制开启 YouTube 受限模式(Restricted Mode) 。 如果你想在家里强制 YouTube 进入受限模式,可以在 路由器的 DNS 设置 中配置以下 DNS 服务器: D...
-
什么是apt-get apt-get是一条 linux命令 ,适用于deb包管理式的 操作系统 ,主要用于自动从互联网的 软件 仓库中搜索、安装、升级、 卸载 软件或操作系统。 apt-get命令一般需要 root权限 执行,所以一般跟着sudo命令 例 su...
-
cd /sys/bus/usb/devices 先不要插入 usb 设备,然后使用 ls -al 命令,可查看到当前的设备;然后插入设备后再使用ls -al 命令查看,对比即可知道插入为哪个设备。 然后进入对应设备的目录,通过查看 idProduct 和 idVendor 文...
-
The Raspberry Pi 4 can drive up to two displays, with a resolution up to 1080p at a 60Hz refresh rate. At 4K resolution, if you connect two...