You are not logged in.
ok en faite tu récupère la table arp du switch ?
si c'est ca, c'est simple car tu as apriori une requete simple qui te le fais sur plein de switch.
Moi j'utilise le soft getif pour récupérer ses infos, et ca fonctionne sur plein de switch.
Offline
me revoilou
tu m'a pas répondu au sujet des cartouches ...
sinon voici une capture (je t'envoi en MP) avec mon soft qui me permet de récupérer les trames arp sur mon routeur
Offline
euh c'est quoi la question des cartouches?
Je vais regarder ce que tu m'a envoyé
Edit:
Arf un programme windows, euh ben ça va être compliqué ça avec mes pc et serveur sous FreeBSD
Last edited by ddurieux (2009-04-11 23:52:57)
Offline
ok ca marche lol
tu plains pas je t'ai envoyer (par mail) un fichier de capture qui est ds wireshark donc sous linux tu pourras le lire
Offline
oui je le sais que je peux le lire , je te parlais de getif
Offline
bah vi je le savais lol
Offline
REbonjour
donc j'ai bien mon script Tracker
quand je le lance
je n'ai plus d'erreur,
j'ai lancement du script
et ensuite plus rien
j'ai taper une touche pour continuer ...
mon fichier comporte ceci
@echo off
echo Chemins php et du script a lancer
SET path_php="C:\Program Files\OCS Inventory NG\xampp\php"
SET plugin_glpi="C:\Program Files\OCS Inventory NG\xampp\htdocs\glpi\plugins\tracker\scripts"
echo Definition du path
PATH = %PATH%;%path_php%
IF EXIST %plugin_glpi%\run_bat.php GOTO RUN
IF NOT EXIST %plugin_glpi%\run_bat.php GOTO EXIT
:RUN
echo Lancement du script
php %plugin_glpi%\run_bat.php %1
pause
GOTO FIN
:EXIT
echo Le chemin vers run_bat.php est incorrect
pause
:FIN
Offline
comme ça a l'air bien, faut voir les logs
Offline
je vais regarder ca alors
il te faudrai lesquels ??
Last edited by sprinteur (2009-04-16 16:29:58)
Offline
Alors dans
Glpi log
Cron:
03-04-2009 12:21
Launch mailgate
03-04-2009 12:21
mailgate Successfull (0.01s)
03-04-2009 12:28
Launch dbreplicate
03-04-2009 12:28
dbreplicate Nothing to do (0.01s)
03-04-2009 12:30
Launch ocsng
03-04-2009 12:30
Check updates from server localhost
03-04-2009 12:30
Update computer 24
03-04-2009 12:30
ocsng Successfull (0.10s)
*/30 * * * * www /var/www/glpi/plugins/tracker/scripts/tracker_fullsync.sh
*/10 * * * * www /var/www/glpi/plugins/tracker/scripts/tracker_fullsync.sh
03-04-2009 12:41
Launch mailgate
03-04-2009 12:41
mailgate Successfull (0.01s)
03-04-2009 12:41
Launch dbreplicate
03-04-2009 12:41
dbreplicate Nothing to do (0.01s)
03-04-2009 12:54
Launch ocsng
03-04-2009 12:54
Check updates from server localhost
03-04-2009 12:54
Update computer 6
03-04-2009 12:54
ocsng Successfull (0.11s)
03-04-2009 14:14
Launch dbreplicate
03-04-2009 14:14
dbreplicate Nothing to do (0.01s)
03-04-2009 14:15
Launch mailgate
03-04-2009 14:15
mailgate Successfull (0.01s)
03-04-2009 14:18
Launch ocsng
03-04-2009 14:18
Check updates from server localhost
03-04-2009 14:18
Update computer 28
03-04-2009 14:18
ocsng Successfull (0.12s)
03-04-2009 14:20
Launch dbreplicate
03-04-2009 14:20
dbreplicate Nothing to do (0.01s)
08-04-2009 08:55
Launch ocsng
08-04-2009 08:55
Check updates from server localhost
08-04-2009 08:55
Update computer 30
08-04-2009 08:55
ocsng Successfull (0.18s)
08-04-2009 12:32
Launch mailgate
08-04-2009 12:32
mailgate Successfull (0.04s)
08-04-2009 12:36
Launch dbreplicate
08-04-2009 12:36
dbreplicate Nothing to do (0.01s)
08-04-2009 12:52
Launch optimize
08-04-2009 12:52
Start optimize tables
08-04-2009 12:52
Optimize tables done
08-04-2009 12:52
optimize Nothing to do (4.44s)
08-04-2009 12:56
Launch cache
08-04-2009 12:56
cache Successfull (0.11s)
09-04-2009 10:21
Launch session
09-04-2009 10:21
Clean session files created since more than 180 seconds
09-04-2009 10:21
session Successfull (0.05s)
09-04-2009 10:27
Launch contract
09-04-2009 10:27
contract Nothing to do (0.03s)
09-04-2009 10:34
Launch infocom
09-04-2009 10:34
infocom Nothing to do (0.01s)
09-04-2009 10:34
Launch logs
09-04-2009 10:34
Cleaning log events passed from more than 30 days
09-04-2009 10:34
logs Nothing to do (0.02s)
09-04-2009 10:39
Launch ocsng
09-04-2009 10:39
Check updates from server localhost
09-04-2009 10:39
Update computer 15
09-04-2009 10:39
ocsng Successfull (2.54s)
09-04-2009 10:45
Launch dbreplicate
09-04-2009 10:45
dbreplicate Nothing to do (0.01s)
09-04-2009 10:50
Launch mailgate
09-04-2009 10:50
mailgate Successfull (0.03s)
09-04-2009 11:03
Launch ocsng
09-04-2009 11:03
Check updates from server localhost
09-04-2009 11:03
Update computer 6
09-04-2009 11:03
ocsng Successfull (0.14s)
09-04-2009 11:49
Launch dbreplicate
09-04-2009 11:49
dbreplicate Nothing to do (0.01s)
09-04-2009 11:50
Launch mailgate
09-04-2009 11:50
mailgate Successfull (0.02s)
09-04-2009 11:52
Launch ocsng
09-04-2009 11:52
Check updates from server localhost
09-04-2009 11:52
Update computer 25
09-04-2009 11:52
ocsng Successfull (0.13s)
09-04-2009 12:17
Launch dbreplicate
09-04-2009 12:17
dbreplicate Nothing to do (0.01s)
09-04-2009 12:44
Launch ocsng
09-04-2009 12:44
Check updates from server localhost
09-04-2009 12:44
Update computer 2
09-04-2009 12:44
ocsng Successfull (0.11s)
09-04-2009 16:24
Launch mailgate
09-04-2009 16:24
mailgate Successfull (0.02s)
09-04-2009 16:39
Launch dbreplicate
09-04-2009 16:39
dbreplicate Nothing to do (0.02s)
10-04-2009 12:35
Launch ocsng
10-04-2009 12:35
Check updates from server localhost
10-04-2009 12:35
Update computer 24
10-04-2009 12:35
ocsng Successfull (0.19s)
10-04-2009 12:46
Launch optimize
10-04-2009 12:46
Start optimize tables
10-04-2009 12:46
Optimize tables done
10-04-2009 12:46
optimize Nothing to do (4.24s)
16-04-2009 10:02
Launch cache
16-04-2009 10:02
cache Successfull (0.24s)
16-04-2009 10:42
Launch mailgate
16-04-2009 10:42
mailgate Successfull (0.03s)
16-04-2009 11:24
Launch dbreplicate
16-04-2009 11:24
dbreplicate Nothing to do (0.02s)
16-04-2009 11:55
Launch session
16-04-2009 11:55
Clean session files created since more than 180 seconds
16-04-2009 11:55
session Successfull (1.31s)
16-04-2009 14:36
Launch contract
16-04-2009 14:36
contract Nothing to do (1.04s)
16-04-2009 14:55
Launch infocom
16-04-2009 14:55
infocom Nothing to do (0.02s)
16-04-2009 14:58
Launch logs
16-04-2009 14:58
Cleaning log events passed from more than 30 days
16-04-2009 14:58
logs Nothing to do (0.04s)
16-04-2009 14:58
Launch ocsng
16-04-2009 14:58
Check updates from server localhost
16-04-2009 14:58
Update computer 31
16-04-2009 14:58
ocsng Successfull (1.04s)
sql-errors:
16-04-2009 12:01
*** MySQL query error :
***
SQL: INSERT INTO glpi_plugin_tracker_config (ID, activation_history, activation_connection, activation_snmp_networking, activation_snmp_peripheral, activation_snmp_phone, activation_snmp_printer, authsnmp, logs) VALUES (\'1\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\', \'DB\',\'0\')
Error: Duplicate entry '1' for key 1
Backtrace :
C:\Program Files\OCS Inventory NG\xampp\htdocs\glpi\plugins\tracker\inc\plugin_tracker.config.classes.php:55 DBmysql->query()
C:\Program Files\OCS Inventory NG\xampp\htdocs\glpi\plugins\tracker\front\plugin_tracker.install.php:47 plugin_tracker_config->initConfig()
C:/Program Files/OCS Inventory NG/xampp/htdocs/glpi/plugins/tracker/front/plugin_tracker.install.php
16-04-2009 12:01
*** MySQL query error :
***
SQL: INSERT INTO glpi_plugin_tracker_config_snmp_networking (ID, active_device_state, history_wire, history_ports_state, history_unknown_mac, history_snmp_errors, history_process) VALUES (\'1\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\')
Error: Duplicate entry '1' for key 1
Backtrace :
C:\Program Files\OCS Inventory NG\xampp\htdocs\glpi\plugins\tracker\inc\plugin_tracker.config.classes.php:348 DBmysql->query()
C:\Program Files\OCS Inventory NG\xampp\htdocs\glpi\plugins\tracker\front\plugin_tracker.install.php:49 plugin_tracker_config_snmp_networking->initConfig()
C:/Program Files/OCS Inventory NG/xampp/htdocs/glpi/plugins/tracker/front/plugin_tracker.install.php
16-04-2009 12:01
*** MySQL query error :
***
SQL: INSERT INTO glpi_plugin_tracker_config_snmp_printer (ID, active_device_state, manage_cartridges) VALUES (\'1\', \'0\', \'0\')
Error: Duplicate entry '1' for key 1
Backtrace :
C:\Program Files\OCS Inventory NG\xampp\htdocs\glpi\plugins\tracker\inc\plugin_tracker.config.classes.php:454 DBmysql->query()
C:\Program Files\OCS Inventory NG\xampp\htdocs\glpi\plugins\tracker\front\plugin_tracker.install.php:51 plugin_tracker_config_snmp_printer->initConfig()
C:/Program Files/OCS Inventory NG/xampp/htdocs/glpi/plugins/tracker/front/plugin_tracker.install.php
16-04-2009 12:01
*** MySQL query error :
***
SQL: INSERT INTO glpi_plugin_tracker_discover_conf (ID, ifaddr_start, ifaddr_end, discover, getserialnumber) VALUES (\'1\', \'192.168.0.1\', \'192.168.0.254\', 0, 0)
Error: Duplicate entry '1' for key 1
Backtrace :
C:\Program Files\OCS Inventory NG\xampp\htdocs\glpi\plugins\tracker\inc\plugin_tracker.snmp.discovery.classes.php:51 DBmysql->query()
C:\Program Files\OCS Inventory NG\xampp\htdocs\glpi\plugins\tracker\front\plugin_tracker.install.php:53 plugin_tracker_discovery->initConfig()
C:/Program Files/OCS Inventory NG/xampp/htdocs/glpi/plugins/tracker/front/plugin_tracker.install.php
log.php:
<?php
/*
* @version $Id: log.php 7763 2009-01-06 18:44:50Z moyo $
-------------------------------------------------------------------------
GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2009 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
--------------------------------------------------------------------------
*/
// Based on:
// IRMA, Information Resource-Management and Administration
// Christian Bauer
// ----------------------------------------------------------------------
// Original Author of file:
// Purpose of file:
// ----------------------------------------------------------------------
$NEEDED_ITEMS=array("user","tracking","computer","printer","networking","peripheral","monitor","software","phone");
define('GLPI_ROOT', '..');
include (GLPI_ROOT . "/inc/includes.php");
checkRight("logs","r");
commonHeader($LANG["Menu"][30],$_SERVER['PHP_SELF'],"admin","log");
//echo "<hr noshade>";
// Show last events
if(isset($_GET["order"]))
{
if(!isset($_GET["start"])) $_GET["start"]=0;
showEvents($_SERVER['PHP_SELF'],$_GET["order"],$_GET["sort"],$_GET["start"]);
}
else
{
showEvents($_SERVER['PHP_SELF'],"","");
}
commonFooter();
?>
logfonctions:
<?php
/*
* @version $Id: log.function.php 7908 2009-01-26 19:35:55Z remi $
-------------------------------------------------------------------------
GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2009 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:
// Purpose of file:
// ----------------------------------------------------------------------
if (!defined('GLPI_ROOT')){
die("Sorry. You can't access directly to this file");
}
/**
* Log history
*
*
*
* @param $id_device
* @param $device_type
* @param $changes
* @param $device_internal_type
* @param $linked_action
**/
function historyLog ($id_device,$device_type,$changes,$device_internal_type='0',$linked_action='0') {
global $DB;
$date_mod=$_SESSION["glpi_currenttime"];
if(!empty($changes)){
// créate a query to insert history
$id_search_option=$changes[0];
$old_value=$changes[1];
$new_value=$changes[2];
if (isset($_SESSION["glpiID"]))
$username = getUserName($_SESSION["glpiID"],$link=0);
else
$username="";
// Build query
$query = "INSERT INTO glpi_history (FK_glpi_device,device_type,device_internal_type,linked_action,user_name,date_mod,id_search_option,old_value,new_value) VALUES ('$id_device','$device_type','$device_internal_type','$linked_action','". addslashes($username)."','$date_mod','$id_search_option','".utf8_substr($old_value,0,250)."','".utf8_substr($new_value,0,250)."');";
$DB->query($query) or die($DB->error());
}
}
/**
* Construct history for device
*
*
*
* @param $id_device ID of the device
* @param $device_type ID of the device type
* @param $oldvalues old values updated
* @param $values all values of the item
**/
function constructHistory($id_device,$device_type,&$oldvalues,&$values) {
global $LINK_ID_TABLE, $LANG ;
if (count($oldvalues)){
// needed to have $SEARCH_OPTION
$SEARCH_OPTION=getSearchOptions();
foreach ($oldvalues as $key => $oldval){
$changes=array();
// Parsing $SEARCH_OPTIONS to find infocom
if ($device_type==INFOCOM_TYPE) {
$ic=new Infocom();
if ($ic->getFromDB($values['ID'])){
$real_device_type=$ic->fields['device_type'];
$id_device=$ic->fields['FK_device'];
if (isset($SEARCH_OPTION[$real_device_type])) foreach($SEARCH_OPTION[$real_device_type] as $key2 => $val2){
if(($val2["field"]==$key&&ereg('infocoms',$val2['table'])) ||
($key=='budget'&&$val2['table']=='glpi_dropdown_budget') ||
($key=='FK_enterprise'&&$val2['table']=='glpi_enterprises_infocoms')) {
$id_search_option=$key2; // Give ID of the $SEARCH_OPTION
if ($val2["table"]=="glpi_infocoms"){
// 1st case : text field -> keep datas
$changes=array($id_search_option, addslashes($oldval),$values[$key]);
} else if ($val2["table"]=="glpi_enterprises_infocoms") {
// 2nd case ; link field -> get data from glpi_enterprises
$changes=array($id_search_option, addslashes(getDropdownName("glpi_enterprises",$oldval)), addslashes(getDropdownName("glpi_enterprises",$values[$key])));
} else {
// 3rd case ; link field -> get data from dropdown (budget)
$changes=array($id_search_option, addslashes(getDropdownName( $val2["table"],$oldval)), addslashes(getDropdownName( $val2["table"],$values[$key])));
}
break; // foreach exit
}
}
}
} else {
$real_device_type=$device_type;
// Parsing $SEARCH_OPTION, check if an entry exists matching $key
foreach($SEARCH_OPTION[$device_type] as $key2 => $val2){
// Linkfield or standard field not massive action enable
if($val2["linkfield"]==$key
|| ( empty($val2["linkfield"]) && $key == $val2["field"]) ){
$id_search_option=$key2; // Give ID of the $SEARCH_OPTION
if($val2["table"]==$LINK_ID_TABLE[$device_type]){
// 1st case : text field -> keep datas
$changes=array($id_search_option, addslashes($oldval),$values[$key]);
}else {
// 2nd case ; link field -> get data from dropdown
$changes=array($id_search_option, addslashes(getDropdownName( $val2["table"],$oldval)), addslashes(getDropdownName( $val2["table"],$values[$key])));
}
break;
}
}
}
if (count($changes)){
historyLog ($id_device,$real_device_type,$changes);
}
}
}
} // function construct_history
/**
* Show History
**
* Show history for a device
*
* @param $id_device
* @param $device_type
**/
function showHistory($device_type,$id_device){
global $DB, $LINK_ID_TABLE,$LANG;
$SEARCH_OPTION=getSearchOptions();
$query="SELECT * FROM glpi_history WHERE FK_glpi_device='".$id_device."' AND device_type='".$device_type."' ORDER BY ID DESC;";
//echo $query;
// Get results
$result = $DB->query($query);
// Number of results
$number = $DB->numrows($result);
// No Events in database
if ($number < 1) {
echo "<br><div class='center'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>".$LANG["event"][20]."</th></tr>";
echo "</table>";
echo "</div><br>";
return;
}
// Output events
echo "<div class='center'><br><table class='tab_cadre_fixe'>";
echo "<tr><th colspan='5'>".$LANG["title"][38]."</th></tr>";
echo "<tr><th>".$LANG["common"][2]."</th><th>".$LANG["common"][27]."</th><th>".$LANG["common"][34]."</th><th>".$LANG["event"][18]."</th><th>".$LANG["event"][19]."</th></tr>";
while ($data =$DB->fetch_array($result)){
$display_history = true;
$ID = $data["ID"];
$date_mod=convDateTime($data["date_mod"]);
$user_name = $data["user_name"];
$field="";
// This is an internal device ?
if($data["linked_action"]){
// Yes it is an internal device
switch ($data["linked_action"]){
case HISTORY_DELETE_ITEM :
$change = $LANG["log"][22];
break;
case HISTORY_RESTORE_ITEM :
$change = $LANG["log"][23];
break;
case HISTORY_ADD_DEVICE :
$field=getDictDeviceLabel($data["device_internal_type"]);
$change = $LANG["devices"][25]." <strong>:</strong> \"".$data[ "new_value"]."\"";
break;
case HISTORY_UPDATE_DEVICE :
$field=getDictDeviceLabel($data["device_internal_type"]);
$change = getDeviceSpecifityLabel($data["device_internal_type"])." : \"".$data[ "old_value"]."\" <strong>--></strong> \"".$data[ "new_value"]."\"";
break;
case HISTORY_DELETE_DEVICE :
$field=getDictDeviceLabel($data["device_internal_type"]);
$change = $LANG["devices"][26]." <strong>:</strong> "."\"".$data["old_value"]."\"";
break;
case HISTORY_INSTALL_SOFTWARE :
$field=$LANG["help"][31];
$change = $LANG["software"][44]." <strong>:</strong> "."\"".$data["new_value"]."\"";
break;
case HISTORY_UNINSTALL_SOFTWARE :
$field=$LANG["help"][31];
$change = $LANG["software"][45]." <strong>:</strong> "."\"".$data["old_value"]."\"";
break;
case HISTORY_DISCONNECT_DEVICE:
$ci=new CommonItem();
$ci->setType($data["device_internal_type"]);
$field=$ci->getType();
$change = $LANG["central"][6]." <strong>:</strong> "."\"".$data["old_value"]."\"";
break;
case HISTORY_CONNECT_DEVICE:
$ci=new CommonItem();
$ci->setType($data["device_internal_type"]);
$field=$ci->getType();
$change = $LANG["log"][55]." <strong>:</strong> "."\"".$data["new_value"]."\"";
break;
case HISTORY_OCS_IMPORT:
if (haveRight("view_ocsng","r")){
$field="";
$change = $LANG["ocsng"][7]." ".$LANG["ocsng"][45]." <strong>:</strong> "."\"".$data["new_value"]."\"";
} else {
$display_history = false;
}
break;
case HISTORY_OCS_DELETE:
if (haveRight("view_ocsng","r")){
$field="";
$change = $LANG["ocsng"][46]." ".$LANG["ocsng"][45]." <strong>:</strong> "."\"".$data["old_value"]."\"";
} else {
$display_history = false;
}
break;
case HISTORY_OCS_LINK:
if (haveRight("view_ocsng","r")){
$ci=new CommonItem();
$ci->setType($data["device_internal_type"]);
$field=$ci->getType();
$change = $LANG["ocsng"][47]." ".$LANG["ocsng"][45]." <strong>:</strong> "."\"".$data["new_value"]."\"";
} else {
$display_history = false;
}
break;
case HISTORY_OCS_IDCHANGED:
if (haveRight("view_ocsng","r")){
$field="";
$change = $LANG["ocsng"][48]." "." <strong>:</strong> "."\"".$data["old_value"]."\" --> <strong>:</strong> "."\"".$data["new_value"]."\"";
} else {
$display_history = false;
}
break;
case HISTORY_LOG_SIMPLE_MESSAGE:
$field="";
$change = $data["new_value"];
break;
}
}else{
$fieldname="";
// It's not an internal device
foreach($SEARCH_OPTION[$device_type] as $key2 => $val2){
if($key2==$data["id_search_option"]){
$field= $val2["name"];
$fieldname=$val2["field"];
}
}
switch ($fieldname){
case "comments" :
$change =$LANG["log"][64];
break;
case "notes" :
$change =$LANG["log"][67];
break;
default :
$change = "\"".$data[ "old_value"]."\" <strong>--></strong> \"".$data[ "new_value"]."\"";
}
}// fin du else
if ($display_history)
{
// show line
echo "<tr class='tab_bg_2'>";
echo "<td>$ID</td><td>$date_mod</td><td>$user_name</td><td>$field</td><td width='60%'>$change</td>";
echo "</tr>";
}
}
echo "</table></div>";
}
/**
* Log an event.
*
* Log the event $event on the glpi_event table with all the others args, if
* $level is above or equal to setting from configuration.
*
* @param $item
* @param $itemtype
* @param $level
* @param $service
* @param $event
**/
function logEvent ($item, $itemtype, $level, $service, $event) {
// Logs the event if level is above or equal to setting from configuration
global $DB,$CFG_GLPI, $LANG;
if ($level <= $CFG_GLPI["event_loglevel"] && !$DB->isSlave()) {
$query = "INSERT INTO glpi_event_log VALUES (NULL, '".addslashes($item)."', '".addslashes($itemtype)."', '".$_SESSION["glpi_currenttime"]."', '".addslashes($service)."', '".addslashes($level)."', '".addslashes($event)."')";
$result = $DB->query($query);
}
}
/**
* Return arrays for function showEvent et lastEvent
*
**/
function logArray(){
global $LANG;
$logItemtype=array("system"=>$LANG["log"][1],
"computers"=>$LANG["log"][2],
"monitors"=>$LANG["log"][3],
"printers"=>$LANG["log"][4],
"software"=>$LANG["log"][5],
"networking"=>$LANG["log"][6],
"cartridges"=>$LANG["log"][7],
"peripherals"=>$LANG["log"][8],
"consumables"=>$LANG["log"][9],
"tracking"=>$LANG["log"][10],
"contacts"=>$LANG["log"][11],
"enterprises"=>$LANG["log"][12],
"documents"=>$LANG["log"][13],
"knowbase"=>$LANG["log"][14],
"users"=>$LANG["log"][15],
"infocom"=>$LANG["log"][19],
"devices"=>$LANG["log"][18],
"links"=>$LANG["log"][38],
"typedocs"=>$LANG["log"][39],
"planning"=>$LANG["log"][16],
"reservation"=>$LANG["log"][42],
"contracts"=>$LANG["log"][17],
"phones"=>$LANG["log"][43],
"dropdown"=>$LANG["log"][44],
"groups"=>$LANG["log"][47],
"entity"=>$LANG["log"][63],
"reminder"=>$LANG["title"][37],
"rules"=>$LANG["log"][65]);
$logService=array("inventory"=>$LANG["log"][50],
"tracking"=>$LANG["log"][51],
"planning"=>$LANG["Menu"][29],
"tools"=>$LANG["log"][53],
"financial"=>$LANG["log"][54],
"login"=>$LANG["log"][55],
"setup"=>$LANG["common"][12],
"security"=>$LANG["log"][66],
"reservation"=>$LANG["log"][58],
"cron"=>$LANG["log"][59],
"document"=>$LANG["Menu"][27],
"plugin"=>$LANG["common"][29]);
return array($logItemtype,$logService);
}
function displayItemLogID($itemtype,$item){
global $CFG_GLPI;
if ($item=="-1" || $item=="0") {
echo " ";//$item;
} else {
if ($itemtype=="infocom"){
echo "<a href='#' onClick=\"window.open('".$CFG_GLPI["root_doc"]."/front/infocom.show.php?ID=$item','infocoms','location=infocoms,width=1000,height=400,scrollbars=no')\">$item</a>";
} else {
if ($item=="-1" || $item=="0") {
echo " ";//$item;
} else {
switch ($itemtype){
case "rules" :
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/rule.generic.form.php?ID=".$item."\">".$item."</a>";
break;
case "infocom" :
echo "<a href='#' onClick=\"window.open('".$CFG_GLPI["root_doc"]."/front/infocom.show.php?ID=$item','infocoms','location=infocoms,width=1000,height=400,scrollbars=no')\">$item</a>";
break;
case "devices":
echo $item;
break;
case "reservation":
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/reservation.php?show=resa&ID=".$item."\">$item</a>";
break;
default :
if ($itemtype[strlen($itemtype)-1]=='s'){
$show=substr($itemtype,0,strlen($itemtype)-1);
}else $show=$itemtype;
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/".$show.".form.php?ID=";
echo $item;
echo "\">$item</a>";
break;
}
}
}
}
}
/**
* Print a nice tab for last event from inventory section
*
* Print a great tab to present lasts events occured on glpi
*
*
* @param $target where to go when complete
* @param $user
**/
function showAddEvents($target,$user="") {
// Show events from $result in table form
global $DB,$CFG_GLPI, $LANG;
list($logItemtype,$logService)=logArray();
$usersearch="%";
if (!empty($user))
$usersearch=$user." ";
// Query Database
$query = "SELECT * FROM glpi_event_log WHERE message LIKE '".$usersearch.addslashes($LANG["log"][20])."%' ORDER BY `date` DESC LIMIT 0,".$CFG_GLPI["num_of_events"];
// Get results
$result = $DB->query($query);
// Number of results
$number = $DB->numrows($result);
// No Events in database
if ($number < 1) {
echo "<br>";
echo "<table class='tab_cadrehov'>";
echo "<tr><th>".$LANG["central"][4]."</th></tr>";
echo "</table>";
echo "<br>";
return;
}
// Output events
$i = 0;
echo "<br><table class='tab_cadrehov'>";
echo "<tr><th colspan='5'><a href=\"".$CFG_GLPI["root_doc"]."/front/log.php\">".$LANG["central"][2]." ".$CFG_GLPI["num_of_events"]." ".$LANG["central"][8]."</a></th></tr>";
echo "<tr>";
echo "<th colspan='2'>".$LANG["event"][0]."</th>";
echo "<th><img src='".$CFG_GLPI["root_doc"]."/pics/puce-down.png' alt='' title=''>".$LANG["common"][27]."</a></th>";
echo "<th width='8%'>".$LANG["event"][2]."</th>";
echo "<th width='60%'>".$LANG["event"][4]."</th></tr>";
while ($i < $number) {
$ID = $DB->result($result, $i, "ID");
$item = $DB->result($result, $i, "item");
$itemtype = $DB->result($result, $i, "itemtype");
$date = $DB->result($result, $i, "date");
$service = $DB->result($result, $i, "service");
//$level = $DB->result($result, $i, "level");
$message = $DB->result($result, $i, "message");
echo "<tr class='tab_bg_2'>";
echo "<td>".$logItemtype[$itemtype].":</td><td class='center'>";
displayItemLogID($itemtype,$item);
echo "</td><td class='center'>".convDateTime($date)."</td><td class='center'>".$logService[$service]."</td><td>$message</td>";
echo "</tr>";
$i++;
}
echo "</table><br>";
}
/**
* Print a nice tab for last event
*
* Print a great tab to present lasts events occured on glpi
*
*
* @param $target where to go when complete
* @param $order order by clause occurences (eg: )
* @param $sort order by clause occurences (eg: date)
* @param $start
**/
function showEvents($target,$order,$sort,$start=0) {
// Show events from $result in table form
global $DB,$CFG_GLPI, $LANG;
list($logItemtype,$logService)=logArray();
// Columns of the Table
$items = array(
"item" => array($LANG["event"][0], "colspan='2'"),
"date" => array($LANG["common"][27], ""),
"service" => array($LANG["event"][2], "width='8%'"),
"level" => array($LANG["event"][3], "width='8%'"),
"message" => array($LANG["event"][4], "width='50%'")
);
// define default sorting
if (!isset($items[$sort])) {
$sort = "date";
}
if ($order!="ASC"){
$order = "DESC";
}
// Query Database
$query_limit = "SELECT * FROM glpi_event_log ORDER BY `$sort` $order LIMIT ".intval($start).",".intval($_SESSION["glpilist_limit"]);
// Number of results
$numrows = countElementsInTable("glpi_event_log");
// Get results
$result = $DB->query($query_limit);
$number = $DB->numrows($result);
// No Events in database
if ($number < 1) {
echo "<div class='center'><strong>".$LANG["central"][4]."</strong></div>";
return;
}
// Output events
$i = 0;
echo "<div class='center'>";
$parameters="sort=$sort&order=$order";
printPager($start,$numrows,$target,$parameters);
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
foreach ($items as $field => $args) {
echo "<th ".$args[1].">";
if ($sort==$field) {
if ($order=="DESC") {
echo "<img src=\"".$CFG_GLPI["root_doc"]."/pics/puce-down.png\" alt='' title=''>";
} else {
echo "<img src=\"".$CFG_GLPI["root_doc"]."/pics/puce-up.png\" alt='' title=''>";
}
}
echo "<a href='$target?sort=$field&order=".($order=="ASC"?"DESC":"ASC")."'>".$args[0]."</a></th>";
}
echo "</tr>";
while ($i < $number) {
$ID = $DB->result($result, $i, "ID");
$item = $DB->result($result, $i, "item");
$itemtype = $DB->result($result, $i, "itemtype");
$date = $DB->result($result, $i, "date");
$service = $DB->result($result, $i, "service");
$level = $DB->result($result, $i, "level");
$message = $DB->result($result, $i, "message");
echo "<tr class='tab_bg_2'>";
echo "<td>".(isset($logItemtype[$itemtype])?$logItemtype[$itemtype]:" ").":</td><td class='center'><strong>";
displayItemLogID($itemtype,$item);
echo "</strong></td><td>".convDateTime($date)."</td><td class='center'>".(isset($logService[$service])?$logService[$service]:$service)."</td><td class='center'>$level</td><td>$message</td>";
echo "</tr>";
$i++;
}
echo "</table></div><br>";
}
?>
voila en esperant que ca puisse t'aider
Merci
Offline
Bonjour à tous,
Merci tout d'abord pour ce plugins.
Je souhaite constituer un model snmp avec les MIB de mes imprimantes ? comment faire.... ?
deuxième question comment attribuer un profil snmp et une ip lorsque les imprimantes sont déjà présentes dans la liste des imprimantes afin de ne pas créer de doublon. Les miennes étant remontées par OCS.
Voilà encore merci de faciliter notre travail quotidien avec toutes ces informations collectées le plus automatiquement possible..
Offline
Pour le modele, le plus simple c'est d'utiliser un des modeles existant, et avec un outil type Mib Browser vérifiait quels sont les oid qui marchent deja, et pour ceux qui marche pas trouver l'oid qui correspond.
Sur vos imprimantes, leur créer un port réseau, saisir juste l'IP, aller sur plugins -> informations SNMP, mettre le modele et l'authent qui va bien
Offline
wrong place to post ..
Last edited by maltyx (2009-09-06 13:39:11)
Offline