Archive for the ‘Moodle’ Category

Impedir doble ejecución del cron de moodle

jueves, marzo 15th, 2018

En las experiencias con Moodle me han sucedido ya varias cosas que contar, una de ellas es la ejecución del cron. En ambientes donde no se conoce bien la carga que va a tener el uso de Moodle se actua bajo la percepción de un mejor o peor caso, basado en lo cual se decide un tiempo entre ejecuciones del cron de Moodle, por ejemplo 20 minutos, lo que sucede es que en ambientes grandes 20 minutos muchas veces no resulta ser suficiente, para lo cual hay que buscar un mecanismo para evitar la doble ejecución del cron, ya que en algunas oportunidades la ejecución queda «tomada» o «pegada» y nunca termina o no termina correctamente.

Encontré en Preventing Duplicate Cron Jobs Execution la forma de hacerlo, pero incluyendo las lineas que llaman al cron de Moodle en una instalación que se asume está en /var/www/html/, adicionando ademas la posibilidad de guardar el log en la carpeta de logs de apache.

PIDFILE=/var/run/moodle_cron.pid
if [ -f $PIDFILE ]
then
  PID=$(cat $PIDFILE)
  ps -p $PID > /dev/null 2>&1
  if [ $? -eq 0 ]
  then
    echo "El proceso ya se esta ejecutando"
    exit 1
  else
    ## El proceso no se encuentra por lo que se asume que no se esta ejecutando
    echo $$ > $PIDFILE
    if [ $? -ne 0 ]
    then
      echo "No se puede crear el PID"
      exit 1
    else
      NOW=$(date +"%Y-%m-%d_%H-%M-%S")
      FILE=/var/log/httpd/moodle_cron.$NOW.log
      /usr/bin/php /var/www/html/admin/cli/cron.php > $FILE 
    fi
  fi
else
  echo $$ > $PIDFILE
  if [ $? -ne 0 ]
  then
    echo "No se puede crear el PID"
    exit 1
  fi
fi

rm $PIDFILE

Cambiar ruta de maillog en Centos

miércoles, marzo 14th, 2018

Muchas veces uno comete el error de dejar particiones pequeñas o particiones no separadas dentro de un ambiente Linux, la problematica esencial es cuando la realidad supera las espectativas de uso dentro de una plataforma.
En mi caso particular en una instalación no dimensione el correcto tamaño para la carpeta /var/log/ porque en realidad desconocía el uso masivo que tenía como envío de correo con la consecuencia que el archivo /var/log/maillog ocupaba demasiado espacio llenando la partición, por lo que me vi forzado a moverlo a otro lugar.

Para ello hay que editar el archiv /etc/rsyslog.conf buscar la linea en donde se encuentra la referencia mail.* y exactamente en la misma linea se encuentra referenciado /var/log/maillog

En mi caso la cambié por /nfs/log/maillog que es un servidor NFS con el suficiente espacio para soportar el crecimiento

Finalmente se ejecuta systemctl restart rsyslog y listo

Habilitar el profiling en Moodle a través de Xhprof

domingo, noviembre 29th, 2015

La opción de Moodle para habilitar el modo profiling esta ubicada en Administracion del sitio > Desarrollo > Profiling

En este caso en imagen debes establcer la opción de habilitación y además establecer un ‘*’ para que pueda hacer un profiling a todas las paginas.

moodle_profiling

Luego en Profiling runs, podras ver la lista de ejecuciones de los distintos accesos a las pagina, al ver el detalle te podrás encontrar con cosas como las siguientes

moodle_profiling2

Crear esquema en Oracle para Moodle (desarrollo)

martes, noviembre 4th, 2014

Antes de la instalación de moodle se requiere un esquema que pueda soportar la instalación. Aqui un video que es para dos cosas: como crear un usuario en Oracle (en la práctica un esquema) y como asignar a este esque un tablespace separado del tablespace USERS.

Encontrar en Moodle (Oracle) un texto dentro de columnas codificadas en Base64

miércoles, mayo 8th, 2013

Una de las cosas que hace moodle que en las columnas donde guarda texto, para evitar ciertas problematicas que solo ellos conocen, codifican el dato en Base64. Esto implica que en algunos casos el texto de la columna se va a ver de la siguiente forma (mirar columna CONFIGDATA):

moodle_blockinstances

Una de las maneras de decodificar directamente en Oracle estas columnas es así (un ejemplo con la tabla m_block de moodle):

select id, utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw( configdata))) 
from m_block_instances 
where blockname = 'html' 
and utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw( configdata))) like '%algun texto%'

Instalando el InstantClient de Oracle para PHP en Linux

miércoles, abril 24th, 2013

Aun cuando puedes encontrar en esta página una descripcion detallada de la instalación, aqui te muestro una instalación paso a paso de los comando aplicados en el orden que se expresa para linux, exceptuando la de php-devel que la instale debido a que no estaba. Esta instalación se hizo en RedHat 6.1.

[root@aro-cl oraclePhp]# rpm -Uvh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:oracle-instantclient11.########################################### [100%]
[root@aro-cl oraclePhp]# rpm -Uvh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:oracle-instantclient11.########################################### [100%]
[root@aro-cl oraclePhp]# rpm -Uvh php-devel-5.3.3-3.el6.x86_64.rpm 
warning: php-devel-5.3.3-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:php-devel              ########################################### [100%]
[root@aro-cl oraclePhp]# tar -xzf oci8-1.4.7.tgz
[root@aro-cl oraclePhp]# cd oci8-1.4.7
[root@aro-cl oci8-1.4.7]# phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
[root@aro-cl oci8-1.4.7]# ./configure --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
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 cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib64/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for Oracle Database OCI8 support... yes, shared
checking PHP version... 5.3.3, ok
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking size of long int... 8
checking checking if we're on a 64-bit platform... yes
checking Oracle Instant Client directory... /usr/lib/oracle/11.2/client64/lib
checking Oracle Instant Client SDK header directory... /usr/include/oracle/11.2/client64
checking Oracle Instant Client library version compatibility... 11.1
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1966080
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
[root@aro-cl oci8-1.4.7]# make install
/bin/sh /root/oraclePhp/oci8-1.4.7/libtool --mode=compile cc  -I. -I/root/oraclePhp/oci8-1.4.7 -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /root/oraclePhp/oci8-1.4.7/oci8.c -o oci8.lo 
libtool: compile:  cc -I. -I/root/oraclePhp/oci8-1.4.7 -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /root/oraclePhp/oci8-1.4.7/oci8.c  -fPIC -DPIC -o .libs/oci8.o
/bin/sh /root/oraclePhp/oci8-1.4.7/libtool --mode=compile cc  -I. -I/root/oraclePhp/oci8-1.4.7 -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /root/oraclePhp/oci8-1.4.7/oci8_lob.c -o oci8_lob.lo 
libtool: compile:  cc -I. -I/root/oraclePhp/oci8-1.4.7 -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /root/oraclePhp/oci8-1.4.7/oci8_lob.c  -fPIC -DPIC -o .libs/oci8_lob.o
/bin/sh /root/oraclePhp/oci8-1.4.7/libtool --mode=compile cc  -I. -I/root/oraclePhp/oci8-1.4.7 -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /root/oraclePhp/oci8-1.4.7/oci8_statement.c -o oci8_statement.lo 
libtool: compile:  cc -I. -I/root/oraclePhp/oci8-1.4.7 -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /root/oraclePhp/oci8-1.4.7/oci8_statement.c  -fPIC -DPIC -o .libs/oci8_statement.o
/bin/sh /root/oraclePhp/oci8-1.4.7/libtool --mode=compile cc  -I. -I/root/oraclePhp/oci8-1.4.7 -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /root/oraclePhp/oci8-1.4.7/oci8_collection.c -o oci8_collection.lo 
libtool: compile:  cc -I. -I/root/oraclePhp/oci8-1.4.7 -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /root/oraclePhp/oci8-1.4.7/oci8_collection.c  -fPIC -DPIC -o .libs/oci8_collection.o
/bin/sh /root/oraclePhp/oci8-1.4.7/libtool --mode=compile cc  -I. -I/root/oraclePhp/oci8-1.4.7 -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -c /root/oraclePhp/oci8-1.4.7/oci8_interface.c -o oci8_interface.lo 
libtool: compile:  cc -I. -I/root/oraclePhp/oci8-1.4.7 -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64 -DHAVE_CONFIG_H -g -O2 -c /root/oraclePhp/oci8-1.4.7/oci8_interface.c  -fPIC -DPIC -o .libs/oci8_interface.o
/bin/sh /root/oraclePhp/oci8-1.4.7/libtool --mode=link cc -DPHP_ATOM_INC -I/root/oraclePhp/oci8-1.4.7/include -I/root/oraclePhp/oci8-1.4.7/main -I/root/oraclePhp/oci8-1.4.7 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/11.2/client64  -DHAVE_CONFIG_H  -g -O2   -o oci8.la -export-dynamic -avoid-version -prefer-pic -module -rpath /root/oraclePhp/oci8-1.4.7/modules  oci8.lo oci8_lob.lo oci8_statement.lo oci8_collection.lo oci8_interface.lo -Wl,-rpath,/usr/lib/oracle/11.2/client64/lib -L/usr/lib/oracle/11.2/client64/lib -lclntsh
libtool: link: cc -shared  .libs/oci8.o .libs/oci8_lob.o .libs/oci8_statement.o .libs/oci8_collection.o .libs/oci8_interface.o   -L/usr/lib/oracle/11.2/client64/lib -lclntsh  -Wl,-rpath -Wl,/usr/lib/oracle/11.2/client64/lib   -Wl,-soname -Wl,oci8.so -o .libs/oci8.so
libtool: link: ( cd ".libs" && rm -f "oci8.la" && ln -s "../oci8.la" "oci8.la" )
/bin/sh /root/oraclePhp/oci8-1.4.7/libtool --mode=install cp ./oci8.la /root/oraclePhp/oci8-1.4.7/modules
libtool: install: cp ./.libs/oci8.so /root/oraclePhp/oci8-1.4.7/modules/oci8.so
libtool: install: cp ./.libs/oci8.lai /root/oraclePhp/oci8-1.4.7/modules/oci8.la
libtool: finish: PATH="/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /root/oraclePhp/oci8-1.4.7/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /root/oraclePhp/oci8-1.4.7/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions:     /usr/lib64/php/modules/
[root@aro-cl oci8-1.4.7]# cd /etc/php.d
[root@aro-cl oci8-1.4.7]# vi oci8.ini
; Enable oci extension module
extension=oci8.so
[root@aro-cl php.d]# cd /etc/httpd/conf.d
[root@aro-cl conf.d]# vi oracle.conf
SetEnv NLS_LANG=AMERICAN_AMERICA.AL32UTF8