ВН
Size: a a a
ВН
k
ВН
ВН
k
k
ВН
k
ВН
ВН
ВН
ВН
ВН
ВН
const info = JSON.parse(await system('rbd info --format json rpool/'+rbd));
const snaps = [ { suffix: '', snap: '' } ];
for (const snap of JSON.parse(await system('rbd snap ls --format json rpool/'+rbd)))
{
const n = Number(snap.id).toString('16');
snaps.push({ suffix: '.'+('0'.repeat(16-n.length))+n, snap: snap.name });
}
for (const s of snaps)
{
const object_map = await system('rados get -p rpool rbd_object_map.'+info.id+s.suffix+' -', { encoding: null });
let allocated = 0;
for (let i = 0; i < info.objects; i++)
{
const v = (object_map.readInt8(18 + Math.floor(i/4)) >> (2*(i%4))) & 0x3;
if (v == 1 || v == 2)
{
allocated++;
}
}
s.used = info.object_size/1024.0/1024.0 * allocated;
}
function system(cmd, options = {})
{
return new Promise((ok, no) => child_process.exec(cmd, { ...options, maxBuffer: 64*1024*1024 }, (err, stdout, stderr) =>
{
if (stderr !== '')
process.stderr.write(stderr);
err ? no(err) : ok(stdout);
}));
}
A
const info = JSON.parse(await system('rbd info --format json rpool/'+rbd));
const snaps = [ { suffix: '', snap: '' } ];
for (const snap of JSON.parse(await system('rbd snap ls --format json rpool/'+rbd)))
{
const n = Number(snap.id).toString('16');
snaps.push({ suffix: '.'+('0'.repeat(16-n.length))+n, snap: snap.name });
}
for (const s of snaps)
{
const object_map = await system('rados get -p rpool rbd_object_map.'+info.id+s.suffix+' -', { encoding: null });
let allocated = 0;
for (let i = 0; i < info.objects; i++)
{
const v = (object_map.readInt8(18 + Math.floor(i/4)) >> (2*(i%4))) & 0x3;
if (v == 1 || v == 2)
{
allocated++;
}
}
s.used = info.object_size/1024.0/1024.0 * allocated;
}
function system(cmd, options = {})
{
return new Promise((ok, no) => child_process.exec(cmd, { ...options, maxBuffer: 64*1024*1024 }, (err, stdout, stderr) =>
{
if (stderr !== '')
process.stderr.write(stderr);
err ? no(err) : ok(stdout);
}));
}
VC
A
ВН
A