PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : کنترل منابع سرور از طریق ویبولتین



maht@b
October 25th, 2011, 12:44
به طوری کلی کنترل یک سایت از تمامی جوانب کاری بسیار مهم می باشد. در این آموزش شما با انجام یک سری کارها میتونید منابع سرور خودتون و کارکرد هرکدوم رو کنترل کنید و اگر هر کدوم از بخش ها دچار مشکلی بود بررسی کنید. این آموزش طبق گفته ی نویسنده ی اون برای وی بی 3 نوشته شده اما برای خیلی ها بر روی وی بی 4 هم کار کرده به درستی. برای انجام این کار به AdminCp خود برید. ایجاد یک پلاگین رو بزنید. admin_index_main3 رو انتخاب کنید و کد زیر را وارد کنید:



$memcache = new Memcache; foreach ($vbulletin->config['Misc']['memcacheserver'] as $key => $server) { $memcache->addServer($server, $vbulletin->config['Misc']['memcacheport'][$key], 1, 1, 1, 15, true); } $stats = $memcache->getExtendedStats(); $memcache->close(); $labels = array ( 'host' => 'Host', 'pid' => 'PID', 'uptime' => 'Daemon Uptime', 'time' => 'Server Time', 'version' => 'Version', 'pointer_size' => 'Pointer Bits', 'rusage_user' => 'RUsage User', 'rusage_system' => 'RUsage System', 'curr_items' => 'Current Items', 'total_items' => 'Total Items', 'bytes' => 'Memory Used', 'curr_connections' => 'Current Connections', 'total_connections' => 'Total Connections', 'connection_structures' => 'Connection Structures', 'cmd_flush' => 'Flushes', 'cmd_get' => 'Gets', 'cmd_set' => 'Sets', 'get_hits' => 'Get Hits', 'get_misses' => 'Get Misses', 'delete_hits' => 'Delete Hits', 'delete_misses' => 'Delete Misses', 'incr_hits' => 'Increment Hits', 'incr_misses' => 'Increment Misses', 'decr_hits' => 'Decrement Hits', 'decr_misses' => 'Decrement Misses', 'cas_hits' => 'CAS Hits', 'cas_misses' => 'CAS Misses', 'cas_badval' => 'CAS Bad Value', 'auth_cmds' => 'Auth Commands', 'auth_errors' => 'Auth Errors', 'evictions' => 'Evictions', 'reclaimed' => 'Reclaimed', 'bytes_read' => 'Data Read In', 'bytes_written' => 'Data Written Out', 'limit_maxbytes' => 'Memory Allocated', 'threads' => 'Threads', 'accepting_conns' => 'Accepting Connections', 'conn_yields' => 'Connection Yields', 'listen_disabled_num' => 'Listening Disabled Num', 'latency' => 'Latency Test', ); $data = array('Host' => '', 'Latency Test' => '', 'Memory Allocated' => '', 'Memory Used' => '', 'Current Items' => '', 'Total Items' => ''); $i=1; foreach($stats as $key => $val) { if (is_array($val)) { $data[$labels['host']][] = $key; foreach($val as $key2 => $val2) { $data[$labels[$key2]][] = (strpos($key2, 'bytes') !== false) ? vb_number_format($val2, 2, true) . iif (preg_match("#(bytes_read|bytes_written)#si", $key2), ' (' . vb_number_format(intval($val2/$val['uptime']), 2, true) . '/sec)') : ($key2 == 'time' ? date("M j, Y, G:i:s", $val2) : (preg_match("#(curr_items|total_items|curr_connections|total_co nnections|connection_structures|cmd_get|cmd_set|ge t_hits|get_misses)#si", $key2) ? number_format($val2) : ($key2 == 'uptime' ? intval($val2 / 86400) . 'd, ' . intval(($val2 % 86400) / 3600) . 'h, ' . intval(($val2 % 3600) / 60) . 'm, ' . intval($val2 % 60) . 's' : $val2))) . iif (preg_match("#(total_connections|cmd_get|cmd_set|bytes_read|byt es_written|get_hits|get_misses)#si", $key2), ' (' . intval($val2/$val['uptime']) . '/sec)'); } $latency = microtime(); $memcache = new Memcache; $memcache->addServer($vbulletin->config['Misc']['memcacheserver'][$i]); $set = $memcache->set('latency-test', 'some value', 0, 10); $get = $memcache->get('latency-test'); $memcache->close(); $data[$labels['latency']][] = round ((microtime() - $latency) * 1000, 4) . ' ms'; $i++; } } print_table_start(); print_table_header('Memcached Servers', count($stats) + 1); foreach($data as $key => $val) { print_cells_row(array_merge((array)"<strong>$key</strong>", $val), 0, 0, -5, 'top', 0, 1); } print_table_footer(2, '', '', false);