You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2007-11-08 15:24:52

theju
Member
Registered: 2007-11-07
Posts: 9

addressing v1.4

Rebonjour,

J'avais les mains dedans alors j'ai continué sur ma lancee. Je trouvais ca tres long d'entrer la plage IP et le réseau a la main (qui a dit que j'étais faignant ??? roll ), j'ai donc modifié un peu le plugin, j'attends vos avis / réactions wink


fichier plugin_addressing.config.php :

ajout de :

$ipconf1=$plugin_addressing_display->fields["ipconf1"];
            $ipconf2=$plugin_addressing_display->fields["ipconf2"];
            $ipconf3=$plugin_addressing_display->fields["ipconf3"];
            $ipconf4=$plugin_addressing_display->fields["ipconf4"];
            $netconf=$plugin_addressing_display->fields["netconf"];

apres

 101 : $system=$plugin_addressing_display->fields["system"];

puis ajout de :

echo "<tr class='tab_bg_1'><td colspan='2'>".$LANGADDRESSING["setup"][23]." :</td>";
            echo "<td colspan='2'><input name=\"ipconf1\" type=\"text\" value=\"".$ipconf1."\" maxlength=\"3\" size=\"4\" /> . ";
            echo "<input name=\"ipconf2\" type=\"text\" value=\"".$ipconf2."\" maxlength=\"3\" size=\"3\" /> . ";
            echo "<input name=\"ipconf3\" type=\"text\" value=\"".$ipconf3."\" maxlength=\"3\" size=\"3\" /> . ";
            echo "<input name=\"ipconf4\" type=\"text\" value=\"".$ipconf4."\" maxlength=\"3\" size=\"3\" />";
            echo "</td>";
            echo "</tr>";
            
            echo "<tr class='tab_bg_1'><td colspan='2'>".$LANGADDRESSING["setup"][24]." :</td>";
            echo "<td colspan='2'>";
            dropdownValue("glpi_dropdown_network", "netconf", $netconf);
            echo "</td>";
            echo "</tr>";

apres les lignes :

  echo "<td>".$LANGADDRESSING["setup"][14]."</td>";
            echo "<td>";
            echo "<select name=\"ip_reserved\">";
            echo "<option value='1' ".($ip_reserved==1?" selected ":"").">".$LANGADDRESSING["setup"][15]."</option>";
            echo "<option value='0' ".($ip_reserved==0?" selected ":"").">".$LANGADDRESSING["setup"][16]."</option>";
            echo "</select>";
            echo "</td>";

Fichier Index.php je remet tout le fichier :

 <?php
