Archive for the ‘Notes’ Category

URL redirection at freeshell.de

Monday, November 22nd, 2010

This blog is hosted by freeshell.de – Nic Nac Project server. Great! 🙂

Since the same page of this server can be reached by several URL, I decided to add a little trick for redirecting my blog visitor to the same address. This may be useful to help web spiders in indexing my pages.

For this reason if  You try to reach

http://www.freeshell.de/~jose
http://nic-nac-project.de/~jose
or any other equivalent URL, Your browser will be redirected to
http://www.nic-nac-project.de/~jose/

Since my blog is a WordPress one, a .htaccess file has been made by my software configuration. I set up the redirection by adding two lines to the .htaccess file created by WordPress in my public_html directory:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~jose/
RewriteCond %{HTTP_HOST}    !^www\.nic-nac-project\.de [NC]
RewriteRule ^(.*)$    http://www.nic-nac-project.de/~jose/$1 [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~jose/index.php [L]
</IfModule>

backup or dump a micro$oft DHCP configuration

Tuesday, August 31st, 2010

On a Microsoft 2003 server It’s possible to backup the DHCP configuration with the command

C:\Documents and Settings\server\Desktop>netsh dhcp server export dumpfilename.netsh all

while If You need a plain text dump (e.g. to plan a migration to a free-software DHCP server)

C:\Documents and Settings\server\Desktop> netsh dhcp server dump all >dumpfilename.txt

Human readers usually like the last way…
dhcp_dump

playing with iSCSI

Monday, May 31st, 2010

Internet SCSI, shortly iSCSI, is an IP based protocol used for networking storage. With iSCSI it’s possible to send commands to remote SCSI storage on remote hosts, for this reason it is quite common in the SAN world.
Since IP networks are very common, iSCSI can be used to transmit data over LAN, WAN, or the Internet and can enable location-independent data storage and retrieval.

Once installed the package iscsitarget, You can specify the location of a shared area

vlinux19:/root# grep -v \# /etc/ietd.conf

Target iqn.2010-03.my.domain:my.storage.id
Lun 0 Path=/dev/sdc,Type=fileio
Alias Test

and, once started the daemon, any Windows client can see the storage with the Microsoft iSCSI initiator.iscsi client

batch ftp script

Sunday, February 7th, 2010

If for some reason You need a quick and dirty script to retrieve some file from a ftp server, just open your text editor and write some things into your file. Then a simple command line command will download the file You have just write the path.

MS-DOS way:

C:\TMP> TYPE COMMANDFILE.TXT

username

password

dir

get wp-config.php

quit

C:\TMP> FTP -S:COMMANDFILE.TXT ftp.server.name

UNIX/LINUX way:

$ cat test

user username password

dir

get wp-config.php

quit

$ ftp -n ftp.server.name < test

wrapped nagios plugin to enable performance data

Tuesday, December 29th, 2009

In the nagios world, PNP4Nagios is an useful tool for collecting measures and drawing a graphic, e.g. to show the use of a monitored resource.
A plugin for PNP4Nagios is useful if it’s able to write some performance data.

So, the plugin output should be something like

PING OK – Packet loss = 0%, RTA = 0.26 ms|’ping reply time’=26ms

instead of

PING OK – Packet loss = 0%, RTA = 0.26 ms

If Your plugin does’n write performance data, You can put a simple shell scritp between nagios and the plugin with a small modification of Your nagios config.

  1. /etc/nagios/commands.cfg

    define command{
    command_name wrapped_ping
    command_line /usr/lib/nagios/plugins/wrapped_ping $HOSTADDRESS$ $ARG1$ $ARG2$
    }

  2. /etc/nagios/services.cfg

    define service{
    use generic-service ; Name of service template to use

    host_name intranet
    service_description PING
    is_volatile 0
    check_period 24×7
    max_check_attempts 3
    normal_check_interval 5
    retry_check_interval 1
    contact_groups admins
    notification_interval 120
    notification_period 24×7
    notification_options w,u,c,r
    check_command wrapped_ping!100.0,20%!500.0,60%
    }

  3. /etc/nagios/serviceextinfo.cfg

    define serviceextinfo {
    host_name intranet
    service_description PING
    action_url /nagios/share/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
    }

Here You can download my version of the wrapped_ping shell script I wrote.

nagios plugin using expect and shell scripting

Tuesday, October 13th, 2009

In some cases, if You need to monitor some remote host resource without SNMP or any other simplest way, maybe You need to write a shell nagios plugin calling an expect script. A quite strange way, I admit.

Well, You can write something like that:

MYRESULT=$(/usr/bin/expect – << EOF
set timeout -1

spawn ssh $MYUSERNAME@$MYHOSTNAME
expect {
ssword: {
send “$MYPASSWORD\r”
}
}
expect {
bash-prompt {
send “$MYCOMMAND\r”
}
}
expect {
bash-prompt {
send “exit\r”
}
}
EOF)

ssh tunnel to get into a private network

Sunday, September 13th, 2009

If Your Linux box is inside a private network and You need some friend of yours get in, ssh may help You: from the linux box try

ssh -R afreeport:localhost:22 user@remote.host.name

E.g. the command

ssh -R 2048:localhost:22 jose@nic-nac-project.de

opens a shell on the nic-nac-project.de host redirecting all connections to port 22 (ssh) to the 2048 port.
It means while your ssh session is opened, all the users logged into nic-nac-project.de host can get inside your Linux box opening a ssh session to 2048 port of localhost.

ssh -p 2048 localhost

Obviously ssh server daemon have to be running on the linux box!

How to make a Debian Lenny Box leave a M$ Active Directory Domain

Thursday, July 9th, 2009

In order to remove a linux box from an Active Directory domain, just do a

# net ads leave  -U adminaccount -W DOMAIN