admin on August 12th, 2009

So, a friend of mine needed to test an email (SMTP) mail server and was writing something to do this in java when I mentioned that it could be tested via telnet.

Here are some of the commands that I’ve used previously:

  1. Telnet to the mail server on the correct port (by default port 25) e.g. telnet mailhost 25
  2. Type EHLO <domain name> and press enter e.g. EHLO test.com
  3. Type MAIL FROM:<valid sending email address> e.g. MAIL FROM:tester1@test.com
  4. Type RCPT TO:<valid receiving mailbox to which you have access> e.g. RCPT TO:tester2@test.com
  5. Type DATA and press enter
  6. (Optional) Type Subject: <subject of the test email> e.g. Subject:This is a test email via telnet to port 25 on mailhost
  7. Press Enter to leave a blank line
  8. Enter the text of the message e.g. This is a test message sent at 10:33 on 12/08/2009
  9. Press Enter, then a full-stop/period, then Enter again to end the message
  10. Type QUIT to disconnect from the mail server
  11. Exit Telnet as normal.

I’ve put the commands in the text in bold so that they’re easier to spot, but if you follow the examples, you should be fine.

Tags: , , , , , ,

admin on August 7th, 2009

Recently, I had to go through this process to work out what to do when my friend’s Macbook wouldn’t start.

Here’s a reminder of the things I tried:

  1. Start in Safe Mode. Do this by holding down the Shift key while starting. Release Shift when you see the Apple logo and this spinning thing.
  2. Start in Single User mode. Do this by holding down Command-S while you start your Mac. This should bring you to a terminal. The first thing to try is fsck -f to see how many problems there are. (You can do fsck -fy which will run fsck and fix any problems automatically, but you may cause serious problems if your disk has major issues. Be careful if you choose this option and understand what you’re doing!) Run this repeatedly until no further problems are reported.
  3. Start your Mac with the OS X disk in the drive. If you have a drive with a tray, hold down the left-mouse button while starting to eject it. If not, insert it as soon as possible. Either way, hold down the ‘C’ key while booting until the apple logo and the spinning thing shows up. Then, go to Utilities, Disk Utilities. Choose to Repair Disk and keep doing this until there are no more errors. Once this has happened, click on Repair Permissions to fix those too.
  4. If you have no luck with either of the above, then boot your machine in target disk mode by holding down the T button during boot until the Apple logo and spinning thing show up. Then connect it to a working Mac and run step 3 from the working Mac. Consider backing up the failing Mac from the good one at this point. At least you’ll get your data back.
  5. Call Apple or take it into one of their stores.

Tags: , , , , , ,

admin on June 12th, 2009

I came across this problem when we were doing a big merge between branches in CVS. Although it doesn’t look like it, the client is making LOTS of connections - they can be seen in /var/log/syslog (on linux) - and there is a limit on the number of connections that can be made in one minute.

This is the sort of entry you’ll see in /var/log/syslog

<hostname> inetd[<pid>]: cvs/tcp server failing (looping), service terminated

To fix this, edit inetd.conf (normally in /etc) to increase the number of connections allowed in a minute e.g.

cvs stream tcp nowait.400 cvs /usr/bin/cvs …

nowait.400 allows 400 connections per minute which should enough! We saw a connection rate of about 180/minute when merging a BIG branch…

Tags: , , , ,

admin on March 31st, 2009

If you want to edit a bunch of files – for dns updates on bind for example, do this:

sed –i s/<text to replace>/<text to replace with>/g filename_to_change

If you’re concerned about backups, then you can do this:

sed –i’<orginal backup file extension>’ s/<text to replace>/<replacement text>/g filename_to_change

e.g. if we want to edit a file and keep the original with a .old extension the following would work

sed –i’.old’ s/<text to replace>/<replacement text>/g filename_to_change

Notice the single quotes after the ‘i’. This will produce a file with an extension of .old as a backup.

Tags: , , , , , ,

admin on March 25th, 2009

Rsync beats using SCP if you’re trying to copy files from one directory/machine to another. Definitely use rsync if you already have a partial copy and want to copy only new/changed files. This will save you having to copy any files that already exist and are the same.

