BUZZ NEEDS YOUR VOTES!



Archive for July, 2008

The downside of a development server is … it’s for development.

It is  not always cost effective to have the exact same setup as you you have in your production environment …

Especially if you have a multi server setup.

So I find myself today moving /var/lib/mysql … being as the OS drive is very small, and pulling down a near 20GB database backup and then trying to rebuild the database on the same drive … well as you can imagine caused a few problems *doh*


/etc/init.d/mysql stop
mv /var/lib/mysql /raid_5/

So surely you just symlink … right?


ln -s /raid_5/mysql /var/lib/mysql
/etc/init.d/mysql start

Well then answer would be no … upon importing the backup


mysql < backup.sql
Can't create table './database/table.frm' (errno: 121)

A nice errorno: 121


/etc/init.d/mysql stop
rm -rf /var/lib/mysql
mkdir /var/lib/mysql
chown mysql:mysql /var/lib/mysql
mount --bind /raid_5/mysql /var/lib/mysql
/etc/init.d/mysql start

et voila …

Data directory is relocated and the import working smoothly. Feel free to suggest any “cleaner” methods.

Comments No Comments »

This is something I find myself having to do, more and more lately due to this VoIP roll out.

From windows (xp)

Start > run > cmd

Once the command window is open ping the IP address of the device (this forces your system to do an ARP request and store the device information in the cache, don’t ask me why but microsoft decided it was a good idea not to lookup the information if it isn’t allready in the cache!)

NOTE: Even if the device blocks ICMP, this should still work, run ettercap on your windows network to see just how many times you will see an ARP request along the lines of “WHO HAS xxx.xxx.xxx.xxx”.

Now to get the MAC address type


arp -a xxx.xxx.xxx.xxx

Where xxx.xxx.xxx.xxx is the IP address of the device you just pinged.


C:\Documents and Settings\buzz>arp -a 10.99.1.10

Interface: XXX.XXX.XXX.XXX --- 0x3
Internet Address Physical Address Type
XXX.XXX.XXX.XXX AA-BB-CC-DD-EE-FF dynamic

Please note this only works for a device on the same IP range.

If you run two ranges, i.e.

192.168.1.XXX

and

192.168.2.XXX

You will need to make the ARP request from a device bound to that range (servers are especially usefull here).

Comments 1 Comment »

Well I’ll be damned, someone has actually done it!

http://www.aut.bme.hu/portal/SymTorrent.aspx?lang=en

A fully featured bittorrent client for your s60 mobile!

I am giving this a go on my N95 8GB now!

UPDATE: This works well by the looks of things.

DISCLAIMER: I AM USING WIFI FOR TORRENTS, DO NOT USE YOUR GPRS / 3G / EDGE DATA SERVICE FOR TORRENTS UNLESS YOU WANT A HUGE BILL!

Comments No Comments »

The page here: http://blog.totalcomputing.co.uk/2007/06/installing-mail-for-exchange-on-nokia.html

Describes how to get mail for exchange ( a nokia app) running on the N95

First install 1.3.1 and enter all your settings, and do a full sync.

Now update to 1.5.0, the reason for this is that once 1.5.0 is installed non of the settings can be changed.

I am yet to give this a go on my N95 8GB, but will post an update once I have.

UPDATE: Download version 2.5.5 here

Comments No Comments »

To test a POP3 connection using telnet open a command window or shell terminal and type the following


telnet smtp.domain.com 25

Where smtp.domain.com is the FQDN (Fully Qualified Domain Name) or IP address of the server you wish to test.

25 also assumes default SMTP configuration.

You will be greeted with something similar to:


Escape character is '^]'.
220 smtp.domain.com

Now you need to enter the HELO command, followed by an idenfication of the server you ar esending from.


HELO buzz.domain.com
250 smtp.domain.com

Anything other than “250″ indicates a problem.

You can now proceed with the test email transaction.


MAIL FROM: buzz@buzz.domain.com
250 Ok
RCPT TO: buzz@smtp.domain.com
250 Ok
DATA
354 End data with .
This is where the data goes, you finish the input by placeing a dot (.) on a single line.

.
250 Ok: queued as D9FA03705C9
QUIT
221 Bye
Connection closed by foreign host.

Comments No Comments »

To test a POP3 connection using telnet open a command window or shell terminal and type the following


telnet pop.domain.com 110

Where pop.domain.com is the FQDN (Fully Qualified Domain Name) or IP address of the server you wish to test.

110 also assumes default pop3 configuration.

You will be greeted with somthing similar to:


Connected to localhost.
Escape character is '^]'.
+OK dovecot ready.

Now you need to authenticate


USER buzz
+OK
PASS thisismypassnorealyitis...honest
+OK Logged in.

Once logged in you can now make use of the following commands

STAT This command will respond as follows (colour added)


STAT
+OK 12 3571942

This indicates there are 12 emails in the mail box with a total size of 3571942 bytes.

LIST This command will list a line for each message with its number and size in bytes


+OK 12 messages:
1 1209
2 307
3 32715
4 218
5 15937
6 3469
7 98724
8 54356
9 1128
10 560
11 1150309
12 2213010
.

RETR 11 This is the retrive command, in this case this will display the contents of email 11

DELE 11 This is the delete command, in this case this will mark email 11 for deletion (will not delete it).

RSET This is the reset command, this will clear any delete flags you have set.

QUIT This command will logout of the current account, any emails marked for deletion will now be deleted.

Comments No Comments »

Or that would be 07/25/2008 for the US readers.

It is here again, the last friday of july is System Administrator Appreciation Day

So get them a card / lifetimes supply of coffee / beer / LOTS AND LOTS of BEER

Or you may find next time that file goes _missing_ there may be a delay in restoring it ;-)

Comments No Comments »

Following on from deploying 802.1Q in prep for these VoIP phones, they have been delivered this morning *yey*, that said a nice error message


2/5 network setup

bad tftp1 address

*meh* .. still not one to wait, so a quick google later reals by pressing “i” followed by “#” on the handset (before it resets), brings up a config menu …

Expect more doubt as I continue to “play”.

Comments No Comments »

Prompted by the following remarks today …

Kerm: “;) there is always an abbreviation in the CLI as all sysadmins are lazy feckers”

Kerm: “Someone might think you actually do work occasionally, god forbid!”

Sysadmins are NOT inherently lazy, we just know how to save time, and are quite adept at doing so …ok?

You cheeky sods!

So let me clear up one instance in which I take a lot of information, and make it quickly and easily accessible using a “Lazy feckers” abbreviation …

Be warned this is a very jaded write up, read on at your own peril.

Right then, onto the point of this post, the sysadmin script part 1, this is going to cover how to check how many connections to a specific port you have on your server.

Trust me this becomes very useful when you have exhausted all other options when trying to figure out why your web server is running like a dog with no legs …


netstat -ant

After running the above on your SSH session you will see lines, and lines … and yet more lines of network connection information, especially if you just run this on a busy server.

Example (colours added):

tcp 0 0 ***.***.***.***:25 ***.***.***.***:32794 ESTABLISHED

Key:

PROTOCOL Tx Rx LOCALHOST:PORT FOREIGN_HOST:PORT CONNECTION STATE

From this information it’s pretty easy to spot this is an inbound SMTP connection.

(If you can’t see why, don’t worry it’s ok maybe it’s genetic)

Now this may be handy, but other than taking all this information and dumping it into a spreadsheet (god knows you love those spreadsheets !!! ), how are you going to figure out how many connections are occurring from that external host?

How infact are you going to be able to easily see how many total connections to that port you have ?!?!

Bash script, now for some history, Bash is the Bourne Again Shell, or as I like to think of it, it is the verb for what I will do to your head if you ask me what BASH / SSH / Shell is again …

Now create a directory:


mkdir ~/.sysadmin
cd ~/.sysadmin

Note the prefixing dot, this will create a “hidden” directory in your home directory (~), the reason for this is so you don’t have system admin script sat in your home directoy, as if you are like me, all sorts of crap moves in an out of that directory on a daily basis, and the last thing you want to do is to have to rummage through backups trying to find “that script you wrote to diagnose connection problems a year ago“.

The point is these scripts will become part of your workflow, once written they will rarely need updating, and should never be called directly, (I mean we’re lazy right? WTH do we want to be typing the full script path for? … oh yeh it saves time!).

In this case:


vi ~/.sysadmin/buzz.sh

You can of course call your script whatever you want, and use any text editor you want, if you don’t like / know vi …


#!/bin/bash
# Sysadmin script PART 1 http://www.saiweb.co.uk
# Provided under the MIT license (http://www.opensource.org/licenses/mit-license.php)
# © D.Busby
function usage {
echo "Usage: portcon port";
echo "i.e. portcon 80";
}
function portcon {
echo "----- Active Connections For Port $1 -----";
netstat -ant | grep "ABC.DEF.HIJ.KLM:$1 " | wc -l
netstat -ant | grep "ABC.DEF.HIJ.KLM:$1 " | awk '{ print $5 }' | awk -F \: '{ print $1 }' | sort | uniq -c | sort -n
}
if [ -z "$1" ]; then
usage;
exit
fi
$1 $2

Ok so the above code is provided with two functions usage and portcon.

MAKE SURE YOU REPLACE “ABC.DEF.HIJ.KLM” WITH YOUR LOCAL IP ADDRESS

CHMOD this file to allow execution.


chmod +x ~/.sysadmin/buzz.sh

Now edit your bashrc file.


vi ~/.bashrc

And add the following:

alias buzz=’~/.sysadmin/buzz.sh’

Now exit (logout) your SSH session and log back in (or SU root > SU your_user for testing).


[buzz@buzz_srv ~]$ buzz
Usage: portcon port
i.e. portcon 80
[buzz@buzz_srv ~]$

Now run the portcon check …


[buzz@buzz_srv ~]$ buzz portcon 80
—– Active Connections For Port 80 —–
505
1 ***.***.***.***
3 ***.***.***.***
3 ***.***.***.***
4 ***.***.***.***
4 ***.***.***.***
5 ***.***.***.***
11 ***.***.***.***
14 ***.***.***.***
16 ***.***.***.***
76 ***.***.***.***
373 ***.***.***.***

(Yes before you ask ***.***.***.*** does display the correct IP address, I have purposely removed them for security).

So, I have taken something that would of resulted in netstat output > spreadsheet to formulas > at a estimate 30mins a time analysis to something that now takes less than 5 seconds to type, and get the relevant output, for roughly the same initial effort (30 mins scripting time).

You could argue you can keep a spreadsheet pre-setup with the right formulas / pivot tables and just dump the data each time, well yes you could but that’s no where near as quick as this …

And no trying to convince me it is as quick and better than the script above, for

  1. You have to wait for excel to open the spreadsheet
  2. You have to copy paste the data
  3. You have to wait for excel to process the formulas

If you have a machine that can do that in time equal to or less than the time it takes the script above to output the data, the only thing I have to say is, stop spending such a budget on desktops and get a better server.

Final Thoughts:

This write up is in jest, and is intended to be read as such, the code and methods provided above are factual. etc …

Comments No Comments »

Some VoiP devices require the use of 802.1Q, encapsulation protocol, to set this up you are going to have to do this using telnet, and on a per port basis.

If you don’t know how to start a telnet session with your Cisco device, then I suggest you stop reading now, and defer this task to someone who does, no offense but getting this wrong can screw up your network.


User Access Verification

Password:
3560>enable
Password:
3560#conf t
Enter configuration commands, one per line. End with CNTL/Z.
3560(config)#int GigabitEthernet0/1
3560(config-if)#switchport trunk encapsulation dot1q
3560(config-if)#switchport mode trunk
3560(config-if)#^Z
3560#wr mem
Building configuration...
[OK]

All you need to know is above, simple rinse and repeat for the other ports you wish to use 802.1Q, of course you can forgo the CTRL+Z followed my wr mem if you have multiple ports to do, just make sure you do CTRL+Z folowed by a “wr mem” otherwise your changes will only effect the current running configuration, if the device is restarted for whatever reason changes will be lost.

Comments No Comments »