Active Users
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
Active Users

 
Post new topic   Reply to topic    Windows Server Forum Index -> Host Integration Server
Author Message
Marc Larivière
Guest





Posted: Mon Apr 18, 2005 8:31 pm    Post subject: Active Users Reply with quote

In HIS Manager, it is possible to view the number of
active users when you go under a server and click "Active
Users".

Is there different way to obtain this information ?
(like .EXE)

We want to graph this information and it's quite tedious
to use HIS Manager to obtain that.

Tanks !!
Back to top
Neil Pike
Guest





Posted: Wed Apr 20, 2005 12:13 am    Post subject: Re: Active Users Reply with quote

Mark,

It should be available via the WMI interface - most of the HIS info is, so I
assume that bit will be...

I've yet to get the time to knock up some "useful" HIS WMI scripts myself.
Too many projects/problems, not enough billable hours in the day.... ;-)

Quote:
In HIS Manager, it is possible to view the number of
active users when you go under a server and click "Active
Users".

Is there different way to obtain this information ?
(like .EXE)

We want to graph this information and it's quite tedious
to use HIS Manager to obtain that.

Neil Pike. Protech Computing Ltd
Back to top
Charles Ezzell (MSFT)
Guest





Posted: Wed Apr 20, 2005 4:52 am    Post subject: Re: Active Users Reply with quote

Yes. I'll get you something in a day or 2. At home now, so...<G>

Charles

"Marc Larivière" <marc.lariviere@mddep.gouv.qc.ca> wrote in message
news:204b01c5442b$aace0c80$a601280a@phx.gbl...
Quote:
In HIS Manager, it is possible to view the number of
active users when you go under a server and click "Active
Users".

Is there different way to obtain this information ?
(like .EXE)

We want to graph this information and it's quite tedious
to use HIS Manager to obtain that.

Tanks !!

Back to top
Charles Ezzell (MSFT)
Guest





Posted: Wed Apr 20, 2005 9:47 pm    Post subject: Re: Active Users Reply with quote

Kind of long, but here you go:
Cut and paste the below into a VBScript file called ActiveUsers.VBS, and run
as CSCRIPT ActiveUsers.VBS

The array is a comma delimited array and should list each HIS Server in the
domain.

As written, it will only work against HIS 2004. See the script where a
simple change can be made to work with HIS 2000.

Output is (as written) is to both file and screen.

Script is supplied as-is, no warranties, etc implied.

Charles

Output:
C:\scripts>cscript active5250users.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

==========================================
Computer: CHARLIEE1
==========================================
ClientAppl: WIN5250
ClientConnectTime: 4/20/2005 12:13:23 PM
ClientMachine: CHARLIEE1
Domain: NORTHAMERICA
User: charliee

ClientAppl: WIN3270
ClientConnectTime: 4/20/2005 12:15:23 PM
ClientMachine: CHARLIEE1
Domain: NORTHAMERICA
User: charliee


*** Begin cut ***
'********************************************************************
'*
'* File: ActiveUsers.VBS
'* Created: April 20, 2005
'* Version: 2.1
'*
'* Main Function: Outputs Active APPC users
'* Usage: CSCRIPT ActiveUsers.VBS
'* output file is hardcoded in CONST_OUTPUTFILE
'* output is displayed to both screen and file
'*
'* Copyright (c) 2005 Microsoft Corporation. All rights reserved.
'*
'********************************************************************

OPTION EXPLICIT
'Define constants
CONST CONST_ERROR = 0
CONST CONST_WSCRIPT = 1
CONST CONST_CSCRIPT = 2
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const CONST_OUTPUTFILE = "c:\ActiveUsers.txt"

'Declare variables
Dim intOpMode
DIM arrComputers
DIM OutPutFile

' Initialize variables
' comma delimited array
arrComputers = ARRAY("CHARLIEE1")

'Check whether the script is run using CScript
Select Case intChkProgram()
Case CONST_CSCRIPT
'Do Nothing
Case CONST_WSCRIPT
Print "Please run this script using CScript." & vbCRLF & _
"This can be achieved by" & vbCRLF & _
"1. Using ""CScript ActiveAPPCUsers.VBS arguments"" or" _
& vbCRLF & _
"2. Changing the default Windows Scripting Host setting to CScript" &
vbCRLF & _
" using ""CScript //H:CScript //S"" and running the script using" &
vbCRLF & _
" ActiveUsers.VBS arguments""."
WScript.Quit
Case Else
WScript.Quit
End Select
Call GetActiveUsers()

'********************************************************************
'*
'* Function intChkProgram()
'* Purpose: Determines which program is used to run this script.
'* Input: None
'* Output: intChkProgram is set to one of CONST_ERROR, CONST_WSCRIPT,
'* and CONST_CSCRIPT.
'*
'********************************************************************
Private Function intChkProgram()
'Declare variables
Dim strFullName, strCommand, i, j

'strFullName should be something like C:\WINDOWS\COMMAND\CSCRIPT.EXE
strFullName = WScript.FullName
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
intChkProgram = CONST_ERROR
Exit Function
End If

i = InStr(1, strFullName, ".exe", 1)
If i = 0 Then
intChkProgram = CONST_ERROR
Exit Function
Else
j = InStrRev(strFullName, "\", i, 1)
If j = 0 Then
intChkProgram = CONST_ERROR
Exit Function
Else
strCommand = Mid(strFullName, j+1, i-j-1)
Select Case LCase(strCommand)
Case "cscript"
intChkProgram = CONST_CSCRIPT
Case "wscript"
intChkProgram = CONST_WSCRIPT
Case Else 'should never happen
Print "An unexpected program is used to run this
script."
Print "Only CScript.Exe or WScript.Exe can be used to
run this script."
intChkProgram = CONST_ERROR
End Select
End If
End If
End Function

'********************************************************************
'*
'* Sub GetActiveUsers()
'* Purpose: Lists Active Users
'* Output: Properties of the object are either printed on screen or saved
'* in strOutputFile.
'*
'********************************************************************
Private Sub GetActiveUsers()
'Declare variables
DIM fso
DIM objOutputFile
DIM strComputer
DIM objWMIService
DIM colItems
DIM objItem
DIM dateTime

'Create a file object
set fso = createobject("Scripting.FileSystemObject")
Set objOutputFile = fso.OpenTextFile(CONST_OUTPUTFILE, 2, True)

For Each strComputer In arrComputers
WriteLine " " , objOutputFile
WriteLine "==========================================" , objOutputFile
WriteLine "Computer: " & strComputer , objOutputFile
WriteLine "==========================================" , objOutputFile
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\MicrosoftHIS")
' for HIS 2000 you need to use MsSnaStatus_ActiveUser
' next line is for HIS 2004
Set colItems = objWMIService.ExecQuery("SELECT * FROM
MsSnaStatus_ClientConnection", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
WriteLine "ClientAppl: " & objItem.ClientAppl , objOutputFile
Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
dateTime.Value = objItem.ClientConnectTime
WriteLine "ClientConnectTime: " & dateTime.GetVarDate(FALSE) ,
objOutputFile
WriteLine "ClientMachine: " & objItem.ClientMachine , objOutputFile
WriteLine "Domain: " & objItem.Domain , objOutputFile
WriteLine "User: " & objItem.User , objOutputFile
WriteLine " " , objOutputFile
Next
Next
objOutputFile.Close
set objOutputFile = NOTHING
set fso = NOTHING
End Sub

'********************************************************************
'*
'* Sub WriteLine()
'* Purpose: Writes a text line either to a file or on screen.
'* Input: strMessage the string to print
'* objFile an output file object
'* Output: strMessage is either displayed on screen or written to a file.
'*
'********************************************************************
Sub WriteLine(ByRef strMessage, ByRef objFile)
objFile.WriteLine strMessage
Print strMessage
End Sub

'********************************************************************
'*
'* Sub Print()
'* Input: strMessage the string to print
'* Output: strMessage is printed on screen
'*
'********************************************************************
Sub Print(ByRef strMessage)
Wscript.Echo strMessage
End Sub

'********************************************************************
'* *
'* End of File *
'* *
'********************************************************************
*** End cut ***
Back to top
Marc Larivière
Guest





Posted: Thu Apr 21, 2005 7:42 pm    Post subject: Re: Active Users Reply with quote

EXCELLENT !

It works very well !

I added counters to obtain the number of simultaneous
active users.

Tank you very much !
Quote:
-----Original Message-----
Kind of long, but here you go:
Cut and paste the below into a VBScript file called
ActiveUsers.VBS, and run
as CSCRIPT ActiveUsers.VBS

The array is a comma delimited array and should list each
HIS Server in the
domain.

As written, it will only work against HIS 2004. See the
script where a
simple change can be made to work with HIS 2000.

Output is (as written) is to both file and screen.

Script is supplied as-is, no warranties, etc implied.

Charles

Output:
C:\scripts>cscript active5250users.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights
reserved.

==========================================
Computer: CHARLIEE1
==========================================
ClientAppl: WIN5250
ClientConnectTime: 4/20/2005 12:13:23 PM
ClientMachine: CHARLIEE1
Domain: NORTHAMERICA
User: charliee

ClientAppl: WIN3270
ClientConnectTime: 4/20/2005 12:15:23 PM
ClientMachine: CHARLIEE1
Domain: NORTHAMERICA
User: charliee


*** Begin cut ***
'*********************************************************
***********
'*
'* File: ActiveUsers.VBS
'* Created: April 20, 2005
'* Version: 2.1
'*
'* Main Function: Outputs Active APPC users
'* Usage: CSCRIPT ActiveUsers.VBS
'* output file is hardcoded in CONST_OUTPUTFILE
'* output is displayed to both screen and file
'*
'* Copyright (c) 2005 Microsoft Corporation. All rights
reserved.
'*
'*********************************************************
***********

OPTION EXPLICIT
'Define constants
CONST CONST_ERROR = 0
CONST CONST_WSCRIPT = 1
CONST CONST_CSCRIPT = 2
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const CONST_OUTPUTFILE = "c:\ActiveUsers.txt"

'Declare variables
Dim intOpMode
DIM arrComputers
DIM OutPutFile

' Initialize variables
' comma delimited array
arrComputers = ARRAY("CHARLIEE1")

'Check whether the script is run using CScript
Select Case intChkProgram()
Case CONST_CSCRIPT
'Do Nothing
Case CONST_WSCRIPT
Print "Please run this script using CScript." & vbCRLF
& _
"This can be achieved by" & vbCRLF & _
"1. Using ""CScript ActiveAPPCUsers.VBS arguments""
or" _
& vbCRLF & _
"2. Changing the default Windows Scripting Host
setting to CScript" &
vbCRLF & _
" using ""CScript //H:CScript //S"" and running
the script using" &
vbCRLF & _
" ActiveUsers.VBS arguments""."
WScript.Quit
Case Else
WScript.Quit
End Select
Call GetActiveUsers()

'*********************************************************
***********
'*
'* Function intChkProgram()
'* Purpose: Determines which program is used to run this
script.
'* Input: None
'* Output: intChkProgram is set to one of CONST_ERROR,
CONST_WSCRIPT,
'* and CONST_CSCRIPT.
'*
'*********************************************************
***********
Private Function intChkProgram()
'Declare variables
Dim strFullName, strCommand, i, j

'strFullName should be something like
C:\WINDOWS\COMMAND\CSCRIPT.EXE
strFullName = WScript.FullName
If Err.Number then
Print "Error 0x" & CStr(Hex(Err.Number)) & "
occurred."
If Err.Description <> "" Then
Print "Error description: " & Err.Description
& "."
End If
intChkProgram = CONST_ERROR
Exit Function
End If

i = InStr(1, strFullName, ".exe", 1)
If i = 0 Then
intChkProgram = CONST_ERROR
Exit Function
Else
j = InStrRev(strFullName, "\", i, 1)
If j = 0 Then
intChkProgram = CONST_ERROR
Exit Function
Else
strCommand = Mid(strFullName, j+1, i-j-1)
Select Case LCase(strCommand)
Case "cscript"
intChkProgram = CONST_CSCRIPT
Case "wscript"
intChkProgram = CONST_WSCRIPT
Case Else 'should never happen
Print "An unexpected program is used
to run this
script."
Print "Only CScript.Exe or
WScript.Exe can be used to
run this script."
intChkProgram = CONST_ERROR
End Select
End If
End If
End Function

'*********************************************************
***********
'*
'* Sub GetActiveUsers()
'* Purpose: Lists Active Users
'* Output: Properties of the object are either printed
on screen or saved
'* in strOutputFile.
'*
'*********************************************************
***********
Private Sub GetActiveUsers()
'Declare variables
DIM fso
DIM objOutputFile
DIM strComputer
DIM objWMIService
DIM colItems
DIM objItem
DIM dateTime

'Create a file object
set fso = createobject("Scripting.FileSystemObject")
Set objOutputFile = fso.OpenTextFile(CONST_OUTPUTFILE,
2, True)

For Each strComputer In arrComputers
WriteLine " " , objOutputFile

WriteLine "==========================================" ,

objOutputFile
Quote:
WriteLine "Computer: " & strComputer , objOutputFile

WriteLine "==========================================" ,

objOutputFile
Quote:
Set objWMIService = GetObject("winmgmts:\\" &
strComputer &
"\root\MicrosoftHIS")
' for HIS 2000 you need to use MsSnaStatus_ActiveUser
' next line is for HIS 2004
Set colItems = objWMIService.ExecQuery("SELECT * FROM
MsSnaStatus_ClientConnection", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
WriteLine "ClientAppl: " & objItem.ClientAppl ,
objOutputFile
Set dateTime = CreateObject
("WbemScripting.SWbemDateTime")
dateTime.Value = objItem.ClientConnectTime
WriteLine "ClientConnectTime: " & dateTime.GetVarDate
(FALSE) ,
objOutputFile
WriteLine "ClientMachine: " & objItem.ClientMachine ,
objOutputFile
WriteLine "Domain: " & objItem.Domain , objOutputFile
WriteLine "User: " & objItem.User , objOutputFile
WriteLine " " , objOutputFile
Next
Next
objOutputFile.Close
set objOutputFile = NOTHING
set fso = NOTHING
End Sub

'*********************************************************
***********
'*
'* Sub WriteLine()
'* Purpose: Writes a text line either to a file or on
screen.
'* Input: strMessage the string to print
'* objFile an output file object
'* Output: strMessage is either displayed on screen or
written to a file.
'*
'*********************************************************
***********
Sub WriteLine(ByRef strMessage, ByRef objFile)
objFile.WriteLine strMessage
Print strMessage
End Sub

'*********************************************************
***********
'*
'* Sub Print()
'* Input: strMessage the string to print
'* Output: strMessage is printed on screen
'*
'*********************************************************
***********
Sub Print(ByRef strMessage)
Wscript.Echo strMessage
End Sub

'*********************************************************
***********
'*
*
'* End of
File *
'*
*
'*********************************************************
***********
*** End cut ***


.
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Host Integration Server All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB