Kaseya Community

Report Value from Config File

This question is answered

I have an application that reads the configuration from a file.  This file contains a line that lists the nodes unique licenses number

I have 75 PC across 6 locations that i need to account for licenses assigment and reporting (need to update monthly)

currently i created a procedure that writes the contence of the config file to an email and sent it to me (machine name is the subject line)

75 emails later i have a mess to pick through (at this point its better than nothing!)

im looking to improve this task by:

creating a procedure that collects only the value of the license line in the config file ( i assume i would need to use the parser for this)

Write the value collected to the audit  info> custom system info field

Then run a Info Center report tabling the collective result of this processes

 

I would love any suggestions from any vets out there improving my proposed solutions

Im also seeking help/suggestions on the parser section of this procedure. so the parser looks like chinese to me

i did find some info on reporting info to a custom field but i need the data to report first and im sure i can figure out the reporting aspect once the first two steps are inplace

 

Thanks in advance

Brock-

 

Verified Answer
  • Thanks for the updates!

    I took HardKnox’s advice and made a vbs to read the config file and output the value to another txt file.


    Here is the overview:


    MedAnywhere FLM Audit Procedure
    Deploy vbs file to read elf.properties and search for flm number
    outputs flm number to txt file
    Reads: c:\MedAnywhere\elf.propities
    Outputs: c:\temp\flminfo.txt
    Read Value from flminfo.txt and updates system info custom field
    Cleans up
    Deletes: #agenttemp#\flm.vbs
    Deletes: c:\temp\flminfo.txt
    Execute Procedure "Update System Info from txt file"
    Done

    Procedure 1 "MedAnywhere FLM Audit"


    <?xml version="1.0" encoding="utf-8"?>
    <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
      <Procedure name="MedAnywhere FLM Audit" treePres="3">
        <Body description="Deploy vbs file to read elf.properties and search for flm number&#xA;outputs flm number to txt file&#xA;&#xA;Reads: c:\MedAnywhere\elf.propities&#xA;Outputs: c:\temp\flminfo.txt&#xA;&#xA;Next&#xA;Read Value from flminfo.txt and updates system info custom field&#xA;&#xA;Then&#xA;Cleans up &#xA;Deletes: #agenttemp#\flm.vbs&#xA;Deletes: c:\temp\flminfo.txt&#xA;&#xA;Done">
          <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false">
            <Parameter xsi:type="EnumParameter" name="VariableType" value="AgentTempDirectory" />
            <Parameter xsi:type="StringParameter" name="SourceContent" value="" />
            <Parameter xsi:type="StringParameter" name="VariableName" value="temp" />
          </Statement>
          <Statement description="Write the selected file to the machine at the path specified - full path required." name="WriteFile" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Path" value="#temp#flm.vbs" />
            <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\flm.vbs" />
          </Statement>
          <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#flm.vbs&quot;" />
            <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
            <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
          </Statement>
          <Statement description="Delete the specified file - full path to the filename required." name="DeleteFile" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Path" value="#temp#flm.vbs" />
          </Statement>
          <Statement description="Execute the specified procedure. - NOTE: this procedure does not complete until the called procedure completes." name="ExecuteScript" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="ScriptID" value="1508318123" />
            <Parameter xsi:type="StringParameter" name="FolderName" value="Client Specific.FMM" />
            <Parameter xsi:type="StringParameter" name="ScriptName" value="Update System Info from txt file" />
            <Parameter xsi:type="StringParameter" name="TimeDelay" value="" />
            <Parameter xsi:type="EnumParameter" name="TimeUnit" value="Immediate" />
          </Statement>
        </Body>
      </Procedure>
    </ScriptExport>


    Vbs code

    Const ForReading = 1
    Const ForAppending = 8
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objRegEx = CreateObject("VBScript.RegExp")
    objRegEx.Pattern = "flm."

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("C:\medanywhere\elf.properties", ForReading)

    Do Until objFile.AtEndOfStream
        strSearchString = objFile.ReadLine
        Set colMatches = objRegEx.Execute(strSearchString)  
        If colMatches.Count > 0 Then
            For Each strMatch in colMatches   
                Set objTextFile = objFSO.OpenTextFile _
        ("c:\temp\flminfo.txt", ForAppending, True)
        objTextFile.WriteLine(Right(strSearchString,6))
    Next
    objTextFile.Close
        End If
    Loop

    objFile.Close



    Then the last procedure "Update System Info from txt file"

    <?xml version="1.0" encoding="utf-8"?>
    <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
      <Procedure name="Update System Info from txt file" treePres="3">
        <Body>
          <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false">
            <Parameter xsi:type="EnumParameter" name="VariableType" value="FileContent" />
            <Parameter xsi:type="StringParameter" name="SourceContent" value="c:\temp\info.txt" />
            <Parameter xsi:type="StringParameter" name="VariableName" value="flm" />
          </Statement>
          <Statement description="Update the selected System Info field with the specified value for the agent this procedure runs on." name="UpdateSystemInfo" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="ColumnName" value="FMM.FLM Number" />
            <Parameter xsi:type="StringParameter" name="Value" value="#flm#" />
          </Statement>
          <Statement description="Delete the specified file - full path to the filename required." name="DeleteFile" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Path" value="c:\temp\info.txt" />
          </Statement>
        </Body>
      </Procedure>
    </ScriptExport>

