Visualizzazione dei risultati da 1 a 9 su 9

Discussione: Server status

  1. #1
    Utente di HTML.it L'avatar di ispuk
    Registrato dal
    Jan 2009
    Messaggi
    1,026

    Server status

    ragazzi so che passerò per il re del copia e incolla ma c'è qualcuno che conosce qualche buono script php per avere il maggior numero di informazioni sul server del proprio sito?

    ho creato un area per vedere lo stato del server ma non ho voglia di cercarmi tutte le possibili funzioni per trovare semplici informazioni di status del server

    magari se partissi da una base a quel punto la potrei espandere a mio piacimento

    vi ringrazio dell'eventuale aiuto


  2. #2
    Utente di HTML.it L'avatar di bubi1
    Registrato dal
    Dec 2009
    Messaggi
    1,230
    phpsysinfo?

  3. #3
    Utente di HTML.it L'avatar di ispuk
    Registrato dal
    Jan 2009
    Messaggi
    1,026
    grazie ,è molto valido ma sinceramente cercavo uno script molto più leggero ,anche di un unica pagina di codice, vorrei una tabellina semplice semplice con le informazioni principali sullo stato del server,ma mi sembra di capire che si fa prima a scriverselo eh....

  4. #4
    mmm ... direi che se metti su munin è un'ottima cosa
    The fastest Redis alternative ... cachegrand! https://github.com/danielealbano/cachegrand

  5. #5
    Utente di HTML.it L'avatar di ispuk
    Registrato dal
    Jan 2009
    Messaggi
    1,026
    ciao danile grazie della info anche a te,ho scaricato munin e dalla demo devo dire che sembra molto appetitoso

    il problema è che non capisco come integrarlo in una pagina .php

    ma in che linguaggio è scritto?

    hai qualche link per l'installazione /integrazione?

    ti ringrazio molto

  6. #6
    munin lo trovi, sicuramente, come pacchetto per la distribuzione che usi sul tuo server

    devi installare munin-node, la configurazione di default generalmente contiene tutto lo scibile, e poi munin.

    Munin node serve ad acquisire le informazioni sul sistema mentre munin serve a connettersi ai vari nodi, acquisire le informazioni dei sistemi remoti (o locale, indifferente), creare i grafici e creare le pagine html con dentro i grafici

    se invece ti serve SOLO acquisire le info per gestirtele poi per i fatti tuoi puoi più semplicemente connetterti al nodo munin o ancora più semplicemente lanciare, tramite i backtick o qualsiasi altra chiamata di php che lancia degli script restituendo l'output, che trovi dentro /etc/munin/plugins.d (se non erro), per avere tutte le informazioni che vuoi sul sistema

    Però, connettersi al nodo di munin è sicuramente una soluzione migliore ... tramite socket ... la comunicazione è estremamente banale

    munin ha plugin per una marea di roba!

    Qui trovi come scrivere plugins e come richiedere informazioni al nodo munin
    http://munin.projects.linpro.no/wiki/HowToWritePlugins

    qui un esempio
    codice:
    # telnet localhost 4949
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    # munin node at foo.example.com
    fetch load
    load.value 0.06
    .
    quit
    Qui trovi altre info come effettuare richieste verso munin-node
    http://munin.projects.linpro.no/wiki..._Munin_plugins

    Volendo puoi tranquillamente utilizzare i grafici che crea lui
    The fastest Redis alternative ... cachegrand! https://github.com/danielealbano/cachegrand

  7. #7
    Utente di HTML.it L'avatar di ispuk
    Registrato dal
    Jan 2009
    Messaggi
    1,026
    ok grazie delle info esaurienti proverò a fare qualcosa ma mi sembra tutto molto complicato,almeno per le mie conoscenze attuali

    grazie mille davvero!!

  8. #8
    pardon, il percorso corretto è
    /etc/munin/plugin

    cmq, mi son messo è ho scritto questa classettina, la pubblichero a breve sul mio sito

    codice:
    <?php
    /**
     * Copyright (c) 2010 Daniele Salvatore Albano.
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     * 1. Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     * 2. Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * THIS SOFTWARE IS PROVIDED BY ALBANO DANIELE SALVATORE AND CONTRIBUTORS
     * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     * POSSIBILITY OF SUCH DAMAGE.
     **/
    
    class Phunin
    {
        const COMMAND_VERSION   = 'version';
        const COMMAND_NODES     = 'nodes';
        const COMMAND_LIST      = 'list';
        const COMMAND_CONFIG    = 'config';
        const COMMAND_FETCH     = 'fetch';
    
        private $socket;
        
        public function __construct($Hostname, $Port)
        {
            // Try to connect to munin node
            $this->ConnectTo($Hostname, $Port);
        }
        
        public function Version()
        {
            return $this->SendCommand(Phunin::COMMAND_VERSION);
        }
        
        public function Nodes()
        {
            return $this->SendCommand(Phunin::COMMAND_NODES);
        }
        
        public function ListPlugins()
        {
            return $this->SendCommand(Phunin::COMMAND_LIST);
        }
        
        public function Config($PluginName)
        {
            return $this->SendCommand(Phunin::COMMAND_CONFIG, trim($PluginName));
        }
        
        public function Fetch($PluginName)
        {
            return $this->SendCommand(Phunin::COMMAND_FETCH, trim($PluginName));
        }
        
        private function ConnectTo($Hostname, $Port)
        {
            // Prepare the socket to connect to remote munin node
            $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
            
            // Do connect
            if (socket_connect($this->socket, $Hostname, $Port) === false)
            {
                throw new Exception(sprintf("Unable to connect to %s:%s", $Hostname, $Port));
            }
            
            // Initialize buffer
            $data = '';
            
            // Read data from socket
            while(($buffer = socket_read($this->socket, 8 * 1024)) !== false)
            {
                // Acquire buffer
                $data .= $buffer;
                
                // Check for \n
                if (substr($data, 0, 16) === '# munin node at ')
                {
                    if (strpos("\n", $data) === false)
                    {
                        return true;
                    }
                    else
                    {
                        if (strlen($data) > 192)
                        {
                            throw new Exception(sprintf("Wrong answer from remote munin node"));
                        }
                    }
                }
                else
                {
                    throw new Exception(sprintf("Wrong answer from remote munin node"));
                }
            }
        }
        
        private function SendCommand($Command, $Argument = false)
        {
            // Check command
            switch($Command)
            {
                case Phunin::COMMAND_VERSION:
                case Phunin::COMMAND_NODES:
                case Phunin::COMMAND_LIST:
                    break;
    
                case Phunin::COMMAND_CONFIG:
                case Phunin::COMMAND_FETCH:
                    
                    if ($Argument == false)
                    {
                        throw new Exception(sprintf("Missing argument for command %s", $Command));
                    }
                    break;
                
                default:
                    throw new Exception(sprintf("Unknown command %s", $Command));
                    break;
            }
            
            // Try to send command
            if (socket_write($this->socket, $Command . ($Argument !== false ? ' ' . $Argument : '') . "\n") == 0)
            {
                throw new Exception(sprintf("Unable to send command %s", $Command));
            }
            
            // Wait for answer
            return $this->ReadAnswer($Command);
        }
        
        private function ReadAnswer($Command)
        {
            // Check command
            switch($Command)
            {
                case Phunin::COMMAND_VERSION:
                case Phunin::COMMAND_LIST:
                    $endsWithDot = false;
                    $charsToStrip = 1;
                    break;
    
                case Phunin::COMMAND_NODES:
                case Phunin::COMMAND_CONFIG:
                case Phunin::COMMAND_FETCH:
                    $endsWithDot = true;
                    $charsToStrip = 3;
                    break;
            }
    
            // Initialize data
            $data = '';
            
            // Read data from socket
            while(($buffer = socket_read($this->socket, 8 * 1024)) !== false)
            {
                // Acquire buffer
                $data .= $buffer;
                
                if (substr($data, -$charsToStrip) == ($endsWithDot == true ? "\n." : '') . "\n")
                {
                    $data = substr($data, 0, -$charsToStrip);
                    break;
                }
                else if (strlen($data) > 16 * 1024)
                {
                    throw new Exception(sprintf("Wrong answer from remote munin node"));
                }
            }
            
            // Split data
            switch($Command)
            {
                case Phunin::COMMAND_VERSION:
                    return $data;
                    break;
                    
                case Phunin::COMMAND_LIST:
                    echo $data;
                    return explode(' ', $data);
                    break;
    
                case Phunin::COMMAND_NODES:
                case Phunin::COMMAND_CONFIG:
                case Phunin::COMMAND_FETCH:
                    return explode("\n", $data);
                    break;
            }
        }
    }
    
    $phunin = new Phunin('192.168.1.15', 4949);
    var_dump($phunin->ListPlugins());
    echo "
    ";
    var_dump($phunin->Config('df'));
    echo "
    ";
    var_dump($phunin->Fetch('df'));
    echo "
    ";
    
    ?>
    come puoi vedere è estremamente semplice
    The fastest Redis alternative ... cachegrand! https://github.com/danielealbano/cachegrand

  9. #9
    Utente di HTML.it L'avatar di ispuk
    Registrato dal
    Jan 2009
    Messaggi
    1,026
    bhe se dovesse trattarsi di inserire solamente questa parte di codice all'interno della pagina allora sarebbe davvero semplice la storia....per tutto il resto c'è mastercard ehehhe

    ma basta inserire il codice nella pagina che si vuole?

    guarda sarebbe una manna dal cielo!!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.