Centos Nagios Centreon Kickstart

Centos Nagios Centreon Kickstart

Centos Nagios Centreon Kickstart 150 150 Roderick Derks

Centos 5.6 x86. Easily adjustable for 64-x86
Ready for Compact Flashcard in a Nagios Satellite
Ready for testing on a VMware Virtual Machine (you would normally use a 64 bit OS in a VM.

 

# Kickstart file generated by Roderick Derks.
# Centos 5.6
# 20120218 gereed genaakt voor Compact Flash Card 8GB

#version=DEVEL
install
url --url http://freenas02.r71.nl:8080/Centos_5.6-x86/cd1/
lang en_US.UTF-8
keyboard us
timezone --utc Europe/Amsterdam
rootpw  --iscrypted $6$AFQ9hKwPBKDUZwXd$E9nM0G2GBa4h2wDoG3D4mbK/fhpg.ER0RovPd4c5zKLHXjv7APZ7/rDAcDSvpFa2CBqq9rEdyZHYw/eY13EON.
selinux --disabled
authconfig --enableshadow --passalgo=sha512 --enablefingerprint
firewall --enabled --ssh --http

#ask for network config during installation
#network --device=eth0 --bootproto=query

#network --device eth0 --bootproto static --ip 10.0.2.100 --netmask 255.0.0.0 --gateway 10.0.1.254 --nameserver 10.0.2.11,10.0.2.12 --hostname tv01.r71.nl
network --device eth0 --bootproto static --ip 10.0.2.101 --netmask 255.0.0.0 --gateway 10.0.1.254 --nameserver 10.0.2.11,10.0.2.12 --hostname sat01.r71.nl
#network --device eth1 --onboot no --bootproto dhcp --hostname tv01.r71.nl

reboot

bootloader --location=mbr --driveorder=sda --append="acpi=off"

# USB drive 8GB
#clearpart --all --drives=sda
#part /boot --fstype ext3 --size=100 --ondisk=sda
#part pv.6 --size=0 --grow --ondisk=sda
#volgroup VolGroup00 --pesize=32768 pv.6
#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1000 --grow --maxsize=2016
#logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=5000 --grow

# Compact Flash Card 8GB
#clearpart --all --drives=hda
#part /boot --fstype ext3 --size=100 --ondisk=hda
#part pv.3 --size=0 --grow --ondisk=hda
#volgroup VolGroup00 --pesize=32768 pv.3
#logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=6496
#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1024

# VMware x86 GUEST
clearpart --all --drives=sda
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.3 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.3
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=6496
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1024

#%packages
#@core
%packages --nobase
kernel-PAE
bzip2
crontabs
dhclient
logrotate
openssh
openssh-clients
openssh-server
pam_passwdqc
sudo
perl
tcpdump
telnet
wget
which
yum
- -audit-libs-python
- -checkpolicy
- -dhcpv6-client
- -ecryptfs-utils
- -ed
- -file
- -gnu-efi
- -gpm
- -hdparm
- -kbd
- -libhugetlbfs
- -libselinux-python
- -libsemanage
- -nspr
- -nss
- -policycoreutils
- -prelink
- -selinux-policy
- -selinux-policy-targeted
- -setools
- -setserial
- -sysfsutils
- -tcl
- -udftools
- -vim-enhanced

#PRE
#%pre
#sleep 1

# POST
%post --log=/root/kickstart-post-log

#import key to be able to use Centos Repo
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

# remove not needed packages
yum -y remove kernel iptables slang usermode wireless-tools
yum -y remove cryptsetup-luks dbus dmidecode hwdata libgpg-error libusb
yum -y remove libvolume_id libxml2-python pciutils
#yum -y remove cyrus-sasl-lib logrotate

###############################################
### from here files are added to the new system
###############################################

######################################################
### Install script for after the first reboot
######################################################

cat >> /root/rict_install01.sh <<_POST01

# disable selinux
setenforce 0
sed -i -e 's/\(^SELINUX=\).*$/\1disabled/' /etc/sysconfig/selinux

# Install Forge Repo
cd /tmp
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm

# update Centos
#yum -y check-update
#yum -y update

# install NTP
yum -y install ntp
ntpdate nl.pool.ntp.org
service ntpd start
chkconfig --level 345 ntpd on

# install apache and php
yum -y install httpd php
service httpd start
chkconfig --level 345 httpd on

# install snmpd
yum -y install net-snmp-utils net-snmpd net-snmp-perl
service snmpd start
chkconfig --level 345 ntpd on

# install rsync
yum -y install rsync

###### tot hier werkt 't
###### Nu Nagios Installeren

# installeer GD libraries voordat Nagios wordt gecompiled
yum -y install gd gd-devel

# download Nagios
cd /tmp
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.3.1.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz

# Install Nagios
#service iptables stop
yum install make gcc kernel-devel -y
service httpd start
cd /tmp/
tar xvzf nagios-3.3.1.tar.gz
cd nagios
adduser nagios
mkdir /usr/local/nagios
chown nagios:nagios /usr/local/nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd apache
/usr/sbin/usermod -G nagcmd nagios
./configure --prefix=/usr/local/nagios --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-webconf
chkconfig --add nagios
chkconfig --level 345 nagios on

# Set some nagios rights
mkdir /usr/local/nagios/var/rw
chown nagios:nagcmd /usr/local/nagios/var/rw
chown nagios:nagcmd /usr/local/nagios/var/rw/nagios.cmd

mkdir /usr/local/nagios/libexec/360viewpoint
chown nagios:nagios /usr/local/nagios/libexec/360viewpoint

# create users to login to the website
mkdir /usr/local/nagios/etc/apache
chown nagios:nagcmd /usr/local/nagios/etc/apache
htpasswd -bc /usr/local/nagios/etc/apache/htpasswd.users nagiosadmin 360viewpoint
htpasswd -b /usr/local/nagios/etc/apache/htpasswd.users roderick 360viewpoint

# Apache reload
service httpd restart
service nagios start

# install and compile NDOMOD
cd /tmp
wget http://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b9/ndoutils-1.4b9.tar.gz/download
tar xvzf ndoutils-1.4b9.tar.gz
cd ndoutils-1.4b9
./configure --prefix=/usr/local/nagios/ --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
make
cp ./src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
chmod 774 /usr/local/nagios/bin/ndo*
chown nagios:nagios /usr/local/nagios/bin/ndo*
cp config/ndo* /usr/local/nagios/etc/

# install nagios plugins
cd /tmp/
tar xvzf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure
make
make install

# preperations for a centreon/nagios satellite
mkdir -al /etc/centreon-broker/
chown nagios:nagcmd /etc/centreon-broker/
chmod 775 /etc/centreon-broker/
mkdir /usr/local/nagios/etc/serviceext/
chown nagios:nagcmd /usr/local/nagios/etc/serviceext/

_POST01

# set executable rights for the script
chmod +x /root/rict_install01.sh

##############################################################################
### rc.local file adjustment so that script above will start after first boot
##############################################################################

# backup originele rc.local maken
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.backup
# test:
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.backup2

#info toevoegen aan rc.local
cat >> /etc/rc.d/rc.local <<_POST02
    # eenmalig uitvoeren  scripts
    echo ---- UITVOEREN SCRIPT /root/rict_install01.sh
    /root/rict_install01.sh
    # Terugplaatsen rc.local.backup naar rc.local (restoren van origineel)
    # waardoor eenmalige uitvoer  script is gegarandeerd
    cp /etc/rc.d/rc.local /root/rc.local
    mv -f /etc/rc.d/rc.local.backup /etc/rc.d/rc.local

_POST02

#################################
### Apache config file for Nagios
#################################

cat >> /etc/httpd/conf.d/nagios.conf <<_POST03
# Roderick Derks

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

<Directory "/usr/local/nagios/sbin">

   AuthType Basic
   AuthName "Nagios Access"

   Options Indexes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
   Require valid-user

   # Lokale autenticatie file ipv LDAP
   AuthUserFile /usr/local/nagios/etc/apache/htpasswd.users

</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
   Options None
   AllowOverride AuthConfig
   Allow from all

</Directory>

_POST03

###################
### NTP config file
###################

cat >> /etc/ntp.conf <<_POST04
# Roderick Derks
# info@roderick-ict.nl

restrict default nomodify notrap noquery
restrict 127.0.0.1
server nl.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server    127.127.1.0    # local clock
fudge    127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
broadcastdelay    0.008
keys        /etc/ntp/keys

_POST04

#####################
### SNMPD config file
#####################

cat >> /etc/snmp/snmpd.conf <<_POST05
# Roderick Derks
# info@roderick-ict.nl

rocommunity public
rwcommunity r71
syslocation “datacenter r71”
syscontact info@roderick-ict.nl
includeAllDisks

_POST05

Roderick Derks

Liefhebber van fietsen, van het oplossen van IT puzzels, en van het delen van informatie om anderen te helpen.

All stories by:Roderick Derks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Your Name (required)

Your Email (required)

Subject

Your Message

Your Name (required)

Your Email (required)

Subject

Your Message