-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hola:
Quiero ejecutar un programa externo cuando aparezca un mensaje determinado en el syslog.
documentación syslog-ng Destination drivers file() pipe() unix-stream() & unix-dgram() udp() & tcp() usertty() program()
Es decir, puedo enviar una retahila de mensajes a un programa. La documentación de program() está en file:///usr/share/doc/packages/syslog-ng/html/index.html##id2510439 y pone:
program()
This driver executes the specified program with the specified arguments and sends messages to the standard input (stdin) of the child.
The program() driver has a single required parameter, specifying a program name to start. The program is executed with the help of the current shell, so the command may include both file patterns and I/O redirection, they will be processed.
Declaration: program(commandtorun);
Note
The program is executed once at startup, and kept running until SIGHUP or exit. The reason for this is to prevent starting up a large number of programs for messages, which would imply an easy DoS.
Example 3.14. Using the program() destination driver
destination d_prg { program("/bin/cat >/dev/null"); };
Que no es lo que yo busco. Lo que hace es arrancarlo desde el principio y mandarle los mensajes que corresponda; y yo quiero que lo ejecute sólo cuando ocurra el mensaje en cuestión.
En fin.
Entonces parece que tengo que hacer algún programita que esté en un bucle esperando un texto por stdin, y que mientras no reciba ninguna linea esté parado. Y pienso hacerlo con un script.
¿pero como?
¿Que bucle pongo en el script para que espere sin hacer nada hasta que llegue una linea por stdin? Esa es mi duda.
¿Quizás esto? :
#!/bin/bash while true ; do read # hacer mis cosas router_ip | grep 0.8.32 | cut --fields=14-15 | logger done
- -- Saludos Carlos E.R.