Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Any API avaialbe for accessing com.ibm.team.repository.admin.activeServices?

Are there any API / OSLC calls available for accessing "ccm/admin#action=com.ibm.team.repository.admin.activeServices"

I am interested in looking at users if the connect directly or via Proxy especially with "com.ibm.team.scm.service.internal.content.VersionedContentService.service".

0 votes


Accepted answer

Permanent link

I use Perl and LWP::UserAgent to good effect here.

!/usr/bin/perl


use LWP::UserAgent;
use Data::Dumper;
use JSON;
use Time::HiRes;

if ( scalar(@ARGV) != 1 ) {
print "Usage: $0 JazzURI, JazzUser, JazzPass\n";
exit -1;
}
my ($JazzURI) = @ARGV;
my($JazzUser)="someid"
my($JazzPass) = "passw0rd";

my $Browser = LWP::UserAgent->new;
$Browser->timeout(15);
$Browser->cookie_jar({ file => "$ENV{HOME}/.kcookies.txt" });
$Browser->default_header('Accept' => "text/json");
push @{ $Browser->requests_redirectable }, 'POST';


# Test the connection to CLM
my ( $BeginTime ) = Time::HiRes::time();
$Response = $Browser->post( $JazzURI );
my ( $EndTime ) = Time::HiRes::time();

if ( ! $Response->is_success ) {
$date=date; chomp($date);
print "$date|Connecting to $JazzURI FAILED!\n";
exit -1;
} else {
# my($printString) = sprintf("%s%.2f%s", "Connection to $JazzURI completed in ", $EndTime - $BeginTime, " Seconds.\n");
# print $printString;
}


# Test the Authetication to CLM
my ( $BeginTime ) = Time::HiRes::time();
$Response = $Browser->post( $JazzURI . "/j_security_check", [ j_username => $JazzUser, j_password => $JazzPass ], );
my ( $EndTime ) = Time::HiRes::time();

if ( $Response->{"headers"}{"x-com-ibm-team-repository-web-auth-msg"} eq "authfailed" ) {
print "Authenticating to $JazzURI FAILED!\n";
exit -1;
} else {
# print Dumper($Response);
$d_cookies=$Response->{_request}->{_headers}->{cookie};
$jsess=get_cookie("JSESSIONID",$d_cookies);
$Browser->default_header('X-Jazz-CSRF-Prevent'=>$jsess);
#my($printString) = sprintf("%s%.2f%s%s", "Authentication to $JazzURI completed in ", $EndTime - $BeginTime, " Seconds.\n",$jsess);
#print STDERR $printString;
}

# Test the Database connection status to CLM
my ( $BeginTime ) = Time::HiRes::time();
$Response = $Browser->get( $JazzURI . "/service/com.ibm.team.repository.service.internal.IServerStatusRestService/ActiveServiceInfo");
my ( $EndTime ) = Time::HiRes::time();
my($json) = new JSON;
my($jsonResponse) = $json->decode($Response->content);
# print Dumper($jsonResponse);
# print $json->pretty->encode($jsonResponse);
if ( !exists( $jsonResponse->{"soapenv:Body"}{response}{returnValue}{value}{currentTime} )) {
exit -1;
} else {
$current_time=$jsonResponse->{"soapenv:Body"}{response}{returnValue}{value}{currentTime}/1000;
$ct = scalar localtime($current_time);
$services=$jsonResponse->{"soapenv:Body"}{response}{returnValue}{value}{services};

for ($i=0; exists($services->[$i]); $i++) {
$start_time=$services->[$i]{startTime}/1000;
$st = scalar localtime ($start_time);
$et = int($current_time - $start_time);
print "$ct|$services->[$i]{service}|$services->[$i]{userId}|$services->[$i]{method}|$st|$et\n";
#if ($services->[$i]{method} =~ m/postRenderReport/) {
# print $services->[$i]{stacktrace};
#}
}
# my($printString) = sprintf("%s|%s|%s|%s|%s|%s|%s\n",$url,$sversion,$ut,$tm,$fm,$mm,$db);
# print $printString;
exit 0;
}

sub get_cookie {
my ($name,$cookies)=@
;
@cookees=split /\;/,$cookies;
@which=grep (/$name/,@cookees);
# print join "\n",@which;
($ckey,$cval) = split /=/,$which[0];
$cval
}

This writes out delimitted data to standard out. Hand the program the uri of the server
e.g. https://server.com:port/ctx



Karthik Krishnan selected this answer as the correct answer

0 votes

Comments

Thank you, Kevin. The script doesn't work for me as it throws this

<noscript><div id="net-jazz-ajax-NoScriptMessage">Javascript is either disabled or not available in your Browser</div></noscript>


I accept this solution as this seems the only way.

Did you update the values for $JazzUser, $JazzPass ?   Beyond that how did you execute ?  The 1 argument should be "valid" public url for the target Jazz application.

I've used the above from v3 through 6.0.3 with good success.

Maybe the LWP::UserAgent has some settings to help ( perldoc LWP::UserAgent )

I did update the user name, password and valid URI for sure :). The moment it hits the url, in my case https://clm-server/admin#action=com.ibm.team.repository.admin.activeServices
I get the not authentication error.

I did tried to print the response and i get this

<noscript><div id="net-jazz-ajax-NoScriptMessage">Javascript is either disabled or not available in your Browser</div></noscript>




I even suppressed the SSL certificate in my case

my $Browser = LWP::UserAgent->new(   ssl_opts => { verify_hostname => 0 },);





Interestingly enough it doesn't drop the cookie, meaning the file isn't created. The path is valid and has permissions to create.

turned out that I need to pass the Referer in HEADER for te script to work. I created my own Python script with the url you have mentioned. Thanks for this.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 515
× 478
× 411

Question asked: Apr 27 '18, 3:50 a.m.

Question was seen: 2,408 times

Last updated: Jul 10 '18, 8:30 a.m.

Confirmation Cancel Confirm