]> git.openstreetmap.org Git - nominatim.git/blob - utils/blocks.php
make apt-get noninteractive. Also fixes the grub error state
[nominatim.git] / utils / blocks.php
1 #!/usr/bin/php -Cq
2 <?php
3
4 require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
5 require_once(CONST_BasePath.'/lib/init-cmd.php');
6 ini_set('memory_limit', '800M');
7
8 $aCMDOptions = array(
9     "Manage service blocks / restrictions",
10     array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
11     array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
12     array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
13     array('list', 'l', 0, 1, 0, 0, 'bool', 'List recent blocks'),
14     array('delete', 'd', 0, 1, 0, 0, 'bool', 'Clear recent blocks list'),
15     array('flush', '', 0, 1, 0, 0, 'bool', 'Flush all blocks / stats'),
16 );
17 getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
18
19 $m = getBucketMemcache();
20 if (!$m) {
21     echo "ERROR: Bucket memcache is not configured\n";
22     exit;
23 }
24
25 if ($aResult['list']) {
26     $iCurrentSleeping = $m->get('sleepCounter');
27     echo "\n Sleeping blocks count: $iCurrentSleeping\n";
28
29     $aBlocks = getBucketBlocks();
30     echo "\n";
31     printf(" %-40s | %12s | %7s | %13s | %31s | %8s\n", "Key", "Total Blocks", "Current", "Still Blocked", "Last Block Time", "Sleeping");
32     printf(" %'--40s-|-%'-12s-|-%'-7s-|-%'-13s-|-%'-31s-|-%'-8s\n", "", "", "", "", "", "");
33     foreach ($aBlocks as $sKey => $aDetails) {
34         printf(" %-40s | %12s | %7s | %13s | %31s | %8s\n", $sKey, $aDetails['totalBlocks'], 
35             (int)$aDetails['currentBucketSize'], $aDetails['currentlyBlocked']?'Y':'N', 
36             date("r", $aDetails['lastBlockTimestamp']), $aDetails['isSleeping']?'Y':'N');
37     }
38     echo "\n";
39 }
40
41 if ($aResult['delete']) {
42     $m->set('sleepCounter', 0);
43     clearBucketBlocks();
44 }
45
46 if ($aResult['flush']) {
47     $m->flush();
48 }