Archive for the ‘Solaris’ Category

* another tool for SVN – list_repositories.pl

Posted on May 11th, 2009 by doug. Filed under Solaris, apache2, eclipse, subversion, tools, websphere.


 

 

One of the features of subversion + apache2 is the ability to list repositories – natively. 

SVNParentPath /apps/repos
SVNListParentPath on

Unfortunately, once you restrict the httpd.conf to individual repositories and start handling permissions separately you lose that.  Both of these permissions, set at the top level, at the parent path to the repositories, have to be commented out to have the individual permissions on the directories below take effect.

And listing just the repositories wasn’t enough for what I had in mind – I wanted a read-only table showing an individual developer or a team lead for a project who has what permissions for the subversion repositories. All the users, all the repositories.

Just your basic cgi.

 

repos

 

 and the script:


#! /bin/perl -w

# script to parse and display users and repositories and rights (R, RW)

use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

##----------------------------
## Variables
##----------------------------

#debug
my $debug = 0; #set to 0 to turn off, 1 (true) to turn on

# title for page
my $PageTitle = "List of SVN Repositories";

## repository directory
my $SVN = "/apps/repos";
## location for htpasswd files
my $HTDIR = "/apps/apache2/conf/htpasswd";
## Set untainted path
$ENV{PATH} = '/apps/apache2/bin:/bin:/usr/bin:/usr/local/bin';
$ENV{IFS} = "" if $ENV{IFS} ne "";

# css
my $css = "http://<your server name>/css/main.css";
my $headerimg = "http://<your server name>/css/roger_rabbit_120.jpg";

##------------------------------
## MAIN
##------------------------------

&standard_header;
my ($ref_repos, $ref_tabledata, $ref_users) = &CreateTableSpace;
&DisplayTable ($ref_repos, $ref_tabledata, $ref_users);
&standard_footer;
exit;

##------------------------------
## subs
##------------------------------

sub standard_header {
    print header();
    print start_html(-Title => "$PageTitle", -BGCOLOR=>"White",
        -style => {
            -src => "${css}"
        }
    );
    print ("<div id=\"header\">\n");
    print p("<img src=\"${headerimg}\" title=\"Wells logo\" alt=\"wells logo\"/>\n");
    print ("</div>\n");
    print ("<div id=\"headertitle\">\n");
    print h3("Repositories<br/>\nusers | read (R) | read & write (RW)\n"); # start_multipart_form() if file upload
}

sub standard_footer {
    print end_html();
}

sub CreateTableSpace {
    my $ref_repos = &GetBlankRepos;
    my @repos = @$ref_repos; # dereference
    my %tabledata = (); # hash to hold table data
    my @users = (); # list of users
    my %seen = ();
    foreach my $rep (@repos) {
        open(FILE, "$HTDIR/${rep}_read") || croak "Failed to open $HTDIR/${rep}_read for reading...";
        my @filelines = <FILE>;
        close FILE;
        foreach my $line (@filelines) {
            # lines are user:passwd
            my ($user, $pass) = split (":", $line);
            unless ($seen{$user}) {
                $seen{$user} = 1; # save as seen
                push (@users, $user); # save the user to a list
            }
            $tabledata{$rep}{$user} = "read";
        }
        open (FILE, "$HTDIR/${rep}_write") || croak "Failed to open $HTDIR/${rep}_write for reading";
        my @file_lines = <FILE>;
        close FILE;
        foreach my $line (@file_lines) {
            # lines are user:passwd
            my ($user, $pass) = split (":", $line);
            unless ($seen{$user}) {
                $seen{$user} = 1; # save as seen
                push (@users, $user); # save the user to a list
            }
            $tabledata{$rep}{$user} = "readwrite";
        }
    }
    return (\@repos, \%tabledata, \@users);
}

sub GetBlankRepos {
    my @repos = ();
    # list $SVN
    opendir (DIR, $SVN) || croak "Failed to open directory $SVN for reading...";
    while (defined(my $file = readdir(DIR))) {
        # skip ".", ".." and .<hidden> files...
        if ($file =~ /^\./) {
            next;
        } else {
            push(@repos, $file);
        }
    }
    return (\@repos);
}

sub DisplayTable {
    my $ref_repos = shift;  #@repos
    my $ref_tabledata = shift; # %tabledata
    my $ref_users = shift; # @users
    # dereference
    my @repos = @$ref_repos;
    my %tabledata = %$ref_tabledata;
    my @users = @$ref_users;
    # repos across the top, users down, R or RW for permissions
    # $tabledata{$rep}{$user} = "readwrite";
    # start table
    print ("<table>\n<tbody>\n");
    # table header
    my $cols = ($#repos + 1);
    print ("<tr><td>Users</td><td colspan=\"$cols\">Repositories</td></tr>\n");
    print ("<div id=\"repotitles\"><tr>\n<td>&nbsp;</td>");
    foreach my $rep (@repos) {
        print ("<td>$rep</td>");
    }
    print ("\n</tr>\n</div>\n");
    foreach my $user (@users) {
        print ("<tr>\n<td>$user</td>");
        foreach my $repo (@repos) {
            if ($tabledata{$repo}{$user}) {
                if ($tabledata{$repo}{$user} eq "read") {
                    print ("<td>R</td>");
                } elsif ($tabledata{$repo}{$user} eq "readwrite") {
                    print ("<td>RW</td>");
                }
            } else {
                print ("<td>&nbsp; - &nbsp;</td>");
            }
        }
        print ("\n</tr>\n");
    }
    # finish table
    print ("</tbody>\n</table>\n");
}

share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Bloglines
  • email
  • Facebook
  • Faves
  • LinkedIn
  • Mixx
  • Netscape
  • Newsrider
  • Slashdot
  • Technorati
  • TwitThis

Tags: , , , .



* eclipsed

Posted on March 29th, 2009 by doug. Filed under Solaris, UNIX & Windows, eclipse, shell.


 

 

eclipse splash

 

I’ve been working with Remote System Explorer (RSE), a terminal and ssh session manager that runs in the Eclipse SDK. This is very cool – the thing is, eclipse runs on Solaris, Linux, Windows, MAC OSX, IBM AIX (of course – IBM created the eclipse framework). It as close to an OS-agnostic framework as anything I’ve ever experienced.

I had primarily intended to use it on windows to add ssh terminal capacity – replacing console2 and cygwin – to connect to UNIX servers. But the interface is so good, I find I’m using it on both UNIX and windows – the konsole terminal is better in some ways at history and at cut-and-paste using mouse buttons directly. So far the context menu from a right-click is the only cut-and-paste that functions within the terminal windows themselves.

On the other hand – in konsole each separate terminal window is a separate authentication – password-response – whereas in eclipse RSE, one authentication can be kept and spawn as many terminal sessions as needed. The organization is better. You can close the terminal sessions down, and leave a connection still intact. Then bring back terminal sessions as needed. That ability alone makes it worth losing the double-click select and middle-button paste from konsole sessions. I’m not yet convinced I can’t find a way to get that working either, that and an unlimited history or at least 10000 lines…

 

eclipse window

 

If I can get that back somehow in the terminal sessions it will be not just slightly better, but a huge amount better than any other session management I’ve used.

Install

You need java. On windows that can be an issue. On UNIX, not so much, pretty much there by default.

Download RSE and eclipse SDK.

Untar or unzip the eclipse package. In windows I unzip to c:\eclipse_3.4.2. In UNIX /usr/local/eclipse.

Unzip the RSE package layered over the eclipse install.

In windows I point a shortcut to c:\eclipse_3.4.2. In UNIX I move /usr/local/eclipse to /usr/local/eclipse_3.4.2, and create a symbolic link /usr/local/eclipse -> /usr/local/eclipse_3.4.2.

Open eclipse. Go to window -> open perspective -> other and open Remote System Explorer.

 

eclipse window

 

Configurations are stored in the workspace folder. Right-click in the left-hand pane and select “New Connection to create connections. Within eclipse you can add software respositories and update and add software from Help -> Software Updates.

 

eclipse window

eclipse window

 

 

— doug

 

share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Bloglines
  • email
  • Facebook
  • Faves
  • LinkedIn
  • Mixx
  • Netscape
  • Newsrider
  • Slashdot
  • Technorati
  • TwitThis

Tags: , , , , .



* ports and processes in Solaris

Posted on September 24th, 2008 by doug. Filed under Solaris.


 

In Linux, “netstat -apn” will list processes versus ports bound to:


dsm@dali:~$ netstat -apn
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:24800 0.0.0.0:* LISTEN 9353/synergys
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN -
tcp 0 0 172.17.8.76:43003 172.19.235.82:22 ESTABLISHED 4305/ssh
tcp 0 0 172.17.8.76:32852 198.200.144.106:22 ESTABLISHED 13523/ssh
tcp 0 0 172.17.8.76:44173 198.200.144.106:22 ESTABLISHED 13546/ssh
tcp 0 0 172.17.8.76:53463 172.17.85.49:22 ESTABLISHED 28801/ssh
tcp 0 0 172.17.8.76:57385 172.19.230.85:22 ESTABLISHED 5208/ssh

If you want to see, say, all the ssh processes:


dsm@dali:~$ netstat -apn | grep ssh
tcp 0 0 172.17.8.76:43003 172.19.235.82:22 ESTABLISHED 4305/ssh
tcp 0 0 172.17.8.76:32852 198.200.144.106:22 ESTABLISHED 13523/ssh
tcp 0 0 172.17.8.76:44173 198.200.144.106:22 ESTABLISHED 13546/ssh
tcp 0 0 172.17.8.76:53463 172.17.85.49:22 ESTABLISHED 28801/ssh
tcp 0 0 172.17.8.76:57385 172.19.230.85:22 ESTABLISHED 5208/ssh
tcp 0 0 172.17.8.76:58116 172.19.220.114:22 ESTABLISHED 5459/ssh
etc...

On Solaris… On SUN’s Solaris there isn’t an easy way to accomplish the same. On a normal non-containerized server you can run netstat and then lsof…

Assume that you know there is a process conflict – some process has already bound to a port 8083. Your process fails because it can’t bind to the port it needs, that port is already in use – somewhere.

netstat –an | grep 8083 gives you:

[dsm@sun1 bin] $ netstat -an | grep 8083
198.200.144.14.8083 *.* 0 0 49152 0 LISTEN
198.200.144.30.8083 *.* 0 0 49152 0 LISTEN
198.200.144.17.8083 *.* 0 0 49152 0 LISTEN
*.8083 *.* 0 0 49152 0 LISTEN
198.200.144.90.8083 *.* 0 0 49152 0 LISTEN
198.200.144.10.8083 *.* 0 0 49152 0 LISTEN

The *.8083 is our problem child, but we don’t have which process is bound to that port yet.


[dsm@sun1 bin] $ lsof -i:8083
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 1548 jb-1 18u IPv4 0x3005df7be68 0t0 TCP s1q:8083 (LISTEN)
java 6903 appadmin 5u IPv4 0x30070580ae8 0t0 TCP *:8083 (LISTEN)
java 7497 jb-2 9u IPv4 0x300099344d0 0t0 TCP webq1:8083 (LISTEN)
java 7989 jb-3 9u IPv4 0x32af1cd79a8 0t0 TCP ntumq1:8083 (LISTEN)
java 9445 jb-ty 9u IPv4 0x30009925e30 0t0 TCP tyq1:8083 (LISTEN)
java 16369 jb-jun 9u IPv4 0x3007b9a21f0 0t0 TCP rjq1:8083 (LISTEN)
[dsm@sun1 bin] $

Process id 6903 if the villian of this piece in this case.

And this works on servers, but not within containerized servers… On a container you get:


$ lsof -i :8083
lsof: can't stat(/devices): No such file or directory

Basically, a zone within a Solaris10 global zone doesn’t have a /devices directory; so you can’t ! You have to do this from the global zone – not ideal :-|

 

— dsm

 

share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Bloglines
  • email
  • Facebook
  • Faves
  • LinkedIn
  • Mixx
  • Netscape
  • Newsrider
  • Slashdot
  • Technorati
  • TwitThis

Tags: , .



engineers

recent posts

What I'm Doing...

  • flying back to Boston tomorrow, and watching my daughter come off a ventilator and breathe on her own... 2 weeks ago
  • writing a startup and shutdown sc ript for all of jboss-land 2009-08-25
  • finished and deployed svnadmin.pl cgi, documented it and checked into subversion... next is more log4j edits, and deploy jsvn (java svn) 2009-05-08
  • More updates...

Posting tweet...

categories

archives

tag cloud

apache apache2 bash shell browsers comics compile cygwin data databases daughter eclipse economics engineer entropy finances firefox 3 hallucinations Heinlein internet java jboss KDE linux moinmoin monitoring nagios plugins RSE scifi script Solaris structure subversion support svn testing tweet UNIX UNIX & Windows web hosting website websphere windows WordPress writing

admin