Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
2a775810
"simplesamlphp-upgrade-notes-1.10" did not exist on "e06eb9f3bbd7480625ac655619a442fb82e02f04"
Commit
2a775810
authored
6 years ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
bin: PSR2
parent
f9218078
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/memcacheSync.php
+33
-35
33 additions, 35 deletions
bin/memcacheSync.php
with
33 additions
and
35 deletions
bin/memcacheSync.php
+
33
−
35
View file @
2a775810
...
@@ -3,19 +3,19 @@
...
@@ -3,19 +3,19 @@
// Check that the memcache library is enabled
// Check that the memcache library is enabled
if
(
!
class_exists
(
'Memcache'
)
&&
!
class_exists
(
'Memcached'
))
{
if
(
!
class_exists
(
'Memcache'
)
&&
!
class_exists
(
'Memcached'
))
{
echo
(
"Error: the memcached (or memcache) PHP extension appears to be unavailable.
\n
"
)
;
echo
"Error: the memcached (or memcache) PHP extension appears to be unavailable.
\n
"
;
echo
(
"
\n
"
)
;
echo
"
\n
"
;
echo
(
"This is most likely because PHP doesn't load it for the command line
\n
"
)
;
echo
"This is most likely because PHP doesn't load it for the command line
\n
"
;
echo
(
"version. You probably need to enable it somehow.
\n
"
)
;
echo
"version. You probably need to enable it somehow.
\n
"
;
echo
(
"
\n
"
)
;
echo
"
\n
"
;
if
(
is_executable
(
'/usr/sbin/phpenmod'
))
{
if
(
is_executable
(
'/usr/sbin/phpenmod'
))
{
echo
(
"It is possible that running one of the following commands as root will fix it:
\n
"
)
;
echo
"It is possible that running one of the following commands as root will fix it:
\n
"
;
echo
(
" phpenmod -s cli memcached
\n
"
)
;
echo
" phpenmod -s cli memcached
\n
"
;
echo
(
" phpenmod -s cli memcache
\n
"
)
;
echo
" phpenmod -s cli memcache
\n
"
;
}
}
exit
(
1
);
exit
(
1
);
}
}
// This is the base directory of the SimpleSAMLphp installation
// This is the base directory of the SimpleSAMLphp installation
...
@@ -38,25 +38,24 @@ $stats = \SimpleSAML\Memcache::getRawStats();
...
@@ -38,25 +38,24 @@ $stats = \SimpleSAML\Memcache::getRawStats();
$keys
=
[];
$keys
=
[];
foreach
(
$stats
as
$group
)
{
foreach
(
$stats
as
$group
)
{
foreach
(
$group
as
$server
=>
$state
)
{
foreach
(
$group
as
$server
=>
$state
)
{
if
(
$state
===
false
)
{
if
(
$state
===
false
)
{
echo
(
"WARNING: Server "
.
$server
.
" is down.
\n
"
)
;
echo
"WARNING: Server "
.
$server
.
" is down.
\n
"
;
$warnServerDown
++
;
$warnServerDown
++
;
continue
;
continue
;
}
}
$items
=
$state
[
'curr_items'
];
$items
=
$state
[
'curr_items'
];
echo
(
"Server "
.
$server
.
" has "
.
$items
.
" items.
\n
"
)
;
echo
"Server "
.
$server
.
" has "
.
$items
.
" items.
\n
"
;
$serverKeys
=
getServerKeys
(
$server
);
$serverKeys
=
getServerKeys
(
$server
);
$keys
=
array_merge
(
$keys
,
$serverKeys
);
$keys
=
array_merge
(
$keys
,
$serverKeys
);
}
}
}
}
echo
(
"Total number of keys: "
.
count
(
$keys
)
.
"
\n
"
)
;
echo
"Total number of keys: "
.
count
(
$keys
)
.
"
\n
"
;
$keys
=
array_unique
(
$keys
);
$keys
=
array_unique
(
$keys
);
echo
(
"Total number of unique keys: "
.
count
(
$keys
)
.
"
\n
"
)
;
echo
"Total number of unique keys: "
.
count
(
$keys
)
.
"
\n
"
;
echo
(
"Starting synchronization.
\n
"
)
;
echo
"Starting synchronization.
\n
"
;
$skipped
=
0
;
$skipped
=
0
;
$sync
=
0
;
$sync
=
0
;
...
@@ -70,20 +69,20 @@ foreach ($keys as $key) {
...
@@ -70,20 +69,20 @@ foreach ($keys as $key) {
}
}
echo
(
"Synchronization done.
\n
"
)
;
echo
"Synchronization done.
\n
"
;
echo
(
$sync
.
" keys in sync.
\n
"
)
;
echo
$sync
.
" keys in sync.
\n
"
;
if
(
$skipped
>
0
)
{
if
(
$skipped
>
0
)
{
echo
(
$skipped
.
" keys skipped.
\n
"
)
;
echo
$skipped
.
" keys skipped.
\n
"
;
echo
(
"Keys are skipped because they are either expired, or are of a type unknown
\n
"
)
;
echo
"Keys are skipped because they are either expired, or are of a type unknown
\n
"
;
echo
(
"to SimpleSAMLphp.
\n
"
)
;
echo
"to SimpleSAMLphp.
\n
"
;
}
}
if
(
$warnServerDown
>
0
)
{
if
(
$warnServerDown
>
0
)
{
echo
(
"WARNING: "
.
$warnServerDown
.
" server(s) down. Not all servers are synchronized.
\n
"
)
;
echo
"WARNING: "
.
$warnServerDown
.
" server(s) down. Not all servers are synchronized.
\n
"
;
}
}
if
(
$warnBigSlab
>
0
)
{
if
(
$warnBigSlab
>
0
)
{
echo
(
"WARNING: "
.
$warnBigSlab
.
" slab(s) may have contained more keys than we were told about.
\n
"
)
;
echo
"WARNING: "
.
$warnBigSlab
.
" slab(s) may have contained more keys than we were told about.
\n
"
;
}
}
/**
/**
...
@@ -99,12 +98,12 @@ function getServerKeys($server)
...
@@ -99,12 +98,12 @@ function getServerKeys($server)
$host
=
$server
[
0
];
$host
=
$server
[
0
];
$port
=
(
int
)
$server
[
1
];
$port
=
(
int
)
$server
[
1
];
echo
(
"Connecting to: "
.
$host
.
":"
.
$port
.
"
\n
"
)
;
echo
"Connecting to: "
.
$host
.
":"
.
$port
.
"
\n
"
;
$socket
=
fsockopen
(
$host
,
$port
);
$socket
=
fsockopen
(
$host
,
$port
);
echo
(
"Connected. Finding keys.
\n
"
)
;
echo
"Connected. Finding keys.
\n
"
;
if
(
fwrite
(
$socket
,
"stats slabs
\r\n
"
)
===
false
)
{
if
(
fwrite
(
$socket
,
"stats slabs
\r\n
"
)
===
false
)
{
echo
(
"Error requesting slab dump from server.
\n
"
)
;
echo
"Error requesting slab dump from server.
\n
"
;
exit
(
1
);
exit
(
1
);
}
}
...
@@ -127,9 +126,8 @@ function getServerKeys($server)
...
@@ -127,9 +126,8 @@ function getServerKeys($server)
// Dump keys in slabs
// Dump keys in slabs
$keys
=
[];
$keys
=
[];
foreach
(
$slabs
as
$slab
)
{
foreach
(
$slabs
as
$slab
)
{
if
(
fwrite
(
$socket
,
"stats cachedump "
.
$slab
.
" 1000000
\r\n
"
)
===
false
)
{
if
(
fwrite
(
$socket
,
"stats cachedump "
.
$slab
.
" 1000000
\r\n
"
)
===
false
)
{
echo
(
"Error requesting cache dump from server.
\n
"
)
;
echo
"Error requesting cache dump from server.
\n
"
;
exit
(
1
);
exit
(
1
);
}
}
...
@@ -149,17 +147,17 @@ function getServerKeys($server)
...
@@ -149,17 +147,17 @@ function getServerKeys($server)
if
(
preg_match
(
'/^ITEM (.*) \[\d+ b; \d+ s\]/'
,
$line
,
$matches
))
{
if
(
preg_match
(
'/^ITEM (.*) \[\d+ b; \d+ s\]/'
,
$line
,
$matches
))
{
$keys
[]
=
$matches
[
1
];
$keys
[]
=
$matches
[
1
];
}
else
{
}
else
{
echo
(
"Unknown result from cache dump: "
.
$line
.
"
\n
"
)
;
echo
"Unknown result from cache dump: "
.
$line
.
"
\n
"
;
}
}
}
}
if
(
$resultSize
>
1900000
||
count
(
$keys
)
>=
1000000
)
{
if
(
$resultSize
>
1900000
||
count
(
$keys
)
>=
1000000
)
{
echo
(
"WARNING: Slab "
.
$slab
.
" on server "
.
$host
.
":"
.
$port
.
echo
"WARNING: Slab "
.
$slab
.
" on server "
.
$host
.
":"
.
$port
.
" may have contained more keys than we were told about.
\n
"
)
;
" may have contained more keys than we were told about.
\n
"
;
$GLOBALS
[
'warnBigSlab'
]
+=
1
;
$GLOBALS
[
'warnBigSlab'
]
+=
1
;
}
}
}
}
echo
(
"Found "
.
count
(
$keys
)
.
" key(s).
\n
"
)
;
echo
"Found "
.
count
(
$keys
)
.
" key(s).
\n
"
;
fclose
(
$socket
);
fclose
(
$socket
);
return
$keys
;
return
$keys
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment