Activity Stream
48,167 MEMBERS
6543 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 3 of 3
  1.     
    #1
    Respected Developer
    Website's:
    X4B.org

    Default SplitIce Sever Process Checker

    This script restarts processes that have died/segfaulted. Wont protect against defuncts or anything like that but its a basic start. Also checks that certain processes dont exceed a set memory usage and if they do can execute a php function or shell command.

    Run via CLI, as root.

    PHP Code: 
    <?php
        
    /* SplitIce Sever Process Checker */
        /* Version: 1.2 */
        /* All distributed versions must keep this header intact */
        /* Need software development work? Contact me: fast, reasonable rates */

        
    $_CONFIG = array();

        
    /* Process is running checks */
        
    $_CONFIG['CHECKS'] = array(
        
    /* Substring to check for => Command to run if not found */
        
    'nginx: worker process'=>'/etc/init.d/nginx restart',
        
    'nginx: master process /usr/sbin/nginx'=>'/etc/init.d/nginx restart',

        
    '/usr/bin/php5-fpm'=>'/etc/init.d/php5-fpm restart',
        
    'searchd' => '/usr/local/bin/searchd'
        
    );

        
    /* Process memory limits */
        
    $_CONFIG['MEM'] = array(
        
    /* Substring to check for => array(max memory,command to run if exceeds) */
        /* Size in KB */
        /* if command is an array then it is treated as a callback (php function) */
        
    'searchd'=>array(1024*1024,array('searchd_restart'))
        );

        
    /* Example Callback for Memory checks */
        
    function searchd_restart($PID){
            
    /* This example deals with the memory leaks in the sphinx daemon */
            
    exec('killall searchd');//Nice kill
            
    exec('killall -2 searchd');//agrivated kill
            
    Sleep(1);
            
    exec('killall -3 searchd');//angy kill
            
    exec('killall -4 searchd');//skitzo kill
            
    passthru('/usr/local/bin/searchd');//reborn :D
        
    }

        
    /* Program Starts */
        
    function processes(){
            
    $processes = array();
            foreach(
    glob('/proc/*/cmdline') as $p){
                
    $pt explode('/',$p);
                if(
    is_numeric($pt[2])) {
                    if(
    $CMD file_get_contents($p)) {
                        
    $processes[$pt[2]] = trim($CMD);
                    }
                }
            }
            return 
    $processes;
        }
        
        function 
    process_mem($PID){
            
    $data file('/proc/'.$PID.'/status');
            foreach(
    $data as $v){
                if(!
    substr_compare($v,'VmRSS:',0,6)){
                    
    $t trim(substr($v,7));
                    
    $t trim(substr($t,0,strpos($t,' ')));
                    return (int)
    $t;
                }
            }
            return 
    false;
        }

        
    $CHECKS = array();
        while(
    true){
            
    $processes processes();
            foreach(
    $_CONFIG['CHECKS'] as $m=>$cmd){
                
    $check false;
                foreach(
    $processes as $PID=>$p){
                    if(
    stripos($p,$m)!==false){
                        
    $check true;
                        break;
                    }
                }
                if(!
    $check){
                    
    passthru($cmd);
                    
    Sleep(5);//Multi-Teired Check delay
                
    }
            }
            foreach (
    $_CONFIG['MEM'] as $process=>$data){
                
    $check false;
                foreach(
    $processes as $PID=>$p){
                    if(
    stripos($p,$process)!==false){
                        
    $check $PID;
                        break;
                    }
                }
                if(
    $check){
                    if(
    process_mem($check)>$data[0]){
                        if(
    is_array($data[1])){
                            
    call_user_func($data[1][0],$check);
                        }else{
                            
    passthru($data[1]);
                        }
                        
    Sleep(5);//Multi-Teired Check delay
                    
    }
                }
            }
            
    Sleep(30);
        }
    ?>
    SplitIce Reviewed by SplitIce on . SplitIce Sever Process Checker This script restarts processes that have died/segfaulted. Wont protect against defuncts or anything like that but its a basic start. Also checks that certain processes dont exceed a set memory usage and if they do can execute a php function or shell command. Run via CLI, as root. <?php /* SplitIce Sever Process Checker */ /* Version: 1.2 */ /* All distributed versions must keep this header intact */ /* Need software development work? Contact me: fast, reasonable rates Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    how to run it but?
    a little more explanation plz..

  4.     
    #3
    Respected Developer
    Website's:
    X4B.org
    Once you have set it up. Usually..

    on debian
    php5 server_process.php
    centos:
    php server_process.php

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Does anyone have SplitIce ioncube decoder?
    By soogoomoo in forum Web Development Area
    Replies: 10
    Last Post: 23rd Feb 2011, 11:14 AM
  2. [FREE] SplitIce's Crazy Giveaway [$5].
    By SplitIce in forum Completed Transactions
    Replies: 15
    Last Post: 5th Feb 2011, 12:55 PM

Tags for this Thread

BE SOCIAL