Home > Blogs > VMware PowerCLI Blog


Automate Log Insight Content Packs with PowerCLI

LI PCLI

Not too long ago I wrote a blog article on my blog www.vtagion.com about automating the deployment and configuration of Log Insight using PowerCLI. I’ve had many people ask if there is a way to automate the import process of Content Packs as well. Is it Possible?

What is a Content Pack?

Content packs are add-on packages that can extend the capabilities of Log Insight into other products. Content packs can be found in the VMware Solution Exchange website. Some Content Packs are compressed and include other files like a readme or PDF. The file that is actually consumed and used by Log Insight is a .VLCP file.

How does your script work?

My script allows a user to place all the desired Content Packs into a target folder which is then added into the Log Insight VM. In my example I chose ‘C:\Temp\ContentPacks’. *note: The Content Packs can be placed in a folder containing other files, the script filters by the correct extension. However, I prefer to have mine organized in this way.

Screenshot 2014-07-29 12.15.04

When you login to Log Insight and go to the Content Pack page you will notice that there are two default Packs (General and vSphere). The manual/default way of adding more packs is to use the link at the bottom of that page which brings up a menu and allows you to find each pack and upload it individually. I wanted to be able to add all five of my packs at the same time.

Screenshot 2014-07-29 12.18.08

The script (which you can get by clicking HERE) only requires 3 variables:

  • $vmname – Name of the Log Insight VM
  • $LIPassword – Root password for the VM
  • $ContentPackLocation – Directory of the Content Packs

This also assumes that your PowerCLI session is already connected to vCenter.

code

In a nutshell, the script will check to make sure that the target folder exists, it will then filter by the Content Pack extension .vlcp, and for each Pack found, it will copy it into the correct directory on the VM in its own folder (CP1, CP2, CP3…).

Once all Packs have been imported, the script will restart the Log Insight service so that the Content Packs become visible in the UI (this will disconnect the user’s LI session and will require that they login again after the script has run)

Screenshot 2014-07-29 12.28.40

Upon logging in after running the script you will see all of the Content Packs are visible and ready to be used.

Screenshot 2014-07-29 12.36.14

Special thanks goes to Steve Flanders (SFlanders.net)
for answering a few questions I had about Log Insight during the write-up of this post.

This entry was posted in Customization and tagged , , , on by .
Brian Graf

About Brian Graf

Brian Graf is a well-known VMware evangelist in the IT community. Over the past 5 years, Brian has done Technical Marketing for PowerCLI Automation and ESXi Lifecycle, Product Management of vCenter Distributed Resource Management features (DRS & HA), and is currently working as a Technical Marketing Manager for VMware Cloud on AWS. Brian is a co-author of the PowerCLI Deep Dive 2nd edition book. He has helped develop VMware certification courses and exams and presents around the world at VMware User Conferences, AWS Summits, Interop, as well as other industry Conferences. Brian is also a Microsoft MVP.

2 thoughts on “Automate Log Insight Content Packs with PowerCLI

  1. Sebastian

    Hi Brian,

    Awesome stuff, help me a lot.
    Just if I can correct one thing, you are missing tick ` at line 38
    because of this PowerCLI trying run content-packs as command, and it failing.
    Copy-VMGuestFile -VM $vmname -Source ($CP.Fullname) -Destination /usr/lib/loginsight/application/etc/content-packs/CP$i/content.json -LocalToGuest -GuestUser root GuestPassword “$LIPassword” -force

    Thank you,
    Sebastian

    Reply
  2. Adhip

    thnaks for the post brain very informative

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*