webhostingtalk.nl
advertentie
advertentie

Evenementen voor de komende 60 Dag(en)

Resultaten 1 tot 5 van de 5
          

  1.  
    #1
    Anoniem
    4 Berichten zijn liked




    Gezocht: SNMP reboot IpoMan 1201

    Langzaam maar zeker is het de bedoeling om over te gaan op de IpoMan remote reboot oplossingen. Op dit moment draait het op apparatuur van APC, maar deze gaat dus vervangen worden.

    Dit zal ook betekenen dat we ons CP aan moeten gaan passen - en voor een klein deel wil ik hier graag iemand voor inhuren. Het gaat mij puur om de aanpassing zodat we in plaats van de onderstaande code een variant kunnen gebruiken die aansluit bij de IpoMan.

    Omdat voor niets de zon op gaat is het geen probleem om hier voor te betalen; zolang de geboden oplossing werkt. Graag wil ik ook terug kunnen vallen op hetzelfde bedrijf/persoon bij het configureren van MRTG. Er zijn wat twijfels over de gevonden voorbeelden namelijk.

    De code die wij nu gebruiken is simpel:

    PHP Code:
    $reboot snmpset($ip$snmp$mibi3); 


  2.  
    #2
    geregistreerd gebruiker
    2.468 Berichten
    Ingeschreven
    03/09/08

    Locatie
    Maasbracht

    31 Berichten zijn liked

    Piwi-Web is offline.

    Bedrijf: Piwi-Web
    Functie: Eigenaar
    URL: www.piwi-web.com
    KvK nummer: 14097251

    Ipoclass is gewoon op het I-net te vinden.
    Zie hieronder de code:

    Code:
    <?php
    
    require_once "HttpClient.class.php";
    
    /**
     * This class switches the Ingrasys IpoMan 1200 outlets from PHP.
     *
     * The HttpClient class from Incutio is required:
     * http://scripts.incutio.com/httpclient/
     *
     * Be aware that we use plain HTTP, so the communication is not
     * encrypted. For security reasons you should not use this class
     * through a public access network.
     *
     * @version 1.1 (May 8, 2008)
     * @author Stefan Mensink <opensource@basemotive.nl>
     * @copyright Basemotive V.O.F.
     */
    class IpoMan {
    	private $ipaddress = null;
    	private $username = null;
    	private $password = null;
    	private $immediateswitching = null;
    	private $client = null;
    
    	/**
    	 * Constructs the IpoMan class
    	 *
    	 * @param string $ipaddress The IP-address (or hostname) for the IpoMan
    	 * @param string $username The username to authenticate with
    	 * @param string $password The username to authenticate with
    	 * @param boolean $immediateswitching Whether or not we want to temporary set the on/off delays to 0 when switching an outlet
    	 */
    	public function __construct($ipaddress, $username, $password, $immediateswitching=false) {
    		$this->ipaddress = $ipaddress;
    		$this->username = $username;
    		$this->password = $password;
    		$this->immediateswitching = $immediateswitching;
    
    		$this->client = new HttpClient($ipaddress);
    		$this->client->setAuthorization($username, $password);
    	}
    
    	/**
    	 * Turns an outlet off and on.
    	 *
    	 * @param integer $outlet The outlet number to switch, 0 is the first outlet, 11 is the last
    	 * @param integer $delay The delay between switching off and on in seconds
    	 */
    	public function resetOutlet($outlet, $delay=1) {
    		// Set outlet on/off delays to 0
    		if ($this->immediateswitching) {
    			$outletSettings = $this->getOutletSettings();
    
    			if ($outlet < 2) $outletonid = "XAAAAAAABADL".chr(ord('A')+$outlet+14);
    			else $outletonid = "XAAAAAAABADM".chr(ord('A')+$outlet-2);
    			$outletoffid = "XAAAAAAABADL".chr(ord('A')+$outlet+2);
    
    			if ($outletSettings[$outletonid]!="0" || $outletSettings[$outletoffid]!="0") {
    				$tmpOutletSettings = $outletSettings;
    				$tmpOutletSettings[$outletonid] = "0";
    				$tmpOutletSettings[$outletoffid] = "0";
    				$this->setOutletSettings($tmpOutletSettings);
    				var_dump($tmpOutletSettings);
    
    				$needRestoreOutletSettings = true;
    			} else {
    				$needRestoreOutletSettings = false;
    			}
    		}
    
    		// Turn outlet off
    		$callarray = array();
    		for ($i=0; $i<12; $i++) {
    			$outletid = "XAAAAAAABOEB".chr(ord('A')+$i);
    			$callarray[$outletid] = ($outlet==$i ? "3" : "1");
    		}
    		$this->client->post('/PageControl.htm', $callarray);
    
    		sleep($delay);
    
    		// Turn outlet on
    		$callarray = array();
    		for ($i=0; $i<12; $i++) {
    			$outletid = "XAAAAAAABOEB".chr(ord('A')+$i);
    			$callarray[$outletid] = ($outlet==$i ? "2" : "1");
    		}
    		$this->client->post('/PageControl.htm', $callarray);
    
    		// Restore default outlet settings
    		if ($this->immediateswitching && $needRestoreOutletSettings) {
    			$this->setOutletSettings($outletSettings);
    		}
    	}
    
    	/**
    	 * Turns an outlet on.
    	 *
    	 * @param integer $outlet The outlet number to switch, 0 is the first outlet, 11 is the last
    	 */
    	public function switchOn($outlet) {
    		// Make sure we have something to do
    		if ($this->getOutletStatus($outlet)=="1") return;
    
    		// Set outlet on delay to 0
    		if ($this->immediateswitching) {
    			$outletSettings = $this->getOutletSettings();
    
    			if ($outlet < 2) $outletonid = "XAAAAAAABADL".chr(ord('A')+$outlet+14);
    			else $outletonid = "XAAAAAAABADM".chr(ord('A')+$outlet-2);
    
    			if ($outletSettings[$outletonid]!="0") {
    				$tmpOutletSettings = $outletSettings;
    				$tmpOutletSettings[$outletonid] = "0";
    				$this->setOutletSettings($tmpOutletSettings);
    				$needRestoreOutletSettings = true;
    			} else {
    				$needRestoreOutletSettings = false;
    			}
    		}
    
    		// Turn outlet on
    		$callarray = array();
    		for ($i=0; $i<12; $i++) {
    			$outletid = "XAAAAAAABOEB".chr(ord('A')+$i);
    			$callarray[$outletid] = ($outlet==$i ? "2" : "1");
    		}
    
    
    		$this->client->post('/PageControl.htm', $callarray);
    
    		// Restore default outlet settings
    		if ($this->immediateswitching && $needRestoreOutletSettings) {
    			$this->setOutletSettings($outletSettings);
    		}
    	}
    
    	/**
    	 * Turns an outlet off.
    	 *
    	 * @param integer $outlet The outlet number to switch, 0 is the first outlet, 11 is the last
    	 */
    	public function switchOff($outlet) {
    		// Make sure we have something to do
    		if ($this->getOutletStatus($outlet)=="0") return;
    
    		// Set outlet off delay to 0
    		if ($this->immediateswitching) {
    			$outletSettings = $this->getOutletSettings();
    
    			$outletoffid = "XAAAAAAABADL".chr(ord('A')+$outlet+2);
    
    			if ($outletSettings[$outletoffid]!="0") {
    				$tmpOutletSettings = $outletSettings;
    				$tmpOutletSettings[$outletoffid] = "0";
    				$this->setOutletSettings($tmpOutletSettings);
    				$needRestoreOutletSettings = true;
    			} else {
    				$needRestoreOutletSettings = false;
    			}
    		}
    
    		// Turn outlet off
    		$callarray = array();
    		for ($i=0; $i<12; $i++) {
    			$outletid = "XAAAAAAABOEB".chr(ord('A')+$i);
    			$callarray[$outletid] = ($outlet==$i ? "3" : "1");
    		}
    		$this->client->post('/PageControl.htm', $callarray);
    
    		// Restore default outlet settings
    		if ($this->immediateswitching && $needRestoreOutletSettings) {
    			$this->setOutletSettings($outletSettings);
    		}
    	}
    
    	/**
    	 * Retrieves the outlet status.
    	 *
    	 * @param integer $outlet The outlet number to retrieve the status for; if ommitted, all outlet statuses are returned
    	 * @return array All outlet statuses, or an integer if a specific outlet was specified
    	 */
    	public function getOutletStatus($outlet='') {
    		$result = array();
    
    		$this->client->get("/Outlet.js");
    		$content = $this->client->getContent();
    		$content_split = explode("\n", $content);
    		foreach ($content_split as $line) {
    			if (strpos($line, "var  Power_status") !== false) {
    				$pos1 = strpos($line, '(');
    				$pos2 = strpos($line, ')');
    				$arraypart = substr($line, $pos1+1, $pos2-$pos1-1);
    				$outletstatusarray = explode(',', $arraypart);
    				foreach ($outletstatusarray as $status) {
    					$result[] = ($status=='"power on"'?1:0);
    				}
    			}
    		}
    
    		if ($outlet!='')
    			return $result[$outlet];
    		else
    			return $result;
    	}
    
    	/**
    	 * Retrieves the value for a form element from the PageControl html.
    	 */
    	private function getContentValue($content, $id) {
    		$pos = strpos($content, $id);
    		$pos2 = strpos($content, 'VALUE="', $pos)+7;
    		$pos3 = strpos($content, '"', $pos2);
    		$value = substr($content, $pos2, $pos3-$pos2);
    		return $value;
    	}
    
    	/**
    	 * Retrieves all the outlet settings from the IpoMan as an array, so we can post it
    	 * again.
    	 */
    	private function getOutletSettings() {
    		$result = $this->client->get("/PageControl.htm");
    		$content = $this->client->getContent();
    
    		$outletSettings = array();
    		
    		for ($i=0; $i<12; $i++) {
    			// Outlet Name
    			$outletid = "XAAAAAAABADJ".chr(ord('A')+$i+1);
    			$outletSettings[$outletid] = $this->getContentValue($content, $outletid);
    			// Outlet Location
    			$outletid = "XAAAAAAABADK".chr(ord('A')+$i+1);
    			$outletSettings[$outletid] = $this->getContentValue($content, $outletid);
    			// Power on Delay (secs)
    			if ($i < 2) $outletid = "XAAAAAAABADL".chr(ord('A')+$i+14);
    			else $outletid = "XAAAAAAABADM".chr(ord('A')+$i-2);
    			$outletSettings[$outletid] = $this->getContentValue($content, $outletid);
    			// Power off Delay (secs)
    			$outletid = "XAAAAAAABADL".chr(ord('A')+$i+2);
    			$outletSettings[$outletid] = $this->getContentValue($content, $outletid);
    			// Output current threshold
    			$outletid = "XAAAAAAABADG".chr(ord('A')+$i+1);
    			$outletSettings[$outletid] = $this->getContentValue($content, $outletid);
    		}
    
    		return $outletSettings;
    	}
    
    	/**
    	 * Sets all the outlet settings to the values given in the array.
    	 */
    	private function setOutletSettings($outletSettings) {
    		$this->client->post('/PageControl.htm', $outletSettings);
    	}
    
    	public function dump() {
    		//$result = $this->client->get("/PagePDUStatus.htm");
    		$result = $this->client->get("/OutletTableStatus.js");
    		$content = $this->client->getContent();
    		echo $content."\n\n";
    	}
    
    }
    
    ?>
    Je hebt er ook de httpclient voor nodig. Die is te vinden door even simpel te googlen

    Poort aanzetten:
    Code:
    $object = new IpoMan($row['IP'],"admin","wachtwoord");
    				 $object->switchOn($ipo_out);
    Poort uitzetten:
    Code:
    $object = new IpoMan($row['IP'],"admin","wachtwoord");
    				 $object->switchOff($ipo_out);
    Poort resetten:
    Code:
    $object = new IpoMan($row['IP'],"admin","wachtwoord");
    				 $object->resetOutlet($ipo_out);
    Ik hoop dat je hier iets aan hebt
    Gewoon de class includen en dan spelen maar!

    EDIT: Ik bied mij trouwens ook aan als ik het voor je moet inbouwen (zie nu pas dat dit in aanbiedingen gezocht staat!)


  3.  
    #3
    Anoniem
    4 Berichten zijn liked




    Het inbouwen van die class moet wel lukken, alleen had ik gehoopt dat we dit via SNMP konden doen. Via HTTP is nogal 'dirty' als je het mij vraagt. Maar dat is niet mogelijk blijkbaar? Anders hou ik mij nog steeds aanbevolen. Mocht dat niet kunnen is het geen probleem om dit in te bouwen. Overigens zal dit puur een code snippet worden, de benodigde variabelen en velden worden gewoon door ons aangeleverd. Inbouwen zullen wij daarna zelf oppakken.

    Dan blijft MRTG over. MRTG is overigens noodzakelijk in verband met onze SQL monitoring. Tenzij iemand beschikt over een tool die het apparaat kan uitlezen en het KWh verbruik naar SQL kan sturen.

  4. advertentie



  5.  
    #4
    Wijtec
    228 Berichten
    Ingeschreven
    15/08/04

    Locatie
    's-Gravenzande

    0 Berichten zijn liked

    PreServer is offline.

    Registrar SIDN: nee
    KvK nummer: 27269292
    Ondernemingsnummer: nvt

    Beste GetUp,

    Wij hebben net een ipoman snmp class ontwikkeld voor ons nieuwe control panel.
    De class is lekker simpel en heeft geen andere dependencies dan php-snmp

    Het gebruik is als simpel als:

    <?php

    require_once 'ipoman.php';

    $ipoman = new ipoman($hostname, $snmp_write_community);
    $ipoman->on($port);

    ?>

    de volgende functies zijn beschikbaar in de class:

    isOn($port)
    isOff($port)

    on($port, $sync = true)
    off($port, $sync = true)
    cycle($port, $wait = 5000, $sync = true)

    status()

    De prijs van deze class is 95 euro ex btw voor een geencode versie en 195 euro voor de source

    Mrtg/cacti configuren is ook geen probleem, deze is bij ons ook uitgebreider dan de voorbeelden die op internet te vinden zijn

    Voor meer informatie of vragen kunt u mij een pm sturen,

    Met vriendelijke groet,

    Wijtec


  6.  
    #5
    Wijtec
    228 Berichten
    Ingeschreven
    15/08/04

    Locatie
    's-Gravenzande

    0 Berichten zijn liked

    PreServer is offline.

    Registrar SIDN: nee
    KvK nummer: 27269292
    Ondernemingsnummer: nvt

    Op verzoek is de prijs verlaagd naar 145 euro en de class uitgebreid met de volgende functies:

    power ($port)
    current ($port)
    ckwh ($port)
    volt ()

    Mvg,

    Wijtec


Forum Rechten

  • Je mag geen nieuwe onderwerpen plaatsen
  • Je mag geen reacties plaatsen
  • Je mag geen bijlagen toevoegen
  • Je mag jouw berichten niet wijzigen
  •  



webhostingtalk.nl
Webhostingtalk.nl © copyright 2001-2013 Alle Rechten Gereserveerd.

Content Relevant URLs by vBSEO 3.6.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75