Skip to content

ClissonFlorian/Centreon-Powershell-Module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Centreon Server PowerShell Module

Description

Use Centreon API easily from Powershell

Table of Contents

One time Setup

Permissions

Install

Install the module from the PowerShell Gallery.

Install-Module CentreonPS

Get Started

List commands of the module

Get-Command -Module CentreonPS

Available cmdlets

Functions Descriptions
New-CentreonConnection To connect to the Centreon Server
Get-CentreonHostStatus Return the centreon hosts status in realtime
Get-CentreonServiceStatus Return the centreon services status in realtime
Invoke-CentreonCommand To manage the centreon objects (add,delete,set,show...)

Centreon Server Connection

You have to re-do this step when the token has expired.

Method 1 : Will request you, your centreon credentials

$Session = New-CentreonConnection -server "192.168.1.50"

Method 2 : Allow to specify your credentials

$Credentials = Get-Credential -UserName fclisson
$Session = New-CentreonConnection -server "192.168.0.30" -Credentials $Credentials

How to use it

Invoke-CentreonCommand allow to manage any centreon object.

You have to specify the object that you want to manage then which action you want to do on it and lastly the value values expected.

Action and object list available from : Centreon Clapi documentation.

Invoke Centreon(Clapi) Command

The following command line allow to add an Host to Centreon :

 Invoke-CentreonCommand -Session $Session -object HOST -action ADD -Values "test;Test host;127.0.0.1;OS-Linux-SNMP-custom;central;Centreon_platform"

The following command line, allow to show the contact groups :

 Invoke-CentreonCommand -Session $Session -object CG -action show

Get Centreon Services

EXEMPLE

Get-CentreonServiceStatus -Session $Session 

OUTPUT

host_id                : 15
name                   : Centeon-central
description            : Broker-Retention
service_id             : 95
state                  : 0
state_type             : 1
output                 : OK: centreon-broker failover/temporary files are ok
                         Checking config '/etc/centreon-broker/central-rrd.xml'\nskipping temporary: no configuration set\nChecking config 
                         '/etc/centreon-broker/central-broker.xml'\nskipping temporary: no configuration set\n
perfdata               : 
max_check_attempts     : 3
check_attempt          : 1
last_check             : 1531062538
last_state_change      : 1528587027
last_hard_state_change : 1528587027
acknowledged           : 0
criticality            : 

Get Centreon Hosts

EXAMPLE 1

Get-CentreonHostsStatus -Session $Session 

EXAMPLE 2

Get-CentreonHostsStatus -Session $Session -status all -order ASC -search '%rsys%'

OUTPUT

    id                     : 15
    name                   : Centeon-central
    alias                  : Centreon central server
    address                : 127.0.0.1
    state                  : 0
    state_type             : 1
    output                 : OK - 127.0.0.1: rta 0.025ms, lost 0%
    max_check_attempts     : 3
    check_attempt          : 1
    last_check             : 1531060693
    last_state_change      : 1528586735
    last_hard_state_change : 1528586735
    acknowledged           : 0
    instance_name          : Central
    criticality            :

Resources

ToDo

  • Not sure that the powershell plugin works with https,to try?
  • Manage case when the token is expired
  • Include authentification from default credentials (Active Directory Auth)
  • Create Set-CentreonServerConfig?
  • Create dynamic parameters on the Invoke-CentreonCommand function

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages