Page 1 of 1 1
Topic Options
#156419 - 2006-02-01 06:12 PM Needed way to log script use
NHA Offline
Lurker

Registered: 2006-01-31
Posts: 2
I have inherited a KIX scripted environment where there appears to be a large number of defunct KIX scripts.

However with 5000+ users, it is difficult to tell for sure.

I wanted to create a line that I could include in each KIX script that would output to a log file some identification information when the cript gets run.

For example, in a batch file I would do something like

echo %user% ran this script at %time% >> \\server\netlogon\scriptlog.txt

If anyone can give me any suggestions I would appreciate it.

Top
#156420 - 2006-02-01 06:17 PM Re: Needed way to log script use
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Open(1,"\\server\netlogon\scriptlog.txt",5)
WriteLine(1,@userid+" Ran "+@scriptname+@date+@time+@crlf)
Close(1)
_________________________
Today is the tomorrow you worried about yesterday.

Top
#156421 - 2006-02-01 07:33 PM Re: Needed way to log script use
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
That is a tad optimistic as there is no error checking for file contention. 5000 users ups the odds on contention. Suppose though, the world does not come to an end if that happens.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#156422 - 2006-02-01 08:55 PM Re: Needed way to log script use
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Just threw out a basic answer, but you are correct it is possible for contention and I did not even think of that.

Depends on if NHA wants to really add that in.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#156423 - 2006-02-02 10:30 AM Re: Needed way to log script use
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Netlogon shares are normally read-only, aren't they?

A simpler solution might be to use LogEvent(). You could log to the local computer and harvest the results, or even better, log to a central computer using the "target" parameter. I confess I've never tried to use the target parameter so I don't know what issues you might have.

You could also read the last accessed date/time of the files. So long as your anti-virus and backup software is not resetting these it should give you the information that you need.

Top
#156424 - 2006-02-02 12:10 PM Re: Needed way to log script use
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Quote:

Netlogon shares are normally read-only, aren't they?




Yes they are, even to Admins.

Top
#156425 - 2006-02-09 05:28 PM Re: Needed way to log script use
NHA Offline
Lurker

Registered: 2006-01-31
Posts: 2
Hi everyone.
Just wanted to say your suggestions worked very well with just a little modification.

Here is what I ended up doing.

Open(1,"\\server\kixlog$\main2.txt",5)
WriteLine(1,@userid+" Ran "+@scriptname+@date+@time+@crlf)
Close(1)

Basicly created a hidden share with write permission for everyone. I know this is a bit of a security risk, but this is only for a short time untill I determine which scrupts are being used.

Thanx for all your help.

Top
#156426 - 2006-02-09 08:35 PM Re: Needed way to log script use
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This type of logging has been discussed several timesover the years. Using a single file can lead to file contention. I write a file for each computer and then have a service running on the server to consolidate the data from the individual files into a database.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#156427 - 2006-02-09 08:42 PM Re: Needed way to log script use
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
log it client side and then copy to the share.

@userid +'-'+@scriptname+'.txt'
@date @time

and then build a simple script to collate the data that you run when you want a report
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#156428 - 2006-02-09 08:44 PM Re: Needed way to log script use
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Quote:


....
However with 5000+ users
....





This has been said before but what's going to happen when 2 users login at (almost) the same time and both want to write to the log file? The first user will open the file and then the second user can't open it because the first user has it open.

Maybe making the name of the log file the same as the username? This will give you a large amount of files but it avoids the possibility of users being unable to open the file and therefore not writing to the file that the script ran then you got screwed up information imho.

After some time you could let a script match the filenames to a user list filtering out the ones did ran the script from the ones that did not.

Changed your script a bit hope you don’t mind.

Code:

Open(1,"\\server\kixlog$\" + @USERID + ".txt",5)
WriteLine(1,@userid +" Ran "+ @scriptname + " using " @wksta + " on " + @date + " - " + @time + @crlf)
Close(1)

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#156429 - 2006-02-09 08:55 PM Re: Needed way to log script use
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
it would be faster to make the file local then move it up.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#156430 - 2006-02-09 09:37 PM Re: Needed way to log script use
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
I don't think you'll see significant speed differences in opening it locally, writing one line to it, closing it and the copying it to the server opposed to opening it on the server, writing one line to it and closing it.

But it is an option that could be used.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#156431 - 2006-02-10 02:49 AM Re: Needed way to log script use
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
And not to debate the issue of contention, but even if it did happen, he would get the info that was originally after. He would still know what scripts were being accessed, just not by who necissarily....
_________________________
Today is the tomorrow you worried about yesterday.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 400 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.081 seconds in which 0.056 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org