--- /dev/null
+/*/.tmp*
+/*_*.deb
+/*_*.dsc
+/*_*.tar.gz
+/*_*.build
+/*_*.upload
+/*_*.changes
* auf-serveur-suivi - pour les choses à installer pour le suivi d'un serveur
Depends: auf-git-etc, apticron | cron-apt, apt-listchanges,
- logcheck, exim4 | mail-transport-agent
+ logcheck, exim4 | mail-transport-agent, munin-node
--- /dev/null
+PACKAGE = $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
+VERSION = $(shell dpkg-parsechangelog | sed -n 's/^Version: //p')
+DIST = $(shell dpkg-parsechangelog | sed -n 's/^Distribution: //p')
+
+all:
+
+clean:
+
+install:
+ install -d -m 0755 $(DESTDIR)/usr/share/glpi/plugins
+ cp -a plugin $(DESTDIR)/usr/share/glpi/plugins/auf
+
+deb:
+ debuild -I.git -I*.ex -us -uc -b && \
+ echo -e "\n\n==> Lancer \"sudo debi\" pour tester l'installation.\n"
+
+release:
+ debuild -I.git -I*.ex -tc -sa -us -uc && debrelease --dput wheezy-test
--- /dev/null
+glpi-plugin-auf (0.84+1) unstable; urgency=low
+
+ * Création du paquet Debian.
+
+ -- Progfou <jean-christophe.andre@auf.org> Fri, 14 Feb 2014 13:33:31 -0500
--- /dev/null
+Source: glpi-plugin-auf
+Section: web
+Priority: extra
+Maintainer: Progfou <jean-christophe.andre@auf.org>
+Build-Depends: debhelper (>= 8.0.0)
+Standards-Version: 3.9.3
+Homepage:
+Vcs-Git: git://git.auf.org/auf-serveur.git
+Vcs-Browser: http://git.auf.org/?p=auf-serveur.git;a=summary
+
+Package: glpi-plugin-auf
+Architecture: all
+Depends: ${misc:Depends}
+Recommends: glpi
+Description: greffon AUF pour GLPI
+ Ce paquet apporte des rapports d'inventaire AUF.
--- /dev/null
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: glpi-plugin-auf
+Source: http://git.auf.org/?p=auf-serveur.git;a=summary
+
+Files: *
+Copyright: 2014 Agence universitaire de la Francophonie -- www.auf.org
+License: GPL-2+
+ This package 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.
+ .
+ This package 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 this program. If not, see <http://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
+
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+%:
+ dh $@
+
--- /dev/null
+/*
+ AUF plugin for GLPI
+ Copyright (C) 2014 AUF -- www.auf.org
+ */
+
+.plugin_auf_show_details {
+ display: show;
+}
+
+.plugin_auf_hide_details {
+ display: hide;
+}
--- /dev/null
+<?php
+/*
+ AUF plugin for GLPI
+ Copyright (C) 2014 AUF -- www.auf.org
+ */
+
+function plugin_auf_install() {
+ return TRUE;
+}
+
+function plugin_auf_uninstall() {
+ return TRUE;
+}
+
+?>
--- /dev/null
+<?php
+//Options for GLPI 0.71 and newer : need slave db to access the report
+$USEDBREPLICATE=1;
+$DBCONNECTION_REQUIRED=0;
+
+include ("../../inc/includes.php");
+
+Session::checkRight("reports", "r");
+Session::checkRight("computer", "r");
+
+#Html::header(Report::getTypeName(2), $_SERVER['PHP_SELF'], "utils", "report");
+Html::header("Systèmes d'exploitation par implantation", $_SERVER['PHP_SELF'], "utils", "report");
+Report::title();
+
+$computer = new Computer();
+
+$state_sql = "";
+if (($state != "") AND ($state != "0")) {
+ $state_sql = " AND `states_id` = '".$state."' ";
+}
+
+$itemtype = 'Computer';
+$table_item = getTableForItemType($itemtype);
+
+echo "<span class='big b'>Systèmes d'exploitation par implantation</span><br><br>";
+echo "<table class='tab_cadrehov'>";
+echo "<tr class='tab_bg_1'><th>Implantation</th><th>Système d'exploitation</th><th>Quantité</th></tr>";
+$green_grand_total = 0;
+$yellow_grand_total = 0;
+$red_grand_total = 0;
+$blue_grand_total = 0;
+$grand_total = 0;
+
+# parcours des régions
+$query = "SELECT id,name,completename FROM glpi_entities WHERE (id=0 OR entities_id=0)";
+$query .= " ".getEntitiesRestrictRequest("AND", "glpi_entities");
+$region_result = $DB->query($query);
+while ($region_data = $DB->fetch_assoc($region_result)) {
+ $region_id = $region_data['id'];
+ if ($region_id != 0) {
+ $region_name = getTreeLeafValueName("glpi_entities", $region_id);
+ } else {
+ $region_name = "AUF (non classé)";
+ }
+ echo "<tr class='tab_bg_1'><td colspan='3' class='b'>$region_name</td></tr>";
+
+ $green_total = 0;
+ $yellow_total = 0;
+ $red_total = 0;
+ $blue_total = 0;
+ $region_total = 0;
+
+# operating systems per computer
+$query = "SELECT COUNT(c.id) AS count, e.name AS ename,
+ (CASE WHEN o.name REGEXP '^Debian ' THEN SUBSTRING_INDEX(REPLACE(o.name,' GNU/Linux',''),'.',1)
+ WHEN o.name REGEXP '^Ubuntu ' THEN SUBSTRING_INDEX(REPLACE(o.name,' LTS',''),'.',2)
+ WHEN o.name REGEXP '^Microsoft ' THEN REPLACE(o.name,'Microsoft ','')
+ WHEN o.name REGEXP '^Mac ' THEN REPLACE(o.name,'Mac ','')
+ ELSE o.name END) AS oname
+ FROM `$table_item` c
+ LEFT JOIN glpi_computers_items i ON (i.itemtype = 'Computer' AND i.items_id = c.id)
+ LEFT JOIN glpi_entities e ON (c.entities_id = e.id)
+ LEFT JOIN glpi_operatingsystems o ON (c.operatingsystems_id = o.id)
+ WHERE c.is_deleted = '0' AND c.is_template = '0'
+ ".getEntitiesRestrictRequest("AND", "c");
+if ($region_id != 0) {
+ $query .= " AND ".getRealQueryForTreeItem("glpi_entities", $region_id, "e.id");
+} else {
+ $query .= " AND e.id = '0'";
+}
+$query .= " GROUP BY 2,3 ORDER BY 2,3";
+$result = $DB->query($query);
+while ($data=$DB->fetch_assoc($result)) {
+ if (empty($data['ename'])) {
+ $data['ename'] = "<i>(indéterminé)</i>";
+ }
+ if (empty($data['oname'])) {
+ $data['oname'] = "<i>(indéterminé)</i>";
+ }
+ if (($data['oname'] == 'Debian 7') || ($data['oname'] == 'Ubuntu 12.04')) {
+ $oname_plus = '<svg width="5" height="5" style="background-color: #00ff00; margin: 1px;"/>';
+ $green_total += $data['count'];
+ } elseif (($data['oname'] == 'Debian 6') || ($data['oname'] == 'Ubuntu 10.04')) {
+ $oname_plus = '<svg width="5" height="5" style="background-color: #ffff00; margin: 1px;"/>';
+ $yellow_total += $data['count'];
+ } elseif ((substr($data['oname'],0,7) == 'Windows') || (substr($data['oname'],strlen($data['oname'])-4,4) == 'OS X')) {
+ $oname_plus = '<svg width="5" height="5" style="background-color: #0000ff; margin: 1px;"/>';
+ $blue_total += $data['count'];
+ } else {
+ $oname_plus = '<svg width="5" height="5" style="background-color: #ff0000; margin: 1px;"/>';
+ $red_total += $data['count'];
+ }
+ echo "<tr class='tab_bg_2 auf_show_details'>";
+ echo "<td> ".$data['ename']."</td>";
+ echo "<td>".$oname_plus." ".$data['oname']."</td>";
+ echo "<td class='numeric'>".$data['count']."</td></tr>";
+ $region_total += $data['count'];
+}
+
+$green_svg = '<svg width="'.(400*$green_total/$region_total).'" height="5" style="background-color: #00ff00; margin: 1px 0;"/>';
+$yellow_svg = '<svg width="'.(400*$yellow_total/$region_total).'" height="5" style="background-color: #ffff00; margin: 1px 0;"/>';
+$red_svg = '<svg width="'.(400*$red_total/$region_total).'" height="5" style="background-color: #ff0000; margin: 1px 0;"/>';
+$blue_svg = '<svg width="'.(400*$blue_total/$region_total).'" height="5" style="background-color: #0000ff; margin: 1px 0;"/>';
+echo "<tr class='tab_bg_2'><td class='b'> Sous-total</td>";
+echo "<td>".$green_svg.$yellow_svg.$red_svg.$blue_svg."</td>";
+echo "<td class='numeric b'>$region_total</td></tr>";
+
+$green_grand_total += $green_total;
+$yellow_grand_total += $yellow_total;
+$red_grand_total += $red_total;
+$blue_grand_total += $blue_total;
+$grand_total += $region_total;
+} // fin des régions
+
+echo "<tr class='tab_bg_1'><td colspan='3'> </td></tr>";
+
+# total operating systems
+$query = "SELECT COUNT(*) FROM `".$table_item."`
+ LEFT JOIN `glpi_computers_items`
+ ON (`glpi_computers_items`.`itemtype` = '".$itemtype."'
+ AND `glpi_computers_items`.`items_id` = `".$table_item."`.`id`)
+ WHERE `".$table_item."`.`is_deleted` = '0'
+ AND `".$table_item."`.`is_template` = '0' ".
+ getEntitiesRestrictRequest("AND", $table_item);
+$result = $DB->query($query);
+$total = $DB->result($result, 0, 0);
+
+$green_svg = '<svg width="'.(400*$green_grand_total/$grand_total).'" height="5" style="background-color: #00ff00; margin: 1px 0;"/>';
+$yellow_svg = '<svg width="'.(400*$yellow_grand_total/$grand_total).'" height="5" style="background-color: #ffff00; margin: 1px 0;"/>';
+$red_svg = '<svg width="'.(400*$red_grand_total/$grand_total).'" height="5" style="background-color: #ff0000; margin: 1px 0;"/>';
+$blue_svg = '<svg width="'.(400*$blue_grand_total/$grand_total).'" height="5" style="background-color: #0000ff; margin: 1px 0;"/>';
+echo "<tr class='tab_bg_1'><td class='b'>Total général</td>";
+echo "<td>".$green_svg.$yellow_svg.$red_svg.$blue_svg."</td>";
+echo "<td class='numeric b'>$total</td></tr>";
+
+echo "</table>";
+
+Html::footer();
+?>
--- /dev/null
+<?php
+//Options for GLPI 0.71 and newer : need slave db to access the report
+$USEDBREPLICATE=1;
+$DBCONNECTION_REQUIRED=0;
+
+include ("../../inc/includes.php");
+
+Session::checkRight("reports", "r");
+Session::checkRight("computer", "r");
+
+Html::header(Report::getTypeName(2), $_SERVER['PHP_SELF'], "utils", "report");
+Report::title();
+
+$computer = new Computer();
+
+$state_sql = "";
+if (($state != "") AND ($state != "0")) {
+ $state_sql = " AND `states_id` = '".$state."' ";
+}
+
+$itemtype = 'Computer';
+$table_item = getTableForItemType($itemtype);
+
+/* reprise du Rapport par défaut */
+// global $DB;
+echo "<span class='big b'>WIP (rapport en cours de développement)</span><br><br>";
+echo "<table class='tab_cadrehov'>";
+
+echo "<tr class='tab_bg_1'><td>Implantation</td><td>Systèmes d'exploitation</td><td>Qtt</td></tr>";
+$green_grand_total = 0;
+$yellow_grand_total = 0;
+$red_grand_total = 0;
+$blue_grand_total = 0;
+$grand_total = 0;
+
+# parcours des régions
+$query = "SELECT id,name,completename FROM glpi_entities WHERE (id=0 OR entities_id=0)";
+$query .= " ".getEntitiesRestrictRequest("AND", "glpi_entities");
+$region_result = $DB->query($query);
+while ($region_data = $DB->fetch_assoc($region_result)) {
+ $region_id = $region_data['id'];
+ if ($region_id != 0) {
+ $region_name = getTreeLeafValueName("glpi_entities", $region_id);
+ } else {
+ $region_name = "AUF (non classé)";
+ }
+ echo "<tr class='tab_bg_1'><td colspan='3' class='b'>$region_name</td></tr>";
+# foreach (getSonsOf("glpi_entities", $data['id']) as $id) {
+# echo "<tr class='tab_bg_1'><td colspan='3' class='b'> ".getTreeValueCompleteName("glpi_entities", $id)."</td></tr>";
+# }
+#}
+ $green_total = 0;
+ $yellow_total = 0;
+ $red_total = 0;
+ $blue_total = 0;
+ $region_total = 0;
+
+# operating systems per computer
+$query = "SELECT COUNT(c.id) AS count, e.name AS ename,
+ (CASE WHEN o.name REGEXP '^Debian' THEN SUBSTRING_INDEX(REPLACE(o.name,' GNU/Linux',''),'.',1)
+ WHEN o.name REGEXP '^Ubuntu' THEN SUBSTRING_INDEX(REPLACE(o.name,' LTS',''),'.',2)
+ ELSE o.name END) AS oname
+ FROM `$table_item` c
+ LEFT JOIN glpi_computers_items i ON (i.itemtype = 'Computer' AND i.items_id = c.id)
+ LEFT JOIN glpi_entities e ON (c.entities_id = e.id)
+ LEFT JOIN glpi_operatingsystems o ON (c.operatingsystems_id = o.id)
+ WHERE c.is_deleted = '0' AND c.is_template = '0'
+ ".getEntitiesRestrictRequest("AND", "c");
+if ($region_id != 0) {
+ $query .= " AND ".getRealQueryForTreeItem("glpi_entities", $region_id, "e.id");
+} else {
+ $query .= " AND e.id = '0'";
+}
+$query .= " GROUP BY 2,3 ORDER BY 2,3";
+$result = $DB->query($query);
+while ($data=$DB->fetch_assoc($result)) {
+ if (empty($data['ename'])) {
+ $data['ename'] = "<i>(indéterminé)</i>";
+ }
+ if (empty($data['oname'])) {
+ $data['oname'] = "<i>(indéterminé)</i>";
+ }
+ if (($data['oname'] == 'Debian 7') || ($data['oname'] == 'Ubuntu 12.04')) {
+ $oname_plus = '<svg width="5" height="5" style="background-color: #00ff00; margin: 1px;"/>';
+ $green_total += $data['count'];
+ } elseif (($data['oname'] == 'Debian 6') || ($data['oname'] == 'Ubuntu 10.04')) {
+ $oname_plus = '<svg width="5" height="5" style="background-color: #ffff00; margin: 1px;"/>';
+ $yellow_total += $data['count'];
+ } elseif ((substr($data['oname'],0,9) == 'Microsoft') || (substr($data['oname'],strlen($data['oname'])-4,4) == 'OS X')) {
+ $oname_plus = '<svg width="5" height="5" style="background-color: #0000ff; margin: 1px;"/>';
+ $blue_total += $data['count'];
+ } else {
+ $oname_plus = '<svg width="5" height="5" style="background-color: #ff0000; margin: 1px;"/>';
+ $red_total += $data['count'];
+ }
+ echo "<tr class='tab_bg_2 auf_show_details'>";
+ echo "<td> ".$data['ename']."</td>";
+ echo "<td>".$oname_plus." ".$data['oname']."</td>";
+ echo "<td class='numeric'>".$data['count']."</td></tr>";
+ $region_total += $data['count'];
+}
+
+$green_svg = '<svg width="'.(500*$green_total/$region_total).'" height="5" style="background-color: #00ff00; margin: 1px 0;"/>';
+$yellow_svg = '<svg width="'.(500*$yellow_total/$region_total).'" height="5" style="background-color: #ffff00; margin: 1px 0;"/>';
+$red_svg = '<svg width="'.(500*$red_total/$region_total).'" height="5" style="background-color: #ff0000; margin: 1px 0;"/>';
+$blue_svg = '<svg width="'.(500*$blue_total/$region_total).'" height="5" style="background-color: #0000ff; margin: 1px 0;"/>';
+echo "<tr class='tab_bg_1'><td class='b'> Sous-total</td>";
+echo "<td>".$green_svg.$yellow_svg.$red_svg.$blue_svg."</td>";
+echo "<td class='numeric b'>$region_total</td></tr>";
+
+$green_grand_total += $green_total;
+$yellow_grand_total += $yellow_total;
+$red_grand_total += $red_total;
+$blue_grand_total += $blue_total;
+$grand_total += $region_total;
+} // fin des régions
+
+echo "<tr class='tab_bg_1'><td colspan='3'> </td></tr>";
+
+# total operating systems
+$query = "SELECT COUNT(*) FROM `".$table_item."`
+ LEFT JOIN `glpi_computers_items`
+ ON (`glpi_computers_items`.`itemtype` = '".$itemtype."'
+ AND `glpi_computers_items`.`items_id` = `".$table_item."`.`id`)
+ WHERE `".$table_item."`.`is_deleted` = '0'
+ AND `".$table_item."`.`is_template` = '0' ".
+ getEntitiesRestrictRequest("AND", $table_item);
+$result = $DB->query($query);
+$total = $DB->result($result, 0, 0);
+
+$green_svg = '<svg width="'.(500*$green_grand_total/$grand_total).'" height="5" style="background-color: #00ff00; margin: 1px 0;"/>';
+$yellow_svg = '<svg width="'.(500*$yellow_grand_total/$grand_total).'" height="5" style="background-color: #ffff00; margin: 1px 0;"/>';
+$red_svg = '<svg width="'.(500*$red_grand_total/$grand_total).'" height="5" style="background-color: #ff0000; margin: 1px 0;"/>';
+$blue_svg = '<svg width="'.(500*$blue_grand_total/$grand_total).'" height="5" style="background-color: #0000ff; margin: 1px 0;"/>';
+echo "<tr class='tab_bg_1'><td class='b'>Total général</td>";
+echo "<td>".$green_svg.$yellow_svg.$red_svg.$blue_svg."</td>";
+echo "<td class='numeric b'>$total</td></tr>";
+
+
+/* requête last updated computers
+$query = "SELECT `last_fusioninventory_update`, `computers_id`
+ FROM `glpi_plugin_fusioninventory_inventorycomputercomputers`
+ LEFT JOIN `glpi_computers` ON `computers_id`=`glpi_computers`.`id`
+WHERE ((NOW() > ADDDATE(last_fusioninventory_update, INTERVAL ".$nbdays." DAY)
+ OR last_fusioninventory_update IS NULL)
+ ".$state_sql.")".getEntitiesRestrictRequest("AND", "glpi_computers")."
+ ORDER BY last_fusioninventory_update DESC";
+$result = $DB->query($query);
+
+echo "<table class='tab_cadre_fixe' cellpadding='5' width='950'>";
+
+echo "<tr class='tab_bg_1'>";
+echo "<th colspan='4'>".__('Number of items')." : ".$DB->numrows($result)."</th>";
+echo "</tr>";
+
+echo "<tr class='tab_bg_1'>";
+echo "<th>".__('Name')."</th>";
+echo "<th>".__('Last inventory')."</th>";
+echo "<th>".__('Serial Number')."</th>";
+echo "<th>".__('Inventory number')."</th>";
+echo "</tr>";
+
+while ($data=$DB->fetch_array($result)) {
+ echo "<tr class='tab_bg_1'>";
+ echo "<td>";
+ $computer->getFromDB($data['computers_id']);
+ echo $computer->getLink(1);
+ echo "</td>";
+ echo "<td>".Html::convDateTime($data['last_fusioninventory_update'])."</td>";
+ echo "<td>".$computer->fields['serial']."</td>";
+ echo "<td>".$computer->fields['otherserial']."</td>";
+ echo "</tr>";
+}
+*/
+
+echo "</table>";
+
+/*
+echo '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="150" height="150">
+ <rect width="90" height="90" x="30" y="30" style="fill:#0000ff;fill-opacity:0.75;stroke:#000000"/>
+ <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red"/>
+ <polygon points="100,10 40,180 190,60 10,60 160,180" style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;" />
+ </svg>';
+echo '<svg width="200" height="200" style="background-color: #D2B48C; display: block; margin-bottom: 5px;" id="embeddedSVG">
+ <g id="myGroup" fill="blue" style="font-size: 18px; text-anchor: middle; font-family: serif;">
+ <circle id="myCircle" cx="100" cy="75" r="50" stroke="firebrick" stroke-width="3" />
+ <text x="100" y="155">Hello World</text>
+ <text x="100" y="175">From Embedded SVG!</text>
+ </g>
+ </svg>';
+*/
+
+Html::footer();
+
+?>
--- /dev/null
+<?php
+/*
+ AUF plugin for GLPI
+ Copyright (C) 2014 AUF -- www.auf.org
+ */
+
+// Init the hooks of the plugins -Needed
+function plugin_init_auf() {
+ global $PLUGIN_HOOKS;
+
+ $PLUGIN_HOOKS['csrf_compliant']['auf'] = TRUE;
+
+ $Plugin = new Plugin();
+ if ($Plugin->isActivated('auf')) { // check if plugin is active
+ if (Session::getLoginUserID()) {
+ $PLUGIN_HOOKS['add_css']['auf'] = "auf.css";
+ }
+ if (isset($_SESSION["glpiname"])) {
+ $report_list = array();
+ if (Session::haveRight("computer", "r")) {
+ $report_list["report.operatingsystems.php"] = "Systèmes d'exploitation par implantation";
+ $report_list["report.wip.php"] = 'WIP (rapport en cours de développement)';
+ }
+ $PLUGIN_HOOKS['reports']['auf'] = $report_list;
+ }
+ }
+}
+
+// Get the name and the version of the plugin - Needed
+function plugin_version_auf() {
+ return array(
+ 'name' => 'AUF',
+ 'version' => '0.1.0',
+ 'author' => 'Jean Christophe André',
+ 'license' => 'GPLv2+',
+ 'homepage' => 'http://git.auf.org/?p=glpi',
+ 'minGlpiVersion' => '0.84');// For compatibility / no install in version < 0.80
+}
+
+// Optional : check prerequisites before install : may print errors or add to message after redirect
+function plugin_auf_check_prerequisites() {
+ if (version_compare(GLPI_VERSION,'0.84','lt') || version_compare(GLPI_VERSION,'0.85','ge')) {
+ _e('This plugin requires GLPI >= 0.84', 'auf');
+ return FALSE;
+ }
+ return TRUE;
+}
+
+// Uninstall process for plugin : need to return true if succeeded : may display messages or add to message after redirect
+function plugin_auf_check_config() {
+ return TRUE;
+}
+
+function plugin_auf_haveRight($module,$right) {
+ return TRUE;
+}
+?>