Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


ServerStatus - Page 2
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

ServerStatus

2

Comments

  • chrispchrisp Member
    edited November 2013

    Phew I finally managed to do use mojeda without MySQL. I use it when I change my configuration though. So I just have to start MySQL when regenerating the json file.

    It's running very fast now as I assumed. From 46MB used RAM to 24MB. This is very much on a 64MB Ram VPS. It would be nice if @Mojeda could work on a MySQL-Free version with a nagios-like configuration or json i don't care, but MySQL is really oversized here.

    Here is what I did:

    1. set SQL charset to UTF-8

    mysql_connect($host, $user, $pass) or die(mysql_error());
    mysql_select_db($data) or die(mysql_error());
    mysql_query('SET CHARACTER SET utf8');
    
    //Template options: "default" and "dark"
    $template = "./templates/dark/";
    

    2. Generate .json file containing all the servers from database

    include('./includes/config.php');
    global $sJavascript, $sTable;
    
    $query = mysql_query("SELECT * FROM servers ORDER BY id") or die(mysql_error());
    
    // BEGIN .json creation
    while( $row = mysql_fetch_array( $query ) ) {
        $json[] = $row;
    }
    
    file_put_contents("data.json", json_encode( $json ));
    // END 
        $sJavascript .= '<script type="text/javascript">
    

    Run ServerStatus in your browser once and you should see data.json has been created. Then...

    3. Replace SQL SELECT by array creation from json file

    In index.php, replace

    $query = mysql_query("SELECT * FROM servers ORDER BY id") or die(mysql_error());
    

    by

    $in = file_get_contents("data.json");
    $array = json_decode($in, true);
    

    and instead of

    while($result = mysql_fetch_array($query)){
    

    load data with

     while (list(, $result) = each($array)) {
    

    For correct UTF displaying i set
    header("Content-Type: text/html; charset=utf-8");
    right after <?php as well.

    4. Modifications to pull/index.php file

    Add new function right under get_data($url)

    function entryByID($Arr,$ID) {
      return array_values(array_filter($Arr, function($arrayValue) use($ID) { return $arrayValue['id'] == $ID; } ))[0];
    }
    

    then comment out those 2 mysql lines (mysql_query and mysql_fetch) or replace it by the json loader like in index.php

    $sId = $_GET['url'];
    if(is_numeric($sId)){
            //$data = mysql_query("SELECT * FROM servers WHERE id='$sId'");
            //$result = mysql_fetch_array($data);
    
            $in = file_get_contents("../data.json");
            $array = json_decode($in, true);
    
            $result = entryByID($array,$sId);
    

    ok and last part..

  • chrispchrisp Member
    edited November 2013

    5. Comment out mysql parts in includes/config.php

    So just comment it out like this:

    /*
    $host = 'localhost';
    $user = 'mojeda';
    $pass = 'xxxxx';
    $data = 'mojeda';
    */
    
    $sSetting['refresh'] = "10000";
    
    
    /*
    mysql_connect($host, $user, $pass) or die(mysql_error());
    mysql_select_db($data) or die(mysql_error());
    mysql_query('SET CHARACTER SET utf8');
    */
    

    And you should be good. Try shutting down your mysql and see if everything still works. Fix small errors I forgot to mentio here maybe. Build yourself a small script to generate future json files with new servers. Done.

    Oh and @mojeda. For v3 if it isn't too late I woul love it if you could use RRD for storing status information. It's small, never changes size when initially created (good for ramdisks) and it wouldn't require you to handle the cleanup of older status information yourself. AND you wouldn't need to use a "real" database. Just my 2 cents. Great work anyway!

  • @ErawanArifNugroho said:
    How do you partition the disk? Sometimes the script can only read the device with it's own permission/www-data. If another disk not detected, maybe you need to change the ownership of it :)

    change to root maybe???
    btw, I got only 3 partition.. the domain was hosted on the largest partiton which is 900GB++... and in virtualmin, I see all the partition was given to the domain..

  • how about like this? chown root:www-data?

  • SpeedyKVMSpeedyKVM Banned, Member

    Nice work. How well will this uptime/downtime alerts part scale?
    http://d.pr/i/YV7G/3jldTjM7

    If there are a ton of 1 minute outages will it show tons of messages on the screen, or only the most recent?

  • edited November 2013

    What script is that? Gordon/Incero

    If it's similar like my other monitoring script, then it will shows an alert everytime an outage detected.

    http://www.vpsdi.com/dashboard/events

  • drserverdrserver Member, Host Rep

    @ErawanArifNugroho
    Your script looks really nice

    Thanked by 1ErawanArifNugroho
  • @ErawanArifNugroho said:
    how about like this? chown root:www-data?

    can I just chown the current user holding the domain?? and how?

  • let say, the disk is /mnt/storage, how about?

    chown www-data:user /mnt/storage

  • @mojeda any chance of seeing v3 anytime soon?.. should include some sort of donate thing somewhere, im sure you would get a few.. :-P

  • mojedamojeda Member
    edited February 2014

    @AutoSniper I lost a lot of work on the control panel I had working so I need to redo it as well as further development, I'm trying to figure a better way that piling everything on for live refreshing vs. X minute incremental updates via a cron job.

    A few people seemed interest in Windows support so I've been looking into that a bit more but no idea how I'm going to get that to work with current setup.

    Edit:

    I don't really venture to LET that much anymore and I'll most likely opt to open an IRC channel somewhere soon.

  • mojeda said: I lost a lot of work on the control panel I had working so I need to redo it as well as further development, I'm trying to figure a better way that piling everything on for live refreshing vs. X minute incremental updates via a cron job.

    shame you lost a lot of work if you need some tips i can point you in the right direction just pm me

  • Never used it.

  • @mojeda
    Well is an awesome bit of software. Keeps me happy not having to sign in thru ssh to see what's going on.

    Might be an idea integrating vnstat or something to it as well as an option so you can see bandwidth usage as well.

  • @mojeda

    How much progress did you lose? Basically a restart from the last git commit or...?

  • @AutoSnipe I'm think I'm going to create a cron script to receive more detailed usage without having to rely on PHP so much for more detailed stuff.

    @HardCloud I lost all of my control panel code, but I have another working one that should work I just need to work on building some classes for servers and stuff.

  • Folks who are following/using or interested in Server Status I welcome you to register at my new development website for server status as well as well as any of my other projects such as Quick Gallery. We also have an IRC chat now as well!

    IRC: https://www.pilabs.io/chat/
    Forums: https://www.pilabs.io/forum/

    I also recommend people who have forked SS into their own version to share that as well :)

    Thanked by 1dedicados
  • bdtechbdtech Member
    edited February 2014

    I am seeing 0% HDD from php-fpm because it needs access to the root directory.

    PHP Warning: disk_free_space(): open_basedir restriction in effect. File(/) is not within the allowed path(s). Wow it needs read access to the whole root directory to populate disk space?

  • @bdtech Everything should work automatically if you've followed the installation instructions. I've installed many times before. Check everything twice.

    Thanked by 1WSS
  • bdtechbdtech Member
    edited February 2014

    @pbalazs123 You aren't probably restricting basedir. I always have it configured for every web app. For my status subdomain I have the web root and I added /proc/ as well

    php_admin_value[disable_functions] = dl,exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
    php_admin_value[open_basedir]=/home/user/www/status.domain.com/ServerStatus/:/proc/:/tmp

  • bdtechbdtech Member
    edited February 2014

    To enable HTTPS and support self-signed certs
    Edit: pull/index.php

    add curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    Replace
    $url = "http://" with $url = "".
    update your server URL(s) to include https:// or http:// protocol

    The main reason I'm doing this is because I want basic auth over HTTPS for ServerStatus. Alternatively, you can restrict by IP in uptime.php and the ServerStatus folder/vhost in NGINX. You could also overkill security a bit by passing/validating a salted key

    End result for Server URL:
    https://user123:[email protected]/

  • In the future I'm hoping to allow multiple methods of pulling data, not just via uptime.php to remove restrictions like PHP needing root access.

  • Is V3 available yet?

  • mojedamojeda Member
    edited February 2014

    @NodeJungle said:
    Is V3 available yet?

    No

  • @jarland said:
    Got it setup here: http://status.jarland.me/

    Looks dead to me :P

  • BotoX made a nice fork of it: https://github.com/BotoX/ServerStatus

    There are clients (python/bash), which are pushing data. Its not done via pulling at all. I quite like it, because you have live traffic as well.

  • Yup, I've been using the BotoX fork, so I wouldn't need to install PHP. I did find that the BotoX fork did run into some problems if I used it on a 32bit Ubuntu install (CPU did not report correct useage), but as soon I re-installed to 64bit everything started working.

  • BotoXBotoX Member

    @gutshotz
    Are you sure the 32bit issue is still happening when you grab the latest master server from my repo and recompile it?
    If you're still experiencing the same issue please let me know, since I thought that it has been fixed a few weeks ago.

    I sent you a python script a while ago, mojeda. Which removes the need of PHP+HTTPD on the "clients", I deleted it since I am not using it anymore but maybe you still have it? I'm sure a lot of people would like to avoid running PHP+HTTPD on every single server.

  • @mojeda waiting for version 3 is like forever -_-

  • @psycholyzern said:
    mojeda waiting for version 3 is like forever -_-

    Yep, any news on its release?

Sign In or Register to comment.