Nagios 札记之三:安装配置 NRPE

2008-07-16 | 15:20分类:Linux | 标签: | 279 Views

监控平台上的安装:
先安装 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 }

Nagios 札记之二:配置

2008-07-15 | 12:13分类:Linux | 标签: | 306 Views

主配置文件 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 用来定义联系人:

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    ; 添加其它联系人用 "," 分隔
}

全文阅读 »

Nagios 札记之一:安装

2008-07-14 | 22:42分类:Linux | 标签: | 328 Views

下载所需软件:
http://www.nagios.org/download/

创建 nagios 用户和组
groupadd nagios
useradd -g nagios -d /usr/local/nagios -s /bin/bash nagios

创建一个 nagcmd 组用于从 Web 接口执行外部命令,并将 nagios 用户和 Apache 用户都加到这个组中
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd nobody

tar zxvf nagios-3.0.3.tar.gz
cd nagios-3.0.3
./configure \
--prefix=/usr/local/nagios \
--with-command-group=nagcmd

make all

make install
make install-init
make install-config
make install-commandmode

安装 Nagios 的 WEB 配置文件到 Apache 的 /etc/httpd/conf.d 目录下
make install-webconf

如果是编译安装的 Apache ,可以手动添加一下配置
cat sample-config/httpd.conf >> /usr/local/apache/conf/httpd.conf

创建 Nagios Web 接口登录的用户
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

确认加载了 cgi_module 和 alias_module ,然后重启 Apache
service httpd restart

安装 Nagios 插件
tar zxvf nagios-plugins-1.4.12.tar.gz
cd nagios-plugins-1.4.12
./configure \
--prefix=/usr/local/nagios \
--with-nagios-group=nagcmd

make
make install

添加 nagios 服务
chkconfig --add nagios
chkconfig nagios on

检查配置文件是否有错误
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

启动
service nagios start

通过 http://IP/nagios 输入用户名密码就可以打开 nagios 的页面了。
此时还只能简单的查看 localhost 的状态。

用 MySQL-Proxy 实现 MySQL 主从模式下的读写分离

2008-07-13 | 22:48分类:Linux, MySQL, Redhat/CentOS | 标签: | 342 Views

准备所需的软件:
读写分离脚本是由 lua 语言编写的,需要安装 lua
http://www.lua.org/
下载适合的 MySQL-Proxy 版本
http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/

安装依赖的库:
yum -y install readline-devel
Installing for dependencies: libtermcap-devel

安装 lua:
tar zxvf lua-5.1.3.tar.gz
cd lua-5.1.3
make linux
make install

安装 MySQL-Proxy:
tar zxvf mysql-proxy-0.6.1-linux-rhel4-x86-32bit.tar.gz
cd mysql-proxy-0.6.1-linux-rhel4-x86-32bit
mv sbin/mysql-proxy /usr/local/sbin/
mv share/mysql-proxy /usr/local/share/
strip /usr/local/sbin/mysql-proxy
全文阅读 »

CentOS 安装过程中使用 softraid 和 LVM

2008-06-24 | 14:30分类:Redhat/CentOS | 标签: | 314 Views

磁盘分区设置开始时 Alt+F2 切换到 shell 进行如下操作:
fdisk /dev/sda
分两个主分区, sda1 100M ,剩下的全给 sda2 ,并且把分区类型都设为 fd
/dev/sdb 也做同样操作。

创建 RAID1
mdadm -C /dev/md0 -l1 -n2 -c128 /dev/sd[a,b]1
mdadm -C /dev/md1 -l1 -n2 -c128 /dev/sd[a,b]2

创建 VG
lvm pvcreate /dev/md1
lvm vgcreate vg0 /dev/md1

然后 Alt+F1 切换回安装界面继续使用 Disk Druid 进行分区操作:
编辑 /dev/md0 ,格式化为 ext3 ,挂载点设为 /boot
在 vg0 上添加逻辑卷挂载根 swap 及其它目录。

安装完成进入系统后执行如下操作:
grub
> device (hd0) /dev/sda
> root (hd0,0)
> setup (hd0)
> device (hd1) /dev/sdb
> root (hd1,0)
> setup (hd1)

如果不能引导,重新用光盘引导系统, linux rescue 进入修复模式执行以上操作。

更换从盘 sdb :
进入系统后执行 fdisk /dev/sdb ,创建和安装系统时一样的分区结构。

然后重新加入 RAID
mdadm /dev/md0 --add /dev/sdb1
mdadm /dev/md1 --add /dev/sdb2

再把 grub 写入 MBR
grub
> device (hd1) /dev/sdb
> root (hd1,0)
> setup (hd1)

更换主盘 sda 需要互换 sda 和 sdb 的数据线接口再进行上述操作。

Pages: Prev 1 2 3 4 5 6 7 8 9 10 Next