ubuntu

Auto-mount Samba Share on Ubuntu and Windows

SambaSamba is a very popular program used to share files, folders, and printers throughout networks with different computers and operating systems.  It's useful if you want to store or share things from one computer, say on an Ubuntu file server, and then access them from around the network, say on a Windows desktop or Ubuntu desktop.

One question I see a lot of mixed answers for on the Ubuntu Forums is "how can I auto-mount my samba share?"  So here are some quick and easy ways to get your samba share mounted on login.

Windows

Windows is pretty straight forward.  The first thing is to open up Notepad.  Paste in the following:

Read more

Automate Ubuntu Server Shutdown

power downSomebody on the Ubuntu Forums was asking how to get their server to shut down automatically when no other computers are online on the network.  This can be useful if you have Wake-On-Lan enabled on the server, and you're only using it for things like printer or file sharing.  I responded with a little php script I whipped up that does the job nicely.

You will need the php package and the nmap package to make this work

sudo apt-get install php nmap

Next, you'll need to know how to setup a cron job.  If you don't, check out this tutorial.

Here is the contents of the php file.
hostsup.php
 

<?php
// Call the nmap command
$output shell_exec('nmap -sP 192.168.1.*');

// Split up the output so we get the number of hosts up
$split1 explode("addresses ("$output);
$split2 explode(" hosts up"$split1[1]);
$hostsup $split2[0];

// If only x number of computer are on + router, shutdown.  Take in account the server being a computer!
if($hostsup == "2") {
    
$shutdown shell_exec('shutdown -h now');
}
?>

You'll need to edit the "192.168.1.*" to fit your network's IP range.  Also, change the $hostsup == "2" to the number of computers you want on when it shuts down.  The server counts as one, your router counts as one, and if you have any of those network printers, they also count.  If it gets an IP, count it.  Feel free to change the shutdown command to something else if you want to put the server into standby or what have you.

In your cron job, just set the command as

php -f /path/to/file/hostsup.php

Set the cron to run as often as you like.  I'd set it for every half-hour just to not use up too many resources, and still be effective.

What this script is doing is executing "nmap -sP 192.168.1.*".  This generates a list of nodes on the network that are currently online, and their IP addresses.  The next 3 lines parse through the information to only get the number of nodes online.  Next we check how many are online, if the numbers match then execute the shutdown command.  You'll need root or sudo access to use the shutdown command, so watch out.

DIY Verizon Ringtones

Verizon WirelessFor those of you using cell phones, one of the more costly features is the ability to download custom ringtones.  Some ringtones on Verizon Wireless can cost $8.00.  That's almost half the price of a standard CD for a 30 second clip of one song.

Some carriers and phones let you choose an mp3 from your music player to use as a ringtone.  Others are open enough to let you go online and (for a price usually) find a ringtone and get it sent to your phone.  However, on Verizon Wireless you seem to be stuck.  You either buy a ringtone through Verizon's Get It Now feature or you wait for a Free download to show up in Get It Now which rarely ever happens.

With some tinkering and exploration online and on other web sites, I've found a way to get your favorite ringtones onto your Verizon phone for free and using any operating system.  You'll need the following:

  1. Your favorite mp3 file
  2. Audacity sound editor.  You will also need to make sure you have the LAME MP3 Encoder so that you can export as an mp3 file.
  3. An E-mail address
  4. Pix messaging.  If you don't have a texting plan, be careful as Verizon may charge you for downloading a text/pix message.

The first step is to open up your mp3 file in Audacity.  Select about 30 seconds worth of the song that you want to use as your ringtone.  Some phones support longer, but it keeps the file size down and therefore makes it faster to send. Also Verizon may reject your message if it's too large.

You can go up to Edit > Trim and this will crop your 30 seconds of music.  Now go to File > Export and save your file as an MP3 file.  The trick is to save it so that the file is an MP3, but its file extention is .midi.  So tack on .midi onto the end of the file name.

save file

save file with a .midi extention

are you sure

Select yes in this dialog box

So what we have so far is a 30 second clip of a song saved as a mp3 file with a .midi file extention.  Simple right?

Next, open up your email client.  For the TO address, your email will be (tendigitnumber) @vzwpix.com.  Example would be 5551230987@vzwpix.com.   You need to make sure that you fill in a subject, so make it something like "ringtone" and fill in something for the body so make it something like "ringtone".

Attach your .midi mp3 file you made earlier, and send the email.

email attachment

Make sure you fill in both a subject and body for the email!

You should get a pix message on your cell phone.  After you open it, go to options and select Save as Ringtone.

You may need to play around with the settings on Audacity to get the best sounding ringtone.  I'd suggest having it on mono instead of stereo, or raising the bitrate at which it encodes your mp3 file.

If you need help with anything, or you have any recommended settings post a comment or contact me.

Update:
This will not charge you for "data transfer" which can be expensive.  This will only charge on your bill as a Pix-Flix message.  If you have texting on your plan, you will not be charged at all.  If you don't have a texting plan, it will only cost about 25 cents for receiving a pix-flix message.

Doesn't charge data!

Folding @ Home

Protein foldAt my house, I have an Ubuntu server setup to store/share files, stream music, develop web sites, and some other things.  I leave it on all day because it serves as the print server for all the family computers, so I figured I could put it to some use.

Incase you've never heard of it, Stanford's Folding@Home project is a massive distributed computing grid, using the processing power of thousands of personal computers' idle cycles to simulate folding proteins.  I'm no scientist but on their web site they explain that folding is how cells work in the body.  When these cells mis-fold, it causes diseases like alzheimer's and mad cow disease.

So I installed the Folding@Home client on my server.  I wonder why more people don't set this up.  It adjusts so that the process doesn't suck all the CPU resources.  The client reports to the servers at Stanford to record both my stats and overall team stats (I joined Team Ubuntu.)

If your computer is on for more than 6 hours a day, you should take a look at it.  Folding@Home has a client for just about every computer operating system, so users from Linux, Windows, and Mac can all help out.  There's also support for multi-core processors, so you can run a client for each core.

Apache versus Lighttpd

I've been a big Apache fan since I was able to apt-get install on my Ubuntu box. Lately I've been messing around with different web servers so I thought I'd try out Lighttpd to see how it compared to Apache.

I used Apache Benchmark to run the test. All I did was run

ab -n 5000 http://localhost/

So I just sent 5000 request to localhost. First I ran Apache by itself. Here are the results:

Finished 5000 requests

Server Software: Apache/2.2.8
Server Hostname: localhost
Server Port: 80

Document Path: /
Document Length: 145 bytes

Concurrency Level: 1
Time taken for tests: 3.910033 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 1990000 bytes
HTML transferred: 725000 bytes
Requests per second: 1278.76 [#/sec] (mean)
Time per request: 0.782 [ms] (mean)
Time per request: 0.782 [ms] (mean, across all concurrent requests)
Transfer rate: 496.93 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 30
Processing: 0 0 1.1 0 30
Waiting: 0 0 0.1 0 6
Total: 0 0 1.2 0 31

Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 0
95% 1
98% 2
99% 3
100% 31 (longest request)

 

It wasn't too bad. Now on to Lighttpd

Finished 5000 requests


Server Software: lighttpd/1.4.19
Server Hostname: localhost
Server Port: 80

Document Path: /
Document Length: 145 bytes

Concurrency Level: 1
Time taken for tests: 2.60885 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 2005000 bytes
HTML transferred: 725000 bytes
Requests per second: 2426.14 [#/sec] (mean)
Time per request: 0.412 [ms] (mean)
Time per request: 0.412 [ms] (mean, across all concurrent requests)
Transfer rate: 950.08 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 31
Processing: 0 0 0.5 0 29
Waiting: 0 0 0.0 0 0
Total: 0 0 0.7 0 32

Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 0
95% 0
98% 1
99% 1
100% 32 (longest request)

If we compare the numbers, it's obvious that Lighttpd did a better job at fulfilling the requests faster, with a higher transfer rate. For now I've switched my server over to Lighttpd. It's only used for torrentflux, vmware, and small testing sites but the switch will definitely free some resources and serve pages more quickly.


Specs

Ubuntu 8.04 Server Edition
512 Mb Ram
1266 Mhz (1.266 Ghz)

 

Syndicate content