Native YAML - monitoring/logicmonitor.py (#18790)

* Native YAML - monitoring/logicmonitor.py

* Fix comments as well

* Fix quotes
pull/18777/head
Fabio Alessandro Locati 8 years ago committed by Matt Clay
parent 8e951b9f98
commit c786f7ca3c

@ -89,7 +89,7 @@ options:
- NOTE You should use Ansible service modules such as M(service) or M(supervisorctl) for managing the Collector 'logicmonitor-agent' and 'logicmonitor-watchdog' services. Specifically, you'll probably want to start these services after a Collector add and stop these services before a Collector remove. - NOTE You should use Ansible service modules such as M(service) or M(supervisorctl) for managing the Collector 'logicmonitor-agent' and 'logicmonitor-watchdog' services. Specifically, you'll probably want to start these services after a Collector add and stop these services before a Collector remove.
- "Host: Perform actions on a host device." - "Host: Perform actions on a host device."
- "Hostgroup: Perform actions on a LogicMonitor host group." - "Hostgroup: Perform actions on a LogicMonitor host group."
- NOTE Host and Hostgroup tasks should always be performed via local_action. There are no benefits to running these tasks on the remote host and doing so will typically cause problems. - 'NOTE Host and Hostgroup tasks should always be performed via delegate_to: localhost. There are no benefits to running these tasks on the remote host and doing so will typically cause problems.'
required: true required: true
default: null default: null
choices: ['collector', 'host', 'datsource', 'hostgroup'] choices: ['collector', 'host', 'datsource', 'hostgroup']
@ -192,352 +192,367 @@ options:
... ...
''' '''
EXAMPLES = ''' EXAMPLES = '''
# example of adding a new LogicMonitor collector to these devices # example of adding a new LogicMonitor collector to these devices
--- ---
- hosts: collectors - hosts: collectors
remote_user: '{{ username }}' remote_user: '{{ username }}'
vars: vars:
company: 'mycompany' company: mycompany
user: 'myusername' user: myusername
password: 'mypassword' password: mypassword
tasks: tasks:
- name: Deploy/verify LogicMonitor collectors - name: Deploy/verify LogicMonitor collectors
become: yes become: yes
logicmonitor: logicmonitor:
target=collector target: collector
action=add action: add
company={{ company }} company: '{{ company }}'
user={{ user }} user: '{{ user }}'
password={{ password }} password: '{{ password }}'
#example of adding a list of hosts into monitoring #example of adding a list of hosts into monitoring
--- ---
- hosts: hosts - hosts: hosts
remote_user: '{{ username }}' remote_user: '{{ username }}'
vars: vars:
company: 'mycompany' company: mycompany
user: 'myusername' user: myusername
password: 'mypassword' password: mypassword
tasks: tasks:
- name: Deploy LogicMonitor Host - name: Deploy LogicMonitor Host
# All tasks except for target=collector should use local_action # All tasks except for target=collector should use delegate_to: localhost
local_action: > logicmonitor:
logicmonitor target: host
target=host action: add
action=add collector: mycompany-Collector
collector='mycompany-Collector' company: '{{ company }}'
company='{{ company }}' user: '{{ user }}'
user='{{ user }}' password: '{{ password }}'
password='{{ password }}' groups: /servers/production,/datacenter1
groups="/servers/production,/datacenter1" properties:
properties="{'snmp.community':'secret','dc':'1', 'type':'prod'}" snmp.community: secret
dc: 1
#example of putting a datasource in SDT type: prod
--- delegate_to: localhost
- hosts: localhost
remote_user: '{{ username }}' #example of putting a datasource in SDT
vars: ---
company: 'mycompany' - hosts: localhost
user: 'myusername' remote_user: '{{ username }}'
password: 'mypassword' vars:
tasks: company: mycompany
- name: SDT a datasource user: myusername
# All tasks except for target=collector should use local_action password: mypassword
local_action: > tasks:
logicmonitor - name: SDT a datasource
target=datasource # All tasks except for target=collector should use delegate_to: localhost
action=sdt logicmonitor:
id='123' target: datasource
duration=3000 action: sdt
starttime='2017-03-04 05:06' id: 123
company='{{ company }}' duration: 3000
user='{{ user }}' starttime: '2017-03-04 05:06'
password='{{ password }}' company: '{{ company }}'
user: '{{ user }}'
#example of creating a hostgroup password: '{{ password }}'
---
- hosts: localhost #example of creating a hostgroup
remote_user: '{{ username }}' ---
vars: - hosts: localhost
company: 'mycompany' remote_user: '{{ username }}'
user: 'myusername' vars:
password: 'mypassword' company: mycompany
tasks: user: myusername
- name: Create a host group password: mypassword
# All tasks except for target=collector should use local_action tasks:
local_action: > - name: Create a host group
logicmonitor # All tasks except for target=collector should use delegate_to: localhost
target=hostgroup logicmonitor
action=add target: hostgroup
fullpath='/servers/development' action: add
company='{{ company }}' fullpath: /servers/development
user='{{ user }}' company: '{{ company }}'
password='{{ password }}' user: '{{ user }}'
properties="{'snmp.community':'commstring', 'type':'dev'}" password: '{{ password }}'
properties:
#example of putting a list of hosts into SDT snmp.community: commstring
--- type: dev
- hosts: hosts
remote_user: '{{ username }}' #example of putting a list of hosts into SDT
vars: ---
company: 'mycompany' - hosts: hosts
user: 'myusername' remote_user: '{{ username }}'
password: 'mypassword' vars:
tasks: company: mycompany
- name: SDT hosts user: myusername
# All tasks except for target=collector should use local_action password: mypassword
local_action: > tasks:
logicmonitor - name: SDT hosts
target=host # All tasks except for target=collector should use delegate_to: localhost
action=sdt logicmonitor:
duration=3000 target: host
starttime='2016-11-10 09:08' action: sdt
company='{{ company }}' duration: 3000
user='{{ user }}' starttime: '2016-11-10 09:08'
password='{{ password }}' company: '{{ company }}'
collector='mycompany-Collector' user: '{{ user }}'
password: '{{ password }}'
#example of putting a host group in SDT collector: mycompany-Collector
--- delegate_to: localhost
- hosts: localhost
remote_user: '{{ username }}' #example of putting a host group in SDT
vars: ---
company: 'mycompany' - hosts: localhost
user: 'myusername' remote_user: '{{ username }}'
password: 'mypassword' vars:
tasks: company: mycompany
- name: SDT a host group user: myusername
# All tasks except for target=collector should use local_action password: mypassword
local_action: > tasks:
logicmonitor - name: SDT a host group
target=hostgroup # All tasks except for target=collector should use delegate_to: localhost
action=sdt logicmonitor:
fullpath='/servers/development' target: hostgroup
duration=3000 action: sdt
starttime='2017-03-04 05:06' fullpath: /servers/development
company='{{ company }}' duration: 3000
user='{{ user }}' starttime: '2017-03-04 05:06'
password='{{ password }}' company=: '{{ company }}'
user: '{{ user }}'
#example of updating a list of hosts password: '{{ password }}'
---
- hosts: hosts #example of updating a list of hosts
remote_user: '{{ username }}' ---
vars: - hosts: hosts
company: 'mycompany' remote_user: '{{ username }}'
user: 'myusername' vars:
password: 'mypassword' company: mycompany
tasks: user: myusername
- name: Update a list of hosts password: mypassword
# All tasks except for target=collector should use local_action tasks:
local_action: > - name: Update a list of hosts
logicmonitor # All tasks except for target=collector should use delegate_to: localhost
target=host logicmonitor:
action=update target: host
company='{{ company }}' action: update
user='{{ user }}' company: '{{ company }}'
password='{{ password }}' user: '{{ user }}'
collector='mycompany-Collector' password: '{{ password }}'
groups="/servers/production,/datacenter5" collector: mycompany-Collector
properties="{'snmp.community':'commstring','dc':'5'}" groups: /servers/production,/datacenter5
properties:
#example of updating a hostgroup snmp.community: commstring
--- dc: 5
- hosts: hosts delegate_to: localhost
remote_user: '{{ username }}'
vars: #example of updating a hostgroup
company: 'mycompany' ---
user: 'myusername' - hosts: hosts
password: 'mypassword' remote_user: '{{ username }}'
tasks: vars:
- name: Update a host group company: mycompany
# All tasks except for target=collector should use local_action user: myusername
local_action: > password: mypassword
logicmonitor tasks:
target=hostgroup - name: Update a host group
action=update # All tasks except for target=collector should use delegate_to: localhost
fullpath='/servers/development' logicmonitor:
company='{{ company }}' target: hostgroup
user='{{ user }}' action: update
password='{{ password }}' fullpath: /servers/development
properties="{'snmp.community':'hg', 'type':'dev', 'status':'test'}" company: '{{ company }}'
user: '{{ user }}'
#example of removing a list of hosts from monitoring password: '{{ password }}'
--- properties:
- hosts: hosts snmp.community: hg
remote_user: '{{ username }}' type: dev
vars: status: test
company: 'mycompany' delegate_to: localhost
user: 'myusername'
password: 'mypassword' #example of removing a list of hosts from monitoring
tasks: ---
- name: Remove LogicMonitor hosts - hosts: hosts
# All tasks except for target=collector should use local_action remote_user: '{{ username }}'
local_action: > vars:
logicmonitor company: mycompany
target=host user: myusername
action=remove password: mypassword
company='{{ company }}' tasks:
user='{{ user }}' - name: Remove LogicMonitor hosts
password='{{ password }}' # All tasks except for target=collector should use delegate_to: localhost
collector='mycompany-Collector' logicmonitor:
target: host
#example of removing a host group action: remove
--- company: '{{ company }}'
- hosts: hosts user: '{{ user }}'
remote_user: '{{ username }}' password: '{{ password }}'
vars: collector: mycompany-Collector
company: 'mycompany' delegate_to: localhost
user: 'myusername'
password: 'mypassword' #example of removing a host group
tasks: ---
- name: Remove LogicMonitor development servers hostgroup - hosts: hosts
# All tasks except for target=collector should use local_action remote_user: '{{ username }}'
local_action: > vars:
logicmonitor company: mycompany
target=hostgroup user: myusername
action=remove password: mypassword
company='{{ company }}' tasks:
user='{{ user }}' - name: Remove LogicMonitor development servers hostgroup
password='{{ password }}' # All tasks except for target=collector should use delegate_to: localhost
fullpath='/servers/development' logicmonitor:
- name: Remove LogicMonitor servers hostgroup target: hostgroup
# All tasks except for target=collector should use local_action action: remove
local_action: > company: '{{ company }}'
logicmonitor user: '{{ user }}'
target=hostgroup password: '{{ password }}'
action=remove fullpath: /servers/development
company='{{ company }}' delegate_to: localhost
user='{{ user }}' - name: Remove LogicMonitor servers hostgroup
password='{{ password }}' # All tasks except for target=collector should use delegate_to: localhost
fullpath='/servers' logicmonitor:
- name: Remove LogicMonitor datacenter1 hostgroup target: hostgroup
# All tasks except for target=collector should use local_action action: remove
local_action: > company: '{{ company }}'
logicmonitor user: '{{ user }}'
target=hostgroup password: '{{ password }}'
action=remove fullpath: /servers
company='{{ company }}' delegate_to: localhost
user='{{ user }}' - name: Remove LogicMonitor datacenter1 hostgroup
password='{{ password }}' # All tasks except for target=collector should use delegate_to: localhost
fullpath='/datacenter1' logicmonitor:
- name: Remove LogicMonitor datacenter5 hostgroup target: hostgroup
# All tasks except for target=collector should use local_action action: remove
local_action: > company: '{{ company }}'
logicmonitor user: '{{ user }}'
target=hostgroup password: '{{ password }}'
action=remove fullpath: /datacenter1
company='{{ company }}' delegate_to: localhost
user='{{ user }}' - name: Remove LogicMonitor datacenter5 hostgroup
password='{{ password }}' # All tasks except for target=collector should use delegate_to: localhost
fullpath='/datacenter5' logicmonitor:
target: hostgroup
### example of removing a new LogicMonitor collector to these devices action: remove
--- company: '{{ company }}'
- hosts: collectors user: '{{ user }}'
remote_user: '{{ username }}' password: '{{ password }}'
vars: fullpath: /datacenter5
company: 'mycompany' delegate_to: localhost
user: 'myusername'
password: 'mypassword' ### example of removing a new LogicMonitor collector to these devices
tasks: ---
- name: Remove LogicMonitor collectors - hosts: collectors
become: yes remote_user: '{{ username }}'
logicmonitor: vars:
target=collector company: mycompany
action=remove user: myusername
company={{ company }} password: mypassword
user={{ user }} tasks:
password={{ password }} - name: Remove LogicMonitor collectors
become: yes
#complete example logicmonitor:
--- target: collector
- hosts: localhost action: remove
remote_user: '{{ username }}' company: '{{ company }}'
vars: user: '{{ user }}'
company: 'mycompany' password: '{{ password }}'
user: 'myusername'
password: 'mypassword' #complete example
tasks: ---
- name: Create a host group - hosts: localhost
local_action: > remote_user: '{{ username }}'
logicmonitor vars:
target=hostgroup company: mycompany
action=add user: myusername
fullpath='/servers/production/database' password: mypassword
company='{{ company }}' tasks:
user='{{ user }}' - name: Create a host group
password='{{ password }}' logicmonitor:
properties="{'snmp.community':'commstring'}" target: hostgroup
- name: SDT a host group action: add
local_action: > fullpath: /servers/production/database
logicmonitor company: '{{ company }}'
target=hostgroup user: '{{ user }}'
action=sdt password: '{{ password }}'
fullpath='/servers/production/web' properties:
duration=3000 snmp.community: commstring
starttime='2012-03-04 05:06' - name: SDT a host group
company='{{ company }}' logicmonitor:
user='{{ user }}' target: hostgroup
password='{{ password }}' action: sdt
fullpath: /servers/production/web
- hosts: collectors duration: 3000
remote_user: '{{ username }}' starttime: '2012-03-04 05:06'
vars: company: '{{ company }}'
company: 'mycompany' user: '{{ user }}'
user: 'myusername' password: '{{ password }}'
password: 'mypassword'
tasks: - hosts: collectors
- name: Deploy/verify LogicMonitor collectors remote_user: '{{ username }}'
logicmonitor: vars:
target: collector company: mycompany
action: add user: myusername
company: {{ company }} password: mypassword
user: {{ user }} tasks:
password: {{ password }} - name: Deploy/verify LogicMonitor collectors
- name: Place LogicMonitor collectors into 30 minute Scheduled downtime logicmonitor:
logicmonitor: target=collector action=sdt company={{ company }} target: collector
user={{ user }} password={{ password }} action: add
- name: Deploy LogicMonitor Host company: '{{ company }}'
local_action: > user: '{{ user }}'
logicmonitor password: '{{ password }}'
target=host - name: Place LogicMonitor collectors into 30 minute Scheduled downtime
action=add logicmonitor:
collector=agent1.ethandev.com target: collector
company='{{ company }}' action: sdt
user='{{ user }}' company: '{{ company }}'
password='{{ password }}' user: '{{ user }}'
properties="{'snmp.community':'commstring', 'dc':'1'}" password: '{{ password }}'
groups="/servers/production/collectors, /datacenter1" - name: Deploy LogicMonitor Host
logicmonitor:
- hosts: database-servers target: host
remote_user: '{{ username }}' action: add
vars: collector: agent1.ethandev.com
company: 'mycompany' company: '{{ company }}'
user: 'myusername' user: '{{ user }}'
password: 'mypassword' password: '{{ password }}'
tasks: properties:
- name: deploy logicmonitor hosts snmp.community: commstring
local_action: > dc: 1
logicmonitor groups: /servers/production/collectors, /datacenter1
target=host delegate_to: localhost
action=add
collector=monitoring.dev.com - hosts: database-servers
company='{{ company }}' remote_user: '{{ username }}'
user='{{ user }}' vars:
password='{{ password }}' company: mycompany
properties="{'snmp.community':'commstring', 'type':'db', 'dc':'1'}" user: myusername
groups="/servers/production/database, /datacenter1" password: mypassword
- name: schedule 5 hour downtime for 2012-11-10 09:08 tasks:
local_action: > - name: deploy logicmonitor hosts
logicmonitor logicmonitor:
target=host target: host
action=sdt action: add
duration=3000 collector: monitoring.dev.com
starttime='2012-11-10 09:08' company: '{{ company }}'
company='{{ company }}' user: '{{ user }}'
user='{{ user }}' password: '{{ password }}'
password='{{ password }}' properties:
snmp.community: commstring
type: db
dc: 1
groups: /servers/production/database, /datacenter1
delegate_to: localhost
- name: schedule 5 hour downtime for 2012-11-10 09:08
logicmonitor:
target: host
action: sdt
duration: 3000
starttime: '2012-11-10 09:08'
company: '{{ company }}'
user: '{{ user }}'
password: '{{ password }}'
delegate_to: localhost
''' '''

Loading…
Cancel
Save