Monitorear el Precio del Bitcoin con Nagios (just for fun)

Con Nagios es posible monitorear lo que queramos.

Con las últimas subidas y bajadas de Bitcoin, se me ocurrió meter en algún dashboard un chequeo. Para eso armé el siguiente script:

check-btc.sh

Consulta contra la API de Bitstamp el LOW o el HIGH del valor.

Se puede usar para recibir una notificación por mail, o para ejecutar una acción mediante un event handler, por ejemplo, comprar o vender.

El script se ejecuta:

./check-btc.sh <high/low> <vaue>

Por ejemplo, el siguiente comando chequea si el valor del último high superó a 1500.

./check-btc.sh high 1500
OK: 1249 | high=1249

Y este ejemplo verifica si el último low, fué inferior a 1000:

./check-btc.sh low 1000
OK: 1214 | low=1214

Además escribe la data para graficar.

Un ejemplo de definición en Nagios:

Comandos:

define command{
    command_name check_btc_high
    command_line $USER1$/check-btc.sh high $ARG1$
}

define command{
    command_name check_btc_low
    command_line $USER1$/check-btc.sh low $ARG1$
}

Servicios:

define service {
    use                           generic-service,srv-pnp
    host_name                     BTC-CHECK
    service_description           BTC HIGH THAN 1500
    check_command                 check_btc_high!1500
    notifications_enabled           0
}

define service {
    use                           generic-service,srv-pnp
    host_name                     BTC-CHECK
    service_description           BTC LOW THAN 1000
    check_command                 check_btc_low!1000
    notifications_enabled         0
}

Y el resultado es:

Saludos !

Read more