WebService::LogicMonitor - Interact with LogicMonitor's API


version 0.153170


  use v5.16;
  use warnings;
  use Try::Tiny;
  use WebService::LogicMonitor;

  # find a hostgroup by name, iterate through its child groups
  # and check the status of a datasource instance

  my $lm = WebService::LogicMonitor->new(
      username => $ENV{LOGICMONITOR_USER},
      password => $ENV{LOGICMONITOR_PASS},
      company  => $ENV{LOGICMONITOR_COMPANY},

  my $top_group_name = shift || die "What group?\n";
  my $datasource     = shift || 'Ping';

  sub recurse_group {
      my $group = shift;
      foreach my $entity (@{$group->children}) {
          if ($entity->is_group) {
              say 'GROUP: ' . $entity->name;
          } elsif ($entity->is_host) {
              say '  HOST: ' . $entity->host_name;
              my $instances = try {
              } catch {
                  say "Failed to retrieve data source instances: " . $_;

              next unless $instances;
              # assume only one instance
              my $instance = shift @$instances;
              say '    datasource status: '
                . ($instance->enabled ? 'enabled' : 'disabled');
              say '    alert status: '
                . ($instance->alert_enable ? 'enabled' : 'disabled');


  my $groups = $lm->get_groups(name => $top_group_name);
  recurse_group(shift @$groups);


LogicMonitor is a SaaS infrastructure monitoring provider. They provide an RPC API which provides most of functionality of their web GUI (with the unfortunate omission of managing DataSources).

They have recently started a REST API which covers a different set of functionality.

This module puts an OO wrapper around the RPC API in what is a hopefully a much more convenient and user-friendly manner.

HOWEVER the API provided by this module is not considered stable and will almost certainly have some changes before version 1.0.


company, username, password

The CUP authentication details for your LogicMonitor account. See



Returns an arrayref of all available escalation chains.

get_escalation_chain_by_name(Str $name)

Convenience wrapper aroung "get_escalation_chains" which only returns chains where a name eq $name.


Retrieves a complete list of accounts as an arrayref.

get_account_by_email(Str $email)

Convenience wrapper aroung "get_accounts" which only returns accounts matching $email.

get_account_by_username(Str $username)

Convenience wrapper aroung "get_accounts" which only returns accounts matching $username.



Returns an arrayref of alerts or undef if none found.

See for what parameters are available to filter the alerts.


Creates and returns a new host. Shortcut for WebService::LogicMonitor::Host new and create

delete_host(Str displayname)

Deletes a host identified by its displayname. Convenience wrapper around "get_host" in WebService::LogicMonitor and "delete" in WebService::LogicMonitor::Host.

get_host(Str displayname)

Return a host.

get_hosts(Int hostgroupid)

Return an array of hosts in the group specified by group_id

In scalar context, will return an arrayref of hosts in the group.

In array context, will return the same arrayref plus a hashref of the group.


Convenience wrapper around "get_hosts" which returns all hosts. BEWARE This will probably take a while.

get_groups(Str|Regexp filter?)

Returns an arrayref of all host groups.

Optionally takes a string or regexp as an argument. Only those hostgroups with names matching the argument will be returned, or undef if there are none. If the arg is a string, it must be an exact match with eq.

get_sdts(Str key?, Int id?)

Returns an array of SDT hashes. With no args, it will return all SDTs in the account. See the LoMo docs for details on what keys are supported.

set_sdt(Str entity, Int|Str id, start = DateTime|Str, end => DateTime|Str, comment => Str?)>

Sets SDT for an entity. Entity can be


The id for Host can be either an id number or hostname string.

To simplify calling this we take two keys, start and end which must be either DateTime objects or ISO8601 strings parseable by DateTime::Format::ISO8601.

      Host    => 'somehost',
      start   => '20151101T1000',
      end     => '20151101T1350',
      comment => 'Important maintenance',

set_quick_sdt(Str entity, Int|Str id, $hours, ...)

Wrapper around "set_sdt" to quickly set SDT starting immediately. The lenght of the SDT can be specfied as hours, minutes or any other unit supported by, but only one unit can be specified.

  $lomo->set_quick_sdt(Host => 'somehost', minutes => 30, comment => 'Reboot to annoy support');
  $lomo->set_quick_sdt(HostGroup => 456, hours => 6);




Ioan Rogers <>


This software is copyright (c) 2015 by Sophos Ltd.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.