XMEN BLOGGER: Linux
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, March 21, 2017

Nagios - Windows passive PING


-Configure nsclient (NSC.ini):

[modules]
;# NSCLIENT++ MODULES
;# A list with DLLs to load at startup.
; You will need to enable some of these for NSClient++ to work.
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
; * *
; * N O T I C E ! ! ! - Y O U H A V E T O E D I T T H I S *
; * *
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
NSClientListener.dll
NRPEListener.dll

[Settings]
allowed_hosts=10.68.55.160
use_file=1

[NRPE]
port=5666
command_timeout=90

[NRPE Handlers]
passive_ping=c:\nsclient\pping.bat

-Create batch file (pping.bat):

@echo off
ping –n 1 178.60.210.204 -w 20000 >NUL
IF ERRORLEVEL 1 GOTO err
IF ERRORLEVEL 0 GOTO ok
GOTO unknown

:err
echo CRITICAL: Ping check failed
exit /B 2

:unknown
echo UNKNOWN: Something went wrong
exit /B 3

:ok
echo OK: Ping succeded
exit /B 0

Monday, January 23, 2017

Cygwin - How to run a crontab


Install cron (Vixie's Cron) first!!! From Cygwin setup.exe!!!



From:
http://stackoverflow.com/questions/707184/how-do-you-run-a-crontab-in-cygwin-on-windows

You have two options:

1. Install cron as a windows service, using cygrunsrv:

cygrunsrv -I cron -p /usr/sbin/cron -a -D
net start cron

2. The 'non .exe' files are probably bash scripts, so you can run them via the windows scheduler by invoking bash to run the script, e.g.:

C:\cygwin\bin\bash.exe -l -c "./full-path/to/script.sh"



Hat tip http://linux.subogero.com/894/cron-on-cygwin/

Start the cygwin-setup and add the “cron” package from the “Admin” category.

We’ll run cron as a service by user SYSTEM. Poor SYSTEM therefore needs a home directory and a shell. The “/etc/passwd” file will define them.

$ mkdir /root
$ chown SYSTEM:root /root
$ mcedit /etc/passwd
SYSTEM:*:......:/root:/bin/bash

The start the service:

$ cron-config
Do you want to remove or reinstall it (yes/no) yes
Do you want to install the cron daemon as a service? (yes/no) yes
Enter the value of CYGWIN for the daemon: [ ] ntsec
Do you want the cron daemon to run as yourself? (yes/no) no
Do you want to start the cron daemon as a service now? (yes/no) yes

Local users can now define their scheduled tasks like this (crontab will start your favourite editor):

$ crontab -e # edit your user specific cron-table HOME=/home/foo
PATH=/usr/local/bin:/usr/bin:/bin:$PATH
# testing
* * * * * touch ~/cron @reboot ~/foo.sh 45 11 * * * ~/lunch_message_to_mates.sh

Domain users: it does not work. Poor cron is unable to run scheduled tasks on behalf of domain users on the machine. But there is another way: cron also runs stuff found in the system level cron table in “/etc/crontab”. So insert your suff there, so that SYSTEM does it on its own behalf:

$ touch /etc/crontab
$ chown SYSTEM /etc/crontab
$ mcedit /etc/crontab
HOME=/root
PATH=/usr/local/bin:/usr/bin:/bin:$PATH
* * * * * SYSTEM touch ~/cron
@reboot SYSTEM rm -f /tmp/.ssh*

Finally a few words about crontab entries. They are either environment settings or scheduled commands. As seen above, on Cygwin it’s best to create a usable PATH. Home dir and shell are normally taken from “/etc/passwd”.

As to the columns of scheduled commands see the manual page.

If certain crontab entries do not run, the best diagnostic tool is this:

$ cronevents



Applied the instructions from this answer and it worked Just to point out a more copy paste like answer (because cygwin installation procedure is kind of anti-copy-paste wise implemented).
Click WinLogo button , type cmd.exe , right click it , choose "Start As Administrator". In cmd prompt:

cd cygwin installer:
set package_name=cygrunsrv cron
setup-x86_64.exe -n -q -s http://cygwin.mirror.constant.com -P %package_name%

Ensure the installer does not throw any errors in the prompt ... If it has - you probably have some cygwin binaries running or you are not an Windows admin, or some freaky bug ...

Now in cmd promt:

C:\cygwin64\bin\cygrunsrv.exe -I cron -p /usr/sbin/cron -a -D
or whatever full file path you might have to the cygrunsrv.exe and start the cron as windows service in the cmd prompt

net start cron

Now in bash terminal run:

crontab -e

set up you cron entry an example bellow:

#sync my gdrive each 10th minute
*/10 * * * * /home/Yordan/sync_gdrive.sh

# * * * * * command to be executed
# - - - - -
# | | | | |
# | | | | +- - - - day of week (0 - 6) (Sunday=0)
# | | | +- - - - - month (1 - 12)
# | | +- - - - - - day of month (1 - 31)
# | +- - - - - - - hour (0 - 23)
# +--------------- minute

Tuesday, November 23, 2010

andLinux!!!

Un Linux en tu PC Windows!!!



Báscamente sirve para ejecutar programas de Linux en Windows!!!

Su web es andLinux

AndLinux esta basado en Ubuntu, por tanto, para todos los linuxeros, será fácil su manejo...

Vamos a ver como lo configuramos desde cero!!!!

Primero acceder como root:

$ sudo su

Te pedirá el passwd de tu user y ya accedes como root...

Ahora actualizamos los paquetes, como es Ubuntu, usamos el comando apt-get:

# apt-get update
# apt-get upgrade

Instalamos el sshd:

# apt-get install ssh

Para cambiar el teclado al español, ejecutar el comando:

# dpkg-reconfigure console-data

Y seleccionamos el teclado "Spanish Standard".

Ahora vamos a modificar la franja horaria:

# cd /etc
# rm localtime
# ln -s /usr/share/zoneinfo/Europe/Madrid localtime

Por ahora ya esta listo y accesible por ssh!!!

Tuesday, April 13, 2010

Acceso a la PlayStationNetwork con v3.15 desde el NSLU2


Es fácil, disponer de un equipo con Linux e instalarle un DNS y un Servidor Web como pueden ser el Bind y el Apache...

Yo he tirado de mi NSLU2 para montar este "salto" para "enañar" a nuestra PS3...

El modo de funcionamiento es sencillo, en la PS3, pones como servidor DNS la ip de nuestro Linux... Entonces, todas las peticiones de resolución de Nombres de nuestra PS3 que realiza a la web de la PlayStationNetwork para saber que versión es la actual, nuestro nuevo servidor DNS "transparente" con Bind, la dirige a nuestro Apache que contiene los datos de actualización correspondientes a la versión antigua... En nuestro caso la v3.15, logicamente, tiene que ser la misma versión que tiene nuestra PS3!!!!

Yo tengo montado en mi NSLU2, la distribución Debian Lenny para ARMv5... Vaya, el procesador del NSLU2...

Por tanto usaré los propios paquetes de Debian para realizar la instalación... Tiraré del apt-get para instalar Bind9 y Thttpd, que es un servidor Web más ligerito que el Apache...

Los pasos a seguir son los siguientes...

Instalamos el Bind9 y el Thttpd:

# apt-get -y install bind9 thttpd

Vamos al directorio donde se encuentra nuestro Bind instalado y nos descargamos la entrada de nuestra resolución DNS de la PlayStationNetwork:

# cd /var/lib/bind
# wget http://www.xs4all.nl/~graver1/ps3/ps3.update.playstation.net.hosts

Modificamos la entrada para añadir la ip de nuestro equipo, es importante que la ip sea fija... En mi caso, mi NSLU2 tiene la 192.168.5.53:

# vi ps3.update.playstation.net.hosts

$ttl 38400
ps3.update.playstation.net. IN SOA ps3proxy. me (
1
10800
3600
604800
38400 )
ps3.update.playstation.net. IN NS ps3proxy.
*.ps3.update.playstation.net. IN A 192.168.5.53


Editamos el fichero de configuración del Bind añadiendo lo siguiente:
# vi /etc/bind/named.conf
zone "ps3.update.playstation.net" {
type master;
file "/var/lib/bind/ps3.update.playstation.net.hosts";
};


Reiniciamos el servicio del Bind:

# rndc reload
server reload successful

Ahora añadimos los ficheros de la web de la PSN que busca nuestra PS3 para saber si esta actualizada o no a la ruta de nuestro servidor web:

# cd /var/www
# wget http://www.xs4all.nl/~graver1/ps3/ps3update.tar.bz2
# tar xf ps3update.tar.bz2


Y ya esta listo para funcionar... Sólo queda cambiar las propiedades de red de nuestra PS3 y decirle que su DNS es nuestro Linux!!!!

Por si no sabeis como hacerlo...

En la PS3, vamos a Ajustes -> Ajustes de red -> Ajustes de conexión a internet.
Seleccionamos Personalizar ajustes, en ajustes de dirección poner lo que muestra por defecto (seguramente automatica), y cuando llegemos a la opción Ajustes de DNS, elegimos manual, e introducimos la ip de nuestro Linux en el DNS primario (es un servidor DNS transparente que "engaña" a la Play para poderse conectar a la PLayStationNetwork), en el DNS secundario lo podemos dejar en blanco (con todo 0.0.0.0) -> MTU en automatico -> No usar Proxy -> y "Usar UPnP". Ya queda Listo!!!!

Decir, que con esta configuración, se puede acceder a todos los contenidos de la PSN, descargar Demos y jugar Online... Eso si, si las demos descargadas piden la v3.21, no se podrá jugar...

Thursday, May 11, 2006

Un Traductor UNIXersal de Comandos

Aqui dejo el enlace de un
'Sysadmin's Unixersal Translator'.