Php
Dimitrii
Messages postés
748
Statut
Membre
-
Dimitrii Messages postés 748 Statut Membre -
Dimitrii Messages postés 748 Statut Membre -
Bonjour,
voila je suis en train de créer un script en php pour récupérer des infos snmp des éléments actifs du réseau ! le problème est que j'ai une erreur que je ne sais résoudre :s
voici le script, l'erreur est sur la ligne en gras :
<html>
<head>
<style>
html, body,div {
font-family:verdana, tahoma;
font-size:8px;
color:#ffffff;
background:#343739;
}
</style>
</head>
<body>
<?php
// définition des IPs des switches à interroger
$ip1='192.168.x.x';
$ip2='192.168.x.x';
// cette fonction prend les ports du switch et son ip en paramètre
// elle interroge le switch sur l'état des ports sélectionnés
function lightport($tab,$ip){
// definition de la communauté
$community="public";
// définition des numéros d'objets SNMP communs
$onlineid=".1.3.6.1.2.1.1.3.0"; // je sais plus ce que c'est !
$placeid =".1.3.6.1.2.1.1.6.0";//emplacement
$nbrifid =".1.3.6.1.2.1.2.1.0"; // nombre d'interfaces
$if1id=".1.3.6.1.2.1.2.2.1.1.1"; // interface numero 1
$if1nomid=".1.3.6.1.2.1.2.2.1.2.1"; //nom de l'interface 1
$if1descid=".1.3.6.1.2.1.2.2.1.2.10"; //description de l'int 1 (if à 3 chiffres)
$statusid=".1.3.6.1.2.1.2.2.1.8.10";// etat de l'interface 1 (if à 3 chiffres)
$Ifmacid=".1.3.6.1.2.1.2.2.1.6.10";//adresse mac de l'interface 1 (if à 3 chiffres)
$ifspeedid=".1.3.6.1.2.1.2.2.1.5.10";//vitesse de l'interface 1 (if à 3 chiffres)
// pour chaque numéro de port transmis dans $tab
foreach ($tab as $int)
{
$intnum=str_pad($int,2,"0",STR_PAD_LEFT); // rajoute un 0 devant les numéros à 1 seul chiffre: 1 ==> 01
$string_oid=$statusid.$intnum; // crèe la chaine SNMP pour interroger le port demandé
$status=snmpget($ip,$community,$string_oid); //requete SNMP
// si status = 1 (ON) sinon OFF: on définit l'image correspondante
if ($status=="1") {$img="on.gif";} else {$img="off.gif";}
// affichage de l'image ON / OFF pour le port
echo('<div style="float:left;width:22px;height:36px;background:url(\'/snmp/images/'.$img.'\');text-align:center"><br>'.substr($intnum,-2).'x</div>');
}
}
?>
<table id="Tableau_01" width="731" height="79" border="0" cellpadding="0" cellspacing="0">
<tr>
<td rowspan="3">
<img src="images/2950_01.gif" width="64" height="79" alt=""></td>
<td colspan="8">
<img src="images/2950_02.gif" width="645" height="33" alt=""></td>
<td rowspan="3">
<img src="images/2950_03.gif" width="22" height="79" alt=""></td>
</tr>
<tr>
<td>
<?php
// construit les images du premier bloc d'IPS pour le 1er switch: appel de la fonction lightport()
$tabint=array('001','002','003','004','005','006','007','008');
lightport($tabint,$ip1);
?>
</td>
<td>
<img src="images/2950_05.gif" width="10" height="36" alt=""></td>
<td>
<?php
$tabint=array('009','010','011','012','013','014','015','016');
lightport($tabint,$ip1);
?>
</td>
<td>
<img src="images/2950_07.gif" width="10" height="36" alt=""></td>
<td>
<?php
$tabint=array('017','018','019','020','021','022','023','024');
lightport($tabint,$ip1);
?>
</td>
<td>
<img src="images/2950_09.gif" width="20" height="36" alt=""></td>
<td>
<?php
$tabint=array('101','102'); //'501' ???
lightport($tabint,$ip1);
?>
</td>
<td>
<img src="images/2950_11.gif" width="33" height="36" alt=""></td>
</tr>
<tr>
<td colspan="8">
<img src="images/2950_12.gif" width="645" height="10" alt=""></td>
</tr>
</table>
<br><br>
<table id="Tableau_01" width="731" height="79" border="0" cellpadding="0" cellspacing="0">
<tr>
<td rowspan="3">
<img src="images/2950_01.gif" width="64" height="79" alt=""></td>
<td colspan="8">
<img src="images/2950_022.gif" width="645" height="33" alt=""></td>
<td rowspan="3">
<img src="images/2950_03.gif" width="22" height="79" alt=""></td>
</tr>
<tr>
<td>
<?php
$tabint=array('001','002','003','004','005','006','007','008');
lightport($tabint,$ip2);
?>
</td>
<td>
<img src="images/2950_05.gif" width="10" height="36" alt=""></td>
<td>
<?php
$tabint=array('009','010','011','012','013','014','015','016');
lightport($tabint,$ip2);
?>
</td>
<td>
<img src="images/2950_07.gif" width="10" height="36" alt=""></td>
<td>
<?php
$tabint=array('017','018','019','020','021','022','023','024');
lightport($tabint,$ip2);
?>
</td>
<td>
<img src="images/2950_09.gif" width="20" height="36" alt=""></td>
<td>
<?php
$tabint=array('101','102'); //'501' ???
lightport($tabint,$ip2);
?>
</td>
<td>
<img src="images/2950_11.gif" width="33" height="36" alt=""></td>
</tr>
<tr>
<td colspan="8">
<img src="images/2950_12.gif" width="645" height="10" alt=""></td>
</tr>
</table>
</body>
</html>
L'erreur donnée est : Fatal error: Maximum execution time of 30 seconds exceeded in C:\cacti\snmp\index.php on line 32
Quelqu'un peut m'aider ?
--
Peut être donnons tous le meilleur de nous même a ceux qui de leur coté de ne nous accordent que rarement une pensée.
voila je suis en train de créer un script en php pour récupérer des infos snmp des éléments actifs du réseau ! le problème est que j'ai une erreur que je ne sais résoudre :s
voici le script, l'erreur est sur la ligne en gras :
<html>
<head>
<style>
html, body,div {
font-family:verdana, tahoma;
font-size:8px;
color:#ffffff;
background:#343739;
}
</style>
</head>
<body>
<?php
// définition des IPs des switches à interroger
$ip1='192.168.x.x';
$ip2='192.168.x.x';
// cette fonction prend les ports du switch et son ip en paramètre
// elle interroge le switch sur l'état des ports sélectionnés
function lightport($tab,$ip){
// definition de la communauté
$community="public";
// définition des numéros d'objets SNMP communs
$onlineid=".1.3.6.1.2.1.1.3.0"; // je sais plus ce que c'est !
$placeid =".1.3.6.1.2.1.1.6.0";//emplacement
$nbrifid =".1.3.6.1.2.1.2.1.0"; // nombre d'interfaces
$if1id=".1.3.6.1.2.1.2.2.1.1.1"; // interface numero 1
$if1nomid=".1.3.6.1.2.1.2.2.1.2.1"; //nom de l'interface 1
$if1descid=".1.3.6.1.2.1.2.2.1.2.10"; //description de l'int 1 (if à 3 chiffres)
$statusid=".1.3.6.1.2.1.2.2.1.8.10";// etat de l'interface 1 (if à 3 chiffres)
$Ifmacid=".1.3.6.1.2.1.2.2.1.6.10";//adresse mac de l'interface 1 (if à 3 chiffres)
$ifspeedid=".1.3.6.1.2.1.2.2.1.5.10";//vitesse de l'interface 1 (if à 3 chiffres)
// pour chaque numéro de port transmis dans $tab
foreach ($tab as $int)
{
$intnum=str_pad($int,2,"0",STR_PAD_LEFT); // rajoute un 0 devant les numéros à 1 seul chiffre: 1 ==> 01
$string_oid=$statusid.$intnum; // crèe la chaine SNMP pour interroger le port demandé
$status=snmpget($ip,$community,$string_oid); //requete SNMP
// si status = 1 (ON) sinon OFF: on définit l'image correspondante
if ($status=="1") {$img="on.gif";} else {$img="off.gif";}
// affichage de l'image ON / OFF pour le port
echo('<div style="float:left;width:22px;height:36px;background:url(\'/snmp/images/'.$img.'\');text-align:center"><br>'.substr($intnum,-2).'x</div>');
}
}
?>
<table id="Tableau_01" width="731" height="79" border="0" cellpadding="0" cellspacing="0">
<tr>
<td rowspan="3">
<img src="images/2950_01.gif" width="64" height="79" alt=""></td>
<td colspan="8">
<img src="images/2950_02.gif" width="645" height="33" alt=""></td>
<td rowspan="3">
<img src="images/2950_03.gif" width="22" height="79" alt=""></td>
</tr>
<tr>
<td>
<?php
// construit les images du premier bloc d'IPS pour le 1er switch: appel de la fonction lightport()
$tabint=array('001','002','003','004','005','006','007','008');
lightport($tabint,$ip1);
?>
</td>
<td>
<img src="images/2950_05.gif" width="10" height="36" alt=""></td>
<td>
<?php
$tabint=array('009','010','011','012','013','014','015','016');
lightport($tabint,$ip1);
?>
</td>
<td>
<img src="images/2950_07.gif" width="10" height="36" alt=""></td>
<td>
<?php
$tabint=array('017','018','019','020','021','022','023','024');
lightport($tabint,$ip1);
?>
</td>
<td>
<img src="images/2950_09.gif" width="20" height="36" alt=""></td>
<td>
<?php
$tabint=array('101','102'); //'501' ???
lightport($tabint,$ip1);
?>
</td>
<td>
<img src="images/2950_11.gif" width="33" height="36" alt=""></td>
</tr>
<tr>
<td colspan="8">
<img src="images/2950_12.gif" width="645" height="10" alt=""></td>
</tr>
</table>
<br><br>
<table id="Tableau_01" width="731" height="79" border="0" cellpadding="0" cellspacing="0">
<tr>
<td rowspan="3">
<img src="images/2950_01.gif" width="64" height="79" alt=""></td>
<td colspan="8">
<img src="images/2950_022.gif" width="645" height="33" alt=""></td>
<td rowspan="3">
<img src="images/2950_03.gif" width="22" height="79" alt=""></td>
</tr>
<tr>
<td>
<?php
$tabint=array('001','002','003','004','005','006','007','008');
lightport($tabint,$ip2);
?>
</td>
<td>
<img src="images/2950_05.gif" width="10" height="36" alt=""></td>
<td>
<?php
$tabint=array('009','010','011','012','013','014','015','016');
lightport($tabint,$ip2);
?>
</td>
<td>
<img src="images/2950_07.gif" width="10" height="36" alt=""></td>
<td>
<?php
$tabint=array('017','018','019','020','021','022','023','024');
lightport($tabint,$ip2);
?>
</td>
<td>
<img src="images/2950_09.gif" width="20" height="36" alt=""></td>
<td>
<?php
$tabint=array('101','102'); //'501' ???
lightport($tabint,$ip2);
?>
</td>
<td>
<img src="images/2950_11.gif" width="33" height="36" alt=""></td>
</tr>
<tr>
<td colspan="8">
<img src="images/2950_12.gif" width="645" height="10" alt=""></td>
</tr>
</table>
</body>
</html>
L'erreur donnée est : Fatal error: Maximum execution time of 30 seconds exceeded in C:\cacti\snmp\index.php on line 32
Quelqu'un peut m'aider ?
--
Peut être donnons tous le meilleur de nous même a ceux qui de leur coté de ne nous accordent que rarement une pensée.