Forrester Total Economic Impactâ„¢ study finds Edwin AI delivered a 313% ROI for composite organization.

Read more

LogicMonitor offers monitoring for Linux systems that leverages the SSH protocol. SSH collects various metrics including CPU, memory and filesystem utilization, uptime, and throughput.

Note: SSH monitoring is designed only for systems not configured with SNMP. SNMP provides more robust monitoring natively, removing the need to configure the SSH monitoring provided by this Linux SSH package.

Configuring Linux instances for SSH involves the following:

  • Adding your Linux host into monitoring.
    For more information on adding resources into monitoring, see Adding Resources.
  • Configuring SSH on the Linux host for the DataSources to apply.
    You must authenticate the Collector’s access to the resource using an SSH public-private key pair instead of a password. 
  • Generating the SSH key pair and copy the public key to the Collector’s host that is assigned to the resource in LogicMonitor and the resource.
    To use an SSH key pair, you need the following:
    • A valid home directory. The SSH server verifies with  ~/.ssh/authorized_keys when authenticating incoming connections.
    • An SSH key pair in classic OpenSSH format (.pem)
      For more information, see How to Use ssh-keygen to Generate a New SSH Key? from SSH.

Note: Use the ssh-keygen -m PEM command to generate the key pair in classic OpenSSH format

Requirements for Monitoring Linux Resources Using SSH

To monitor Linux resources using SSH, do the following:

  • Import the latest version of all Linux SSH LogicModules. DataSources for SSH modules automatically begin collecting data after installation.
    For more information, see Module Installation.
  • Assign SSH credentials as properties on the Linux resource within LogicMonitor to authenticate on the Linux host.
    For more information, see Defining Authentication Credentials.
  • Ensure the Linux kernel is updated to version 2.6.24 or newer, and using one of the following Linux distros:
    • CentOS
    • Debian
    • Oracle Linux
    • RHEL
    • Ubuntu

Recommendation: Use a user account without access privilege when defining authentication credentials. The LogicModules in this package do not require any specialized permissions to monitor Linux using SSH.

LogicModules in other monitoring packages may require additional permissions. This has been confirmed through testing against clean installations of Debian, Ubuntu Server and CentOS, but does not account for additional hardening steps applied to a system.

Linux SSH Control Groups and Service Status Instance DataSources

To monitor your Linux environment, you must add the control group and service status DataSources to LogicMonitor as resources. You can accomplish this in one of the following ways:

  • Adding the instances manually—use the Resource Tree to add control groups and service instances.
  • Using Active Discovery—Enable Active Discovery for control groups and service instance DataSources to detect and add them automatically. For more information, see Active Discovery.

Recommendation: The Control Groups and Service Status DataSources do not include Active Discovery scripts by default. LogicMonitor recommends manually adding only the control groups and services that you want to monitor.

Automatically enabling Active Discovery for all control groups and services on a host can create a large number of monitored instances. This can result in excessive alert generation and make instance management difficult.

If your environment contains a manageable number of control groups and services, you can enable Active Discovery from the DataSource definition and embed the corresponding Groovy script as a parameter of “SCRIPT” in the discovery method dropdown.

For more information, see Active Discovery Script for the Linux_SSH_Cgroups DataSource Definition and Active Discovery Script for the Linux_SSH_ServiceStatus DataSource Definition.

Finding and Manually Adding Control Groups as Instances

Note: The following steps use a Docker container as an example of a control group to monitor. To manually monitor a Linux control group, you must first identify the control group name on the monitored host. This task uses the Linux systemd-cgtop utility to locate an existing control group, atd.service. Replace this value with the name of the control group you want to monitor.

  1. On the monitored Linux host, open a terminal and run the following command: systemd-cgtop -n1 -b
    This command displays the control groups that are using the most resources. The -n1 flag (short for --iterations=1) denotes only one iteration of the command to execute. The -b flag (short for --batch) forces the command to run in batch mode.
  2. From the command output, identify the control group you want to monitor and copy its name, excluding the parent container path.
    For example, if the output displays the following:
    system.slice/atd.service
    Then use the following command:
    atd.service
    docker container commands

