-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT/ d- s: a- C++ UL++ P L++ E--- W+++ N o? K- w O-- M?
V PS PE Y-- PGP t 5? X R tv b DI D+++ G e+++ h--- r+++ y+++
------END GEEK CODE BLOCK------
Y tú, qué clase de geek eres?.
En este blog iré contando cosas de la informática, linux, hardware, cacharreos,... en general un blog friki-geek ;-)
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT/ d- s: a- C++ UL++ P L++ E--- W+++ N o? K- w O-- M?
V PS PE Y-- PGP t 5? X R tv b DI D+++ G e+++ h--- r+++ y+++
------END GEEK CODE BLOCK------
ivan@doraemon:~$ sudo apt-get install checkinstall alien
ivan@doraemon:~$ sudo alien -d paquete.rpm
ivan@doraemon:~$ sudo dpkg -i paquete.deb
ivan@doraemon:~$ tar zxvf paquete.tar.gz
ivan@doraemon:~$ cd paquete
ivan@doraemon:~/paquete $ ./configure
ivan@doraemon:~/paquete $ make
ivan@doraemon:~/paquete $ sudo checkinstall
$ ./configure --prefix=PREFIX --with-nagios-user=SOMEUSER --with-nagios-group=SOMEGROUPDonde: PREFIX es la ruta en donde queremos instalar y que llamaremos $NAGIOS_HOME.
$ make all
$ make install
# OBJECT CONFIGURATION FILE(S)
# Plugin commands (service and host check commands)
cfg_file=/internet/vtprov/nagios/etc/checkcommands.cfg
# Misc commands (notification and event handler commands, etc)
cfg_file=/internet/vtprov/nagios/etc/misccommands.cfg
# You can split other types of object definitions across several
# config files if you wish (as done here), or keep them all in a
# single config file.
cfg_file=/internet/vtprov/nagios/etc/bigger.cfg
# NAGIOS USER
nagios_user=vtprov
# NAGIOS GROUP
nagios_group=users
# EXTERNAL COMMAND OPTION
# This option allows you to specify whether or not Nagios should check
# for external commands (in the command file defined below). By default
# Nagios will *not* check for external commands, just to be on the
# cautious side. If you want to be able to use the CGI command interface
# you will have to enable this. Setting this value to 0 disables command
# checking (the default), other values enable it.
check_external_commands=1
[...]
define command{
command_name check_ping
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}
define command{
command_name check_http
command_line $USER1$/check_http -H $ARG1$ -p $ARG2$ --url=$ARG3$
}
define command{
command_name check_http_wm
command_line $USER1$/check_http -H $ARG1$ -p $ARG2$ -a USER:PASSWD
}
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $ARG1$ -c $ARG2$ -a $ARG3$ $ARG4$ $ARG5$
}# 'notify-by-email' command definition
define command{
command_name notify-by-email
command_line /usr/bin/printf "Subject: ** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ** %b\n\n ***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail $CONTACTEMAIL$
}
# '24x7' timeperiod definition
define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
# 'workhours' timeperiod definition
define timeperiod {
timeperiod_name Workhours
alias "Normal" Working Hours
monday 08:00-19:00
tuesday 08:00-19:00
wednesday 08:00-19:00
thursday 08:00-19:00
friday 08:00-15:00
}
# 'vt-prov' contact definition
define contact {
contact_name vt-prov
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email user1@empresa.com,user2@empresa.com
}
# 'host1' host definition
define host{
use generic-host
host_name host1
alias Servidor host1
address 172.24.88.169
check_command check-host-alive
max_check_attempts 10
check_period 24x7
notification_interval 120
notification_period 24x7
notification_options d,u,r
contact_groups vt-prov
}
# 'solaris-servers' host group definition
define hostgroup{
hostgroup_name solaris-servers
alias Solaris Servers
members host1,host2,host4,host6
}
define service{
use generic-service
host_name host1
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 1
retry_check_interval 1
contact_groups vt-prov
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_ping!100.0,20%!500.0,60%
}define service{
use generic-service
host_name host2
service_description ENTORNO1 - Servicio2
is_volatile 0
check_period 24x7
max_check_attempts 1
normal_check_interval 5
retry_check_interval 1
contact_groups vt-prov
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_http!host2!10102!/servicio/jsp/autent/login.jsp
}define service{
use generic-service
host_name host2
service_description host2 - /var
is_volatile 0
check_period 24x7
max_check_attempts 1
normal_check_interval 5
retry_check_interval 1
contact_groups vt-prov
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!7997!check_disk!7!5!/var
}define servicegroup{
servicegroup_name ENTORNO1 - TOMCATs
alias ENTORNO1 - TOMCATs
members host2,ENTORNO1 - Servicio2,host2,ENTORNO1 - Servicio3,host2,ENTORNO1 - Servicio8
}$ nagios -v ../etc/nagios.cfg
Nagios 2.4
Copyright (c) 1999-2006 Ethan Galstad (http://www.nagios.org)
Last Modified: 05-31-2006
License: GPL
Reading configuration data...
Running pre-flight check on configuration data...
Checking services...
Checked 82 services.
Checking hosts...
Checked 5 hosts.
Checking host groups...
Checked 1 host groups.
Checking service groups...
Checked 16 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 26 commands.
Checking time periods...
Checked 4 time periods.
Checking extended host info definitions...
Checked 0 extended host info definitions.
Checking extended service info definitions...
Checked 0 extended service info definitions.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
$ nagios -d ../etc/nagios.cfg
ScriptAlias /nagios/cgi-bin "/internet/vtprov/nagios/sbin/"
<Directory "/internet/vtprov/nagios/sbin">
AllowOverride AuthConfig
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
Alias /nagios "/internet/vtprov/nagios/share"
<Directory "/internet/vtprov/nagios/share">
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
AuthName "Acceso a Nagios"
AuthType Basic
AuthUserFile /internet/vtprov/nagios/etc/htpasswd.users
require valid-user
$ htpasswd -c /internet/vtprov/nagios/etc/htpasswd.users nagios
# PORT NUMBER
server_port=7997
# SERVER ADDRESS
server_address=172.24.88.169
# ALLOWED HOST ADDRESSES
# This is a comma-delimited list of IP address of hosts that are allowed
# to talk to the NRPE daemon.
allowed_hosts=127.0.0.1,172.24.86.11
# NRPE USER
nrpe_user=nrpe
# NRPE GROUP
nrpe_group=users
# COMMAND ARGUMENT PROCESSING
# This option determines whether or not the NRPE daemon will allow clients
# to specify arguments to commands that are executed. This option only works
# if the daemon was configured with the --enable-command-args configure script
# option.
#
# *** ENABLING THIS OPTION IS A SECURITY RISK! ***
# Read the SECURITY file for information on some of the security implications
# of enabling this variable.
#
# Values: 0=do not allow arguments, 1=allow command arguments
dont_blame_nrpe=1
# COMMAND DEFINITIONS
command[check_disk]=/home/user/nrpe/check_disk.sh $ARG1$ $ARG2$ $ARG3$
check_nrpe!7997!check_disk!7!5!/varEn esta llamada 7997 es el puerto del nrpe en la máquina remota, check_disk es el nombre lógico del script y 7, 5 y /var son los parámetros del script. Éste comprueba el porcentaje de espacio libre del filesystem que recibe como parámetro y lo compara con los dos umbrales que le pasamos. Si es menor de un 7% genera un warning y si es menor de un 5% genera un error crítico.
#!/bin/ksh
# check_disk.sh: Comprueba el tamaño de un filesystem y
# devuelve el estado en función de dos umbrales definidos.
#
# Iván López Martín
warning=$1
critical=$2
filesystem=$3
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
size=`df -k $filesystem | grep $filesystem | awk '{print $4}'`
sizeMB=`echo "$size/1024" | bc`
percentage=`df -k $filesystem | grep $filesystem | awk '{print $5}' | sed -e s/%//g`
freePercentage=`echo "100-$percentage" | bc`
if [ "$freePercentage" -le "$critical" ]; then
echo "DISK CRITICAL - free space: "$filesystem" $sizeMB MB"
return $STATE_CRITICAL
fi
if [ "$freePercentage" -le "$warning" ]; then
echo "DISK WARNING - free space: "$filesystem" $sizeMB MB"
return $STATE_WARNING
fi
echo "DISK OK - free space: "$filesystem" $sizeMB MB"
return $STATE_OK
$ nrpe -c nrpe.cfg -d
ivan@doraemon:~$ tar zxf truecrypt-4.3a-source-code.tar.gz
ivan@doraemon:~$ cd truecrypt-4.3a-source-code/Linux
ivan@doraemon:~/truecrypt-4.3a-source-code/Linux$ sudo ./build.sh
Checking build requirements...
Building kernel module... /home/ivan/truecrypt-4.3a-source-code/Linux/Kernel/Dm-target.c: In function `dm_truecrypt_init´:
/home/ivan/truecrypt-4.3a-source-code/Linux/Kernel/Dm-target.c:659: error: too many arguments to function `kmem_cache_create´
make[2]: *** [/home/ivan/truecrypt-4.3a-source-code/Linux/Kernel/Dm-target.o] Error 1
make[1]: *** [_module_/home/ivan/truecrypt-4.3a-source-code/Linux/Kernel] Error 2
make: *** [truecrypt] Error 2
Error: Failed to build kernel module
//bio_ctx_cache = kmem_cache_create ("truecrypt-bioctx", sizeof (struct bio_ctx), 0, 0, NULL, NULL);
bio_ctx_cache = kmem_cache_create ("truecrypt-bioctx", sizeof (struct bio_ctx), 0, 0, NULL);ivan@doraemon:~/truecrypt-4.3a-source-code/Linux$ sudo ./build.sh
Checking build requirements...
Building kernel module... Done.
Building truecrypt... Done.
ivan@doraemon:~/truecrypt-4.3a-source-code/Linux$ sudo ./install.sh
Checking installation requirements...
Testing truecrypt... Done.
Install binaries to [/usr/bin]:
Install man page to [/usr/share/man]:
Install user guide and kernel module to [/usr/share/truecrypt]:
Installing kernel module...
Done.
Installing truecrypt to /usr/bin... Done.
Installing man page to /usr/share/man/man1... Done.
Installing user guide to /usr/share/truecrypt/doc... Done.
Installing backup kernel module to /usr/share/truecrypt/kernel... Done.
ivan@doraemon:~$ uname -a
Linux doraemon.casa 2.6.23.11-ILM #1 SMP Sat Dec 15 10:04:16 CET 2007 i686 GNU/Linux
[root@esxconsole root]# uname -a
Linux esxconsole 2.4.9-vmnix2 #1 Thu Sep 8 14:46:53 PDT 2005 i686 unknown
[root@esxconsole root]# vdf -h
Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p2 2.4G 866M 1.4G 38% /
/dev/cciss/c0d0p1 50M 12M 36M 25% /boot
none 188M 0 187M 0% /dev/shm
vmhba2:0:0:6 200G 62G 138G 30% /vmfs/vmhba2:0:0:6
[root@esxconsole root]# ls -lh /vmfs/vmhba2\:0\:0\:6/
-rw------- 1 root root 20G Nov 13 10:28 W2K3_DiskC.vmdk
-rw------- 1 root root 5.0G Nov 13 10:28 W2K3_DiskE.vmdk
-rw------- 1 root root 7.9G Nov 7 09:48 SwapFile.vswp
-rw------- 1 root root 15G Nov 13 10:25 WXP_Client1_DiskC.vmdk
[root@esxconsole vmhba2:0:0:6]# gzip -c W2K3_DiskC.vmdk > W2K3_DiskC_CLON.vmdk.gz
[root@esxconsole vmhba2:0:0:6]# ls -lh
-rw------- 1 root root 20G Nov 13 10:28 W2K3_DiskC.vmdk
-rw------- 1 root root 1.7G Nov 8 16:44 W2K3_DiskC_CLON.vmdk.gz
[root@esxconsole root]# vmkusagectl install
Info: Adding cron job
[root@esxconsole vmhba2:0:0:6]# vmkfstools -e ExportVM.vmdk vmhba2:0:0:6:WXP_Client1_DiskC.vmdk
Exporting disk vmhba2:0:0:6:WXP_Client1_DiskC.vmdk:
Export: 100% done.
[root@esxconsole vmhba2:0:0:6]# ls -lh ExportVM*
-rw------- 1 root root 1.6G Nov 22 09:17 ExportVM-s001.vmdk
-rw------- 1 root root 1.0G Nov 22 09:17 ExportVM-s002.vmdk
-rw------- 1 root root 1.1G Nov 22 09:17 ExportVM-s003.vmdk
-rw------- 1 root root 2.0G Nov 22 09:17 ExportVM-s004.vmdk
-rw------- 1 root root 912M Nov 22 09:17 ExportVM-s005.vmdk
-rw------- 1 root root 2.0G Nov 22 09:17 ExportVM-s006.vmdk
-rw------- 1 root root 1.5G Nov 22 09:17 ExportVM-s007.vmdk
-rw------- 1 root root 1.2M Nov 22 09:17 ExportVM-s008.vmdk
-rw------- 1 root root 614 Nov 22 09:17 ExportVM.vmdk
$ /usr/platform/sun4us/sbin/prtdiag -v
System Configuration: Sun Microsystems sun4us Fujitsu Siemens PRIMEPOWER650 1- slot 8x SPARC64 V
System clock frequency: 270 MHz
Memory size: 12288 Megabytes
========================= CPUs =========================
Run Ecache CPU CPU
Brd CPU Module MHz MB Impl. Mask
--- --- ------ ----- ---- ----- ----
0 0 0 1349 2.0 5 0.8
0 1 1 1349 2.0 5 0.8
0 2 2 1349 2.0 5 0.8
0 3 3 1349 2.0 5 0.8
0 4 4 1349 2.0 5 0.8
0 5 5 1349 2.0 5 0.7
0 6 6 1349 2.0 5 0.8
0 7 7 1349 2.0 5 0.8
Luego hay otro "truquillo" para sustituir un disco de ej: 80 GB por uno de 300Gb en caliente y sin que nadie lo note, pero eso seguro que nos lo tiene guardado Iván para otro dia.
shian:~# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
shian:~# vgextend vg01 /dev/sdb1
Volume group "vg01" successfully extended
shian:~# vgdisplay -v vg01
Using volume group(s) on command line
Finding volume group "vg01"
--- Volume group ---
VG Name vg01
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 5.99 GB
PE Size 4.00 MB
Total PE 1534
Alloc PE / Size 256 / 1.00 GB
Free PE / Size 1278 / 4.99 GB
VG UUID BpNJTl-9tlr-DjzM-C8Mb-LfnL-NWDa-uyWDpf
--- Logical volume ---
LV Name /dev/vg01/lvdatos
VG Name vg01
LV UUID 7CYTLY-YgI2-c64S-F50h-vPXH-TEk9-o4hFOE
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:0
--- Physical volumes ---
PV Name /dev/sda1
PV UUID 1wounc-DIHj-Tf54-4h2c-4rcB-w137-gLH4I6
PV Status allocatable
Total PE / Free PE 511 / 255
PV Name /dev/sdb1
PV UUID N0nwct-jNnY-eU0D-6Evh-tkIN-9vKs-9KsV3v
PV Status allocatable
Total PE / Free PE 1023 / 1023
shian:~# pvmove /dev/sda1
mirror: Required device-mapper target(s) not detected in your kernel
shian:~# modprobe dm_mirror
shian:~# pvmove -v /dev/sda1
/dev/sda1: Moved: 100.0%
shian:~# vgdisplay -v vg01
...
...
--- Physical volumes ---
PV Name /dev/sda1
PV UUID 1wounc-DIHj-Tf54-4h2c-4rcB-w137-gLH4I6
PV Status allocatable
Total PE / Free PE 511 / 511
PV Name /dev/sdb1
PV UUID N0nwct-jNnY-eU0D-6Evh-tkIN-9vKs-9KsV3v
PV Status allocatable
Total PE / Free PE 1023 / 767
shian:~# vgreduce -v vg01 /dev/sda1
Removed "/dev/sda1" from volume group "vg01"
shian:~# vgdisplay -v vg01
Using volume group(s) on command line
Finding volume group "vg01"
--- Volume group ---
VG Name vg01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 11
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 4.00 GB
PE Size 4.00 MB
Total PE 1023
Alloc PE / Size 256 / 1.00 GB
Free PE / Size 767 / 3.00 GB
VG UUID BpNJTl-9tlr-DjzM-C8Mb-LfnL-NWDa-uyWDpf
--- Logical volume ---
LV Name /dev/vg01/lvdatos
VG Name vg01
LV UUID 7CYTLY-YgI2-c64S-F50h-vPXH-TEk9-o4hFOE
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:0
--- Physical volumes ---
PV Name /dev/sdb1
PV UUID N0nwct-jNnY-eU0D-6Evh-tkIN-9vKs-9KsV3v
PV Status allocatable
Total PE / Free PE 1023 / 767