You are not logged in.
Bonjour,
J'aimerais créé un rapport listant toute mes application (qui sont stocké dans le plugg-in appweb) avec les serveur sur lesquelles elles sont installé, les base de donné(qui sont stocké dans le plug-in sgbd) qui lui sont liés ainsi que le serveur sur lequel est la base de donné.
Pour ce faire j'ai installé le plug-in reports et créé un plug-in dont le code est donné plus bas.
mon problème est que pour faire ça, j'ai besoin d'exécuté plusieurs requêtes mysql les une à la suite des autres (deux pour créé des tables temporaire et une pour rapatrier les données).
Sauf que la fonction simpleReport semble bloqué a la fin de la première requête.
Quand je passe par mon requêteur sql ou par la ligne de commande, elle s'exécute bien (même si elle reste à pofiner pour un affichage plus net).
Grace au mode débug de glpi on voit que ca bloque à la fin de la ligne 54 :
WHERE glpi_plugin_sgbd_device.`device_type`=1;
Si vous avez des idées sur la façon d'envoyer des requête multiple dans simpleReport ou une méthode de contournement (autre fonction...) je suis preneur.
Merci d'avance.
ps: il y a beaucoup de chose dans mon select, mais ca me permet d'y voir plus claire dans mon requêteur.
si joint le code complet du rapport:
<?php
/*
----------------------------------------------------------------------
GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2008 by the INDEPNET Development Team.
http://indepnet.net/ http://glpi-project.org/
----------------------------------------------------------------------
LICENSE
This file is part of GLPI.
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
------------------------------------------------------------------------
*/
/*
* ----------------------------------------------------------------------
* Original Author of file: Thibaut Stauder
*
* Purpose of file:
* Generate Liste Application Report
* ----------------------------------------------------------------------
*/
//Options for GLPI 0.71 and newer : need slave db to access the report
$USEDBREPLICATE=1;
$DBCONNECTION_REQUIRED=0; // not really a big SQL request
define('GLPI_ROOT', '../../../..');
include (GLPI_ROOT . "/inc/includes.php");
includeLocales("listappli");
simpleReport(
// Report Name
"listappli",
// SQL statement
"CREATE TEMPORARY TABLE temp SELECT glpi_plugin_sgbd_device.* ,glpi_computers.`name` AS bddcomputname
FROM glpi_plugin_sgbd_device CROSS JOIN glpi_computers
ON (glpi_plugin_sgbd_device.`FK_device`=glpi_computers.`ID` )
WHERE glpi_plugin_sgbd_device.`device_type`=1;
CREATE TEMPORARY TABLE temp2 SELECT glpi_plugin_sgbd_device.* ,glpi_plugin_appweb.`name` AS sgbdname
FROM glpi_plugin_sgbd_device CROSS JOIN glpi_plugin_appweb
ON (glpi_plugin_sgbd_device.`FK_device`=glpi_plugin_appweb.`ID` )
WHERE glpi_plugin_sgbd_device.`device_type`=1300;
SELECT
g.`name` AS apliname,
g.`ID`,
g.`address` AS url,
g.`backoffice` AS urladmin,
g.`server`,
m.`ID`,
m.`name` AS servertype,
g.`version` AS version,
g.`usertest` AS usertest,
g.`mdptest` AS mdptest,
h.`FK_appweb`,
h.`FK_device`,
h.`device_type`,
i.`ID`,
i.`name` AS computname,
j.`on_device`,
j.`device_type`,
j.`ifaddr` AS ip,
k.`name` AS bddname,
k.`FK_entities`,
k.`ID`,
l.`FK_sgbd`,
l.`FK_device`,
l.`bddcomputname`,
n.`FK_sgbd`,
n.`FK_device`
FROM
glpi_plugin_appweb AS g LEFT JOIN glpi_plugin_appweb_device AS h ON (g.`ID`=h.`FK_appweb`)
LEFT JOIN glpi_computers AS i ON (h.`FK_device`=i.`ID`)
LEFT JOIN glpi_networking_ports AS j ON (j.`on_device`=i.`ID`)
LEFT JOIN temp2 AS n ON (n.`FK_device`=g.`ID`)
LEFT JOIN glpi_plugin_sgbd AS k ON (k.`ID`=n.`FK_sgbd`)
LEFT JOIN temp AS l ON (n.`FK_sgbd`=l.`ID`)
CROSS JOIN glpi_dropdown_plugin_appweb_server_type AS m ON (m.`ID`=g.`server`)
WHERE h.`device_type`=1 AND j.`device_type`=1".
getEntitiesRestrictRequest(" AND ", "glpi_plugin_appweb")."
ORDER BY g.`name` ASC",
// Columns title (optional), from $LANG
array (
"apliname" => $LANG['plugin_reports']['listappli'][2],
"url" => $LANG['plugin_reports']['listappli'][3],
"urladmin" => $LANG['plugin_reports']['listappli'][4],
"servertype" => $LANG['plugin_reports']['listappli'][5],
"version" => $LANG['plugin_reports']['listappli'][6],
"usertest" => $LANG['plugin_reports']['listappli'][7],
"mdptest" => $LANG['plugin_reports']['listappli'][8],
"computname" => $LANG['plugin_reports']['listappli'][9],
"ip" => $LANG['plugin_reports']['listappli'][10],
"bddname" => $LANG['plugin_reports']['listappli'][11],
"bddcomputname" => $LANG['plugin_reports']['listappli'][9]
),
// Sub title
"",
// Group by
array ("apliname")
);
?>
Last edited by drakith (2009-10-01 16:31:09)
Configuration: GLPI v 0.72 // Centos (el5) // Apache/Mysql 5
Offline
et dans les logs de glpi ? tu dois avoir la trace complète de l'eereur sql ? il dit quoi ?
Xavier Caillaud
Blog GLPI Infotel
Offline
Voila ce que me retourne le mode débug de glpi
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; CREATE TEMPORARY TABLE temp2 SELECT glpi_plugin_sgbd_device.* ,glpi_plugin_app' at line 4
Par contre je n'ai trouvé aucun fichier ".log" dans les dossier de glpi.
A cas ou ça puisse servir, je suis sous GLPI v0.72 et plug-in report v1.3.0
Last edited by drakith (2009-10-01 17:03:47)
Configuration: GLPI v 0.72 // Centos (el5) // Apache/Mysql 5
Offline
actives les traceurs dans la config de glpi et relances-le
Xavier Caillaud
Blog GLPI Infotel
Offline
Mince j'ai raté ta réponce a 2 minutes près...
Je fais ça demain matin en arrivant au taf et je te dis ce que ça donne.
En tout cas merci et bravo pour la rapidité de réponse
Configuration: GLPI v 0.72 // Centos (el5) // Apache/Mysql 5
Offline
Je ne suis pas certain que l'utilisation de tables termporaire soit une bonne idée.. mais bon.
Faudrait essayer :
$DB->query($request1)
$DB->query($request2)
$simpleReport(.....$request3....);
+
P.S. les alias, c'est vraiment illisible...
Dév. Fedora 29 - PHP 5.6/7.0/7.1/7.2/7.3/7.4 - MariaDB 10.3 - GLPI master
Certifié ITILv3 - RPM pour Fedora, RHEL et CentOS sur https://blog.remirepo.net/
Offline
héhé merci ça marche nickel avec $DB->query($request)
Sinon pour la table temporaire, c'est le seul moyen que j'ai trouvé pour lier la table glpi_plugin_sgbd_device en fonction de device_type (si 1 la lier à un serveur et si 1300 la lier à une application).
J'ai tenté pas mal de chose avec un if ou un case mais ça n'a jamais donné le résultat escompté, au mieux j'avais 2000-3000 lignes au lieu de 400, au pire j'avais rien dans la colonne serveur de base de donné.
En tout cas encore merci pour le coup de main parce que là j'étais vraiment dans l'impasse
Configuration: GLPI v 0.72 // Centos (el5) // Apache/Mysql 5
Offline
Bon mon rapport marche nickel, j'ai épuré mon code et rendu plus lisible.
J'ai fait une deuxième version sans les champ qui on été ajouté à notre base de donné si ca peut servir à quelqu'un.
Donc il fait la liste de toute les applications du plug-in appweb(nom, type de serveur,version) les les serveur qui lui sont liés(nom et ip), les base qui lui sont liés tiré du plug-in sgdb (nom) et les serveur liés au bases (nom).
<?php
/*
----------------------------------------------------------------------
GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2008 by the INDEPNET Development Team.
http://indepnet.net/ http://glpi-project.org/
----------------------------------------------------------------------
LICENSE
This file is part of GLPI.
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
------------------------------------------------------------------------
*/
/*
* ----------------------------------------------------------------------
* Original Author of file: Thibaut Stauder
*
* Purpose of file:
* Generate Liste Application Report
* ----------------------------------------------------------------------
*/
//Options for GLPI 0.71 and newer : need slave db to access the report
$USEDBREPLICATE=1;
$DBCONNECTION_REQUIRED=0; // not really a big SQL request
$request1="CREATE TEMPORARY TABLE temp SELECT glpi_plugin_sgbd_device.* ,glpi_computers.`name` AS bddcomputname
FROM glpi_plugin_sgbd_device CROSS JOIN glpi_computers
ON (glpi_plugin_sgbd_device.`FK_device`=glpi_computers.`ID` )
WHERE glpi_plugin_sgbd_device.`device_type`=1";
$request2="CREATE TEMPORARY TABLE temp2 SELECT glpi_plugin_sgbd_device.* ,glpi_plugin_appweb.`name` AS sgbdname
FROM glpi_plugin_sgbd_device CROSS JOIN glpi_plugin_appweb
ON (glpi_plugin_sgbd_device.`FK_device`=glpi_plugin_appweb.`ID` )
WHERE glpi_plugin_sgbd_device.`device_type`=1300";
define('GLPI_ROOT', '../../../..');
include (GLPI_ROOT . "/inc/includes.php");
includeLocales("listappli");
$DB->query($request1);
$DB->query($request2);
simpleReport(
// Report Name
"listappli",
// SQL statement
"SELECT
appweb.`name` AS apliname,
appweb.`version` AS version,
typeapply.`name` AS servertype,
servapp.`FK_appweb`,
servapp.`FK_device`,
servapp.`device_type`,
computer.`name` AS computname,
ip.`ifaddr` AS ipadress,
bdd.`name` AS bddname,
l.`FK_sgbd`,
l.`FK_device`,
l.`bddcomputname`,
n.`FK_sgbd`,
n.`FK_device`
FROM
glpi_plugin_appweb AS appweb LEFT JOIN glpi_plugin_appweb_device AS servapp ON (appweb.`ID`=servapp.`FK_appweb`)
LEFT JOIN glpi_computers AS computer ON (servapp.`FK_device`=computer.`ID`)
LEFT JOIN glpi_networking_ports AS ip ON (ip.`on_device`=computer.`ID`)
LEFT JOIN temp2 AS n ON (n.`FK_device`=appweb.`ID`)
LEFT JOIN glpi_plugin_sgbd AS bdd ON (bdd.`ID`=n.`FK_sgbd`)
CROSS JOIN temp AS l ON (l.`FK_sgbd`=bdd.`ID`)
CROSS JOIN glpi_dropdown_plugin_appweb_server_type AS typeapply ON (typeapply.`ID`=appweb.`server`)
WHERE servapp.`device_type`=1 AND ip.`device_type`=1".
getEntitiesRestrictRequest(" AND ", "glpi_plugin_appweb")."
ORDER BY appweb.`name` ASC",
// Columns title (optional), from $LANG
array (
"apliname" => $LANG['plugin_reports']['listappli'][2],
"servertype" => $LANG['plugin_reports']['listappli'][5],
"version" => $LANG['plugin_reports']['listappli'][6],
"computname" => $LANG['plugin_reports']['listappli'][9],
"ipadress" => $LANG['plugin_reports']['listappli'][10],
"bddname" => $LANG['plugin_reports']['listappli'][11],
"bddcomputname" => $LANG['plugin_reports']['listappli'][9]
),
// Sub title
"",
// Group by
array ("apliname")
);
?>
http://www.toofiles.com/fr/oip/document … appli.html
(local $lang anglais et français)
voilà voilà et encore merci pour l'aide
Last edited by drakith (2009-10-02 11:34:22)
Configuration: GLPI v 0.72 // Centos (el5) // Apache/Mysql 5
Offline
Marche po
Unknown column 'glpi_plugin_appweb.FK_entities' in 'where clause'
avec getEntitiesRestrictRequest(" AND ", "appweb")." c'est mieux
Xavier Caillaud
Blog GLPI Infotel
Offline
Moi ca marche mieux avec ca :
<?php
/*
----------------------------------------------------------------------
GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2008 by the INDEPNET Development Team.
http://indepnet.net/ http://glpi-project.org/
----------------------------------------------------------------------
LICENSE
This file is part of GLPI.
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
------------------------------------------------------------------------
*/
/*
* ----------------------------------------------------------------------
* Original Author of file: Thibaut Stauder
*
* Purpose of file:
* Generate Liste Application Report
* ----------------------------------------------------------------------
*/
//Options for GLPI 0.71 and newer : need slave db to access the report
$USEDBREPLICATE=1;
$DBCONNECTION_REQUIRED=0; // not really a big SQL request
define('GLPI_ROOT', '../../../..');
include (GLPI_ROOT . "/inc/includes.php");
includeLocales("listappli");
$request1="CREATE TEMPORARY TABLE temp SELECT glpi_plugin_sgbd_device.* ,glpi_computers.`name` AS bddcomputname
FROM glpi_plugin_sgbd_device CROSS JOIN glpi_computers
ON (glpi_plugin_sgbd_device.`FK_device`=glpi_computers.`ID` )
WHERE glpi_plugin_sgbd_device.`device_type`=".COMPUTER_TYPE." GROUP BY bddcomputname";
$request2="CREATE TEMPORARY TABLE temp2 SELECT glpi_plugin_sgbd_device.* ,glpi_plugin_appweb.`name` AS sgbdname
FROM glpi_plugin_sgbd_device CROSS JOIN glpi_plugin_appweb
ON (glpi_plugin_sgbd_device.`FK_device`=glpi_plugin_appweb.`ID` )
WHERE glpi_plugin_sgbd_device.`device_type`=".PLUGIN_APPWEB_TYPE."";
$DB->query($request1);
$DB->query($request2);
simpleReport(
// Report Name
"listappli",
// SQL statement
"SELECT
appweb.`name` AS apliname,
appweb.`version` AS version,
typeapply.`name` AS servertype,
servapp.`FK_appweb`,
servapp.`FK_device`,
servapp.`device_type`,
computer.`name` AS computname,
ip.`ifaddr` AS ipadress,
bdd.`name` AS bddname,
l.`FK_sgbd`,
l.`FK_device`,
l.`bddcomputname`,
n.`FK_sgbd`,
n.`FK_device`
FROM
glpi_plugin_appweb AS appweb LEFT JOIN glpi_plugin_appweb_device AS servapp ON (appweb.`ID`=servapp.`FK_appweb`)
LEFT JOIN glpi_computers AS computer ON (servapp.`FK_device`=computer.`ID` AND servapp.`device_type`=".COMPUTER_TYPE.")
LEFT JOIN glpi_networking_ports AS ip ON (ip.`on_device`=computer.`ID` AND ip.`device_type`=".COMPUTER_TYPE.")
LEFT JOIN temp2 AS n ON (n.`FK_device`=appweb.`ID`)
LEFT JOIN glpi_plugin_sgbd AS bdd ON (bdd.`ID`=n.`FK_sgbd`)
CROSS JOIN temp AS l ON (l.`FK_sgbd`=bdd.`ID`)
CROSS JOIN glpi_dropdown_plugin_appweb_server_type AS typeapply ON (typeapply.`ID`=appweb.`server`)
WHERE 1=1 ".
getEntitiesRestrictRequest(" AND ", "appweb")."
ORDER BY appweb.`name` ASC",
// Columns title (optional), from $LANG
array (
"apliname" => $LANG['plugin_reports']['listappli'][2],
"servertype" => $LANG['plugin_reports']['listappli'][5],
"version" => $LANG['plugin_reports']['listappli'][6],
"computname" => $LANG['plugin_reports']['listappli'][9],
"ipadress" => $LANG['plugin_reports']['listappli'][10],
"bddname" => $LANG['plugin_reports']['listappli'][11],
"bddcomputname" => $LANG['plugin_reports']['listappli'][9]
),
// Sub title
"",
// Group by
array ("apliname")
);
?>
Xavier Caillaud
Blog GLPI Infotel
Offline
Mettre une restriction (getEntitiesRestrictRequest) sur un alias est une très mauvaise idée.
La fonction réalise plusieurs tests dont les résultats dépendent du nom de la table. Donc le résultat "pourra" être faussé si on passe un alias.
+
Dév. Fedora 29 - PHP 5.6/7.0/7.1/7.2/7.3/7.4 - MariaDB 10.3 - GLPI master
Certifié ITILv3 - RPM pour Fedora, RHEL et CentOS sur https://blog.remirepo.net/
Offline
tsmr, c'est bizarre j'ai pas eu ton erreur .
M'enfin si t'as trouvé une solution c'est déjà ça
Mais comme dit Rémy, je suis pas sur que ça soit une super idée de faire le test sur un allias.
See you.
Configuration: GLPI v 0.72 // Centos (el5) // Apache/Mysql 5
Offline
Tu as plusieurs entités toua si ?
Xavier Caillaud
Blog GLPI Infotel
Offline
heu oui j'ai une entité racine avec une grosse dizaine de sous entités, plusieurs centaine de de serveur réparti dans les entités, environs 400 applis liés sur un ou plusieurs serveurs et à une ou plusieurs bases de donné ainsi qu'environ environ 200 bases.
le tout mélangé dans divers entités qui se croisent (certaine applis d'une entité sont liés à des serveurs de l'entité racine par exemple).
par contre les comptes avec lesquels j'ai testé le script sont admin de l'entité racine en récursif, c'est peu être ça.
Je testerais demain matin avec un compte classique pour voir si j'ai le même problème.
Configuration: GLPI v 0.72 // Centos (el5) // Apache/Mysql 5
Offline
j'avais un peu oublié de faire le retours, donc après test, ça marche que pour les utilisateur de l'entité racine.
Les autre n'ont aucune appli retourné.
m'enfin pour moi ça le fait vu que seul les admins de l'entité racine doivent avoir accès à ce rapport.
Configuration: GLPI v 0.72 // Centos (el5) // Apache/Mysql 5
Offline