Kontrollbase - MySQL Monitoring


Kontrollbase Client setup process on Ubuntu / Debian Servers

These instructions apply to the following Linux flavors: Ubuntu, KUbuntu, Debian. In fact, most Linux'es that use apt-get will see this document as useful. This has been tested on Ubuntu 8.10

Important:  The following Perl modules are required to be on each client server. If you don't have them installed the client script will fail to run. The first example installs one required module. Repeat as needed for the other modules. If they are not available on apt-get you can get them on CPAN.

Perl-5 Modules: Net::SNMP, Getopt::Long, POSIX, Sys::Hostname, DBI, Time::HiRes .

1. Setup MySQL user for Kontrollbase on Client Server

Note: You need to create the "kontrollbase" user on every client server that Kontrollbase will be monitoring. The account needs the following permissions: SELECT,PROCESS on every single schema that will be monitored.

--(1)> mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4332 Server version: 5.0.67-0ubuntu6-log (Ubuntu) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> grant SELECT, PROCESS, SUPER, REPLICATION CLIENT on *.* to 'kontrollbase'@'localhost' identified by 'password-here'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)

2. Install SNMP and SNMPd using apt-get

Here we will install the apt-get version of SNMP and SNMPd so that Kontrollbase can query the client server's OS information. ROOT-(0)> apt-get install snmp snmpd Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: snmp snmpd 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 231kB of archives. After this operation, 1008kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com intrepid-updates/main snmp 5.4.1~dfsg-7.1ubuntu6.1 [156kB] Get:2 http://us.archive.ubuntu.com intrepid-updates/main snmpd 5.4.1~dfsg-7.1ubuntu6.1 [74.5kB] Fetched 231kB in 1s (147kB/s) Preconfiguring packages ... Selecting previously deselected package snmp. (Reading database ... 125559 files and directories currently installed.) Unpacking snmp (from .../snmp_5.4.1~dfsg-7.1ubuntu6.1_i386.deb) ... Selecting previously deselected package snmpd. Unpacking snmpd (from .../snmpd_5.4.1~dfsg-7.1ubuntu6.1_i386.deb) ... Processing triggers for man-db ... Setting up snmp (5.4.1~dfsg-7.1ubuntu6.1) ... Setting up snmpd (5.4.1~dfsg-7.1ubuntu6.1) ... * Starting network management services:

3. Modify the config file

We only need the most basic setup for snmpd. If you already have snmp running on your client server(s) then make sure the host settings reflect the correct read-only community string for said client server so that Kontrollbase can properly poll the system information using a local-listening snmpd. ROOT-(0)> cd /etc/snmp/ ROOT-(0)> cp snmpd.conf snmpd.conf.orig ROOT-(0)> echo "rocommunity public" > snmpd.conf ROOT-(0)> /etc/init.d/snmpd restart * Restarting network management services: [ OK ]

4. Create Kontrollbase system user on client server and set password

If your server is setup to use a non-passwd style authentication scheme then go ahead and add the required user in the other manner. We'll only discuss the system passwd/shadow authentication method here. ROOT-(0)> useradd -m kontrollbase ROOT-(0)> passwd kontrollbase Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully

5. Login remotely, create ssh-key and then copy public key to authorized_keys file

ROOT-(0)> ssh kontrollbase@192.168.0.105 kontrollbase@192.168.0.105's password: $ ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/home/kontrollbase/.ssh/id_dsa): Created directory '/home/kontrollbase/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/kontrollbase/.ssh/id_dsa. Your public key has been saved in /home/kontrollbase/.ssh/id_dsa.pub.
Here you will want to get the id_dsa.pub or id_sha.pub key from the user you're running Kontrollbase as on the Kontrollbase server, and paste that key into the kontrollbase client servers's user authorized_keys file. Then we'll set the proper permissions on the file to ensure we can use it for keybased authentication. $ emacs .ssh/authorized_keys (note: paste the key into this file) $ chmod 644 .ssh/authorized_keys

6. Login again to make sure ssh key is working correctly.

Using ssh from the Kontrollbase server, login to the Kontrollbase client server that we're working on. ROOT-(0)> ssh kontrollbase@192.168.0.105 Linux human 2.6.27-11-generic #1 SMP Thu Jan 29 19:24:39 UTC 2009 i686 Last login: Wed Mar 4 18:56:49 2009 from node1

7. copy the kontrollbase client script to the host

Using the scp command, copy the Kontrollbase client script to the server that we're working on. You have to put the script into the user's home directory - no where else. ROOT-(root@node1)-(/var/www/html/kontrollbase/bin)-ROOT ROOT-(0)> scp kontroll-client-5.0.x_linux-x86.pl kontrollbase@192.168.0.105:. kontroll-client-5.0.x_linux-x86.pl 100% 19KB 19.4KB/s 00:00

8. Install perl modules if needed

See note at the top of this page if you need to know what this step is about. $ apt-get install libnet-snmp-perl Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: libcrypt-des-perl libdigest-hmac-perl libdigest-sha1-perl libio-socket-inet6-perl The following NEW packages will be installed: libnet-snmp-perl 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 112kB of archives. After this operation, 532kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com intrepid/main libnet-snmp-perl 5.2.0-1 [112kB] Fetched 112kB in 1s (72.5kB/s) Selecting previously deselected package libnet-snmp-perl. (Reading database ... 125704 files and directories currently installed.) Unpacking libnet-snmp-perl (from .../libnet-snmp-perl_5.2.0-1_all.deb) ... Processing triggers for man-db ... Setting up libnet-snmp-perl (5.2.0-1) ...

9. Test the client script without flags




Note: If you get the same output as above, that means your client server is ready to be polled by the Kontrollbase server. Later we will test the script with the correct MySQL flags.

10. Symlink the cnf file

We need the cnf file to be in the same place on all servers - since Kontrollbase was designed for Redhat servers we're going to symlink the MySQL cnf file to the Redhat location - it's ok, this is a better place for it :) --(0)> sudo ln -s /etc/mysql/my.cnf /etc/my.cnf

11. Run the client script with MySQL testing flags

Run the client with the help flag to get the default options. This way you can tell if you need to specify things differently. --(0)> ./kontroll-client-5.0.x_linux-x86.pl --help #################################### kontroll-client_linux-x86.pl Gets OS and MySQL stats, outputs XML http://kontrollsoft.com package version: 2.0 #################################### --help = this message --snmp-host = snmp host address --snmp-port = snmp port --snmp-retries = snmp retries --snmp-rocomminity = snmp rocommunity --snmp-timeout = snmp timeout --snmp-version = snmp version --mysql-user = mysql username --mysql-pass = mysql password --mysql-port = mysql port --mysql-db = mysql database --mysql-host = mysql host defaults if variables not specified snmp-host: localhost snmp-port: 161 snmp-rocommunity: public snmp-version: 1 snmp-timeout: 5 snmp-retries: 2 mysql-user: root mysql-pass: mysql-port: 3306 mysql-db: mysql mysql-host: 127.0.0.1

12. Then run the script with the user we created on the server for Kontrollbase

Pass the user and password to the script from the user we created on the client server. If the script outputs a long list of XML data and no errors the your client server is ready to be added to the host panel in Kontrollbase!