`
icarusli
  • 浏览: 531130 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

nagios+LAMP自动安装脚本

    博客分类:
  • WEB
阅读更多



#!/bin/sh
# Nagios V3.03 install script
# Write by zhengyp
#Date:2008-10-8


# Softwares are all store in /usr/local/src
cd /usr/local/src
#Install LAMP for Nagios

# Step 1. Install Apache
tar zxvf httpd-2.2.9.tar.gz
cd httpd-2.2.9
./configure --prefix=/usr/local/apache --enable-so --enable-mods-shared=all
make && make install
#Configure the apache server for PHP
sed -i 's#DirectoryIndex index.html#& index.php#' /usr/local/apache/conf/http.conf
sed -i '/AddType application\/x-gzip .gz .tgz/i\AddType application/x-httpd-php .php\
AddType application/x-httpd-php-source .phps' /usr/local/apache/conf/http.conf

#Step 2. Install Mysql As a server
#Add a mysql user
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
cd ..
tar zxvf mysql-5.1.26-rc.tar.gz
cd mysql-5.1.26-rc/
./configure --prefix=/usr/local/mysql/ --without-debug --with-unix-socket-path=/usr/local/mysql/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=gbk,gb2312,utf8 --with-pthread --enable-thread-safe-client
make && make install
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
cp support-files/my-medium.cnf /usr/local/mysql/my.cnf
cd ../

#Initialize the database
#You can change the data directory by set "--datadir="
#mkdir /data
#chown -R mysql:mysql /data

/usr/local/mysql/bin/mysql_install_db --defaults-file=/usr/local/mysql/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/local/mysql/mysql.pid --skip-locking --port=3306 --socket=/tmp/mysql.sock
#Start Mysql
/bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &

#Step 3. Install PHP
#If you use CentOS, Please run yum to check that the graphics library have installed.Also it will update for these softwares
#If you use Redhat , Install the graphics library by "rpm" command
cd ..
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc- devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel

tar zxvf php-5.2.6.tar.gz
cd php-5.2.6
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-apxs2=/usr/local/apache/bin/apxs --with-freetype --with-jpeg --with-png --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --with-curl --with-curlwrappers --with-gd --enable-gd-native-ttf --with-openssl
make && make install
cd ..

#Step 4.Install Nagios 3.03
#Add nagios user
adduser nagios
mkdir /usr/local/nagios
chown nagios:nagios /usr/local/nagios
groupadd nagcmd
usermod -G nagcmd nagios
tar zxvf nagios-3.0.3.tar.gz
cd nagios-3.0.3
sed -i 's#wav#x-mplayer2#' cgi/status.c
#Configure and make
./configure --prefix=/usr/local/nagios --with-command-group=nagcmd --with-httpd-conf=/usr/local/apache/conf/httpd.conf --with-gd
make all
make install
make install-init
make install-config
make install-commandmode

#Add a user for nagios ,You can change the passwd for the user you add
/usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd nagios <<EOF
123
123
EOF

sed -i '/AddType application\/x-gzip .gz .tgz/i\AddType application/x-httpd-php .php\
AddType application/x-httpd-php-source .phps' /usr/local/apache/conf/http.conf

sed -i '/<\/IfModule>/a\Alias /nagios/cgi-bin/images/ "/usr/local/nagios/share/images/"\
<Directory "/usr/local/nagios/share/images/">\
    AllowOverride None\
    Options None\
    Order allow,deny\
    Allow from all\
    AuthType Basic\
    AuthName "Login User"\
    AuthUserFile /usr/local/nagios/etc/htpasswd\
    require user nagios\
</Directory>\
ScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin/"\
<Directory "/usr/local/nagios/sbin/">\
AllowOverride None\
    Options None\
    Order allow,deny\
    Allow from all\
    AuthType Basic\
    AuthName "Login User"\
    AuthUserFile /usr/local/nagios/etc/htpasswd\
    require user nagios\
</Directory>\
Alias /nagios/ "/usr/local/nagios/share/"\
<Directory "/usr/local/nagios/share/">\
    AllowOverride None\
    Options None\
    Order allow,deny\
    Allow from all\
    AuthType Basic\
    AuthName "Login User"\
    AuthUserFile /usr/local/nagios/etc/htpasswd\
    require user nagios\
</Directory>' /usr/local/apache/conf/http.conf
sed -i 's#ServerName www.temple.com:80#ServerName 127.0.0.1#' /usr/local/apache/conf/http.conf
/usr/local/apache/bin/apachectl start

#Step 5. Install Naigos plugins
#Install plugins
cd /usr/local/src
tar xvzf nagios-plugins-1.4.12.tar.gz
cd nagios-plugins-1.4.11
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround --with-nagios-user=nagios --with-mysql=/usr/local/mysql
make && make install

# Install nrpe
cd /usr/local/src
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure --enable-ssl --with-ssl-lib=/usr/local/nagios/openssl/lib --with-kerberos-inc=/usr/local/nagios/openssl/include --enable-command-args
make;make install
make install-plugin
make install-daemon
make install-daemon-config
chown nagios:nagios /usr/local/nagios/etc/nrpe.cfg
sed 's#dont_blame_nrpe=0#dont_blame_nrpe=1#' /usr/local/nagios/etc/nrpe.cfg
#Add nrpe to service
echo "nrpe 5666/tcp # NRPE" >>/etc/service
echo " " > /etc/xinetd.d/nrpe
sed -i '/ /i\service nrpe\
{\
disable     =   no\
flags       =   REUSE\
socket_type =   stream\
wait        =   no\
user        =   nagios\
server      =   /usr/local/nagios/bin/nrpe\
server_args =   -c /usr/local/nagios/etc/nrpe.cfg --inetd\
log_on_failure += USERID\
only_from = 192.168.0.200 #nagiosServer IP\
}' /etc/xinetd.d/nrpe

#Step 6. Configure Naigos
#Add the user who you've create in step 4 by htpasswd for nagios
cd /usr/local/nagios/etc
sed -i 's#default_user_name=guest#default_user_name=nagios' cgi.cfg
sed -i 's#=nagiosadmin#=nagiosadmin,nagios' cgi.cfg
#Start nagios
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
service nagios start

#Step 7 . Set all servers start after system boot
echo "/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg" >> /etc/rc.local
echo "service nagios start" >> /etc/rc.local
echo "/bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &" >> /etc/rc.local
echo "/usr/local/apache/bin/apache/bin/apachectl start" >> /etc/rc.local

分享到:
评论

相关推荐

    nagios+nrpe详细安装配置

    此外,Nagios 还支持自定义shell脚本以监控特定服务,并通过Web界面展示监控信息和报警通知。 **Nagios 系统特点:** 1. 监控主机资源和网络服务,提供实时状态报告。 2. 支持用户自定义插件以监控特殊服务。 3. ...

    Nagios+nagiosql配置

    - 运行安装脚本,将Nagiosql与Nagios关联起来。 - 配置Web服务器(如Apache)以支持Nagiosql的Web界面访问。 **3.2 使用Nagiosql** 通过Nagiosql的Web界面,你可以方便地添加、编辑和管理Nagios的配置,包括定义...

    编译安装LAMP环境和nagios部署.docx

    【编译安装LAMP环境和Nagios部署】 在Linux环境中,LAMP(Linux, Apache, MySQL, PHP)是一套常见的Web服务器基础架构,而Nagios则是一种网络监控工具,用于检查系统的运行状态。以下将详细介绍如何在CentOS环境下...

    nagios配置安装

    本文将详细介绍如何在Linux环境中配置和安装Nagios,包括搭建LAMP环境、下载安装Nagios及其插件,以及进行必要的配置。 一、搭建LAMP环境 LAMP是指Linux、Apache、MySQL和PHP的组合,是运行Nagios所需的基础环境。...

    Cacti和Nagios网络监控平台安装配置

    - 可以使用插件或脚本自动同步Cacti和Nagios中的监控对象和服务信息。 ### 使用Cacti和Nagios进行监控 #### Cacti+SNMP的监控 Cacti通过SNMP协议收集数据,可以监控Linux和Windows主机。具体步骤包括: - 在目标...

    nagios监控linux主机、web等各种服务,并实现飞信自动报警

    ### Nagios监控Linux主机、Web服务及其实现飞信自动报警 #### 一、Nagios简介 Nagios是一款非常强大的开源网络监控系统,它主要用于监控计算机系统的各种服务状态,比如服务器硬件健康状况、应用软件运行状态、...

    cacti和nagios安装步骤

    总之,安装CACTI和NAGIOS需要熟悉Linux系统管理,理解LAMP环境的构建,以及对网络监控工具的基本配置。这个过程虽然复杂,但完成后,你可以通过图形化的界面监控网络设备的性能,及时发现并解决潜在问题。

    Centos 5.2安装Cacti并集成Nagios安装文档

    Nagios的安装同样需要其依赖库,如NRPE(Nagios Remote Plugin Executor)和Nagios Plugins。使用`yum install nagios nagios-plugins-all nrpe`命令进行安装。 7. **配置Nagios**: 编辑配置文件`/etc/nagios/...

    Cacti+Nagios构建网络监控平台

    - **Windows监控**:通过安装Nagios客户端或使用特定插件监控Windows服务。 - **配置规则**:设置监控频率、阈值以及告警条件等。 ##### 3.3 Syslog配置 - **Linux监控机**:配置syslog服务器接收来自受控主机的...

    cacti+nagios

    本文将详细介绍如何在LAMP平台上安装和配置Cacti与Nagios,包括所需的软件包下载地址。Cacti是一款强大的网络流量监控工具,而Nagios则主要用于系统主机和服务的监控。这两款工具可以无缝集成,共同提供全面的网络...

    运维工程师快捷运维脚本

    实现快速安装nginx、mysql、php、redis、nagios、运维经常使用的脚本等等... 简单 高效 快捷! Linux下很多操作命令,都可以根据业务需求通用化,脚本化,关键是思路,很多LAMP/LNMP一键安装包,也是这样。 脚本化后...

    利用Nagios监控linuxwindows及飞信报警总结

    #### 一、Nagios简介与安装 **Nagios**是一款开源的网络监控系统,它可以帮助系统管理员跟踪计算机系统的状态,如网络服务(SMTP、POP3、HTTP等)、主机资源(如CPU负载、磁盘利用率)以及其他应用,并在发生故障时...

    linux下cacti和nagios安装和整合.docx

    ### Linux下Cacti和Nagios安装及整合知识点 #### Cacti安装部署 **Cacti** 是一种基于 PHP 的开源网络监控系统,它能够通过 SNMP 协议从远程设备收集数据,并利用 RRDTool 来绘制图表。这对于 Linux 系统管理员来...

    项目基于shell、python,开发的运维脚本工具库

    实现快速安装nginx、mysql、php、redis、nagios、运维经常使用的脚本等等... 简单 高效 快捷!Linux下很多操作命令,都可以根据业务需求通用化,脚本化,关键是思路,很多LAMP/LNMP一键安装包,也是这样。脚本化后,...

    lamp软件包

    - 监控:使用Nagios、Zabbix等工具监控服务器状态,确保系统健康运行。 通过LAMP软件包,你可以快速搭建一个完整的Web开发环境,为创建复杂而高效的Web应用提供强大支持。如果你在搭建过程中遇到任何问题,可以联系...

    快捷运维,,项目基于shell、python,运维脚本工具库+源代码+文档说明

    - 实现快速安装nginx、mysql、php、redis、nagios、运维经常使用的脚本等等... - 简单 高效 快捷! - Linux下很多操作命令,都可以根据业务需求通用化,脚本化,关键是思路,很多LAMP/LNMP一键安装包,也是这样。 -...

Global site tag (gtag.js) - Google Analytics