This are some problems that you may encounter after installing Munin:

Apache modules are not tracking, so they are not showing statistics, you may want to check Munin logs (specifically /var/log/munin/munin-node.log) to see what is going on.

If you got something like Can’t locate object method “new” via package “LWP::UserAgent”, you need to install the package libwww-perl which contains the LWP::UserAgent required. Thanks to Crowdway.

If you already have installed the libwww-perl package, but Munin is still not showing data, you may need to enable and configure the status module on Apache. Make sure you allow localhost (and the name of the server as well) to access the location server-status on apache2.conf or status.conf. Also, this plugins need the ExtendedStatus flag to be On.

You should have something like:

<IfModule mod_status.c>
#
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Uncomment and change the ".example.com" to allow
# access from other hosts.
#
ExtendedStatus On
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from localhost ip6-localhost
    Allow from vps02.graphium.net
    #Allow from .example.com
</Location>
<IfModule>

Sometimes you can get permission errors on your logs, so the best way to get rid of them is to ensure that all involved files in Munin process are own by munin user and group. We can run as root:

 $ chown -R munin.munin /var/lib/munin /var/log/munin /var/www/munin

There are some plugins that require a parameter to work. For example, those that refer to networking (if_, if_err_, ip_) needs the network interface we want to track. In my case (VPS), this is venet0, but on a usual box it can be eth0.

We can list the available interfaces by running the command:

$ ifconfig

Then, to correctly enable this modules, we need to append the name of the interface:

$ ln -s /usr/share/munin/plugins/if_ /etc/munin/plugins/if_venet0

A convenient way to see the result of each module, we can run them independently:

$ munin-run apache_processes
busy80.value 7
idle80.value 1
$ munin-run if_venet0
down.value 7721322
up.value 37550800

By this command, we can ensure that the plugin is working fine and getting results.

Tags: , , , ,

Munin is a small tool for monitoring resources on servers. I think it is very useful, specially on small VPS, that needs to save resources. Reports are written as HTML files, so we will need a Web Server like Apache to see this reports.

First, we install it and add some extra plugins:

$ sudo apt-get install munin munin-plugins-extra

Now, we can make some changes to the default configuration, located at /etc/munin/munin.conf. For example, we can change any of the paths where Munin works:

dbdir /var/lib/munin
htmldir /var/www/munin
logdir /var/log/munin
rundir /var/run/munin

Specially, the htmldir path, where all the reports are written to see through Apache or the one you are using. Remember to move the directory /var/www/munin to where you wanted if you change that configuration line. We can protect this directory with an htaccess file to only give access to some users.

We can configure email notifications if a change occur (like from a OK situation to a WARNING). To do this, we just need to uncomment or add the following line:

contact.someuser.command mail -s "Munin notification" your@email.com

By default, Munin will monitor localhost, but we can add other boxes (clients), these machines will only need to install munin-node package.

Then, we can enable some plugins (more plugins can be found here and here). To do this, we need to create a symbolic link per each plugin we want to activate. I’m going to enable apache and mysql modules, but you are free to enable the modules you need:

$ cd /etc/munin/plugins
$ sudo ln -s /usr/share/munin/plugins/apache_* .
$ sudo ln -s /usr/share/munin/plugins/mysql_* .

Each time a module is enable or disable, we need to restart the service, so we can do the following:

$ sudo /etc/init.d/munin-node restart

Also, it is recommended to reassign all files on the htmldir to munin user and group by doing:

$ sudo chown munin.munin -R /var/www/munin

And then, to avoid waiting 5 minutes until munin cron runs again, we force it by:

$ sudo /usr/bin/munin-cron --force-root

If we are not completely satisfied with the default template, we can modify it, they are HTML files (with some minor special template tags). Anyone with some knowledge of HTML and CSS can do that. We can even download other already created templates (I have found some errors on that template’s JavaScript, I hope I’ll get some time to post the modified template, in the meanwhile, if anyone need it, please drop me a line to send you the files).

Finally, as this post is not as complete as I would like, I leave some links that may help:

Tags: , , , , ,

On my work, I have a box with WinXP, running Virtual Box as a host, and a Ubuntu Server 9.10 box as a guest. My problem is that the firewall on the corporate network does not allow Ubuntu to update the date and time against any NTP server (like pool.ntp.org or ntp.ubuntu.com). So, I need a way to keep the hour updated on the guest. Fortunately, VirtualBox has the ability to synchronize it from the host, the only thing I need to do was to install the Guest Additions package.

To do this, first, we need to click on Devices/Install Guest Additions (from the VirtualBox menu).

Then, on the Ubuntu Server, we install some pre-requisites:

