Parsing structured data from Installatron using Terminal Commands

This advanced guide will expose Domain of One’s Own administrators to command line interfaces that allow you to generate structured data reports from Installatron. The uses for this range wildly from understanding what software your users are installing to version reporting and other analytics. For the purposes of this guide we will use the Terminal available in WHM, however the same commands can be executed by SSH as root or within any bash script that has root access.

Installatron has a command line interface with a variety of commands that you can run that are documented at Installatron Command-line Interfaces. The primary command that will output all data from all installations is /usr/local/installatron/installatron --installs

Keep in mind that Installatron stores and will expose sensitive data via this command, in particular the database credentials for each install and the layout of files and tables that makeup each install. However the output of the command is huge for even smaller servers, so we need a way to filter the output of this command.

We have a tool installed on each server called jq which is a command line json processor. Because the output from Installatron’s command line interface is json, we can pipe that command to jq to filter and generate interesting reports. You can find a lot of documentation around the filters available with jq at jq Manual (development version) but let’s look at some real world examples within our context.

We can pass a search parameter to Installatron with the -q flag so /usr/local/installatron/installatron --installs --q scalar will only display information on Scalar installs. Now if we pipe that to jq we can have it count the number of installs like this: /usr/local/installatron/installatron --installs --q scalar | jq '.data | length'

jq defines .data as the top level of the json object and we can not only use the length operator to get the number of items in the object, we can also have it filter and print specific data from each item. Let’s say you want to see a breakdown of the software version of each install for a particular application. The command /usr/local/installatron/installatron --installs --q scalar | jq '.data | .[].version' will print each software version of Scalar installed on the server.

This allows us to easily identify out of date software. More practically a request we get often is for a list of URLs for all software installs on a particular software. Since Installatron stores the URL as part of the json object this is now a simple one-line query `/usr/local/installatron/installatron --installs | jq ‘.data | .[].url’

Add > file.txt to the end of any command to save the output to a text file for later processing and reporting.

This only begins to cover the surface of what’s possible when using Installatron’s command line interface in conjunction with jq to filter and parse the results and generate the data you need from the server. We’d love to how you might use this data in interesting ways to report on and expose the activity happening in your community.

2 Likes

Working through this very helpful guide again for the first time in awhile. Has the path to installatron changed? Looked in what I thought were obvious alternatives but can’t find the path to run the jq tasks I had saved.

No, but you do have to be logged in as root by SSH to access the installatron path for this. I just tested on Muhlenberg’s server and this command works just fine:\

/usr/local/installatron/installatron --installs | jq '.data | .[].url'

Or have I misunderstood what you’re trying to do?

Ah, I thought I could use the terminal included in cpanel.

In other words, I overlooked that this is accomplished through the terminal in WHM. Not the terminal you can access in the cpanel associated with our primary domain account. I should have noticed where I was supposed to be from your screen captures. Should anyone else not see the /installatron/ directory, they’ve likely made the same mistake. All set now.