20111020

fdupes: Buscar ficheros duplicados - fdupes: Find duplicate files

Seguro que a muchos de vosotros se os ha presentado la situación de tener que buscar duplicados en vuestros sistemas GNU/Linux, ya sea en local o en red.
Buscando por la red puedes encontrar utilidades ya sea para la línea de comandos o con GUI. La cosa es que yo suelo utilizar fdupes.
Esta utilidad nos permite buscar y, si los encuentra, borrar los ficheros duplicados en nuestros discos.
Instalar esta utilidad en (K)Ubuntu es tan sencillo como:
sudo apt-get install fdupes

Una vez instalado sólo debemos ejecutarlo sobre la unidad que queramos y esperar el resultado.
bdispatcher@laptop:~$ sudo fdupes -r /home/bdispatcher/docs/web/
/home/bdispatcher/docs/web/backup/diptico_trip.FH11
/home/bdispatcher/docs/web/diptico_trip.FH11

/home/bdispatcher/docs/web/backup/fonfo1.jpg
/home/bdispatcher/docs/web/fonfo1.jpg

/home/bdispatcher/docs/web/backup/NORMAL
/home/bdispatcher/docs/web/NORMAL

/home/bdispatcher/docs/web/backup/Gothic.TTF
/home/bdispatcher/docs/web/Gothic.TTF

Cómo muchos de vosotros supondréis, fdupes hace uso del MD5 de los ficheros para ver si se encuentran duplicados o no.
Para más info sobre el uso de este comando, you know, man.

Probably most of you have wondered yourselves about the amount of disk wasted becouse of duplicate files on your GNU/Linux systems.
You could find some utils searching the web, but I'll reccomend you fdupes which would allow you to search and delete, if exists, the duplicate files on your filesystem.
To install this utility on your K(Ubuntu) system you only have to type is:
sudo apt-get install fdupes

Once installed, you just have to run it and wait for the result:
bdispatcher@laptop:~$ sudo fdupes -r /home/bdispatcher/docs/web/
/home/bdispatcher/docs/web/backup/diptico_trip.FH11
/home/bdispatcher/docs/web/diptico_trip.FH11

/home/bdispatcher/docs/web/backup/fonfo1.jpg
/home/bdispatcher/docs/web/fonfo1.jpg

/home/bdispatcher/docs/web/backup/NORMAL
/home/bdispatcher/docs/web/NORMAL

/home/bdispatcher/docs/web/backup/Gothic.TTF
/home/bdispatcher/docs/web/Gothic.TTF

As you could guess fdupes use MD5 to find out if two files are the same.
To get more info about this command, you know, man. 

PS. I know, I know. My English is not good enought but, the more you help me, the more I learn.

20111018

CISCO ASA conceder acceso ASDM - CISCO ASA grant ASDM access

Estos días he tenido que configurar los Cisco ASA para permitir el acceso ASDM. El acceso se lo tengo que dar a la dirección ip 192.168.10.200 desde la interfaz SISTEMAS.
Para esto me he conectado por ssh (acceso que ya tenía y he entrado lo siguiente:
bdispatcher@laptop:~$ ssh admin@asa
admin@asa's password:
Type help or '?' for a list of available commands.
asa> enable
Password: *********
asa# conf t
asa(config)# http 192.168.10.200 255.255.255.255 SISTEMAS
asa(config)# wr
Building configuration...
Cryptochecksum: xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
89743 bytes copied in 3.560 secs (29914 bytes/sec)
[OK]
asa(config)# quit
asa# quit
Logoff
Connection to asa closed.
bdispatcher@laptop:~$

Para más info sobre la concesión y revocación de estos accesos:
http://www.cisco.com/en/US/docs/security/asa/asa72/configuration/guide/mgaccess.html

Those days I had to configure the Cisco ASA firewall to allow the ASDM access. The rule I need must permit the access to the ip address 192.168.10.200 from the SYS interface.
To do that I logged to the ASA using the already open ssh access and I entered the following:
bdispatcher@laptop:~$ ssh admin@asa
admin@asa's password:
Type help or '?' for a list of available commands.
asa> enable
Password: *********
asa# conf t
asa(config)# http 192.168.10.200 255.255.255.255 SYS
asa(config)# wr
Building configuration...
Cryptochecksum: xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
89743 bytes copied in 3.560 secs (29914 bytes/sec)
[OK]
asa(config)# quit
asa# quit
Logoff
Connection to asa closed.
bdispatcher@laptop:~$

If you need more info about granting and revoking access check this link:
http://www.cisco.com/en/US/docs/security/asa/asa72/configuration/guide/mgaccess.html

PS. I know, I know. My English is not good enought but, the more you help me, the more I learn.

20111003

Nagios DISK UNKNOWN - free space:|

Tengo a medio montar un servidor de Nagios para chequear el funcionamiento de los servidores y servicios de mi organización. Los chequeos que por ahora tengo configurado son los básicos, disco, CPU, memoria, etc.
La cosa es que los chequeos de algunas particiones de mis servidores GNU/Linux me arrojan el siguiente resultado:
     Status: UNKNOWN
     Status information: DISK UNKNOWN - free space: |

Lo primero es conectarme al servidor de Nagios y realizar el chequeo desde la línea de comandos:
bdispatcher@nagserver:~$ /opt/nagios/libexec/check_nrpe -H fileserver -p 5666 -c check_sdd1
DISK UNKNOWN - free space:|

Y obtengo el mismo resultado. Lo siguiente es conectarme al cliente de Nagios, y comprobar la ejecución del plugin check_disk desde este. Copio el chequeo tal cual lo tengo en el fichero nrpe.cfg y lo ejecuto en el terminal:
bdispatcher@fileserver:~$ /opt/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sdd1
DISK WARNING - free space: /opt/files/datos 3696 MB (12% inode=99%);| /opt/files/datos=25003MB;24188;27212;0;30236

Pues aquí sí que funciona. Después de mucho probar y poco pensar, me doy cuenta de que el problema es que el chequeo lo ejecuta el proceso nrpe, que se ejecuta con el usuario nagios, el cual no tiene permisos sobre la ruta /opt/files, así que no puede comprobar el espacio del disco montado sobre esa ruta:
nagios@fileserver:~$ df -h
S.ficheros          Tamaño Usado  Disp Uso% Montado en
/dev/sda1             4,9G  1,3G  3,4G  28% /
/dev/sdc1             9,7G  5,2G  4,1G  57% /opt/files
df: «/opt/files/datos»: Permiso denegado
tmpfs                 506M     0  506M   0% /dev/shm
nagios@fileserver:~$

Para resolverlo, basta con dar permisos a este usuario (más bien se los doy al resto de usuario y restrinjo el acceso más abajo en el árbol, y probamos de nuevo:
bdispatcher@fileserver:~$ sudo chmod 755 /opt/files
bdispatcher@fileserver:~$ su - nagios
nagios@fileserver:~$ df -h
S.ficheros          Tamaño Usado  Disp Uso% Montado en
/dev/sda1             4,9G  1,3G  3,4G  28% /
/dev/sdc1             9,7G  5,2G  4,1G  57% /opt/files
/dev/sdd1              30G   25G  3,7G  88% /opt/files/datos
tmpfs                 506M     0  506M   0% /dev/shm
nagios@fileserver:~$

Al ejecutar ahora el chequeo obtengo el resultado esperado:
bdispatcher@nagserver:~$ /opt/nagios/libexec/check_nrpe -H fileserver -p 5666 -c check_sdd1
DISK WARNING - free space: /opt/files/datos 3696 MB (12% inode=99%);| /opt/files/datos=25003MB;24188;27212;0;30236

Y con esto una piojera menos, y un warning más :-(

I am deploying a Nagios server to schedule some checks over the servers and the services on my organization. First of all, some of the basic checks like disk, CPU, memory, etc.
But some of the disk checks return an unknown status like this::
     Status: UNKNOWN
     Status information: DISK UNKNOWN - free space: |

The first that springs to my mind is to execute this check manually on the Nagios server:
bdispatcher@nagserver:~$ /opt/nagios/libexec/check_nrpe -H fileserver -p 5666 -c check_sdd1
DISK UNKNOWN - free space:|

With the same result, so the next step is to try it again but on the server which has the Nagios client installed. After a fast review of the nrpe.cfg configuration file to copy and paste the check and: 
bdispatcher@fileserver:~$ /opt/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sdd1
DISK WARNING - free space: /opt/files/datos 3696 MB (12% inode=99%);| /opt/files/datos=25003MB;24188;27212;0;30236

Wow!! It works here!! Some days and some tests after, I bump into the big clue. The checking process is executed by the nrpe, running with the user nagios, which has no permissions on the path /opt/files, so it can't check the free space available on the disk mounted on this path:
nagios@fileserver:~$ df -h
S.ficheros          Tamaño Usado  Disp Uso% Montado en
/dev/sda1             4,9G  1,3G  3,4G  28% /
/dev/sdc1             9,7G  5,2G  4,1G  57% /opt/files
df: «/opt/files/datos»: Permiso denegado
tmpfs                 506M     0  506M   0% /dev/shm
nagios@fileserver:~$

All I need to solve it is to give read and execution (access) permissions to this user. I'll cut the access on a lower level on the tree:
bdispatcher@fileserver:~$ sudo chmod 755 /opt/files
bdispatcher@fileserver:~$ su - nagios
nagios@fileserver:~$ df -h
S.ficheros          Tamaño Usado  Disp Uso% Montado en
/dev/sda1             4,9G  1,3G  3,4G  28% /
/dev/sdc1             9,7G  5,2G  4,1G  57% /opt/files
/dev/sdd1              30G   25G  3,7G  88% /opt/files/datos
tmpfs                 506M     0  506M   0% /dev/shm
nagios@fileserver:~$

The next check gives me the expected output:
bdispatcher@nagserver:~$ /opt/nagios/libexec/check_nrpe -H fileserver -p 5666 -c check_sdd1
DISK WARNING - free space: /opt/files/datos 3696 MB (12% inode=99%);| /opt/files/datos=25003MB;24188;27212;0;30236

And that's all folks!

PS. I know, I know. My English is not good enought but, the more you help me, the more I learn.