Periodic Lasso reports for Insights from a Linux server

Gabriele Bartolini
Gabriele Bartolini

Schedule periodic Lasso reports of your PostgreSQL or Barman installations on Linux to take advantage of EDB Insights and keep your database infrastructure healthy.


If your Linux servers can access our infrastructure, you can run a cron job that periodically (for example once a week) runs the latest available version of Lasso and automatically uploads the report into Insights.

IMPORTANT: We recommend that you manually run the reporting process first before you schedule a regular reports.

If your Linux servers cannot access our infrastructure, you can ask your Operations/Security department to open outbound access to the 443 port on the list of IPv4 and IPv6 addresses that you can find in the Lasso documentation. If this operation is not possible, the rest of the article is useless.

Example of script for automated reports

In this section you can find an example of Shell script that automatically downloads the latest version of Lasso from the Portal and stores it in a temporary folder for reuse. It then executes a Lasso report with the current user and uploads the result to EDB's infrastructure. Subsequent runs will check that the executable already exists and, in case it is not the latest available version of Lasso, downloads the binary again.

Such a script can be placed on your system so that the postgres user or the barman user can execute it. The script can be in the home directory of the user (e.g. $HOME/bin) or in a global directory such as /opt or /usr/local/bin.

Ideally, your systems will be managed through a configuration manager such as Puppet, Chef, or Ansible and you can easily automate the process.

The example script accepts two parameters, which can be set via command line or through environment variables:

  • one parameter controls the required company token, which can be found in your company's details page (from the left panel, select "Company Info > Company")
  • the other specifies the optional work directory (by default $HOME/.edb-lasso), used by Lasso to keep a temporary copy of the executable and to run the report

Feel free to modify the script according to your security and operational needs, making sure through that the meaning and goals remain unaltered. Do not hesitate to open a severity 4 issue for assistance.

Source code


# Example of script for periodic run of EnterpriseDB Lasso
# External network access to EnterpriseDB infrastructure is required
# This script can be used as a cron job for the postgres, enterprisedb
# and barman users, with recommended weekly frequency.

set -eu

# Parameters initialisation

# Help screen
usage() {
cat <<EOF
EnterpriseDB Lasso - Cron reporting script


- COMPANY_TOKEN: the company token as reported in EnterpriseDB Portal
- WORKDIR: optional work directory (default: ~/.edb-lasso)

# Verify the company token
if [ -z "${COMPANY_TOKEN}" ]
exit 1

# Creates the directory if it doesn't exist
if ! mkdir -p "${WORKDIR}"
echo "Please make sure that WORKDIR (${WORKDIR}) is writable"
exit 2

cd "${WORKDIR}"

# Verify the available reporter version
if [ -x "${REPORTER}" ] && "${REPORTER}" --is-latest-version > /dev/null 2>&1

if [ ${DOWNLOAD_REQUIRED} -eq 1 ]
echo -n "Downloading new edb-lasso version: "
curl -LSso "${REPORTER}" "${COMPANY_TOKEN}/lasso-linux-$(uname -m)"
chmod +x "${REPORTER}"
echo done.

# Run Lasso and upload the report to EnterpriseDB infrastructure
TMPDIR="${WORKDIR}" "${REPORTER}" --upload

Cron setup

The next step is to setup the cron for the periodic reports. Our recommendation is to start with a weekly report. Alternatively, you can opt for a monthly report.

IMPORTANT: Avoid collecting information on a daily or even finer basis, unless explicitly requested by EDB. There is no real benefit at the moment for Insights with increasing the frequency of the reports.

In case you manage several servers, please make sure you spread the reports at least a few minutes apart from each other.

The procedure is identical for PostgreSQL, EPAS or Barman reports. What changes is the user that needs to set the cron job.


Suppose that:

  • you want to perform a weekly report of your PostgreSQL server, every Saturday at 4.03AM
  • you are connected as postgres user on the PostgreSQL server
  • you have installed the above script in $HOME/bin/ and it is executable

You can then add the following entry in your postgres user's crontab:

03 4 * * 6 [ -x $HOME/bin/ ] && $HOME/bin/

In case your infrastructure is managed via configuration managers, please speak with your operations department on how to add this job.

Was this article helpful?

0 out of 0 found this helpful