Jump to content

File usage monitor - not sure where to start.....


Recommended Posts

I want to collect data about share and file usage on several servers. I have identified several products that will do most of what I want, but they all have shortcomings and either wont do precisely what I need, are chargeable (company wont fund this) or some need installation on host, which I wont be able to get past our rigorous change process. (plus it's a learning curve for me)

I can see files open and who is accessing them via computer management, but have no idea where I would start to collect this using AutoIT. I would imagine it will be a periodic API call 'snapshot' view.

I need to collate the following info:

File and path being accessed

Username accessing it

ComputerName/IP address accessing it

I know it can be done using VB, but if possible I want to use AutoIT, but I'm not sure what I should be querying. I can run the script locally on the server or remotely

Any ideas suggestions?

Thanks

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Link to comment
Share on other sites

WOW!! First time I ever posted and got no response at all. Is there really no way of doing this with AutoIT?

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Link to comment
Share on other sites

Well first I imagine you know that you could most likely automate what you are manually doing.

But then again you never mentioned if you had even tried that.

I'm far from an expert, but is WMI not meant for this sort of thing?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

John - automating the literal process of what I do manually isn't really viable, which is why I failed to discuss it - open computer management, expand 'Shared Folders', select 'Open Files' and look at the items listed in the right hand pane.

I want to extract that list to a logfile, and unfortunately I am also far from being an expert, hence the 'not sure where to start' in the title.

Whenever I have posted on this forum, people have always been kind enough to point me in the right direction, As there had been no response whatsoever, I simply sought some form of clarification as to whether this was or wasn't possible

Thank you for your help

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Link to comment
Share on other sites

I'm not shure but is this a pointer in the direction you want to go?

;Computer Management Shared Files
ShellExecute("compmgmt.msc")
WinWaitActive("Computerbeheer")
send("{DOWN}{DOWN}{DOWN}{DOWN}{RIGHT}{DOWN}{DOWN}{DOWN}")
ControlClick("Computerbeheer", "", "[CLASS:ToolbarWindow32; INSTANCE:2]", "left", 1, 69, 10)
send("{DOWN}{DOWN}{DOWN}{ENTER}")
Sleep(1000)
send("afile")

Replace "Computerbeheer" with "Computer management"

Link to comment
Share on other sites

Hi Waardd - I really want to perform a lower level O/S query rather than use an MMC. I know it can be done with VB

(objResource.Path & "," & objResource.User & "," & GetUserName(objResource.User) & "," & GetUsersMachine(objResource.User))

but I wanted to do the whole thing using AutoIT, because it would be useful (and nice to have) for future stuff. It may be the case that it falls outside AutoIT capabilities, in which case I will do it with VB.

Thank you tho for at least suggesting an approach

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Link to comment
Share on other sites

built in windows command:

net file

then for instance if there are 5 items listed, and one has and id of 55, run:

net file 55

and that would give you the information you might be looking for.

if you don't care about the detailed information, then what you want would be relatively easy.

download psexec, put it on whatever machine will be running this code.

If you already have a list of computers - save the list to a txt file (you can also pull from Active Directory on the fly if you wanted).

Read the file to an array, then for each item in the array run:

psexec computername net file > c:workingdircomputername_connections.log

psexec actually supports running commands based on a text file, so you could skip using autoit altogether ....although it would be a bit more difficult to create individual log files, or append to an existing log.

If you want the detailed information for each ID listed per computer, you would need to create an inner For loop that parses the data to only look for the lines that contain id's, then run the 'net file id' command, and save that information to a log file.

Link to comment
Share on other sites

Thanks for this - it's certainly an option, although it's a bit convaluted.

The VB query gives me the IP address which in turn gives me the users location based on subnet, however the Net File query doesn't. I know I can query DNS for the info, but that relies on DNS being absolutely correct (I KNOW that's gonna fail - we're talking > 30k machines, 3 forests and 8 domains lol) for the entire country.

Due to workload, I haven't had time to investigate it fully yet, but _Net_Share_SessionEnum() looks like it may be just what I'm looking for.

edit - or _Net_Share_FileEnum() I only just discovered the _Net_Share_ commands, so very optimistic

Edited by shornw

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Link to comment
Share on other sites

_Net_Share_FileEnum() I only just discovered the _Net_Share_ commands, so very optimistic

I completely forgot about those functions. Yes, _Net_Share_FileEnum() should get you exactly what you are looking for.

You still need to build a for loop to iterate through each machine you want the stats, and then you might want to use _FileWriteFromArray for logging.

**edit** based on your comments, it appears you don't already know the names/ip's - so you either need to iterate through each ip, ie

10.1.1.2 to 10.1.1.254, then 10.1.2.2 to 10.1.2.254, etc.

BUT... you can use the AD udf to connect and get computer names for all of AD and iterate that way... but we aren't big enough for forrests or mulitple domains (save our test AD)..(only 1,600~ devices)....it can definitely be done, but it is still reliant on DNS being accurate. As you know, if you try to connect to a specific pc to get the report, but the DNS record is stale, you will likely be pulling a report from a different computer.

Gotta clean up DNS before you can trust any report data.

Edited by z0iid
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...