Thursday, August 21, 2008

Show mounted filesystems on a Netapp

We're working on moving from an old Netapp to a new Netapp. Before doing so, we need to make sure that no systems have any mount points on the old filer still mounted.

On a regular/unix nfs server, you would login to the box and run "showmount -a" which queries the mount daemon. The netapp systems don't offer the showmount command though.

I found a mailing list article that explained you can run "showmount -a XYZ" where XYZ is the hostname/ip of your netapp filer.

roadrunner:~ # showmount -a 172.16.2.6
All mount points on 172.16.2.6:
10.1.112.17:/vol/root
172.16.13.16:/vol/space/offsite.backup
172.16.13.18:/vol/space/offsite.backup
172.16.13.5:/vol/space/db.preprod
172.16.13.5:/vol/space/offsite.backup
172.16.13.7:/vol/space/offsite.backup
172.16.23.1:/vol/space/endeca.preprod
172.16.23.6:/vol/space/db.preprod
172.16.23.6:/vol/space/offsite.backup
172.16.3.6:/vol/root
mailhost:/vol/space/imagemgr
roadrunner:~ # 
Now I know what hosts I need to check before deprovisioning this Netapp.

Update: From the article, I missed the caveat. NFS is stateless, so some unix hosts could still have the system mounted, but not actively use the mount.

As suggested, I turned the nfs.per_client_stats.enable bit on, and now I'll just wait and see who is actively using the Netapp.

netapp> options nfs
[...]
nfs.netgroup.strict          off        
nfs.per_client_stats.enable  off        
nfs.require_valid_mapped_uid off        
[...]
netapp> options nfs.per_client_stats.enable on
netapp> nfsstat -l
172.16.2.2                  NFSOPS =          6 ( 0%)
172.16.3.2    mailhost                        NFSOPS =          8 ( 0%)
netapp> 

Labels: , , , ,

Tuesday, August 19, 2008

DNS Resolver

I had a list of domains that needed their MX records updated. I first wanted to make sure that our DNS servers were authoritative for those zones. I used Perl and the Net::DNS CPAN module to figure out the NS records for each domain.
#!/usr/bin/perl

use Net::DNS;

my $resolver = Net::DNS::Resolver->new;
my $query = "";
my $domain = "";

open(FILE, "</tmp/domains.txt");
while() {
  chomp;
  $domain = $_;
  $query = $resolver->query($domain, "NS");
  print $domain;
  if($query) {
    foreach my $rr ($query->answer) {
      next unless $rr->type eq "NS";
      print ",", $rr->nsdname;
    }
    print "\n";
  } else {
    print ",DOES NOT RESOLVE\n";
  }
}

Labels: ,

Wednesday, August 13, 2008

Tcl version of ucfirst

The load balancers we use at work have a TCL command line interface. A co-worker needed a TCL function written that would take a string as input and return the string transformed so that the first letter was upper case and the rest were lower case. There is a built in string function called toupper but that capitalizes the full string instead of only the first.

My solution (shown below) is to split the string into two strings, toupper the first string and tolower the second, then append them together. The result is the equivalent of Perl's ucfirst implemented in TCL.

proc ucfirst str {
 set a [ string toupper [ string range $str 0 0 ]]
 append a [ string tolower [ string range $str 1 end ]]
 return $a
}
You can use this from the command line by using tclsh. Below is what running this code will look like (the % is the tclsh prompt).

[jasonn@jnoble-vm ~]$ tclsh
% proc ucfirst str {
 set a [ string toupper [ string range $str 0 0 ]]
 append a [ string tolower [ string range $str 1 end ]]
 return $a
}
%
% set mystring "firetruck"
firetruck
% set t [ ucfirst $mystring ]
Firetruck
% set mystring "cop car"
cop car
% set t [ ucfirst $mystring ]
Cop car
% exit
[jasonn@jnoble-vm ~]$

Labels: , ,