Ben Ruset Sysadmin, etc.

10Aug/070

Lame Update

Couple of things to touch on:

1. I found my first example of "why do it in Perl when shell will do it better/quicker/easier?" Consider this - njpinebarrens.com backs up it's database and the webroot for three sites nightly to a gzipped tar file to a 40GB USB external drive. The site itself takes up a few gig, so clearly a nightly script that doesn't clean out old stuff is not a sustainable thing. As such, the drive filled up and I lost a few nights backup. I was going to write a perl script to run the backup (which really is just doing a mysqldump and tar czvf'ing the /var/www directory up) and delete files older than X days. Then I googled a bit and came up with:

find /backup -mtime +7 -exec rm -f {} \;

That pretty much does what I need it to do. One line. No mess. Of course I now feel like an awful sysadmin for not realizing I could do that before. Oh well.

2. Verizon is coming to fix the loud hummmmmmmmmmm in my line tomorrow. I feel like my copper phone line is an antique. I really need to find a nice old 1940's rotary phone and stick it in my house somewhere.

3. BBQ at Helene's tomorrow. Maybe there will be some Zumba.

4. Devin mentioned me in his blog. I don't rate high enough to be mentioned by name though. Also, I like to think of myself as more than just "the IT guy." I may have to flip my BOFH excuse calendar out and blame the slow network on... sunspots.

5. Gonna try to take some photos this weekend. Gonna try to remember to charge the battery in the camera.

6. Getting vendors to call you back is a pain. So far I am waiting on:

  • A quote from Yipes for point to point Metro Area Ethernet (it's a MAN baby!) between the office and the colo
  • A con call with Watchguard on Monday
  • A replacement Sun V210 (should be shipping next week)
  • Verizon to call me back about their metro area ethernet
Filed under: Perl, Work No Comments
7Aug/070

First Real Perl Script

I spent the better day working on a perl script to configure the Advanced Lights Out Manager on Sun Sunfire servers. This script will basically read in a bunch of variable and execute the various shell commands to get the ALOM fired up. The basic syntax will be:

./configurealom.pl ipaddress netmask gateway y|Y|n|N

The last value tells the script if you want to have it reboot the ALOM card or not. You need to reboot the card for changes to happen, I believe. I included the reboot command as an option for safety.

#!/usr/bin/perl

use Shell;

($ip, $netmask, $gateway, $reset) = @ARGV;

$uname = uname('-i');
$hostname = `hostname`;
chomp($uname);
chomp($hostname);

$scadmpath = "/usr/platform/$uname/sbin/scadm";

`$scadmpath set if_network true`;
`$scadmpath set netsc_tpelinktest true`;
`$scadmpath set netsc_dhcp false`;
`$scadmpath set netsc_ipaddr $ip`;
`$scadmpath set netsc_ipnetmask $netmask`;
`$scadmpath set netsc_ipgateway $gateway`;

if ($reset eq "y" || $reset eq "Y")  {

$reset = `$scadmpath resetrsc`;
print "Configured the Sun ALOM on $hostname as:\n";
$shownetwork = `$scadmpath shownetwork 2>&1`;
print $shownetwork;
}

else {
print "Configured the Sun AOLM on $hostname with: \n";
print "IP address: " . $ip . "\n";
print "Netmask: " . $netmask . "\n";
print "Gateway: " . $gateway . "\n\n";
print "Don't forget to reset the ALOM with the following command:\n";
print $scadmpath . " shownetwork\n";
}

Things to do:

  • Do I really need use Shell; ?
  • Error checking. Right now you can put any value into the array for the config. I'd like to check for a) the existence of a value and b) if it's in the right syntax.
  • Is there a better way of checking to reset the card? Using the || operator seems a bit kludgey, but so does newvar$ = lc($reset);.
Filed under: Perl, Tech No Comments