Forum Discussion
18 hours ago, Michael Rodrigues said:@Vitor Santos, @Mike Moniz, thanks for the discussion. I did some digging in JIRA, as this has come up before. I think I found a DataSource that solves this, it just never found its way into core. I'll get this into a sprint for review so we can see about giving it a proper release. Code looks like this:
def user = hostProps.get("win.user") def pass = hostProps.get("win.pass") def path = instanceProps.get("wildvalue") def command = "cmd /c dir ${path} /a | findstr \"File(s) Dir(s)\""; if(user && pass) { command = "cmd /c net use ${path} /user:${user} ${pass} & dir ${path} /a | findstr \"File(s) Dir(s)\""; } def stdout = (command.tokenize()).execute().text; def result = stdout.readLines(); def fileInfo = result[-2]; def dirInfo = result[-1]; def tokens = fileInfo.split(); println("Files=${tokens[0]}"); println("UsedSpace=${tokens[2].replace(',','')}"); tokens = dirInfo.split(); println("Folders=${tokens[0]}"); println("FreeSpace=${tokens[2].replace(',','')}"); return 0;
Hello @Michael Rodrigues, thanks for sharing this!
If possible, please advise once that gets published.
In the meanwhile I've used this code (tweaked it a little bit) & created a DataSource for what we want.
Downside here is, from what I tested it only works if the LM collector service is running as user (not as local system) but, I guess this does the trick (since we force that service to run as an admin account).
Thank you!
Related Content
- 4 years ago