$ aptitude install build-essential linux-headers-$(uname -r) -y

Now, we will mount the virtual CD-ROM (where the Guest Additions are):

$ mount /dev/cdrom /mnt/

And then, run the installer script (there is a 32-bit and 64-bit versions). For 32-bit (which is the most probable, as VirtualBox Open Source only supports 32-bit guests):

$ /mnt/VBoxLinuxAdditions-x86.run

Or for 64-bit guest:

$ /mnt/VBoxLinuxAdditions-amd64.run

It should install the available modules (like timesync), and drop a fail message saying that X server
was not found, which is OK as we are working with a server without GUI.

Finally, we umount the CD-ROM:

$ umount /mnt/

Now, the guest box time should be sync with the host, so we have one less thing to worry about.

Tags: , , ,

This will be a series of posts about configuring a Linux server (I’m working with Ubuntu, but should work with minor changes with other distributions), mainly because I have done this several times now by reviewing different websites and blogs, so I wanted to do a guide that works for me (and maybe for others too).

First, we create a user to avoid the use of root (in case you are not using the default Ubuntu installation, that asks you to create a user):

$ adduser myuser
Adding user 'myuser' ...
Adding new group 'myuser' (1000) ...
Adding new user 'myuser' (1000) with group 'myuser' ...
Creating home directory '/home/myuser' ...
Copying files from '/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for myuser
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y

It is also possible to use the command useradd (that is a linux command itself, not that user-friendly) instead of useradd (this one is a perl script that makes a little more easy user creation).

We need to assign add this user to the sudoers (users that are able to use the sudo command to make changes to the system).

$ visudo

And add the following line:

myuser  ALL=(ALL) ALL

Then, we need to hardening SSH server (be very careful about this modifications because if SSH is the only way you have to configure your server, any error may left you lock out of your box).

Before making any change, we better make a backup of our original config file:

$ cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bk

Then, we need to change the following parameters on /etc/ssh/sshd_config:

  • Port Number: Change it to any random port number, try to use one that any known service uses, see the list of services in here.
  • Listen Address: Instead of listen to every interface on your server, just listen to the main IP address.
  • Protocol: Make sure that this parameter is set to 2 (instead of 2, 1).
  • If possible, avoid root login by disabling PermitRootLogin. All root operations can be done using sudo command (at least on Debian/Ubuntu based distributions). Make sure you have created other users on your box, and add them to the allow list of users to log through SSH (AllowUsers [username1] [username2] parameter).
  • Disable X11Forwarding.
  • Replace password authentication with Public/Private Keys. To do this, make sure your users have their Private Keys and the Public Keys are configured on the server. Then, disable PasswordAuthentication and UsePAM parameters. Make sure that RSAAuthentication and Pubkeyauthentication parameters are enabled.
  • If you have noticed that OpenSSH server may take a while from the moment you enter your username and the password prompt, it is because it tries to make some DNS resolves. You can avoid this by disabling UseDNS parameter.

You should end with a file like this:

Port XXXX
ListenAddress XXX.XXX.XXX.XXX
[...]
PermitRootLogin no
[...]
RSAAuthentication yes
PubkeyAuthentication yes
[...]
PasswordAuthentication no
[...]
X11Forwarding no
[...]
UsePAM no
UseDNS no
AllowUsers myuser user2

Then, we need to restart the SSH server by doing:

$ /etc/init.d/ssh restart

Do not close your current session, just open another to your box using the new port, this way we make sure we are not locked out of it.

On the next post I will be configuring IPTables as a firewall for our box.

UPDATE 17/Apr/2010: Parameter PasswordAuthentication included for disabling keyboard-interactive authentication.

In this link you can find a very good explanation about the main options on SSH config file.

Tags: , , ,

I have noticed that my Ubuntu box is lately always trying to reach a SMTP server (detected through Wireshark tool). After reviewing the list of running processes that contains the word mail (running ps aux | grep mail on console), I found a couple of them called Nullmailer that seems the responsible of that and indeed, it was.

So a Google search led me to this thread, where in that case, Nullmailer registered entries on Syslog (which possible happened on my computer also). The messages that Nullmailer was trying to send were related to Cron jobs output. So, the solution was to delete the queue of messages of this program, located on /var/spool/nullmailer/queue/.

Tags: , , ,

Durante la migración de la web de DeChalaca desde el servicio Grid-Service de MediaTemple hacia un nuevo VPS, el último punto que quedó por resolver fue que las fechas en la web se mostraban en inglés (aunque el Joomla estaba configurado para que lo hagan en español). El problema era que el servidor, un flamante Ubuntu 8.04, no tenía instalado las locales del español. La solución fue muy sencilla (como root):

