Skip to content

Instantly share code, notes, and snippets.

@infotek
Created November 3, 2016 14:06
Show Gist options
  • Save infotek/5345ecfbc09217dec4051bee2bd3cfa9 to your computer and use it in GitHub Desktop.
Save infotek/5345ecfbc09217dec4051bee2bd3cfa9 to your computer and use it in GitHub Desktop.
<?php
$perf = array
(
Qcache_free_memory => array
(
value => 15848240,
uom => ''
),
Qcache_inserts => array
(
value => 42685,
uom => c
),
Qcache_lowmem_prunes => array
(
value => 0,
uom => c
),
"Qcache_qu@eries_in_cachepurple" => array
(
value => 5390,
uom => c
),
"Qcache_qu@eries_in_cache" => array
(
value => 1,
uom => ''
),
"Qcache_qu@eries_in_cac4e" => array
(
value => 2,
uom => ''
),
"Qcache_qu@eries_in_cac3e" => array
(
value => 3,
uom => ''
),
"Qcache_qu@eries_in_cac2e" => array
(
value => 4,
uom => ''
),
);
print_r($perf);
foreach ($perf as $k => $v) {
$ds_name = preg_replace('/[^a-zA-Z0-9_]/', '', $k);
if ( strlen($ds_name) >= 19 ) {
$ds_name = substr($ds_name,0,19);
echo( $k . " exceeds 19 characters, renaming to " . $ds_name . "\n");
}
if ($ds_name != $k) {
// ds_name has changed. check if ds_name is already in the array
echo("ds_name = " . $ds_name . "\n");
while(isset($perf[$ds_name])){
echo($ds_name . " isset\n");
for( $i = 0; $i<2; $i++ ){
echo("i = " . $i . "\n");
$ds_name = substr($ds_name,0,18) . $i;
if (!isset($perf[$ds_name])){
echo("setting\n");
$perf[$ds_name] = $v;
unset($perf[$k]);
}
}
}
}
}
print_r($perf);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment