Install cn=monitor on Ubuntu 14.04 LTS

Here are some notes how I install cn=monitor v3.2.1 on Ubuntu 14.04 LTS
Tribut to Andreas Andersson for a great job http://cnmonitor.sourceforge.net/
Please refer to ”CN=Monitor 3.2.1.pdf” for more information.

Prereq is a ”vanilla” Ubuntu 14.04 LTS server

Install LDAP client

$ sudo apt-get install ldap-utils

$ dpkg --get-selections | grep ldap
ldap-utils		install
libldap-2.4-2:amd64	install

Avoid common name validation in certificates for LDAPS

$ vi /etc/ldap/ldap.conf
TLS_REQCERT  never

Install Apache2

$ sudo apt-get install apache2

Install PHP:

$ sudo apt-get install php5 php5-cli php5-ldap

$ dpkg --get-selections | grep php
libapache2-mod-php5     install
php5                    install
php5-cli                install
php5-common             install
php5-json               install
php5-ldap               install
php5-readline           install

Install MySQL:

$ sudo apt-get install mysql-server mysql-client php5-mysql

$ dpkg --get-selections | grep php
libapache2-mod-php5     install
php5                    install
php5-cli                install
php5-common             install
php5-json               install
php5-ldap               install
php5-mysql              install
php5-readline           install

key_buffer_size-depricated

Unzip cnmonitor-3.2.1-1.zip in /usr/share

$ sudo unzip cnmonitor-3.2.1-1.zip -d /usr/share

Install database schema

$ mysql -u root -p < /usr/share/cnmonitor/sql/mysql.sql

Restart Apache Web server

$ sudo service apache2 restart

Move config directory to /etc, create symbolic link and set file permissions:

$ sudo mv /usr/share/cnmonitor/config /etc/cnmonitor
$ sudo ln -s /etc/cnmonitor /usr/share/cnmonitor/config 
$ sudo chown -R root:www-data /etc/cnmonitor
$ sudo chmod -R 650 /etc/cnmonitor
$ sudo chmod -R +x /usr/share/cnmonitor/bin

Copy cnmonitor.conf to conf-available directory

$ sudo cp /usr/share/cnmonitor/conf/httpd/cnmonitor.conf /etc/apache2/conf-available/.

Enable cnmonitor configuration in Apache Web server

$ sudo a2enconf cnmonitor

Activate the new configuration

$ sudo service apache2 reload

Configure cn=monitor

Please refer to section ”5. Configuration” in CN=Monitor 3.2.1.pdf

View MySQL query log

http://dev.mysql.com/doc/refman/5.1/en/query-log.html

 

mysql> SHOW VARIABLES LIKE "general_log%";
+------------------+-----------------------------+
| Variable_name    | Value                       |
+------------------+-----------------------------+
| general_log      | OFF                         |
| general_log_file | /var/lib/mysql/neqali50.log |
+------------------+-----------------------------+
2 rows in set (0.00 sec)

mysql> SET GLOBAL general_log = 'ON';
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW VARIABLES LIKE "general_log%";
+------------------+-----------------------------+
| Variable_name    | Value                       |
+------------------+-----------------------------+
| general_log      | ON                          |
| general_log_file | /var/lib/mysql/neqali50.log |
+------------------+-----------------------------+
2 rows in set (0.00 sec)

mysql> SET GLOBAL general_log = 'OFF';
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE "general_log%";
+------------------+-----------------------------+
| Variable_name    | Value                       |
+------------------+-----------------------------+
| general_log      | OFF                         |
| general_log_file | /var/lib/mysql/neqali50.log |
+------------------+-----------------------------+
2 rows in set (0.00 sec)

mysql> exit

SASL authentication failed server smtp.gmail.com

Problem

After setting up smtp.gmail.com as relayhost for postfix I stumbled into problem when this showed up in /var/log/mail.log

SASL authentication failed; server smtp.gmail.com
https://accounts.google.com/ContinueSignIn
Please log in via your web browser and then try again.
Learn more at https://support.google.com/mail/bin/answer.py?answer=787

Solution

Allow access to your Google account via
https://accounts.google.com/DisplayUnlockCaptcha

Gmail SMTP server relay with Postfix in Ubuntu 12.04

Tribut to Diogo Esteves http://yaui.me/postfix-gmail-smtp-server-relay-ubuntu/

Prerequisites

$ sudo apt-get install postfix libsasl2-2 libsasl2-modules ca-certificates

Edit /etc/postfix/main.cf

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

Create file /etc/postfix/sasl_passwd

[smtp.gmail.com]:587 user.name@gmail.com:password
$ sudo chmod 400 /etc/postfix/sasl_passwd
$ sudo postmap /etc/postfix/sasl_passwd
$ cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem
$ sudo /etc/init.d/postfix reload

jinfo ”can’t attach to the process”

Tried to run jinfo on my Ubuntu 12.04 and got this error message:

$ ./jinfo <vmid>
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process

enabled debugging:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

and tried again:

$ ./jinfo <vmid>
Attaching to process ID <vmid>, please wait...
Debugger attached successfully.
Server compiler detected.
...
...
$ 

Solution found here:
http://blog.thecodingmachine.com/fr/content/fixing-java-memory-leaks-ubuntu-1104-using-jmap

Install Java 6 in Ubuntu

Java 6

Download jdk-6u45-linux-x64.bin from Oracle

$ chmod +x jdk-6u45-linux-x64.bin
$ ./jdk-6u45-linux-x64.bin
$ sudo mv jdk1.6.0_45 /opt
$ sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_45/bin/java" 1
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/jdk1.6.0_45/bin/javac" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/jdk1.6.0_45/bin/javaws" 1

$ sudo update-alternatives --set java /opt/jdk1.6.0_45/bin/java
$ sudo update-alternatives --set javac /opt/jdk1.6.0_45/bin/javac
$ sudo update-alternatives --set javaws /opt/jdk1.6.0_45/bin/javaws
($ sudo update-alternatives --config java)

Edit /etc/profile

JAVA_HOME=/opt/jdk1.6.0_45
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

Vi Vim Less

show hidden characters

:set list
:set nolist

show line number

:set number

Basic search and replaceEdit
The :substitute command searches for a text pattern, and replaces it with a text string.

:%s/foo/bar/g

Find each occurrence of ’foo’, and replace it with ’bar’.

:%s/foo/bar/gc

Change each ’foo’ to ’bar’, but ask for confirmation first.

:%s/\<foo\>/bar/gc

Change only whole words exactly matching ’foo’ to ’bar’; ask for confirmation.

:%s/foo/bar/gci

Remove all empty lines

:v/./d