Blog

Introducing the Longitude Command Line Interface

January 02, 2018 | Ken Leoni

Longitude 10.1 introduces the new Longitude Command Line Interface (CLI). The Longitude CLI complements the Longitude Web Interface (Longitude Console) with new scripting capabilities that can be used to automate Longitude’s monitoring behavior.  

Like the Longitude Console, the Longitude CLI is easy to master and lightweight. The Longitude CLI provides the following administrative capabilities:

  • Add/remove application monitoring for a computer or group

  • Suspend/Resume monitoring for a computer or group

  • List all computers monitored by an application

  • Add a computer to a group

  • List all suspended computers

  • List all groups or all computers in a group

 

The Longitude CLI works by providing commands that interact with the Longitude Console. Since the Longitude CLI can be run from a command prompt, it can be easily be incorporated into any script that can run Windows commands - e.g. batch files or Powershell.

Adding Server and Applications for Monitoring

Adding Server and Applications for Monitoring with Longitude CLI
Figure 1:     Longitude CLI initiating the monitoring of a Windows Server

 

Adding server appropriate monitoring can now be implemented as a step in building a new server. The Longitude CLI, allows users to easily incorporate Longitude's built-in knowledge base as part of any server build script. 

For example (Figure 1), the Longitude CLI can automate as follows:

 

  1. Run the Longitude command to monitor the application (/a) Windows on computer (/c) poland.test.net:

    longitude monitor /a Windows /c poland.test.net

    The Longitude Windows application is preconfigured to make scheduled collections of key performance indicators (KPIs) and evaluate the KPIs for performance and availability issues. 


  2. Adds computer (/c) Poland to the (/g) "Development" group:

    longitude /g Development /c poland.test.net

    When Longitude finds issues it will generate alerts to the dashboard and initiate any preconfigured notifications or corrective actions.  Notifications and/or actions can be configured for computers or for groups.  By adding poland.test.net to the Development group, it will be configured to take any actions assigned to to that group when performance and availability issues are found.


  3. The data from the server will automatically be included in scheduled reports for the Development group.



Server Discovery and Monitoring using PowerShell

The Longitude Console includes built-in device discovery and monitoring that detects servers and network devices via network scanning.  The Longitude CLI allows you to expand device discovery with scripts using customized criteria.

Example 1 – Monitor all the Windows Servers in a Windows Domain
## searchbase is the domain specification
## dcbase is a domain controller for that domain
## if -searchbase & -server are left out of the query,
## the query will default to the current domain

$searchbase = "DC=test,DC=net"
$dcbase = "DC01.test.net"

$serverlist = (Get-ADComputer -Filter {operatingsystem -like '*Server*'} `
   -SearchBase $searchbase -Server $dcbase | select name | sort-object name)

foreach ($server in $serverlist)
    {
    c:\LongitudeCommand\longitude monitor /c $server.name /a windows
     }

 

The PowerShell Script in Example 1 scans an Active Directory domain controller for computers with "Server" as part of their Operating System name.  All computers in this list are then configured to be monitored using Longitude's built-in knowledge base for Windows.

 

Example 2 – Monitor all Windows devices in an OU
## searchbase is the domain specification
## dcbase is a domain controller for that domain
## if -searchbase & -server are left out of the query,
## the query will default to the current domain
$searchbase = "DC=test,DC=net"
$dcbase = "DC01.test.net"

## The name of the OU is read in as a command line argument.
## If the script is run without arguments all OUs will be returned.
$group = '*OU=' + $args[0] + '*'

## Using DistinguishedName with Filter doesn't work if you use wildcards.
## So we filter after the data is collected

$serverlist = (Get-ADComputer -Filter * -SearchBase $searchbase -Server $dcbase `
   | ? {$_.DistinguishedName -like $group} | sort-object name)

foreach ($server in $serverlist)
    {
    c:\LongitudeCommand\longitude monitor /c $server.name /a windows
    }

 

The PowerShell Script in Example 2 once again scans through Active Directory, but in this case it will look at the computer's DistinguishedName to check if it contains a specified organizational unit (OU) string.  Any computers that match this string (e.g. "OU=Development", or "OU=Production") will be added to the results which are then be monitored using Longitude's built-in knowledge base for Windows.


 

 

Controlling Server and Application Monitoring

Longitude Suspend and Resume and Remove.png
Figure 2:     Longitude CLI stopping the monitoring of a Windows Server


Organizations where the server and network device counts are volatile can employ scripts with the Longitude CLI to take devices temporarily off line (from monitoring) or permanently remove them from being monitored altogether. 

The “suspend” command is very helpful in situations where a server and or its application are taken temporarily off line and you want Longitude to simply stop collecting and evaluating key metrics until the monitoring is reinstated later on either via the Longitude CLI ‘s “resume” command or user configuration via the Longitude Console.

The Longitude CLI is quite easy to master, for additional detail on the Longitude CLI please consult the online help.

Longitude CLI Tutorial

 

 
Find and solve issues instantly
System performance monitoring
 
 

 

Start Your Free 14 Day Trial of  Longitude Today!

Sign Up for the Blog

Heroix will never sell or redistribute your email address.