5

At my workplace, we have lab machines that we use to do our testing.

The standard procedure to reserve a machine for testing was to walk around the office to make sure that no one was using the machine.

This is highly inefficient and time consuming.

At first, I set up a web page where people could reserve the lab machine but nobody was keeping the page updated so that turned up to be useless.

I finally found a solution using Microsoft log parser and wanted to share it to the stack overflow community.

It is a batch file that runs on the machine so the user can identify the last users that use the machine and easily IM them to ask if the machine is free.

Is there a better solution to do this?

Nik Reiman
  • 39,067
  • 29
  • 104
  • 160
Julien Nephtali
  • 455
  • 1
  • 6
  • 12
  • 1
    you asked a question then answered it 2 min later.... are you blogging? – cgreeno Feb 18 '09 at 21:36
  • 3
    This is actually considered acceptable by the site creators. I think the question should have been more questiony, but asking a question solely to answer it yourself is perfectly fine. – EBGreen Feb 18 '09 at 21:38
  • I don't even think it needs to be a wiki. It isn't a poll and it is not SO meta discussion. – EBGreen Feb 18 '09 at 21:38
  • I have no objections to this sort of thing. He had a programming problem, solved it himself, and decided to share. If I had any more votes today I'd vote him up. – Paul Tomblin Feb 18 '09 at 21:43
  • @bthb: I thought it was weird too. In fact, I suspected that the OP might have been gaming the site (i.e. asking a question, then logging in with another account to answer the question and collect rep), but botched it midway. However, I think EBGreen is correct :) – Juliet Feb 18 '09 at 21:46

6 Answers6

8

Use the built-in command qwinsta (Query Win Station) to figure out what sessions (including console) are active or inactive (disconnected) and then act on the given information (creds to krusty.ar btw for linking this already).

If you feel people are abusing the machine in question, refer to rwinsta to nuke their sessions into oblivion...

Oskar Duveborn
  • 2,189
  • 16
  • 20
2

You will need to install the Microsoft Log Parser

Then create the following 2 files

TSLoginsDetails.sql

SELECT 
      timegenerated, 
      EXTRACT_TOKEN(Strings,1,'|') AS Domain, 
      EXTRACT_TOKEN(Strings,0,'|') AS User, 
      EXTRACT_TOKEN(Strings,3,'|') AS SessionName,
      EXTRACT_TOKEN(Strings,4,'|') AS ClientName,
      EXTRACT_TOKEN(Strings,5,'|') AS ClientAddress,
      EventID
FROM Security 
WHERE EventID=682 
ORDER BY timegenerated DESC

TSLogins.bat

echo off
cls
c:
cd "c:\Program Files\Log Parser 2.2\"
logparser.exe file:TSLoginsDetails.sql -o:DATAGRID

Now by placing this batch file on the desktop, the user can see who were the last people to login and contact them by IM to verify if they are done.

Julien Nephtali
  • 455
  • 1
  • 6
  • 12
  • Expand it so when you log in, if it isn't the current user who logged in last, set an alert to contact the correct person. (Start IM, prefill email, use some other notification protocol.) If it was the current user, do nothing. – MrChrister Feb 18 '09 at 21:37
  • Doesn't this require that the person running the batch file have already logged in to the machine in question; in other words, possibly already broken into the other user's session? – Ben Dunlap Feb 18 '09 at 21:40
  • Why don't you have your users log in to these lab machines with their own user accounts? Then when someone else tries to log in, Windows will just tell you that another session is currently active, and it will tell you who is logged in. – Ben Dunlap Feb 18 '09 at 21:45
  • bslorence We log in console. We dont have a domain set up in our workplace. Its not considered harmful if you cut-off someone's session just as long as you dont stop a load test someone else started. – Julien Nephtali Feb 18 '09 at 21:48
  • I see. Are you running the s/w you develop on these lab machines or are they just test clients for servers running separately? I'm just asking because it sounds like you might also all be logging in with admin privileges to the test machines. – Ben Dunlap Feb 18 '09 at 21:54
  • Separate thought, sort of: can you change "FROM Security" in your query to "FROM \\remotemachine\Security" to allow developers to run this from their own machines? Credentials might be a problem if you don't have Active Directory. – Ben Dunlap Feb 18 '09 at 22:01
  • ... I guess that also wouldn't work if your developers aren't running Windows at their desks. ;-) – Ben Dunlap Feb 18 '09 at 22:01
1

How about posting the information from the log file to the website that tells who is currently using the machine as well.

  1. Check and notify when they log in.
  2. Updated the "who is using the machine" page you made prior.
  3. Run a AT job that checks every couple of hours who is on it.
MrChrister
  • 3,555
  • 5
  • 22
  • 34
1

Totally out of the box:

You can install the Software Testing Automation Framework (STAF) on your servers and desktops to manage your tests. It's written in Java, so you can use it on Windows and Unix/Linux desktops and servers.

Using STAF, you can create a resource pool of test servers on which you conduct tests, then write STAX jobs (STAX is a STAF execution framework) to conduct the tests. The job can grab the first available server from the resource pool, run the test, monitor the test status, log results, notify the submitter, then release the server back into the pool when done. If you have multiple people submitting jobs for tests, STAF will manage the queue of requests and satisfy them as they came in. Users can either monitor the job from their desktop, or you can set up email alerts to notify them when the test is complete.

Patrick Cuff
  • 28,540
  • 12
  • 67
  • 94
0

I'm not sure if I understand you, but there are a set of command line tools to deal with terminal server sessions, and there's also a Windows API to do the same if you need to do this from a program.

krusty.ar
  • 4,015
  • 1
  • 25
  • 28
0

Since it sounds like you're a microsoft shop, you can set up the machines as resources in outlook/exchange and reserve them that way.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • 1
    I think the issue is more a matter of compliance. The OP already had a scheduling system in place but it was not used. – EBGreen Feb 18 '09 at 22:19