Changeset 135

Show
Ignore:
Timestamp:
03/14/06 15:49:04 (3 years ago)
Author:
ludo
Message:

ocs ng fixes: linux and mac agent tested. added modem infos (from r3115)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/webmin/lrs-inventory/agent/lrs-inventory.conf

    r133 r135  
    88Alias /lrs-transfert /usr/share/webmin/lrs-inventory/agent/ 
    99Alias /lrs-transfer /usr/share/webmin/lrs-inventory/agent/ 
     10Alias /ocsinventory /usr/share/webmin/lrs-inventory/agent/transfertNG.php 
  • trunk/webmin/lrs-inventory/agent/transfertNG.php

    r133 r135  
    11<?php 
     2# 
     3# $Id$ 
     4# 
     5# Linbox Rescue Server 
     6# Copyright (C) 2005  Linbox FAS 
     7# 
     8# This program is free software; you can redistribute it and/or 
     9# modify it under the terms of the GNU General Public License 
     10# as published by the Free Software Foundation; either version 2 
     11# of the License, or (at your option) any later version. 
     12# 
     13# This program is distributed in the hope that it will be useful, 
     14# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     16# GNU General Public License for more details. 
     17# 
     18# You should have received a copy of the GNU General Public License 
     19# along with this program; if not, write to the Free Software 
     20# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
    221 
    322        $QUERY; 
     
    1130 
    1231        // Read compressed data 
     32        $data = ""; 
    1333        $stdin = fopen('php://input','r'); 
    14         $data = fread($stdin,$_SERVER['CONTENT_LENGTH']); 
     34        while (!feof($stdin)) { 
     35            $data .= fread($stdin, 8192); 
     36        } 
    1537        fclose($stdin); 
    16          
    17         // Write it in a temporary file 
    18         $fh = fopen("/tmp/${_SERVER[REMOTE_ADDR]}.tmp",'w'); 
    19         fwrite($fh,$data); 
    20         fclose($fh); 
    21          
    2238        // Uncompress it 
    23         exec("perl uncompress.pl /tmp/${_SERVER[REMOTE_ADDR]}.tmp",$DATA); 
    24         $DATA = join('',$DATA); 
     39        $DATA = gzuncompress($data); 
    2540         
    2641        system("rm /tmp/${_SERVER[REMOTE_ADDR]}.tmp -f"); 
     
    3247        ereg('<DEVICEID>([a-zA-Z0-9_-]+)</DEVICEID>', $DATA, $matches); 
    3348        $DEVICEID = $matches[1]; 
    34          
    35         $DEBUG = true; 
     49                 
     50        //exec("echo \"$DATA\" >>/tmp/log"); 
     51        //$DEBUG = true; 
    3652 
    37         if ( $QUERY=='PROLOG' ) 
    38  
     53        if ( $QUERY=='PROLOG' ) { 
    3954                // Always send the inventory 
    40                 $data = '<?xml version="1.0" encoding="utf-8" ?><REPLY><RESPONSE>send</RESPONSE></REPLY>'; 
    41  
     55                $resp = '<?xml version="1.0" encoding="utf-8" ?><REPLY><RESPONSE>SEND</RESPONSE></REPLY>'; 
     56        } 
    4257        else if ( $QUERY=='INVENTORY' ) 
    4358        { 
    4459                // Extract inventory data 
    45                 ereg('(<HARDWARE>.+)<\/CONTENT>', $DATA, $matches); 
     60                ereg('<CONTENT>(.+)<\/CONTENT>', $DATA, $matches); 
    4661                $INVENTORY = '<?xml version="1.0" encoding="utf-8" ?><Inventory>'. $matches[1] .'</Inventory>'; 
     62                $resp = '<?xml version="1.0" encoding="utf-8" ?><REPLY><RESPONSE>no_account_update</RESPONSE></REPLY>'; 
    4763 
    48                 $data = '<?xml version="1.0" encoding="utf-8" ?><REPLY><RESPONSE>no_update</RESPONSE></REPLY>'; 
    49  
     64                // Store data on the server 
    5065                // Parse data 
    5166                $machines = & $datasource->readMachine( array($DEVICEID), null, 'OcsNG' ); 
    5267 
    53                 // Store data on the server 
    5468                for ( $i=0 ; $i<count($machines) ; $i++ ) 
    5569                { 
    5670                        $machine = & $machines[$i]; 
    57  
    58                         foreach ( array_keys($machine->m_Components) as $type ) 
    59  
    60                                 $datasource->write($machine->m_Components[$type]); 
     71                        if ($machine->getName() != "") { 
     72                                foreach ( array_keys($machine->m_Components) as $type ) { 
     73                                        $datasource->write($machine->m_Components[$type]); 
     74                                } 
     75                        } 
    6176                } 
    6277 
    6378        } 
    6479 
    65         print gzcompress($data); 
    66  
    67  
     80        print gzcompress($resp); 
     81         
    6882?> 
  • trunk/webmin/lrs-inventory/classes/Drivers/Csv/Definitions/Modem.xml

    r133 r135  
    66         
    77        <Versions> 
     8 
     9                <Version number="3.0"> 
     10                 
     11                        <Directory>Modems</Directory> 
     12 
     13                        <Fields> 
     14                                <Field index="0">Host</Field> 
     15                                <Field index="1">Vendor</Field> 
     16                                <Field index="2">Model</Field> 
     17                                <Field index="3">ExpandedDescription</Field> 
     18                                <Field index="4">Type</Field> 
     19                        </Fields> 
     20         
     21                </Version> 
    822         
    923                <Version number="2.0"> 
  • trunk/webmin/lrs-inventory/classes/Drivers/Csv/Definitions/Monitor.xml

    r133 r135  
    1313                        <Fields> 
    1414                                <Field index="0">Host</Field> 
    15                                 <Field index="1">Stamp</Field> 
    16                                 <Field index="2">Description</Field> 
    17                                 <Field index="3">Type</Field> 
     15                                <Field index="1">Manuf</Field> 
     16                                <Field index="2">Stamp</Field> 
     17                                <Field index="3">Description</Field> 
     18                                <Field index="4">Type</Field> 
    1819                        </Fields> 
    19          
     20                                
    2021                </Version> 
    2122         
  • trunk/webmin/lrs-inventory/classes/Drivers/Sql/SqlDriver.php

    r133 r135  
    5353                        // hack used by transfer.php to make sure that an inventory has the same 
    5454                        // Id for all object types 
    55                         $todayinventory = new Inventory($this->m_InvIdDate, $this->m_InvIdTime);                        
     55                        $todayinventory = new Inventory($this->m_InvIdDate, $this->m_InvIdTime); 
    5656                } 
    5757                $this->m_InvIdDate = $todayinventory->getDate(); 
     
    6262                { 
    6363                        $ismachine = $object->getClassName()=='machine'; 
     64 
     65                        if ($object->getClassName() == "object") continue; 
    6466 
    6567                        // Get object and machine IDs in the database 
     
    6769                        debug("Object ID : $objectid"); 
    6870                         
     71                         
    6972                        if ( $ismachine ) 
    7073 
    71                                 $this->saveCustomFields($object); 
     74                                $this->saveCustomFields($object);      // obsolete ? 
    7275 
    7376                        else 
  • trunk/webmin/lrs-inventory/classes/Drivers/Xml/Maps/OcsNGMap.xml

    r133 r135  
    99                <MappedField from="OSNAME" to="OperatingSystem" /> 
    1010                <MappedField from="OSVERSION" to="Version" /> 
     11                <MappedField from="OSCOMMENTS" to="Build" /> 
    1112                <MappedField from="PROCESSORT" to="ProcessorType" /> 
    1213                <MappedField from="PROCESSORS" to="ProcessorFrequency" /> 
     
    7273                <MappedField from="CAPTION" to="Stamp" /> 
    7374                <MappedField from="DESCRIPTION" to="Description" /> 
     75                <MappedField from="MANUFACTURER" to="Manuf" /> 
    7476                <MappedField from="TYPE" to="Type" /> 
    7577 
     
    7880        <MappedObject name="NETWORKS" class="Network"> 
    7981 
    80                 <MappedField from="DESCRIPTION" to="Description" /> 
    81                 <MappedField from="TYPE" to="CardType" /> 
     82                <MappedField from="DESCRIPTION" to="CardType" /> 
     83                <MappedField from="TYPE" to="NetworkType" /> 
    8284                <MappedField from="TYPEMIB" to="MIB" /> 
    8385                <MappedField from="SPEED" to="Bandwidth" /> 
     
    166168        </MappedObject> 
    167169 
     170        <MappedObject name="MODEMS" class="Modem"> 
     171                <MappedField from="NAME" to="Vendor" /> 
     172                <MappedField from="MODEL" to="Model" /> 
     173                <MappedField from="DESCRIPTION" to="ExpandedDescription" /> 
     174                <MappedField from="TYPE" to="Type" /> 
     175        </MappedObject> 
     176 
     177        <MappedObject name="ACCOUNTINFO" class="Null"> 
     178        </MappedObject> 
     179 
     180        <MappedObject name="ACCESSLOG" class="Null"> 
     181        </MappedObject> 
     182 
     183        <MappedObject name="DEVICEID" class="Null"> 
     184        </MappedObject> 
     185 
    168186</MappedFields> 
  • trunk/webmin/lrs-inventory/classes/Drivers/Xml/XmlDriver.php

    r133 r135  
    140140                         
    141141                        // For each component of the machine 
    142                         for ( $j=0 ; $j<count($machine->m_Components[$type]) ; $j++ ) 
    143  
     142                        for ( $j=0 ; $j<count($machine->m_Components[$type]) ; $j++ ) { 
    144143                                // Only append the current component to the end of array 
    145                                 $objects[] = & $machine->m_Components[$type][$j]; 
    146  
    147                 } 
    148                  
     144                                $obj = & $machine->m_Components[$type][$j]; 
     145                                $obj->setHost($machine); 
     146                                $objects[] = & $obj; 
     147                        } 
     148                } 
     149         
    149150                return $objects; 
    150151        } 
     
    199200 
    200201                xml_parser_free($parser); 
    201                  
     202 
    202203                return $machine; 
    203204        } 
     
    244245                 
    245246                $xmlmap = & $GLOBALS['CURRENTXMLMAP']; 
     247 
     248                //echo $GLOBALS['CURRENTLEVEL'].":$name;".$GLOBALS['CURRENTTAG'].";"; 
    246249                 
    247250                switch ( $GLOBALS['CURRENTLEVEL'] ) 
     
    262265                                        } 
    263266 
    264                                         if ( class_exists($class)
     267                                        if ( class_exists($class) && $class != "Null"
    265268                                        { 
    266269                                                unset($GLOBALS['CURRENTOBJECT']); 
     
    277280                                        else 
    278281                                        { 
    279                                                 global $datasource; 
    280                                                 $datasource->loadComponentClass('Object'); 
     282                                                //global $datasource; 
     283                                                //$datasource->loadComponentClass('Object'); 
    281284                                                 
    282                                                 $GLOBALS['CURRENTOBJECT'] = new Object(); 
     285                                                unset($GLOBALS['CURRENTOBJECT']); 
     286                                                // = new Object(); 
    283287                                        } 
    284288                                } 
     
    315319        function characterDataXmlParser($parser, $data) 
    316320        { 
    317                 if ( ! empty($data) && $data!='N/A'
     321                if ( trim($data) != "" && $data!='N/A' && isset($GLOBALS['CURRENTOBJECT'])
    318322                {                
    319323                        $object = & $GLOBALS['CURRENTOBJECT']; 
    320324         
    321                         $object->setProperty($GLOBALS['CURRENTFIELD'], $data); 
     325                        $object->setProperty($GLOBALS['CURRENTFIELD'], utf8_decode($data)); 
    322326         
    323327                        $machine = & $GLOBALS['CURRENTMACHINE']; 
    324328                         
    325329                        // Sets the machine name 
    326                         if ( $GLOBALS['CURRENTFIELD']=='Host' && $GLOBALS['CURRENTTAG']=='HARDWARE' ) 
    327  
     330                        if ( ($GLOBALS['CURRENTFIELD']=='Host' || $GLOBALS['CURRENTFIELD']=='NAME') && $GLOBALS['CURRENTTAG']=='HARDWARE') { 
    328331                                $machine->setName($data); 
    329  
    330                 } 
    331         } 
    332  
    333  
     332                        } 
     333                } 
     334        } 
    334335?> 
  • trunk/webmin/lrs-inventory/debian/changelog

    r133 r135  
    1 webmin-lrs-inventory (2.0.8) stable; urgency=low 
     1webmin-lrs-inventory (2.0.9) stable; urgency=low 
    22 
    33  * First package. Replaces webmin-lbs-inventory 
  • trunk/webmin/lrs-inventory/module.info

    r133 r135  
    33desc_fr=LRS : Inventaire 
    44depends=1.030 lbs_common 
    5 version=2.0.8 
     5version=2.0.9 
  • trunk/webmin/lrs-inventory/peripherals.cgi

    r133 r135  
    99        renderTable('Input'); 
    1010        renderTable('Monitor'); 
     11        renderTable('Modem'); 
    1112 
    1213    print perl_exec("lbs_footer.cgi"); 
  • trunk/webmin/lrs-inventory/sql/create-db.sh

    r133 r135  
    55 
    66# lastest db version 
    7 TOVER=4 
     7TOVER=5 
    88 
    99# 
  • trunk/webmin/lrs-inventory/tmpl/en/Monitor.tpl

    r133 r135  
    1515                        <tr> 
    1616                                <th>Client {SORT_HOST}</th> 
    17                                 <th>Category {SORT_STAMP}</th> 
     17                                <th>Manufacturer {SORT_MANUF}</th> 
    1818                                <th>Description {SORT_DESCRIPTION}</th> 
    1919                                <th>Type {SORT_TYPE}</th> 
     20                                <th>Category {SORT_STAMP}</th> 
    2021                                <th>Appearance {SORT_FIRSTAPPARITION}</th> 
    2122                        </tr> 
     
    2526                        <tr class="{ROWCLASS}"> 
    2627                                <td class="{HOST_CLASS}">{HOSTL}</td> 
    27                                 <td class="{STAMP_CLASS}">{STAMP}</td> 
     28                                <td class="{MANUF_CLASS}">{MANUF}</td> 
    2829                                <td class="{DESCRIPTION_CLASS}">{DESCRIPTION}</td> 
    2930                                <td class="{TYPE_CLASS}">{TYPE}</td> 
     31                                <td class="{STAMP_CLASS}">{STAMP}</td> 
    3032                                <td class="{FIRSTAPPARITION_CLASS}">{FIRSTAPPARITION}</td> 
    3133                        </tr> 
  • trunk/webmin/lrs-inventory/tmpl/fr/Monitor.tpl

    r133 r135  
    1515                        <tr> 
    1616                                <th>Client {SORT_HOST}</th> 
    17                                 <th>Categorie {SORT_STAMP}</th> 
     17                                <th>Fabriquant {SORT_MANUF}</th> 
    1818                                <th>Description {SORT_DESCRIPTION}</th> 
    1919                                <th>Type {SORT_TYPE}</th> 
     20                                <th>Categorie {SORT_STAMP}</th> 
    2021                                <th>Apparition {SORT_FIRSTAPPARITION}</th> 
    2122                        </tr> 
     
    2526                        <tr class="{ROWCLASS}"> 
    2627                                <td class="{HOST_CLASS}">{HOSTL}</td> 
    27                                 <td class="{STAMP_CLASS}">{STAMP}</td> 
     28                                <td class="{MANUF_CLASS}">{MANUF}</td> 
    2829                                <td class="{DESCRIPTION_CLASS}">{DESCRIPTION}</td> 
    2930                                <td class="{TYPE_CLASS}">{TYPE}</td> 
     31                                <td class="{STAMP_CLASS}">{STAMP}</td> 
    3032                                <td class="{FIRSTAPPARITION_CLASS}">{FIRSTAPPARITION}</td> 
    3133                        </tr>