Kaseya Community

Looking for best method to collect/combine results from multiple Agents into one file

  • Hello to all. I am looking for a little advice..

    I am trying to determine the best way to collect/combine results from multiple Agents in a machien group into one file stored on a designated server/machine in that machine group.

    For example, let's say I have a Defrag script that runs on all the computers in a machine group. The defrag script creates two text files - one showing the %defrag at the beginning, and a second showing the %defrag at the end. The two files are stored in a AgentTemp folder on each Agent.

    When the script runs, I would like to append the contents of these two files into a master file stored on a server, and then have that file emailed to me. That way I could easily look at the email message and/or the contents of that file, and see the results from the defrag operations for all of the computers in that machine group.

    I could easily do this if all the machines were on the same physical LAN. But sometimes there are laptops that may be in the field, as well as computers from multiple offices - all in the same machine group.

    So I am trying to figure out the best method to accomplish this, when machines may not be on the same LAN.

    I am thinking of reading the file contents from the Agent into a script variable, then running a script on the designated collection machine/server to take that info and save to file.

    But I wanted to check with others before I got started, in case there was a better method.

    Lloyd

    Legacy Forum Name: Looking for best method to collect/combine results from multiple Agents into one file,
    Legacy Posted By Username: lwolf
  • bump.... i am going to bump this post...

    I am looking for a way to collect text from a file on Agent#1, and Agent#2,... and Agent #99, and combine them all into one file on Agent #100. The agents are all for the same customer, but may be on different networks, LANS, etc.

    Any ideas for how to accomplish this?

    Thanks in advance.

    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • Lloyd,

    You could use the "Get File" function to bring each file back to your K server. You could then write a vbscript to combine the files on your server.

    You know the group name you need to query the database for the list of machines. Using that list, you then know the path on your K server to the machine profile to get to each file ("\Kaseya\UserProfiles\.\). Then loop through the machines and combine the file. Then if need be, run another script to put the file back on Agent #100 machine.

    I realize this is a multiple step process, but don't really see a way to do it in one step given the machines are in different locations.

    Hope this helps.

    Rich

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: rkniffin
  • Can't you just write the values to the script log, and then create a Log Report on the Kaseya server to collect all the information into a report, schedule it to run at a given time and e-mail it to you?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Lmhansen
  • Thanks to both for the suggestions. I appreciate it.

    AT this time, I do not have the Kaseya Agent installed on my kserver. If I install it, I could call a script that would do my file copies for me.

    The Kaseya KB says its okay to install the Agent on the Kserver. I wa wondering if anyone else has done this, and if so, were there any problems?

    Thanks!

    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • Well, I thought I had this figured out, but ran into a roadblock....

    First, I installed the Agent on my kserver.

    Then, In my script that runs on the Agents, I have the following commands:
    - run an MS defrag (analysis only) and save resulst to text file on the local Agent (Agent_temp\defrag\MS-defrag-scanonly-result.txt)
    - upload that text file to my kserver (which locally on my phtsical kserver, gets stored in D:\Kaseya\UserProfiles\GUIDhere\GetFiles\defrag\MS-defrag-scanonly-result.txt
    - use a Variable to store the Agent GUID of the server/machine on the network that is supposed to be the collect of all the text file (#Collector_GUID#)
    - use a Managed Variable to store the Agent GUID of the kserver ()
    - save the GUID of the Agent that is running the degrag script to a variable (#Agent_GUID#)
    - Use the Schedule Script command to schedule a script tp run, immediately, assigned to the kserver itself (), which is to append (using the DOS copy + command) the contents of the MS-defrag-scanonly-result.txt uploaded file for the Agent to an Collector text file.

    - The Collector script that runs on the KServer simply runs the Execute Shell Command for the following DOS command:

    copy D:\Kaseya\UserProfiles\#Collector_GUID#\GetFiles\defrag\MS-defrag-Collector.txt+D:\Kaseya\UserProfiles\#Agent_GUID#\GetFiles\defrag\MS-defrag-scanonly-result.txt D:\Kaseya\UserProfiles\#Collector_GUID#\GetFiles\defrag\MS-defrag-Collector.txt

    I thought I was good to go, but it fails on LINE 1 in my Collector scipt, saying that a variable I am using is not defined.

    Then I realized my problem. I can successfully pass variables down to subscripts using the Execute Script command, but not using the Schedule Script command. Since I want the script running on the workstation to schedule/run a script on my kserver, I believe must use the Schedule Script command, as that is the only command that supports the passing of a GUID for the Agent to run on.

    So, I don't think my current method will work.

    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • I haven’t tested this, and dont know if the answer to your issue could possibly be this simple (but often it is). There are three ways to "Pipe" to a file... one replaces, another appends, the third is less relevant here...

    Simply put;
    > replaces the file content
    >> Appends to a file.

    Seems like if you used this method writing to a full UNC path from all agents to the same location you would get what your asking for. No?

    Hope this helps.

    Kirk...

    More details on Pipes…

    http://docs.freebsd.org/info/gawk/gawk.info.File_Pipe_Redirection.html



    `print ITEMS > OUTPUT-FILE'
    This type of redirection prints the items onto the output file
    OUTPUT-FILE.

    `print ITEMS >> OUTPUT-FILE'
    This type of redirection prints the items onto the output file
    OUTPUT-FILE. The difference between this and the single-`>'
    redirection is that the old contents (if any) of OUTPUT-FILE are
    not erased.

    `print ITEMS | COMMAND'
    It is also possible to send output through a "pipe" instead of
    into a file. This type of redirection opens a pipe to COMMAND
    and writes the values of ITEMS through this pipe, to another
    process created to execute COMMAND.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: kfeathers
  • Some thing that might help with this...

    1) You can save the GetFile contents into a commong folder rather than in than in each machines profile. Example here assume you are using GetVariable to put the machine/groupid in a variable called machineid. The GetFile uses relative paths so in the folder to save to put /../../../../MyFolder/#machineid#.txt .

    In this case the file will be saved in C:\MyFolder on the K-Server rather than deep in the profile.

    3) Use schedule script to execute a script on the server after you run it on the client. Be careful here, if you schedule all the clients to run at the same time, schedule the server separately. We've had a few problems where we've gotten the same script scheduled multiple times.

    4) In the server script simply do "TYPE *.TXT >> MySummary.OUT" and you'll have a single file with all the result. You'll have to deal with using > or >> and when the file gets reset or you'll always just append.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: doug.jenkins@ispire.ca
  • The first point you make here:

    1) You can save the GetFile contents into a commong folder rather than in than in each machines profile. Example here assume you are using GetVariable to put the machine/groupid in a variable called machineid. The GetFile uses relative paths so in the folder to save to put /../../../../MyFolder/#machineid#.txt .


    is simply gold. Thank you very much!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: mparr
  • Great tip on the path. Thanks.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: rkniffin
  • Doug,

    Thanks very much. I think I tried something like that before, but got stuck. Seems liek it shoudl work. I will try again.

    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • When I found this one it opened up a whole new level of opportunities for me. All the stuff that I used to get mailed individually from scripts or write to an event log and try to sort out, I now put to a common location and run a script that drops it into an SQL database.

    Using this and Kaseya views I have a single report that all my people see that pretty much lays out the work for the day it includes sorted tickets, sorted and grouped event logs, backup status and other things we feel are key to be moniitored.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: doug.jenkins@ispire.ca