1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Server Status Script?

Discussion in 'Programming' started by hilljd00, Jan 15, 2010.

  1. #1
    Hey,

    I am trying to build a page for my server status, nice and simple.

    What i am looking for is a red/green light system and maybe a couple of other stats like server uptime.

    So if a service is down you get a red circle if the service is live you get a green circle... You get the idea

    What have you got or can reccomend me?

    Thank you
    Jon
     
    hilljd00, Jan 15, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php
    function cs($hostip, $port)
    {
            if (!$ifcs = @fsockopen($hostip, $port, $errno, $errstr, 1)) // attempt to connect
            {
                echo '<img src="/u/up.png" alt="Up" />';
            }
            else
            {
                echo '<img src="/u/down.png" alt="Down" />';
                if ($ifcs)
                {
                    @fclose($ifcs); //close connection
                }
            }
    }
    
    $u = shell_exec('uptime');
    ?>
    
    <h2>Server uptime</h2> <?php echo $u; ?><br />
    <h2>Current status</h2>
    HTTP: <?php cs('192.168.1.1','80'); ?><br />
    
    PHP:
     
    krsix, Jan 17, 2010 IP