miércoles, 13 de abril de 2016

Support TI cheaper for Europe or Australia

Look this Gif and check for yourself

Support TI cheaper
make animated gifs like this at MakeaGif


You can contact us: contacto @ cacaoenbytes.com


domingo, 24 de mayo de 2015

Nuevo libro en Amazon

Escribo esta corta nota, para promocionar el libro de comando básicos que publica el autor de este blog en Amazon, el precio son 2.99$, espero sea de su agrado: el link

jueves, 18 de septiembre de 2014

Monitorear servidor Solaris 10 sobre nagios core 3.5.1

Tenia ganas desde hace años de escribir este post, mas no sabia como orientarlo, pero, ordenemos como deben funcionar las cosas en forma general:


La guia universal para instalar sobre todo lo que sea *nix (GNU/Linux, Unix) esta aquí

Si quieres instalar el servidor con nagios 3.5.1 primero ve aquí

Es importante que entendamos que para monitorear o monitorizar con nagios, se realizan dos procesos, instalar el plugin en el cliente y configurar en  el servidor lo que estamos monitoreando o monitorizando:

Para nuestro tutorial de hoy, recordemos:
Negritas para los comandos
Italicas para las salidas o resultados

Para trabajar con el tema vamos a dividirlo en dos partes:

Servidor y cliente (cliente entiéndase como la maquina que queremos monitorear):
Iniciemos con el cliente:

En nuestra receta usaremos:
-Solaris 10 (me pareció mucho mejor, hacerlo con un sistema operativo no tan común), debo agradecerle a Javier Sánchez y Anabel Broce en la AIG por permitirme usar su servidor.
1.- Crear usuario nagios
root # useradd -d /usr/local/nagios -m nagios
cp: /usr/local/nagios: No such file or directory
chown: /usr/local/nagios: No such file or directory

Como podrán ver estoy dejando los errores para el caso de que les suceda :D

Es necesario crear la carpeta o mejor dicho el “home directory”, grupo y asignar los premisos en las carpetas:
root # mkdir -p /usr/local/nagios
root #

root # chown nagios:nagios /usr/local/nagios/
chown: unknown group id nagios
root # groupadd nagios
root # usermod -g nagios nagios
root # grep nagios /etc/passwd
nagios:x:105:101::/usr/local/nagios:/bin/sh
root # grep nagios /etc/group
nagios::101:
root #

root # chown nagios:nagios /usr/local/nagios/
root #



2.- Es necesario descargar el paquete nrpe, procedamos a hacerlo con el comando wget:
root # cd /usr/local/nagios/
root # ls
root # mkdir downloads
root # cd downloads/
root # wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
bash: wget: command not found
root # find / -name wget
/var/tmp/SDocTool/texlive/2010/tlpkg/installer/wget
/usr/sfw/bin/wget
^C
root # /usr/sfw/bin/wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
--2014-04-10 13:26:10--  http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
Resolving downloads.sourceforge.net...

3.- De igual forma es necesario descargar el paquete para manejar los plugins:
root # /usr/sfw/bin/wget http://nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
--2014-04-10 14:50:12--  http://nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
Resolving nagios-plugins.org... 72.14.186.43

4.- Desempaquetemos el paquete de los plugins:
root # ls
nagios-plugins-1.5.tar.gz  nrpe-2.15.tar.gz
root # gunzip nagios-plugins-1.5.tar.gz
root # tar xvf nagios-plugins-1.5.tar
x nagios-plugins-1.5, 0 bytes, 0 tape blocks
x nagios-plugins-1.5/release, 4 bytes, 1 tape blocks
x nagios-plugins-1.5/po, 0 bytes, 0 tape blocks
x nagios-plugins-1.5/po/LINGUAS, 7 bytes, 1 tape blocks
x nagios-plugins-1.5/po/ChangeLog, 452 bytes, 1 tape blocks
x nagios-plugins-1.5/po/stamp-po, 10 bytes, 1 tape blocks
x nagios-plugins-1.5/po/nagios-plugins.pot, 140271 bytes, 274 tape blocks
x nagios-plugins-1.5/po/de.gmo, 7836 bytes, 16 tape blocks
x nagios-plugins-1.5/po/fr.gmo, 95571 bytes, 187 tape blocks

......
x nagios-plugins-1.5/build-aux/missing, 10346 bytes, 21 tape blocks
x nagios-plugins-1.5/build-aux/ltmain.sh, 283670 bytes, 555 tape blocks
x nagios-plugins-1.5/build-aux/install-sh, 13998 bytes, 28 tape blocks
x nagios-plugins-1.5/build-aux/depcomp, 20899 bytes, 41 tape blocks
x nagios-plugins-1.5/build-aux/config.sub, 35543 bytes, 70 tape blocks
x nagios-plugins-1.5/build-aux/config.rpath, 18717 bytes, 37 tape blocks
x nagios-plugins-1.5/build-aux/config.guess, 44826 bytes, 88 tape blocks
x nagios-plugins-1.5/build-aux/compile, 7274 bytes, 15 tape blocks

5.- Desempaquetamos el paquete de nrpe:
root # gunzip nrpe-2.15.tar.gz
root # tar xvf nrpe-2.15.tar
x pax_global_header, 52 bytes, 1 tape blocks
x nrpe-2.15, 0 bytes, 0 tape blocks
x nrpe-2.15/Changelog, 9966 bytes, 20 tape blocks
x nrpe-2.15/LEGAL, 441 bytes, 1 tape blocks
x nrpe-2.15/Makefile.in, 2056 bytes, 5 tape blocks
x nrpe-2.15/README, 7056 bytes, 14 tape blocks
x nrpe-2.15/README.SSL, 1172 bytes, 3 tape blocks
x nrpe-2.15/README.Solaris, 669 bytes, 2 tape blocks
x nrpe-2.15/SECURITY, 3564 bytes, 7 tape blocks
x nrpe-2.15/config.guess, 43882 bytes, 86 tape blocks
x nrpe-2.15/config.sub, 32304 bytes, 64 tape blocks
x nrpe-2.15/configure, 226894 bytes, 444 tape blocks
....

x nrpe-2.15/src/acl.c, 17573 bytes, 35 tape blocks
x nrpe-2.15/src/check_nrpe.c, 12772 bytes, 25 tape blocks
x nrpe-2.15/src/nrpe.c, 53893 bytes, 106 tape blocks
x nrpe-2.15/src/snprintf.c, 34417 bytes, 68 tape blocks
x nrpe-2.15/src/utils.c, 10109 bytes, 20 tape blocks
x nrpe-2.15/subst.in, 1705 bytes, 4 tape blocks
x nrpe-2.15/update-version, 2937 bytes, 6 tape blocks


6.- Desde el directorio donde esta desempaquetados los plugins procedemos a inciar la compilacion:

root # ./configure
checking for a BSD-compatible install... build-aux/install-sh -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking whether make sets $(MAKE)... yes
checking build system type... sparc-sun-solaris2.10
checking host system type... sparc-sun-solaris2.10
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/nagios/downloads/nagios-plugins-1.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details


Nos devuelve un error relacionado a la falta del compilador, en este caso gcc o cc, entonces para solucionarlo es necesario definir en el PATH la ruta del compilador:
root # find / -name gcc
/usr/sfw/lib/gcc
/usr/sfw/bin/gcc
/usr/sfw/libexec/gcc
root # echo $PATH
/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/dt/bin:/usr/platform/SUNW,Sun-Fire-V245/sbin:/opt/sun/bin:/opt/SUNWexplo/bin:/opt/SUNWsneep/bin:/opt/SUNWjet/bin:/opt/SUNWsesscs/cli/bin
root #


root # export PATH=$PATH:/usr/sfw/bin
root #

root # echo $PATH
/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/dt/bin:/usr/platform/SUNW,Sun-Fire-V245/sbin:/opt/sun/bin:/opt/SUNWexplo/bin:/opt/SUNWsneep/bin:/opt/SUNWjet/bin:/opt/SUNWsesscs/cli/bin:/usr/sfw/bin


Compilemos nuevamente:
root # ./configure
checking for a BSD-compatible install... build-aux/install-sh -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking whether make sets $(MAKE)... yes
checking build system type... sparc-sun-solaris2.10
checking host system type... sparc-sun-solaris2.10
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
..........

checking for ICMP ping syntax... /usr/sbin/ping -n -s %s 56 %d
checking for ICMPv6 ping syntax...

..........
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
            --with-apt-get-command:
              --with-ping6-command:
               --with-ping-command: /usr/sbin/ping -n -s %s 56 %d
                       --with-ipv6: yes
                      --with-mysql: /usr/sfw/bin/mysql_config
                    --with-openssl: yes
                     --with-gnutls: no
               --enable-extra-opts: no
                       --with-perl: /usr/bin/perl
             --enable-perl-modules: no
                     --with-cgiurl: /nagios/cgi-bin
               --with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin
                   --enable-libtap: no
root #


root # make
make  all-recursive
Making all in gl
rm -f alloca.h-t alloca.h && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
  cat ./alloca.in.h; \
} > alloca.h-t && \
mv -f alloca.h-t alloca.h
rm -f c++defs.h-t c++defs.h && \
sed -n -e '/_GL_CXXDEFS/,$p' \
  < ../build-aux/snippet/c++defs.h \
  > c++defs.h-t && \
mv c++defs.h-t c++defs.h
rm -f warn-on-use.h-t warn-on-use.h && \
sed -n -e '/^.ifndef/,$p' \
  < ../build-aux/snippet/warn-on-use.h \
  > warn-on-use.h-t && \
mv warn-on-use.h-t warn-on-use.h
rm -f arg-nonnull.h-t arg-nonnull.h && \
...............

mv -f .deps/check_icmp.Tpo .deps/check_icmp.Po
/bin/bash ../libtool --tag=CC    --mode=link gcc -DNP_VERSION='"1.5"' -g -O2   -L. -L/lib -o check_icmp check_icmp.o ../plugins/netutils.o ../plugins/utils.o ../lib/libnagiosplug.a ../gl/libgnu.a  -lnsl -lsocket -lresolv -lnsl -lsocket -lresolv -lpthread -ldl
libtool: link: gcc -DNP_VERSION=\"1.5\" -g -O2 -o check_icmp check_icmp.o ../plugins/netutils.o ../plugins/utils.o  -L. -L/lib ../lib/libnagiosplug.a ../gl/libgnu.a -lnsl -lsocket -lresolv -lpthread -ldl
gcc -DLOCALEDIR=\"/usr/local/nagios/share/locale\" -DHAVE_CONFIG_H -I. -I..   -D_REENTRANT -I/include -m64 -g -O2 -MT pst3-pst3.o -MD -MP -MF .deps/pst3-pst3.Tpo -c -o pst3-pst3.o `test -f 'pst3.c' || echo './'`pst3.c
mv -f .deps/pst3-pst3.Tpo .deps/pst3-pst3.Po
/bin/bash ../libtool --tag=CC    --mode=link gcc -m64 -g -O2 -m64  -L. -L/lib -o pst3 pst3-pst3.o  -lpthread -ldl
libtool: link: gcc -m64 -g -O2 -m64 -o pst3 pst3-pst3.o  -L. -L/lib -lpthread -ldl
Making all in po

root  # make install
Making install in gl
make  install-recursive
if test no = no; then \
  case 'solaris2.10' in \
    darwin[56]*) \
      need_charset_alias=true ;; \
    darwin* | cygwin* | mingw* | pw32* | cegcc*) \
      need_charset_alias=false ;; \
    *) \
      need_charset_alias=true ;; \
  esac ; \
else \
  need_charset_alias=false ; \
fi ; \
if $need_charset_alias; then \
  /bin/bash ../build-aux/mkinstalldirs /usr/local/nagios/lib ; \
fi ; \
if test -f /usr/local/nagios/lib/charset.alias; then \
  sed -f ref-add.sed /usr/local/nagios/lib/charset.alias > /usr/local/nagios/lib/charset.tmp ; \
  ../build-aux/install-sh -c -m 644 /usr/local/nagios/lib/charset.tmp /usr/local/nagios/lib/charset.alias ; \
  rm -f /usr/local/nagios/lib/charset.tmp ; \
