CentOS5.5下搭建nagios
一、搭建环境:
一台CentOS5.5x86的系统,ip我默认使用的是nat的,这根据你自己的喜好设置就行了,在这我们是在虚拟机上搭建的,为了方便起见关闭了防火墙和selinux,如果在真实环境中需要做一 些设置,这里就不多讲了。
二、所需软件:
对于初学者而言最痛苦的莫过于下载所需要的软件包,为了方便大家我将所需要的软件包的下载地址罗列出来方便大家下载:
•
apache我们就用系统光盘自带的就可以了
php我们使用编译安装
下载地址:
rrdtool-1.4.7.tar.gz 绘图引摯
下载地址:
•
nagios-3.3.1.tar.gz 主程序英文版
下载地址:
•
nagios-cn-3.2.3.tar.bz2 主程序中文版
下载地址:
•
nagios-plugins-1.4.15.tar.gz 插件程序
下载地址:
•
pnp-0.4.14.tar.gz 结合rrdtool出图
下载地址:
•
nrpe-2.12.tar.gz 监控linux主机
下载地址:
•
NSClient++-0.3.9-Win32.msi 监控32位windows主机
下载地址:%2B%2B-0.3.9-Win32.msi
•
NSClient++-0.3.9-x64.msi 监控64位windows主机
下载地址:%2B%2B-0.3.9-x64.msi
==================================================================
三、开始nagios安装前的准备:
1、安装Rrdtool绘图引摯
# tar zxvf rrdtool-1.4.7.tar.gz
# cd rrdtool-1.4.7
# ./configuer --prefix=/usr/local/rrdtool
# make && make install
2、安装apache:
# yum -y install httpd*
3、编译安装php:
# ./configuer --prefix=/usr/local/php5.2
--enable-mbstring
--with-apxs2=/usr/sbin/apxs
--with-config-file-path=/usr/local/php5.2
# make
# make test
# make install
4、修改httpd.conf配置文件
# vi
/etc/httpd/conf/httpd.conf添加一下内容:
AddType application/x-httpd-php .php //在770行
index.php //在392行
5、保存退出
6、启动apache测试php:
# service httpd
restart
# echo "
wellcome to the apache web site !">/var/www/html/index.html
# vi
/var/www/html/index.php添加一下内容:
phpinfo();
?>
保存退出
7、启动浏览器输入: server ip/index.html,如果出现
wellcome to
the apache web site !说明你的apache没问题了,然后输入: server
ip/index.php出现php测试页面证明你的php没问题了,如果没有出现那就仔细检查检查
8、创建nagios用户和组
# groupadd
nagcmd//添加nagcmd用户组,用以通过web页面提交外部控制命令
# useradd nagios//添加一个名为nagios的用户用以专门跑nagios
# passwd nagios//设置密码
# usermod -a -G nagcmd nagios//将nagios用户加入nagcmd组
# usermod -a
-G nagcmd apache 将apache用户加入nagcmd组
==================================================================
四、下面开始正式安装nagios主程序包了
1、解压并进行编译安装:
# tar jxvf nagios-cn-3.2.3.tar.bz2//这里使用中文安装,有兴趣的同
学也可以使用英文安装
# cd
nagios-cn-3.2.3
# ./configure --with-command-group=nagcmd
make all //编译
make install //安装nagios主要程序,cgi和html文件等
make install-init //安装nagios启动脚本
make install-config //将配置文件的例子复制到nagios配置文件里
make install-commandmode //配置nagios目录权限
这时nagios基本已经安装完成,默认安装后的配置文件用于启动nagios是没有问题的。
# make
install-webconf 安装nagios的web接口,会在 /etc/httpd/conf.d/创建 nagios.conf文件
# htpasswd
-c /usr/local/nagios/etc/htpasswd.users nagiosadmin
设置登陆web界面时HTTP验证的账号密码
# service
httpd restart 启动apache
2、启动浏览器输入: server ip/nagios将会弹出一个用户登录框,这时输入你的用户名和密码就可以进入到nagios的主界面,不过这是如果你选择左边的选项它会提示服务器内部错误等信息,这是因为缺少插件,下面我们进行插件的安装
3、安装plugin插件:
# tar zxvf nagios-plugins-1.4.15.tar.gz
# cd
nagios-plugins-1.4.15
# ./configure
--with-nagios-user=nagios --with-nagios-group=nagios
# make
&& make install
# ls -l /usr/local/nagios/libexec/ 可以看到插件都装载这个目录下了
# chkconfig
--add nagios
# chkconfig nagios on
4、此时刷新页面再试就会出现自带的效果图
(function main(Global) {
var CONSTANTS = {
PLAYER_DOM: 'object[data],embed[src],iframe[src]',
PLAYERS: [
{
find: /^http:\/\/static\.youku\.com\/.*?q?(player|loader)(_[^.]+)?\.swf/,
replace: ''
},
{
find: /^http:\/\/js\.tudouui\.com\/.*?\/TudouVideoPlayer_Homer_[^.]*?.swf/,
replace: ''
},
{
find: /^http:\/\/player\.youku\.com\/player\.php\//,
replace: ''
},
{
find: /^http:\/\/dp\.tudou\.com\/nplayer[^.]*?\.swf|http:\/\/js\.tudouui\.com\/doupao\/nplayer[^.]*?\.swf/,
replace: ''
},
{
find: /^http:\/\/\/(([a-z]|programs)\/.*)/,
replace: ''
}
],
SHARE_DOM: '#panel_share input,input#copyInput.txt',
SHARES: [
{
find: /http:\/\/player\.youku\.com\/player\.php\//,
replace: ''
},
{
find: /http:\/\/\/(.*v\.swf)/,
replace: ''
}
],
TIPS_HOLDER: '#miniheader,#gTop',
TIPS: '
OpenGG.Clean.Player \u5DF2\u542F\u7528 \u5bbd\u5c4f/\u7a84\u5c4f
',
STYLE: '.playBox_thx #player.player,.playBox_thx #player.player object{min-height:' + Math.max(Global.innerHeight * 0.6, 580) + 'px !important}.tips_container{position:absolute;top:3em;padding:1em 2em;right:50px;color:green;opacity:0.4;background:#ddd;z-index:999999}.tips_container:hover{opacity:0.8}.tips_container .tips_toggleWide{color:red;cursor:pointer;display:none}',
NODEINSERTED_HACK: '@-moz-keyframes nodeInserted{from{opacity:0.99;}to{opacity:1;}}@-webkit-keyframes nodeInserted{from{opacity:0.99;}to{opacity:1;}}@-o-keyframes nodeInserted{from{opacity:0.99;}to{opacity:1;}}@keyframes nodeInserted{from{opacity:0.99;}to{opacity:1;}}embed,object{animation-duration:.001s;-ms-animation-duration:.001s;-moz-animation-duration:.001s;-webkit-animation-duration:.001s;-o-animation-duration:.001s;animation-name:nodeInserted;-ms-animation-name:nodeInserted;-moz-animation-name:nodeInserted;-webkit-animation-name:nodeInserted;-o-animation-name:nodeInserted;}',
TOGGLE_BTN: '.tips_container .tips_toggleWide'
};
var DONE = [];
var UTIL = {
addCss: function (str) {
var style = document.createElement('style');
style.textContent = str;
document.head.appendChild(style);
},
procFlash: function (elem) {
if (DONE.indexOf(elem) !== -1) {
return;
}
if (this.reloadFlash(elem)) {
DONE.push(elem);
}
},
reloadFlash: function (elem) {
var attrs = ['data', 'src'];
var players = CONSTANTS.PLAYERS;
var reloaded = false;
UTIL.forEach(attrs, function (attr) {
UTIL.forEach(players, function (player) {
var find = player.find;
var replace = player.replace;
var value = elem[attr];
if (value && find.test(value)) {
var nextSibling = elem.nextSibling;
var parentNode = elem.parentNode;
var clone = elem.cloneNode(true);
clone[attr] = value.replace(find, replace);
parentNode.removeChild(elem);
parentNode.insertBefore(clone, nextSibling);
//Baidu tieba shit.
if(getComputedStyle(clone).display==='none'){
clone.style.display='block';
}
reloaded = true;
}
});
});
return reloaded;
},
forEach: function (arr, callback) {
if (this.isArrayLike(arr)) {
if (Array.prototype.forEach) {
Array.prototype.forEach.call(arr, callback);
} else {
var i = 0;
for (i = 0; i < arr.length; ++i) {
callback.call(arr[i], arr[i]);
}
}
}
},
isArrayLike: function (obj) {
if (typeof obj !== 'object') {
return false;
}
var types = ['Array', 'NodeList', 'HTMLCollection'];
var i = 0;
for (i = 0; i < types.length; ++i) {
if (Object.prototype.toString.call(obj).indexOf(types[i]) !== -1) {
return true;
}
}
return false;
}
};
var STORE;
(function(){
var isStorage = true;
if(!Global.localStorage){
isStorage = false;
}else{
try{
var key = String(Math.random());
localStorage.setItem(key,'test');
if(localStorage.getItem(key)!=='test'){
throw 'not equal';
}
localStorage.removeItem(key);
}catch(e){
isStorage=false;
}
}
STORE = {
getItem: function(key){
if(isStorage){
return localStorage.getItem(key);
}
},
setItem: function(key, value){
if(isStorage){
localStorage.setItem(key, value);
}
}
};
})();
function init() {
function onDOMNodeInsertedHandler(e) {
var target = e.target;
if (target.nodeType === 1 && /OBJECT|EMBED|IFRAME/ig.test(target.nodeName)) {
UTIL.procFlash(target);
}
}
function onAnimationStartHandler(e) {
if (e.animationName === 'nodeInserted') {
var target = e.target;
if (target.nodeType === 1 && /OBJECT|EMBED|IFRAME/ig.test(target.nodeName)) {
UTIL.procFlash(target);
}
}
}
function animationNotSupported(){
var style = document.createElement('div').style;
var arr = ['animation', 'MozAnimation', 'webkitAnimation', 'OAnimation'];
for(var i =0;i
阅读(448) | 评论(0) | 转发(1) |