All Replies
  • Bump!

  • I don't think a log parser will help tyou with this, since it only looks at new added lines in a log / text file.

    I would fire that application of yours through a procedure, then use some dos batch or (win)linux tools to grep the line and data that is wanted.

    Put that into antoher txt file (output redirection) and read that into a varibale in kaseya, from there you can indeed put it in a custom field.

  • Not as powerful as Grep but it has its own merit for not requiring to copy the grep tool to the target computer is FIND command.

    An annoyance I found when piping from a text file out to a text file is that it always added the file name to the log/text file but I figured out that if you use the TYPE command with the FIND command you can locate just the line you want without the extra bits.

    Alternatively you could write a VBscript (if you had the know how) read the file and to write the bits out that you want and even replace bits to be more human readable format using the Replace command. I have recently made one that I use for cleaning up a single text line you get when using the find command to remove any pre or post bits of text that you don't want to be part of the Kaseya Variable.

  • Thanks for the updates!

    I took HardKnox’s advice and made a vbs to read the config file and output the value to another txt file.


    Here is the overview:


    MedAnywhere FLM Audit Procedure
    Deploy vbs file to read elf.properties and search for flm number
    outputs flm number to txt file
    Reads: c:\MedAnywhere\elf.propities
    Outputs: c:\temp\flminfo.txt
    Read Value from flminfo.txt and updates system info custom field
    Cleans up
    Deletes: #agenttemp#\flm.vbs
    Deletes: c:\temp\flminfo.txt
    Execute Procedure "Update System Info from txt file"
    Done

    Procedure 1 "MedAnywhere FLM Audit"


    <?xml version="1.0" encoding="utf-8"?>
    <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
      <Procedure name="MedAnywhere FLM Audit" treePres="3">
        <Body description="Deploy vbs file to read elf.properties and search for flm number&#xA;outputs flm number to txt file&#xA;&#xA;Reads: c:\MedAnywhere\elf.propities&#xA;Outputs: c:\temp\flminfo.txt&#xA;&#xA;Next&#xA;Read Value from flminfo.txt and updates system info custom field&#xA;&#xA;Then&#xA;Cleans up &#xA;Deletes: #agenttemp#\flm.vbs&#xA;Deletes: c:\temp\flminfo.txt&#xA;&#xA;Done">
          <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false">
            <Parameter xsi:type="EnumParameter" name="VariableType" value="AgentTempDirectory" />
            <Parameter xsi:type="StringParameter" name="SourceContent" value="" />
            <Parameter xsi:type="StringParameter" name="VariableName" value="temp" />
          </Statement>
          <Statement description="Write the selected file to the machine at the path specified - full path required." name="WriteFile" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Path" value="#temp#flm.vbs" />
            <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\flm.vbs" />
          </Statement>
          <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Command" value="wscript &quot;#temp#flm.vbs&quot;" />
            <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
            <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
          </Statement>
          <Statement description="Delete the specified file - full path to the filename required." name="DeleteFile" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Path" value="#temp#flm.vbs" />
          </Statement>
          <Statement description="Execute the specified procedure. - NOTE: this procedure does not complete until the called procedure completes." name="ExecuteScript" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="ScriptID" value="1508318123" />
            <Parameter xsi:type="StringParameter" name="FolderName" value="Client Specific.FMM" />
            <Parameter xsi:type="StringParameter" name="ScriptName" value="Update System Info from txt file" />
            <Parameter xsi:type="StringParameter" name="TimeDelay" value="" />
            <Parameter xsi:type="EnumParameter" name="TimeUnit" value="Immediate" />
          </Statement>
        </Body>
      </Procedure>
    </ScriptExport>


    Vbs code

    Const ForReading = 1
    Const ForAppending = 8
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objRegEx = CreateObject("VBScript.RegExp")
    objRegEx.Pattern = "flm."

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("C:\medanywhere\elf.properties", ForReading)

    Do Until objFile.AtEndOfStream
        strSearchString = objFile.ReadLine
        Set colMatches = objRegEx.Execute(strSearchString)  
        If colMatches.Count > 0 Then
            For Each strMatch in colMatches   
                Set objTextFile = objFSO.OpenTextFile _
        ("c:\temp\flminfo.txt", ForAppending, True)
        objTextFile.WriteLine(Right(strSearchString,6))
    Next
    objTextFile.Close
        End If
    Loop

    objFile.Close



    Then the last procedure "Update System Info from txt file"

    <?xml version="1.0" encoding="utf-8"?>
    <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
      <Procedure name="Update System Info from txt file" treePres="3">
        <Body>
          <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false">
            <Parameter xsi:type="EnumParameter" name="VariableType" value="FileContent" />
            <Parameter xsi:type="StringParameter" name="SourceContent" value="c:\temp\info.txt" />
            <Parameter xsi:type="StringParameter" name="VariableName" value="flm" />
          </Statement>
          <Statement description="Update the selected System Info field with the specified value for the agent this procedure runs on." name="UpdateSystemInfo" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="ColumnName" value="FMM.FLM Number" />
            <Parameter xsi:type="StringParameter" name="Value" value="#flm#" />
          </Statement>
          <Statement description="Delete the specified file - full path to the filename required." name="DeleteFile" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Path" value="c:\temp\info.txt" />
          </Statement>
        </Body>
      </Procedure>
    </ScriptExport>