else \
  if $need_charset_alias; then \
    sed -f ref-add.sed charset.alias > /usr/local/nagios/lib/charset.tmp ; \
    ../build-aux/install-sh -c -m 644 /usr/local/nagios/lib/charset.tmp /usr/local/nagios/lib/charset.alias ; \
    rm -f /usr/local/nagios/lib/charset.tmp ; \
  fi ; \
fi
....................


Making install in plugins-root
 ../build-aux/install-sh -c check_dhcp /usr/local/nagios/libexec/check_dhcp
 chown root /usr/local/nagios/libexec/check_dhcp
 chmod ug=rx,u+s /usr/local/nagios/libexec/check_dhcp
 ../build-aux/install-sh -c check_icmp /usr/local/nagios/libexec/check_icmp
 chown root /usr/local/nagios/libexec/check_icmp
 chmod ug=rx,u+s /usr/local/nagios/libexec/check_icmp
 ../build-aux/install-sh -c pst3 /usr/local/nagios/libexec/pst3
 chown root /usr/local/nagios/libexec/pst3
 chmod ug=rx,u+s /usr/local/nagios/libexec/pst3
Making install in po
if test "nagios-plugins" = "gettext-tools"; then \
  ../build-aux/install-sh -c -d /usr/local/nagios/share/gettext/po; \
  for file in Makefile.in.in remove-potcdate.sin     Makevars.template; do \
    ../build-aux/install-sh -c -m 644 ./$file \
                    /usr/local/nagios/share/gettext/po/$file; \
  done; \
  for file in Makevars; do \
    rm -f /usr/local/nagios/share/gettext/po/$file; \
  done; \
else \
  : ; \
fi

8.- Verifiquemos en el directorio donde quedan instalados:
root # ls /usr/local/nagios/libexec/
check_apt           check_icmp          check_nt            check_snmp
check_breeze        check_ifoperstatus  check_ntp           check_spop
check_by_ssh        check_ifstatus      check_ntp_peer      check_ssh
check_clamd         check_imap          check_ntp_time      check_ssmtp
check_cluster       check_ircd          check_nwstat        check_tcp
check_dhcp          check_jabber        check_oracle        check_time
check_dig           check_load          check_overcr        check_udp
check_disk          check_log           check_pgsql         check_ups
check_disk_smb      check_mailq         check_ping          check_users
check_dns           check_mrtg          check_pop           check_wave
check_dummy         check_mrtgtraf      check_procs         negate
check_file_age      check_mysql         check_real          pst3
check_flexlm        check_mysql_query   check_rpc           urlize
check_ftp           check_nagios        check_sensors       utils.pm
check_hpjd          check_nntp          check_simap         utils.sh
check_http          check_nntps         check_smtp
root #

9.-Probemos si un plugin funciona en la maquina:
root # /usr/local/nagios/libexec/check_disk -w 10 -c 5 -p /
DISK OK - free space: / 6176 MB (24% inode=86%);| /=18784MB;25202;25207;0;25212
root #


10.- Ahora compilemos  nrpe:
root # ls
nagios-plugins-1.5      nrpe-2.15               pax_global_header
nagios-plugins-1.5.tar  nrpe-2.15.tar
root #


root # ./configure
checking for a BSD-compatible install... ./install-sh -c
checking build system type... sparc-sun-solaris2.10
checking host system type... sparc-sun-solaris2.10
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking whether make sets $(MAKE)... yes
checking how to run the C preprocessor... gcc -E
checking for egrep... egrep
.............
...........................................+..........................+...................+.....++*++*++*++*++*++*
checking for Kerberos include files... could not find include files
checking for perl... /usr/bin/perl
configure: creating ./config.status
config.status: creating Makefile
config.status: creating subst
config.status: creating src/Makefile
config.status: creating package/solaris/Makefile
config.status: creating init-script
config.status: creating init-script.debian
config.status: creating init-script.suse
config.status: creating nrpe.spec
config.status: creating sample-config/nrpe.cfg
config.status: creating sample-config/nrpe.xinetd
config.status: creating include/config.h


*** Configuration summary for nrpe 2.15 09-06-2013 ***:

 General Options:
 -------------------------
 NRPE port:    5666
 NRPE user:    nagios
 NRPE group:   nagios
 Nagios user:  nagios
 Nagios group: nagios


Review the options above for accuracy.  If they look okay,
type 'make all' to compile the NRPE daemon and client.

root #
root # make all
cd ./src/; make ; cd ..
gcc -g -O2 -I/usr/sfw/include/openssl -DHAVE_CONFIG_H -I ../include -I ./../include -o nrpe ./nrpe.c ./utils.c ./acl.c -L/usr/sfw/lib  -lssl -lcrypto -lnsl -lsocket
gcc -g -O2 -I/usr/sfw/include/openssl -DHAVE_CONFIG_H -I ../include -I ./../include -o check_nrpe ./check_nrpe.c ./utils.c -L/usr/sfw/lib  -lssl -lcrypto -lnsl -lsocket

*** Compile finished ***

If the NRPE daemon and client compiled without any errors, you
can continue with the installation or upgrade process.

Read the PDF documentation (NRPE.pdf) for information on the next
steps you should take to complete the installation or upgrade.

root #

root # make install
cd ./src/ && make install
make install-plugin
.././install-sh -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
.././install-sh -c -m 775 -o nagios -g nagios check_nrpe /usr/local/nagios/libexec
make install-daemon
.././install-sh -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
.././install-sh -c -m 775 -o nagios -g nagios nrpe /usr/local/nagios/bin
root #



root # make install-daemon-config
./install-sh -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
./install-sh -c -m 644 -o nagios -g nagios sample-config/nrpe.cfg /usr/local/nagios/etc
root #

11.- Verifiquemos la existencia de nrpe y probemoslo:

root # svcs svc:/network/nrpe/tcp:default
STATE          STIME    FMRI
online         16:00:28 svc:/network/nrpe/tcp:default
root #


root # netstat -a | grep nrpe
      *.nrpe               *.*                0      0 49152      0 LISTEN
root #


root #  inetadm -l svc:/network/nrpe/tcp:default
SCOPE    NAME=VALUE
         name="nrpe"
         endpoint_type="stream"
         proto="tcp"
         isrpc=FALSE
         wait=FALSE
         exec="/usr/sfw/sbin/tcpd -c /usr/local/nagios/etc/nrpe.cfg -i"
         arg0="/usr/local/nagios/bin/nrpe"
         user="nagios"
default  bind_addr=""
default  bind_fail_max=-1
default  bind_fail_interval=-1
default  max_con_rate=-1
default  max_copies=-1
default  con_rate_offline=-1
default  failrate_cnt=40
default  failrate_interval=60
default  inherit_env=TRUE
default  tcp_trace=FALSE
default  tcp_wrappers=FALSE
default  connection_backlog=10

root # /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.15

-----------------------

Sobre el servidor la tarea a mi parecer es mucho menor:




1.- Debemos colocar nuestro nuevo comando sobre el archivo command.cfg:
root # vi /usr/local/nagios/etc/commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
2.- Definamos el archivo que llevara la configuracion:
root # vi  /usr/local/nagios/etc/solaris.cfg
define host{
name linux-box ; Name of this template
use generic-host ; Inherit default values
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS - ITS A TEMPLATE
}
define host{
use linux-box ; Inherit default values from a template
host_name Solaris ; The name we're giving to this server
alias Solaris 10 ; A longer name for the server
address x.x.x.x ; IP address of the server
}
define service{
use generic-service
host_name Solaris
service_description CPU Load
check_command check_nrpe!check_load
}
En el archivo anterior van todos los servicios
3.- El ultimo paso en el servidor es reiniciar nagios:
root # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Enjoy!!!

lunes, 4 de agosto de 2014

Boot single-user en solaris 11.1 (para x86)

Se ha convertido en un karma arrancar solaris 11.1 en modo single-user, nos han agregado líneas para mas bonita resolución, la receta es así :
1.- Cuando estés en Grub, selecciona tu arranque.

2.- Edita, es decir, presiona "e".

3.- Busca Multiboot y coloca -s al final de la línea


4.- Presionar "F10" o "ctrl-x" para arrancar.


Nota: Si quieres ver lo que ocurre, mientras arranca quita "-B console=graphics".
Eso es todo!.

Enjoy.