Kaseya Community

[procedure] VMware ESX configuration report (with convert2pdf kaseyascript function)

  • To get an overview of the configuration on an VMware ESX host I use an application named RVtools (http://www.robware.net/)
    I thought it might be usefull to implement this in a kaseya script to create reports based on the output. Fortunately the tool has an export to CSV option which makes things quite easy.

    how does this procedure works:
     - When the procedure is scheduled it prompts for parameters: esxhost, user and password.
     - When the procedure is executed it writes a zip file named Rvtools to the agent workdir\tools and extracts a folder with the same name. 
       After this a file named csv2html_rvtools.bat gets written to workdir\tools\RVtools.
     - One of the extracted files rvtools.exe is executed with some switches and the parameters you typed in the popup.
      * If successful rvtools.exe writes a csv file for every configuration category (one per tab you would normally see in the GUI of RVtools).
       * When RVtools fails the process keeps running in the background.
     - procedure is paused for 45 seconds.
     - A check is made whether rvtools.exe is still running, if that's the case the script kills rvtools.exe and exits.
     - csv2html_rvtools.bat kicks in to convert the CSV files to a HTML report.
     * Which delim is used in the CSV seems to depend on the regional settings or some other settings on the agent, either way the delim can be different on each agent.
       in my environment on some agents the CSV is delimitted by ; and others use , . The script takes care of determining which is used and ignores delims within quoted text. Also the script puts space between double delims because the cmd for loop in the batch file that splits the CSV's otherwise misses columns.
       it's likely there are still some unforeseen issues in the CSV handling.
     - Once the CSV is converted to html it will be passed to an AgentProcExtension named Convert2PDF (A custom kaseya script function).
     - The kaseya server downloads the output to the agent documents "Document\vmware-esxinfo-<esxhost>.pdf"

    download read-esx-host.zip - 10.54MB


        Procedure 6006-VMware-ESX-info-RVtoolsExport.xml
        Procedure Convert2PDF.xml
      <files used by Convert2PDF procedure>
      <files used by 6006-VMware-ESX-info-RVtoolsExport  procedure


     - extract read-esx-host.zip
     - copy the html2pdf and vmware folder to C:\Kaseya\WebPages\ManagedFiles\VSASharedFiles (change the path to your kaseya folder location)
     - import the procedures
     - copy AgentProcExtensions45.xml to C:\Kaseya\xml\Procedures\AgentProcExtensions (WARNING: if the file already exists change the number to next one that does not and change the number to the last one +1, note if there's a gap in the numbers the AgentProcExtension won't work)
     - Open the AgentProcExtension you just copied in a text editor and check the following line:
    <Step name="Convert2PDF" type="ExecuteCustomScript" scriptId="1502992497" prompt="Convert2PDF" description="Converts the content of a file rendered in webkit to PDF." stepNameTemplate="&lt;span class='proc-name'&gt;Convert2PDF&lt;/span&gt; with params &lt;span class='proc-text-arg'&gt;{Parameter1}, {Parameter2}." showOsType="true">
    Make sure that the number assigned to scriptId is the same as the one Convert2PDF procedure has after you imported it.
     - Edit the variables in Convert2PDF for PDF layout customization (header, footer, spacing etc.) and the title in the convert2pdf step in the 6006-VMware-ESX-info-RVtoolsExport  procedure.

    For more information about wkhtmltopdf, the tool used in convert2pdf check: http://code.google.com/p/wkhtmltopdf/


     - Add a function to export the config from multiple esxhosts at once and merge the data into one report (this is usefull in case the network of an agent has multiple ESX hosts, but no virtual center)
     - Add more PDF profiles to the convert2pdf procextension
     - Switch to seperate css file for stylesheet, easier to edit (batch file is full of escape characters)

    I can't add more settings/parameters to the Convertd2PDF procextensions because it's currently limited to three (kaseya could you please fix this?)
    Also be aware that custom procextensions can be overwritten when kaseya adds new procextensions.
    (currently as far as I know you can't do anaything to prevent that because the suffix number of your procextension filename has to be in sequence with the rest.)

    Also a rather big security con I can't fix: The password you enter in the popup is not hidden under asterisks.
    I recommend using readonly accounts for this script.


    Please post feedback and share improvements.


    [edited by: jelle.stoel at 11:05 PM (GMT -7) on 6-23-2011] typo
  • Most excellent!

  • Hi, This is a great piece of work, well done

    The problem is the file is no longer available to download.

    Can you put it back up


  • Hi Jelle, This tool looks great as well i don't know how i missed it but can you please repost the download.



  • as requested: http://www.megaupload.com/?d=OA7Q2TDZ

    I haven't made any changes yet, due to lack of time. In a few cases the tables end up malformed because there are some issues with sanitizing the input in the CSV2HTML batch script. I think it needs to be rewritten in powershell or some other language to get this right.

    [edited by: jelle.stoel at 8:17 AM (GMT -8) on 1-19-2012] .
  • This looks amazingly useful! Going to have a tinker this morning!

  • Hmm, can't seem to import the 6006 procedure, no errors, it just doesn't seem to show up anywhere after import!

    Will walk away, make a cup of tea and then see if it magically works afterward :-) (IE it's probably user error!)

  • Hello Jelle, This tool looks awesome, thansk for sharing.  I plan to try it today,


  • Im having the same issue importing the 6006 procedure.  I receive the following:

    Error - The procedure '6006-VMWare-ESX-info-RVToolsExport' could not be imported.  The given key was not present in the dictionary.

  • Ok, havent figured out exactly whats missing, but got it imported by removing the following step and then manually adding it once the import was completed:

             <Statement description="Converts the content of a file rendered in webkit to PDF." name="Convert2PDF" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

               <Parameter xsi:type="StringParameter" name="Parameter1" value="#workdir#\tools\RVTools\output.html #workdir#\tools\RVTools\output.pdf" />

               <Parameter xsi:type="StringParameter" name="Parameter2" value="Audit VMware ESX - RVtools info export" />

               <Parameter xsi:type="StringParameter" name="Parameter3" value="-O Landscape" />


    Hopefully short term this will help get it up and running!

  • I got it to import by doing all the server side steps first and then re-attemptign the import.

    The issue I have now is that it claims to successfully run, but the convert procedure doesn't get called and nothing seems to happen. This was on a vSphere box on server2008 that still has UAC enabled though so we're going to give it a go on a w2k3 box...

  • @Bryan, you're right - In the end I had to do the same (remove fromt he script and add manually) otherwise it imported as a corrupt script.

    The procedure is failing for me on the 'then' at step 10. Curses. - Are there any other stages that others had to add to get theirs to work?



  • esx2.png

    Hello Phil, please post the relevant contents of your agent procedure log

    Also have you tried running the steps manually?

     this is how 6006 looks in my environment:

    (note: it's the same as the one in the archive except rvtools.zip is named rvtools2.zip and some remarks)




    I've tested the procedure on the following OS's:
    windows 7 x86 = ok
    windows 2008 x86 = ok
    windows 2008 r2 = ok

    [edited by: jelle.stoel at 8:18 AM (GMT -8) on 1-19-2012] .
  • Heya Jelle -

    I have been doing some testing and it seems to fail at the convert2pdf stage, therefore I think perhaps there's an issue with the agentprocextension (I placed the agentprocextension as number 49 as we had 1-48 already) or the Convert2PDF ScriptID.

    In other words. It creates the CSVs and the output.html perfectly now! :-)

    What I have been trying to locate is the exact place where the scriptID is stored. I am only now beginning to learn agent procedures and I am trying to learn the hard way :-)



    [edited by: Phil G at 8:21 AM (GMT -8) on 1-19-2012] added extra detail :-)
  • scriptid.png

    Hi Phil,

    You should export the convert2pdf script again, so you can see which script ID has been assigned

    Regarding procextensions: be aware that kaseya can overwrite custom procextensions. We experienced this a few months ago when we noticed that convert2pdf stopped working. Turned out that a new function "Execute Powershell Command (64-bit, Run As User)" had been pushed in an update. (AgentProcExtensions48.xml)