snmpset

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • snmpset

    Hallo,
    ich möchte mit Hilfe von snmpset einen Switch umkonfigurieren. Ich habe ein Listenfeld mit 3 Auswahlmöglichkeiten, das ausgewählte soll dann auf den Switch geschrieben werden. Jetzt frag ich mich, wie ich die Funktion genau einbinden soll.
    ------------------------------------------------------------------------------------
    <?php//snmpget system stats
    $host = "192.168.28.2";
    $community = "Kronus";
    $OID_1 = "IF-MIB::ifName";

    //snmpwalk mit html- Verschachtelung/Tabelle
    $sysinterface = snmpwalk($host, $community,$OID_1);
    $sysalias = snmpwalk($host, $community,"IF-MIB::ifAlias");
    $sysspeed = snmpwalk($host, $community,"IF-MIB::ifHighSpeed");
    $sysstate = snmpwalk($host,$community,"CISCO-C2900-MIB::c2900PortDuplexState");
    $sysstatus = snmpwalk($host,$community,"CISCO-C2900-MIB::c2900PortDuplexStatus");
    $sysindex = snmpwalk($host, $community,"IF-MIB::ifIndex");
    $syson = snmpwalk($host, $community,"IF-MIB::ifOperStatus");
    $set = snmpset($host, $community,".1.3.6.1.4.1.9.9.87.1.4.1.1.31","CISCO-C2900-MIB::c2900PortDuplexStatus","i","1");
    $verändern = snmpset($host, $community,"CISCO-C2900-MIB::c2900PortDuplexStatus","CISCO-C2900-MIB::c2900PortDuplexStatus","i","2");

    //get system name
    $sysname = snmpget($host, $community,"system.sysName.0");

    //get system uptime
    $sysup = snmpget($host, $community,"system.sysUpTime.0");
    $sysupre = eregi_replace("([0-9]{3})","",$sysup);
    $sysupre2 = eregi_replace("Timeticks:","",$sysupre);
    $sysupre3 = eregi_replace("[()]","",$sysupre2);

    echo '<p>
    System Name: '.ltrim($sysname,'STRING:').'<br>
    System Uptime: '.$sysupre3.'<br>
    Host: '.$host.'<br>
    Community: '.$community.'<br>
    <hr><p/>';

    //Tabelle
    echo "<form method=post action=snmpget.php><input type=submit value=Abschicken>
    <table border=1><tr><th>ifName</th><th>ifAlias</th><th>ifHighSpeed</th>
    <th>Link</th><th>Status</th><th>verändern</th><th>State</th>
    <th>konfigurieren</th></tr>";

    //echo "hier:" . $Status[3];FA 0/3-----Array Index 3-------Ausgabe Interface 4--------4=0123
    $i=0;
    for ($sysindex[$i] = 1; $i < count($sysindex)-3 ; $i++)
    {
    echo "<tr><td>";
    echo ereg_replace("STRING:","",$sysinterface[$i]);
    echo "</td><td>" . ltrim($sysalias[$i],"STRING:") . "</td><td>" . ltrim($sysspeed[$i],"Gauge32:") . "</td><td>";
    if (ltrim($syson[$i],"INTEGER: ") == "up(1)") {echo "up";}
    if (ltrim($syson[$i],"INTEGER: ") == "down(2)") {echo "down";}
    echo "</td><td>";
    if (ereg_replace("INTEGER: ","",$sysstatus[$i]) == "fullduplex(1)") {echo "full";}
    if (ereg_replace("INTEGER: ","",$sysstatus[$i]) == "halfduplex(2)") {echo "half";}

    echo "</td><td>";
    echo "<select name=State[]><option selected>";
    if ($State[$i] == "")
    {
    if (ereg_replace("INTEGER: ","",$sysstatus[$i]) == "fullduplex(1)") {echo "full";}
    if (ereg_replace("INTEGER: ","",$sysstatus[$i]) == "halfduplex(2)") {echo "half";}
    if (ereg_replace("INTEGER: ","",$sysstatus[$i]) == "autoNegotiate(3)") {echo "auto";}
    }
    else {echo $State[$i];}
    echo "</option>";
    echo "<option>half</option><option>full</option><option>auto</option></select>";
    $sysprin = ltrim($sysstatus[$i],'INTEGER: ');
    $sysprint = eregi_replace("[()]","",$sysprin);
    $sysprint1 = eregi_replace("duplex1","",$sysprint);
    $sysprint2 = eregi_replace("duplex2","",$sysprint1);
    $sysprint3 = eregi_replace("Negotiate3","",$sysprint2);
    if ($sysprint3 == $State[$i]) {echo "";}

    else {echo $State[$i];}
    echo "</td><td>";
    if (ereg_replace("INTEGER: ","",$sysstate[$i]) == "fullduplex(1)") {echo "full";}
    if (ereg_replace("INTEGER: ","",$sysstate[$i]) == "halfduplex(2)") {echo "half";}
    if (ereg_replace("INTEGER: ","",$sysstate[$i]) == "autoNegotiate(3)") {echo "auto";}
    echo "</td><td>";
    echo "<select name=Status[]><option selected>";
    if ($Status[$i] == "")
    {
    if (ereg_replace("INTEGER: ","",$sysstate[$i]) == "fullduplex(1)") {echo "full";}
    if (ereg_replace("INTEGER: ","",$sysstate[$i]) == "halfduplex(2)") {echo "half";}
    if (ereg_replace("INTEGER: ","",$sysstate[$i]) == "autoNegotiate(3)") {echo "auto";}
    }
    else {echo $Status[$i];}
    echo "</option>";
    echo "<option>half</option><option>full</option><option>auto</option></select>";
    $sysstar = ltrim($sysstate[$i],'INTEGER: ');
    $sysstates = eregi_replace("[()]","",$sysstar);
    $sysstates1 = eregi_replace("duplex1","",$sysstates);
    $sysstates2 = eregi_replace("duplex2","",$sysstates1);
    $sysstates3 = eregi_replace("Negotiate3","",$sysstates2);
    if ($sysstates3 == $Status[$i]) {echo "";}

    else {echo $Status[$i];}

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

    echo "</form>";
    }
    ?>
    -------------------------------------------------------------------------------------------------------------------------
    Danke im voraus
    Zuletzt geändert von PeterPan35; 07.06.2007, 01:05.

  • #2
    Bitte lies unsere Regeln, verwende PHP-Tags und achte darauf, dass man dann nicht horizontal scrollen muß. Vielen Dank.

    Kommentar

    Lädt...
    X