Custom monitoring server with nagios and cacti

    Under a cat tips on the rapid deployment of a "monitoring system" through nagios and cacti.

    Suppose there is a pristine server with debian lenny preinstalled. And we have to make an amusement park with blackjack and girls out of this shapeless mass. Hmm, although not, you probably still need to make a monitoring server with nagios and cacti.

    First of all, you need to install an ssh server and mc (midnight commander), I think to comment on why and why we do it unnecessarily. Next we put nagios. We will set it in a “kosher” way, using apt. This will save us from the problem of dependencies, many hours of climbing in the wilds of configuration files and reduce the deployment time of the system. And so, we recruit the magic team
    debian:~# apt-get update
    debian:~# apt-get install openssh-server
    debian:~# apt-get install mc





    debian:~# apt-get install nagios3

    and, voila, we have already installed nagios in a minimal configuration. What happened? The package manager looked at the dependencies for the nagios3 package. In addition to the basic package, plugins for nagios, apache and many, many necessary libraries were installed.
    Minimal configs for nagios and apache were also created. In theory, everything should "work out of the box", but as usual you have to use a file.

    As we can see, in the /etc/nagios3/nagios.conf config it is indicated that ordinary http authorization is used to access nagios, but unfortunately there is no authorization file.
    In order to fix this mournful fact, we will create it with a team. Please note that the user must be exactly nagiosadmin, and not Vasya, Lucy or Petruchio.
    debian:~# htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin
    New password:
    Re-type new password:
    Adding password for user nagiosadmin


    This is due to the fact that by default in nagios.cfg the user with access to all functions is nagiosadmin.

    We include the processing of external commands, a thing needed, for example, for “Re-schedule the next check of this host”.
    debian:~# mcedit /etc/nagios3/nagios.cfg

    check_external_commands=1

    We change permissions and owners Installation of nagios3 is completed. We can go into the nagios3 interface by typing in your favorite browser http: // youre_server_ip / nagios3 Now, with a clear conscience, let's proceed to its configuration. You can immerse yourself in configuration files and edit them for hours, getting indescribable satisfaction with multiple orgasms from this process. Or perform the act of setting up the nagios through the web interface. For example, applying NagiosQL.
    chown -R nagios.www-data /var/lib/nagios3
    chmod -R 770 /var/lib/nagios3/spool
    chmod 644 /etc/nagios3/resource.cfg





    In order to observe the "kosher" installation of NagiosQL, we add a repository with the selected NagiosQL to the list of repositories.
    The list of repositories can be found in /etc/apt/sources.list: Next, to get only NagiosQL from the debian.swobspace.net repository, create the file / etc / apt / preferences and specify in it our preferences for installing packages. We get and import keys for debian.swobspace.net repository. Updating the list of packages. Installing NagiosQL. This is where we fully see the advantage of the “kosher” approach in installing packages, the dependencies were php, mysql, the necessary modules and libraries. No need to puzzle why some function does not work, or why the schedule is not generated.

    deb http:// debian.swobspace.net lenny main
    deb-src http:// debian.swobspace.net lenny main


    debian:~# touch /etc/apt/preferences



    Package: *
    Pin: origin debian.swobspace.net
    Pin-Priority: 200

    Package: nagiosql
    Pin: origin debian.swobspace.net
    Pin-Priority: 600



    debian:~# wget http:// www.swobspace.net/wob@swobspace.net.pub.asc -O- | apt-key add -


    debian:~# apt-get update


    debian:~# apt-get install nagiosql


    During installation, you will be asked root password to access the mysql database, be sure to write it down on a piece of paper.

    Setting
    1. Activate the NagiosQL installer 2. Go to http: // youre_server_ip / nagiosql and perform the installation in the intuitive web interface, this is where the piece of parchment on which we wrote down the mysql root password with obscure scribbles will be required. 3. After a successful installation, deactivate the NagiosQL installer for reliability, you can delete the entire folder with the installer 4. Add a line to /etc/nagios3/nagios.cfg. 5. Create the folder / etc / nagios / import and copy all the configs from /etc/nagios3/conf.d and / etc / nagios-plugins / into it. And import them into NagiosQL. Data import is carried out in the menu Tools => Data import
    debian:~# touch /usr/share/nagiosql/htdocs/install/ENABLE_INSTALLER




    debian:~# rm -f /usr/share/nagiosql/htdocs/install/ENABLE_INSTALLER

    debian:~# rm -rf /usr/share/nagiosql/htdocs/install


    cfg_dir=/etc/nagiosql/domains/localhost




    6. We throw in the trash a sheet with the recorded root password for mysql.

    Next, you have to deal with NagiosQL yourself, google translate to help you.

    Installing cacti itself, like nagios, is very straightforward.

    debian:~# apt-get install cacti

    You will again see a rather large list of dependencies, without hesitation type Yes. During the installation process We again need an unfortunate leaflet with a password from mysql, in vain we probably threw it into the trash.

    It remains to configure cacti, everything is simple here, as with NagiosQL. Intuitive interface.
    http: // youre_server_ip / cacti
    Standard login and password for access to cacti: admin / admin.

    Now, suppose we have a server from which we will take data and draw graphs on them.
    We will take data using snmpd. We
    install snmpd on the server from which we will take data (again, I mean that the server has debian lenny).
    shaper:~# apt-get install snmpd

    in the / etc / default / snmpd config, change the ip address on which the snmpd daemon will accept requests

    shaper:~# mcedit /etc/default/snmpd

    instead of
    SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
    changing the
    SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid you_server2_ip'

    Add a line to the file /etc/snmp/snmpd.conf

    rocommunity my_snmp_community youre_server_ip

    rocommunity- read-only access is allowed
    my_snmp_community- snmp community for access to data
    youre_server_ip- ip from which is allowed access to the daemon

    Reboot snmp
    shaper:~# /etc/init.d/snmpd restart

    Further operations are done in the interface Cacti
    Console => Management => Devices => Add (Top right corner)
    Descpription - machine description
    Hostname - IP
    Host Template - udc / net SNMPD Host

    SNMP Version - Version 2

    SNMP Community - snmp community specified on the server

    Click Create
    If after that we see

    Ping Results
    Host is alive

    Click Create Graphs for this Host We
    put the “checkboxes” on the graphs that you want to draw and click Create (for gigabit interfaces you need select in the selector select a graph type - In / Out Bits (64-bit Counters))

    If everything went well again, we can add “our server” to the graph tree
    Console => Management => Graph Trees => Default Tree => Add (Top right corner)

    Tree Item Type - select Host
    Host - our server

    Click Create.
    And after 5-10 minutes we enjoy the schedules.

    Mercilessly destroying the sheet with the recorded root password for mysql

    It took us no more than half an hour to configure the basic monitoring server. Again, please note the basic.
    The rest is in your hands, as they say, no one restricts the flight of fantasy, the main thing is not to abuse hallucinogens.

    Also popular now: