How to find the number of active Clearquest users using a script

Technote (FAQ)


Question

How do you find the count of active users in IBM Rational ClearQuest?

Cause

Using a script to count ClearQuest Active users at any point of time to provide a quick solution for Admin/Management to maintain correct metrics/Stats.

Answer

The following script will count the Active ClearQuest users at any point of time and will print the output to the command line.

Note: This script is applicable on Windows platform and ClearQuest must be installed on the machine where the script is running.

Procedure:

  1. Open a command prompt and run the following command to see if CQperl is installed:

    cqperl -v

    Note: It should return the Perl version installed on the machine. If this command does not give the output of Perl version, change directory (cd) in the command window to set to the correct path where cqpearl.exe resides.

    For example: C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe

  2. Create a text file which contains your Schema Repository Login information.

    Example:

    **************
    For # example- connection_info.txt
    This text file should contain the below 3 lines-
    dbset:<Schema Repository Name>
    user:<Admin user>
    passwd:<Admin password>
    **************

  3. Save the following script text to notepad with a .pl extension and the run the script using the following command:

    cqperl <filename.pl>

    Note: You should have both "perl" file and "Text" file in the same directory. If not, modify the path in the script accordingly.

Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.




*******************************

#!C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe

#Identify the correct location of your CQperl.exe file and give the path above

use CQPerlExt;

#Provide the text file location containing Schema login information in the below format-
#dbset:CQ Schema Repository Name
#user:admin
#passwd:Admin password

#You should have both "perl" file and "Text" file in the same directory. If not, please modify the below
# path accordingly.
#Fetching the Schema Repository details from the file and putting them into respective variables.

my $file = './connection_info.txt';

open (FILE, $file) || die "Error: $!\n";
while (<FILE>) {
if ($_ =~ m/dbset:(\S+)/) {
$d = $1;
}
if ($_ =~ m/user:(\S+)/) {
$u = $1;
}
if ($_ =~ m/passwd:(\S+)/) {
$p = $1;
}
}
close (FILE);

my $dbset = $d;
my $adminUser = $u;
my $adminPasswd = $p;

#Create a Rational ClearQuest admin session
$adminSession= CQAdminSession::Build();
#Logon as admin
$adminSession->Logon( "$u", "$p", "$d" );

#Get the list of users in the repository.

$userList = $adminSession->GetUsers();

 #Get the number of users

$numUsers = $userList->Count();
#Iterate through the users

print "Total Number of users = $numUsers\n";
$numActiveusers = 0;

#Rinning a loop to check each user if Active or not.
for ( $x=0; $x<$numUsers; $x++ )
{
#Get the specified item in the collection of users
$userObj = $userList->Item( $x );
$usercnt = $userObj->GetActive();
# print "User status is = $usercnt\n";
if ($usercnt)
{
$numActiveusers = $numActiveusers + 1;
}
}
print "Number of Active Users = $numActiveusers\n";

#Unbuild the Admin session
CQAdminSession::Unbuild($adminSession);
****************************

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

Rational ClearQuest
User Administration

Software version:

7.0.1, 7.1, 7.1.2, 7.1.2.3, 8.0

Operating system(s):

Windows

Reference #:

1637753

Modified date:

2013-06-26

Translate my page

Machine Translation

Content navigation