Note: Unless “CPUAccounting=1” and “MemoryAccounting=1” are enabled for the services in question, no resource accounting displays and the data shown by systemd-cgtop will be incomplete.

  1. In LogicMonitor, navigate to the Resource Tree and select the Linux host.
  2. Select “Add Monitored Instance” from the Manage dropdown menu.
    For more information on manually adding instances, see Adding Instances.
    1. In Add Monitored Instance, enter “Control Groups” in the DataSource field and enter “atd.service” in the Wildcard Value field.
    2. Enter a Name for your instance.
  3. (Optional) Add a Description for your instance.
  4. Select Save.
    If successful, the instance displays under the DataSource on the Resources page.
    SSH resource with monitored control group instance
  1. To verify data collection, navigate to the Raw Data tab for the instance and select Poll Now.

LogicMonitor collects data and updates the displayed results when polling completes.

Finding and Manually Adding Services as Instances

  1. In a command line, run the following command: 
    systemctl list-units -a --type=service
    This command displays all units that systemd loaded or attempted to load, regardless of their current state on the system. The -a flag (shorthand for --all) ensures all units are listed including those which are inactive. The --type=service flag returns only service units.
  2. From the resulting output, copy the name of the service you want to monitor from the UNIT column.
    service instance commands
  1. In LogicMonitor, navigate to the Resource Tree and select the Linux host.
  2. Select “Add Monitored Instance” from the Manage dropdown menu.
    For more information on manually adding instances, see Adding Instances.
  3. In Add Monitored Instance, enter “Service Status” in the DataSource field and the copied service name in the Wildcard Value field.
  4. Enter a Name for your instance.
  5. (Optional) Add a Description for your instance.
  6. Select Save.
    If successful, the instance displays under the DataSource on the Resources page.
  7. To verify data collection, navigate to the Raw Data tab for the instance and select Poll Now.

Note: You can add services manually by specifying the linux.ssh.services property on the resource.

Active Discovery Script for the Linux_SSH_Cgroups DataSource Definition

Use the following script to enable Active Discovery in the Control Groups DataSource definition:

/*******************************************************************************
© 2007-2024 - LogicMonitor, Inc. All rights reserved.
 ******************************************************************************/
import com.santaba.agent.groovy.utils.GroovyScriptHelper as GSH
import com.logicmonitor.mod.Snippets
def azureHost = hostProps.get("auto.network.resolves") == "false" ? hostProps.get("system.azure.privateIpAddress") 
 : null
def loader = GSH.getInstance(GroovySystem.version).getScript("Snippets", Snippets.getLoader())
def remote = loader.load("lm.remote", "0").create(hostProps)
 .withHost(azureHost ?: hostProps.get("system.hostname"))
 .withKey(hostProps.get("ssh.pass") ? "" : hostProps.get("ssh.cert", "~/.ssh/id_rsa"))
 .withTimeout(15000)