$ cd /usr/share/locales
$ ./install-language-pack es_ES
$ ./install-language-pack es_PE

Para ver la lista de locales que están instalados en el sistema, se utiliza el siguiente comando:

$ locale -a

Tags: , ,

Luego de haber instalado Windows 7 hace algunos meses, en un equipo donde tenía tanto el Windows XP como Ubuntu 9.04, quedó inaccesible este último. Esto debido a que el instalador de Windows no reconoce otro sistema operativo que no sea propio de Microsoft (a diferencia de Linux).

Se debe tomar en cuenta NO utilizar el Live CD de Ubuntu 9.10 para restaurar el Grub de las versiones anteriores de Ubuntu. Esto debido a que Ubuntu 9.10 y posteriores utilizan Grub2, que difiere mucho de la primera versión.

Lo primero que se debe hacer es iniciar la máquina con algún Live CD de Linux (como el de Ubuntu, que es el que utilicé en el proceso).

Una vez que está funcionando, abrimos un terminal. Vamos a necesitar los privilegios del root, por lo que lo más práctico sería ir al shell respectivo:

sudo -i

Luego, creamos un punto de montaje para la partición de Ubuntu:

mkdir /mnt/linux

Después, montamos la partición:

mount /dev/sda2 /mnt/linux

Donde sda2 (sd porque es un disco SATA, a por ser el primer disco duro, y 2 por ser el número de la partición) es la partición donde se encuentra Ubuntu. Si no estamos seguros de cual es la partición, podemos usar el programa GParted (visual) o el comando:

fdisk -l

Una vez que está montada la partición, podemos corroborar que sea la partición listando los archivos en ella:

ls -la /mnt/linux
ls -la /mnt/linux/boot

Luego de que estamos seguros que es la partición correcta, pasamos a reinstalar el Grub mediante el siguiente comando:

grub-install --root-directory=/mnt/linux /dev/sda

En caso aparezca algún error o advertencia, podemos probar el siguiente comando:

grub-install --root-directory=/mnt/linux /dev/sda --recheck

Donde sda hace referencia al disco (usualmente el primario) cuyo MBR será utilizado para instalar el Grub (ojo que NO incluye el número de partición).

Reiniciamos y deberíamos ver ya el menú de booteo del Grub.

Vía: Ubuntu Documentation

Tags: , , , ,

Hace un rato me vi en la necesidad de borrar todos los directorios .svn (aquellos que coloca Subversion en cada directorio de nuestra copia de trabajo para llevar el control de cambios). El problema era que esta copia de trabajo tiene una estructura de directorios bastante extensa, por lo que hacerlo manualmente no era una opción eficiente. Afortunadamente, desde la linea de comando de Linux podemos hacer lo siguiente:

find . -name ".svn" -exec rm -rf {} \;

Tags:

En los repositorios de Ubuntu Hardy (la última versión LTS liberada hasta este momento) sólo se puede encontrar subversion 1.4 debido a que en este tipo de versiones de Ubuntu, las versiones de los paquetes no se actualizan tan a menudo (salvo por correcciones y bugs) como uno quisiera.

Entonces, para poder instalar subversion 1.5, se debe hacer una pequeña maniobra. Primero, agregar lo siguiente al archivo /etc/apt/sources.list:

deb http://ppa.launchpad.net/clazzes.org/ubuntu hardy main

Luego, actualizamos la base de datos de paquetes:

$ aptitude update

Después procedemos a instalar este sistema de control de versiones:

$ aptitude install subversion

Cuando ya esté instalada esta versión, quitamos o comentamos (con un #) la línea agregada en /etc/apt/sources.list:

#deb http://ppa.launchpad.net/clazzes.org/ubuntu hardy main

Finalmente, volvemos a hacer un update de los paquetes:

$ aptitude update

Tags: , ,

Para ver la versión de Ubuntu que está corriendo mi server, hago lo siguiente:

$ cat /etc/*-release

El resultado en mi caso es:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04"

Este procedimiento sirve también para otras distribuciones como Red Hat.

Una forma alternativa de hacerlo es mediante:

$ cat /etc/issue

Que mostrará por ejemplo:

Ubuntu 8.04 "Hardy Heron" \n \l

Aunque esta forma solo funciona en Ubuntu. En otras distros pueden probar:

$ cat /etc/motd

O también:

$ cat /etc/redhat-version

Una tercera forma, para las distrbuciones que adoptan LSB, es mediante el comando:

$ lsb_release -a

Esto mostrará:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 8.04.2
Release:        8.04
Codename:       hardy

Tags: , , , ,