ddurieux / glpi_app_grafana

GNU Affero General Public License v3.0
23 stars 13 forks source link

GLPI app for Grafana

Introduction

This application gets information in GLPI (Gestion Libre de Parc Informatique). It use the REST API added in version 9.1. You will be able to have graphs, singlestat, tables... of your data (tickets, devices, users...).

screenshot

This is an example:

screenshot1

Datasource

For the GLPI datasource, you will need:

GLPI Webserver

On your GLPI webserver, you need active the CORS. Documentation about CORS

Apache

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE"
Header set Access-Control-Allow-Credentials true
Header set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding, App-Token, Session-Token"

NGINX

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Origin,Content-Type,Accept,Authorization,App-Token,Session-Token';

Dashboard

You can get a simple dashboard here

screenshot1

Table panel

Create a new Table panel and then edit the panel. Select the GLPI datasource and add a new Query in the panel Metrics.

The configuration will require:

When Is it a table is checked, the query result will be displayed as a table and you can define up to 6 columns to be displayed. For each column in the table, select the query result field and the name of the column.

When Is it a table is not checked, the query result is considered as a usual Grafana timeseries and it will displayed as is. See Grafana table panel for more information.

Single stat panel

Problem with server access

If you have the message: There isn't an active API client matching your IP address in the configuration (ip, ip) where you have 2 IPs and the same, you need apply a patch into GLPI:

diff --git a/inc/api.class.php b/inc/api.class.php
index 3ae2966ce..a4a18dc9e 100644
--- a/inc/api.class.php
+++ b/inc/api.class.php
@@ -105,6 +105,10 @@ abstract class API extends CommonGLPI {

       // retrieve ip of client
       $this->iptxt = Toolbox::getRemoteIpAddress();
+      $spl = explode(',', $this->iptxt);
+      if (count($spl) > 1) {
+         $this->iptxt = $spl[0];
+      }
       $this->ipnum = (strstr($this->iptxt, ':')===false ? ip2long($this->iptxt) : '');

       // check ip access

Bugs / features

If you have a bug repoort or request feature, you can open issues in the github repository

Professional support

Do you need professional support, training, others?

Please contact the DCS Easyware company / send a mail to dcs.glpi@dcsit-group.com

Changelog

2.0.1

2.0.0 (unreleased)

1.4.0

1.3.0

1.2.0

1.1.0

1.0.0

First version