// Expected output pattern capturing cgroup name, tasks, CPU, memory, input, output.
// Unless "CPUAccounting=1" and "MemoryAccounting=1" are enabled for the services in question, 
// no resource accounting will be available and the data shown by systemd-cgtop will be incomplete.
def line_pattern = ~/^\/?([^\/]+)\/(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*$/
def command_output = remote.exec('systemd-cgtop -n1 -b --cpu=percentage')
command_output.eachLine { line ->
 def matcher = line_pattern.matcher(line) ?: [:]
 // Process lines that contain a match except cgroups in user.slice
 if (matcher.size() > 0 && matcher[0][1] != "user.slice" && matcher[0][1] != "docker") {
 // Replace invalid wildvalue characters with underscores
 def wildvalue = matcher[0][2].replaceAll(/[:|\\|\s|=]+/,"_")
 def cgroupPath = matcher[0][1].replaceAll(/[:|\\|\s|=]+/,"_")
 println "${wildvalue}##${wildvalue}######auto.cgroup.path=${cgroupPath}"
 }
}
return 0
Groovy

Active Discovery Script for the Linux_SSH_ServiceStatus DataSource Definition

The Service Status DataSource has default alerts that you may want to adjust when monitoring all services. Use the following script to enable Active Discovery in the Service Status DataSource definition:

/*******************************************************************************
© 2007-2024 - LogicMonitor, Inc. All rights reserved.
 ******************************************************************************/
import com.santaba.agent.groovy.utils.GroovyScriptHelper as GSH
import com.logicmonitor.mod.Snippets
def azureHost = hostProps.get("auto.network.resolves") == "false" ? hostProps.get("system.azure.privateIpAddress") 
 : null
def loader = GSH.getInstance(GroovySystem.version).getScript("Snippets", Snippets.getLoader())
def remote = loader.load("lm.remote", "0").create(hostProps)
 .withHost(azureHost ?: hostProps.get("system.hostname"))
 .withKey(hostProps.get("ssh.pass") ? "" : hostProps.get("ssh.cert", "~/.ssh/id_rsa"))
 .withTimeout(15000)
// Expected output pattern capturing cgroup name, tasks, CPU, memory, input, output.
// Unless "CPUAccounting=1" and "MemoryAccounting=1" are enabled for the services in question, 
// no resource accounting will be available and the data shown by systemd-cgtop will be incomplete.
def line_pattern = ~/^\/?([^\/]+)\/(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*$/
def command_output = remote.exec('systemd-cgtop -n1 -b --cpu=percentage')
command_output.eachLine { line ->
 def matcher = line_pattern.matcher(line) ?: [:]
 // Process lines that contain a match except cgroups in user.slice
 if (matcher.size() > 0 && matcher[0][1] != "user.slice" && matcher[0][1] != "docker") {
 // Replace invalid wildvalue characters with underscores
 def wildvalue = matcher[0][2].replaceAll(/[:|\\|\s|=]+/,"_")
 def cgroupPath = matcher[0][1].replaceAll(/[:|\\|\s|=]+/,"_")
 println "${wildvalue}##${wildvalue}######auto.cgroup.path=${cgroupPath}"
 }
}
return 0
Groovy

LogicModules in Package

LogicMonitor’s package for Linux SSH Monitoring consists of the following LogicModules. For full coverage, ensure that all of these LogicModules are imported into your LogicMonitor platform:

Display NameTypeDescription
addCategory_Linux_SSHPropertySourceAssigns a value of “Linux_SSH” to the system.categories property for Linux hosts (excluding AWS and Azure) not properly identified due to unconfigured SNMP, and attempts to connect using SSH using the properties set on the resource/Collector.
Linux_SSH_InfoPropertySourceGathers Linux system information such as kernel name, kernel release, kernel version, hardware name, hardware platform, node name, processor type, and operating system.
Block Device PerformanceDataSourceMonitors I/O for disks and partitions on Linux systems using SSH.
Control GroupsDataSourceMonitors Linux Control Groups resource and task usage through the systemd-cgtop command.
CPU CoresDataSourceMonitors CPU usage per core using SSH.
CPU / MemoryDataSourceMonitors Linux CPU and Memory utilization using SSH.
FilesystemsDataSourceMonitors the Linux filesystem utilization metrics.
Network InterfacesDataSourceMonitors Linux network interface metrics such as throughput, packet transmission, errors, packet drops, collisions, and operating status.
Service StatusDataSourceMonitors Linux systemd services using the systemctl command.
TCP / UDP StatsDataSourceRetrieves TCP and UDP statistics from netstat.
UptimeDataSourceMonitors the Linux hosts uptime using SSH.

When configuring static datapoint thresholds on the various metrics tracked by this package’s DataSources, LogicMonitor follows the technology owner’s best practice KPI recommendations.

Note: Adjust predefined thresholds as needed for your environment.

For more information on tuning datapoint thresholds, see Static Thresholds for Datapoints.

14-day access to the full LogicMonitor platform