E.g.

rsync -avz user1@machine1.fqdn:/source/directory/with/all/the/files/* /target/directory/

The -avz options are for:
-a archive mode, which includes a lot of things:

-r recursive (assess/copy subdirectories)
-l copy symlinks as symlinks
-p preserve pemissions
-t preserve modification times
-g preserve group
-o preserve owner (but this will only work if you are super-user)
-D (try and transfer block and special devices - only works as super-user)

-v verbose output
-z compress if possible

There’s also the -n switch which basically executes a dry run and shows you what would happen if you were to run the command.
The -e switch allows you to specify the shell you want to use - if for some reason it’s not picking the one you want. The default is SSH unless you have an environment variable RSYNC_RSH set.

However, sometimes when you use * to say all files in a certain directory e.g.

rsync -e ssh -avz user1@machine1.fqdn:/source/directory/with/all/the/files/* .

rsync will respond with: Argument list too long. This is because the *nix shell expansion creates a list of every single file which can be quite a few!

So, the solution is this:
rsync -e ssh -avz user1@machine1.fqdn:/source/directory/with/all/the/files/. .

Watch out for those trailing slashes - they decide if rsync will create a directory into which to put all the files…

Tags: , , , , , , ,

This is a simple way to get an email from a *nix command line that will test that emails can be sent. I’ve also set it up so that it tells you the name of the user who sent the email and the machine from which it was sent. The time and date is so that if you’re testing multiple times, you can see which emails made it and compare with several users.

echo "Test from `whoami`@`uname -n` on `date`" | mail -s "Test email from `uname -n`" <address1> <address2> <address3...>

This should create an email with the *nix user as the sender to the addresses specified with the subject and the time and date set at the time of sending.

It should help to diagnose if mail is working.

Tags: , , , ,

admin on March 13th, 2009

If you’re using NAT on your virtual machines, you can make the guest O/S services accessible from the host O/S by doing port forwarding. Obviously, this means that the guest O/S can be accessed by anything on the network which may be good or bad depending on your environment.

Anyway, here’s the excerpt from the VirtualBox user manual:

VBoxManage setextradata “Linux Guest” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol” TCP
VBoxManage setextradata “Linux Guest” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort” 22
VBoxManage setextradata “Linux Guest” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort” 2222

That’s 3 different commands with no line breaks in each line.

Replace the “Linux Guest” with the name of your virtual machine - and the ports/protocol if you need to.

I tried it previously in a different order from someone else’s blog post and it didn’t work for me. The order above does seem to work thankfully!

Tags: , , , , , ,

admin on March 13th, 2009

There are, apparently, two ways to create a clone of the Virtualbox drives. The ‘right’ way and the ‘wrong’ way.

The right way is to use the following:

VBoxManage clonehd <filename> <outputfile>

You can optionally use the UUID as the input filename.

Anyway, the ‘wrong’ way to do it is to make a copy of the .vdi file in the O/S as I did. Then when you try and attach it, it won’t work!

To fix this situation do this:

VBoxManage internalcommands sethduuid <filename>

I have NO idea if this is supported, so try it at your own risk - I copied the backup again to make sure I could rollback.

Tags: , , , , , , , , ,

admin on March 10th, 2009

A couple of gotcha’s here…

If you get an error saying that OC4J configuration issue <blah blah instance> not found (often TSH1),  check the ORACLE_SID variable to make sure it’s correct. The ‘$ORACLE_HOME/bin/emctl start dbconsole’ command should now work. Check this by looking at http://servername/1158/em (by default)

The other one is that when you start the Enterprise Manager first time and log in, you get a ‘java.lang.excception no such metric’. If this is the case, then under Related links, check the Monitoring Configuration and make sure that the dbsnmp user has been set up correctly i.e. with the correct password. Test the connection from there and the problem should go away.

Tags: , , , , , , , , ,

admin on January 23rd, 2009

Here’s an interesting slide deck from Jay at MySQL, which shows some very simple concepts to take into account when looking at MySQL performance.

http://www.slideshare.net/techdude/how-to-kill-mysql-performance?src=related_normal&rel=366335

Tags: , , ,