Re: APC memory utalization checker

From: Date: Sun, 17 Apr 2005 18:35:47 +0000
Subject: Re: APC memory utalization checker
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-2279@lists.php.net to get a copy of this message
Could you explain why you are using 3 segments? I never really understood the reason for that and have always just fixed my machines to a single segment in which case the avail_mem number is simple. -Rasmus Ammar Ibrahim wrote:
I want to monitor memory utalization percentage for APC, I want to be able to output the percentage as an integer, so that Nagios( Monitoring System) can read it and send a notification on high memory usage. Here's the script: <?php
        $info = apc_sma_info();
        $total_size = $info['num_seg'] * $info['seg_size'];
        $usage = ($total_size - $info['avail_mem']) / $total_size;
        $usage_percent = (int)($usage * 100);
        echo $usage_percent;
?> For some weird reason, i think that $info['avail_mem'] is not what what I thought it was. Do I need to iterate over all segments and read offsets and sum them? If so, Sometimes APC splits the segment. e.g. look at the first segment below Array (
    [num_seg] => 3
    [seg_size] => 31457280
    [avail_mem] => 79565368
    [block_lists] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [size] => 2104
                            [offset] => 5916888
                        )
                    [1] => Array
                        (
                            [size] => 16648752
                            [offset] => 14808520
                        )
                )
            [1] => Array
                (
                    [0] => Array
                        (
                            [size] => 31457256
                            [offset] => 16
                        )
                )
            [2] => Array
                (
                    [0] => Array
                        (
                            [size] => 31457256
                            [offset] => 16
                        )
                )
        )
)


« previous php.pecl.dev (#2279) next »