/*
 * @version $Id: setup.php,v 1.2 2006/04/02 14:45:27 moyo Exp $
 ----------------------------------------------------------------------
 GLPI - Gestionnaire Libre de Parc Informatique
 Copyright (C) 2003-2006 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: Gilles PORTHEAULT
// Purpose of file:
// ----------------------------------------------------------------------

define('GLPI_ROOT', '../..'); 
include (GLPI_ROOT . "/inc/includes.php"); 

commonHeader($LANGADDRESSING["title"][1],$_SERVER['PHP_SELF'],"utils","report");

if(plugin_addressing_haveRight("addressing","r") || haveRight("config","w")){

if(!isset($_SESSION["glpi_plugin_addressing_installed"]) || $_SESSION["glpi_plugin_addressing_installed"]!=1) {
        glpi_header("./front/plugin_addressing.config.php");
    } 
    else {

     $plugin_addressing_display=new plugin_addressing_display();
    $plugin_addressing_display->getFromDB('1');


    echo "<div align='center'>";

    echo "<form name='form' method='post' action='./front/plugin_addressing.display.php'>";
    echo "<table class='tab_cadre' width='70%'>";
    echo "<tr class='tab_bg_1'>";
    echo "<td>".$LANGADDRESSING["reports"][3];
    dropdownValue("glpi_dropdown_network", "network", $plugin_addressing_display->fields["netconf"]);
    echo "<input type='text' value='".$plugin_addressing_display->fields["ipconf1"]."' name='ipdebut1' size='3'>.";
    echo "<input type='text' value='".$plugin_addressing_display->fields["ipconf2"]."' name='ipdebut2' size='3'>.";
    echo "<input type='text' value='".$plugin_addressing_display->fields["ipconf3"]."' name='ipdebut3' size='3'>.";
    echo "<input type='text' value='".$plugin_addressing_display->fields["ipconf4"]."' name='ipdebut4' size='3'>";
    echo "&nbsp;".$LANGADDRESSING["reports"][20]."&nbsp;";
    echo "<input type='text' value='255' name='ipfin4' size='3'>";
    echo "</td><td align='center'>";
    echo "<input type='submit' value='".$LANGADDRESSING["reports"][4]."' class='submit'>";
    
    echo "</td><td align='center'>";
   // $plugin_addressing_display=new plugin_addressing_display();
    //$plugin_addressing_display->getFromDB('1');        
    if($plugin_addressing_display->fields["ping"]!=0)
    echo "<input type='checkbox' name='ping' checked='checked'>".$LANGADDRESSING["reports"][30];

    echo "</td></tr>";
    echo "</table>";
    echo "</form>";

//echo $LANGADDRESSING["setup"][0];
    echo "</div>";
}

}else{
    echo "<div align='center'><br><br><img src=\"".$CFG_GLPI["root_doc"]."/pics/warning.png\" alt=\"warning\"><br><br>";
        echo "<b>".$LANG["login"][5]."</b></div>";
}

commonFooter();

?>

fichiers de langage :

$LANGADDRESSING["setup"][23]="Plage IP par défaut";
$LANGADDRESSING["setup"][24]="Réseau par défaut";

et

$LANGADDRESSING["setup"][23]="Default IP Range";
$LANGADDRESSING["setup"][24]="Default network";

et enfin la database :

ALTER TABLE `glpi_plugin_addressing_display` ADD `ipconf1` SMALLINT NULL,
ADD `ipconf2` SMALLINT NULL,
ADD `ipconf3` SMALLINT NULL,
ADD `ipconf4` SMALLINT NULL,
ADD `netconf` SMALLINT NOT NULL DEFAULT '0';


Voila, en esperant que ca servira ...

Juju

Offline

#2 2007-11-08 16:52:18

theju
Member
Registered: 2007-11-07
Posts: 9

Re: addressing v1.4

Améliorations des performances pour le ping

La commande ping est assez lente, on ne cherche pas a définir un temps de latence mais uniquement si l'hôte répond. J'ai donc intégré un 3emem système nomme "linux fping" qui utilise la commande fping (plus rapide) (sous debian : apt-get install fping)
Ca me permet de passer de 225 a 20 seconde de traitement pour un sous réseau entier :

plugin_addressing.config.php :

echo "<tr class='tab_bg_1'><td colspan='4'><div align='center'><select name=\"system\">";
            echo "<option value='0' ".($system==0?" selected ":"").">".$LANGADDRESSING["setup"][20]."</option>";
            echo "<option value='2' ".($system==2?" selected ":"").">".$LANGADDRESSING["setup"][25]."</option>";
            echo "<option value='1' ".($system==1?" selected ":"").">".$LANGADDRESSING["setup"][21]."</option>";

(ajout de l'option2)

plugin_addressing.functions_setup.php : modif de la fonction plugin_addressing_ping($system,$ip) pour prendre en compte le nouveau systeme :
Attention, pour des raison de rapidité je fait un fping de 100ms, marche très bien sur mon reseau local mais attention aux faux négatifs ...

function plugin_addressing_ping($system,$ip)
{    
    $list ='';
    switch ($system){
    
    case 0:
    // linux ping
        exec("ping -w 1 ".$ip, $list);    
        $nb=count($list);
        if (isset($nb)){
            for($i=0;$i<$nb;$i++)
            {
                if(strpos($list[$i],"ttl=")>0) return true;
            }
        }
    break;
    
    case 1:
    //windows
        exec("ping.exe -n 1 -w 1 -i 1 ".$ip, $list);
        $nb=count($list); 
        if (isset($nb)){
            for($i=0;$i<$nb;$i++)
            {
                if(strpos($list[$i],"TTL")>0) return true;
            }
        }
    break;
    
    case 2:
    //linux fping
    exec("fping -r1 -c1 -t100 ".$ip, $list);    
        $nb=count($list);
        if (isset($nb)){
            for($i=0;$i<$nb;$i++)
            {
                if(strpos($list[$i],"bytes")>0) return true;
            }
        }
    break;    
    }
}

Fichiers de langage :

$LANGADDRESSING["setup"][20] = "Linux ping";
$LANGADDRESSING["setup"][25] = "Linux fping ";

pour les 2 fichiers.

Je pense que c'est tout ...

Offline

#3 2007-11-09 12:10:27

tsmr
GLPI-DEV
From: Rennes
Registered: 2005-08-26
Posts: 11,632
Website

Re: addressing v1.4


Xavier Caillaud
Blog GLPI Infotel

Offline

#4 2007-11-09 12:20:33

theju
Member
Registered: 2007-11-07
Posts: 9

Re: addressing v1.4

ya pas de quoi, pour une fois que je peut faire quelque chose !

Offline

#5 2007-11-09 12:21:59

tsmr
GLPI-DEV
From: Rennes
Registered: 2005-08-26
Posts: 11,632
Website

Re: addressing v1.4

Si tu en as d'autres n'hésites pas big_smile


Xavier Caillaud
Blog GLPI Infotel

Offline

Board footer

Powered by FluxBB