mirror of https://gitee.com/bigwinds/arangodb
unpacker for inspector reports (#5546)
This commit is contained in:
parent
e92ac9264b
commit
10888f33bb
|
@ -592,26 +592,31 @@ function getServerData(arango) {
|
|||
agencyConfig = arango.GET('_api/agency/config');
|
||||
}
|
||||
const status = arango.GET('_admin/status');
|
||||
const time = require('internal').time();
|
||||
|
||||
var tmp = executeExternalAndWait(
|
||||
'/bin/bash', ['-c', 'date -u "+%Y-%m-%d %H:%M:%S %Z" | tee /tmp/inspector-date.out > /dev/null']);
|
||||
const date = fs.readFileSync('/tmp/inspector-date.out', 'utf8').slice(0,-1);
|
||||
tmp = executeExternalAndWait(
|
||||
'/bin/bash', ['-c', 'dmesg | tee /tmp/inspector-dmesg.out > /dev/null']);
|
||||
const dmesg = fs.readFileSync('/tmp/inspector-dmesg.out', 'utf8');
|
||||
const dmesg = fs.readFileSync('/tmp/inspector-dmesg.out', 'utf8').slice(0,-1);
|
||||
tmp = executeExternalAndWait(
|
||||
'/bin/bash', ['-c', 'df -h | tee /tmp/inspector-df.out > /dev/null']);
|
||||
const df = fs.readFileSync('/tmp/inspector-df.out', 'utf8');
|
||||
const df = fs.readFileSync('/tmp/inspector-df.out', 'utf8').slice(0,-1);
|
||||
tmp = executeExternalAndWait(
|
||||
'/bin/bash', ['-c', 'cat /proc/meminfo | tee /tmp/inspector-meminfo.out > /dev/null']);
|
||||
const meminfo = fs.readFileSync('/tmp/inspector-meminfo.out', 'utf8');
|
||||
const meminfo = fs.readFileSync('/tmp/inspector-meminfo.out', 'utf8').slice(0,-1);
|
||||
tmp = executeExternalAndWait(
|
||||
'/bin/bash', ['-c', 'uptime | tee /tmp/inspector-uptime.out > /dev/null']);
|
||||
const uptime = fs.readFileSync('/tmp/inspector-uptime.out', 'utf8');
|
||||
const uptime = fs.readFileSync('/tmp/inspector-uptime.out', 'utf8').slice(0,-1);
|
||||
tmp = executeExternalAndWait(
|
||||
'/bin/bash', ['-c', 'uname -a | tee /tmp/inspector-uname.out > /dev/null']);
|
||||
const uname = fs.readFileSync('/tmp/inspector-uname.out', 'utf8');
|
||||
const uname = fs.readFileSync('/tmp/inspector-uname.out', 'utf8').slice(0,-1);
|
||||
var top;
|
||||
if (status.pid !== undefined) {
|
||||
tmp = executeExternalAndWait(
|
||||
'/bin/bash', ['-c', 'top -b -H -p ' + status.pid + ' -n 1 | tee /tmp/inspector-top.out > /dev/null']);
|
||||
top = fs.readFileSync('/tmp/inspector-top.out', 'utf8');
|
||||
top = fs.readFileSync('/tmp/inspector-top.out', 'utf8').slice(0,-1);
|
||||
}
|
||||
|
||||
var local = {};
|
||||
|
@ -637,7 +642,7 @@ function getServerData(arango) {
|
|||
report[server] = {
|
||||
version:version, log:log, dmesg:dmesg, statistics:statistics,
|
||||
status:status, df:df, uptime:uptime, uname:uname, meminfo:meminfo,
|
||||
local:local};
|
||||
local:local, date:date, time:time};
|
||||
|
||||
if (agencyConfig !== undefined) {
|
||||
report[server].config = agencyConfig;
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
#!/bin/bash
|
||||
|
||||
filename=arango-inspector.json
|
||||
outdir=arango-inspector
|
||||
|
||||
if [[ $# > 1 ]]; then
|
||||
echo "**Error** - usage: unpackInspectorReport [filename]"
|
||||
exit 1
|
||||
elif [[ $# == 1 ]]; then
|
||||
filename=$1
|
||||
fi
|
||||
|
||||
if [ -f $filename ]; then
|
||||
|
||||
# check json validity
|
||||
if jq -e . >/dev/null 2>&1 <<<"$json_string"; then
|
||||
mkdir arango-inspector
|
||||
if [[ $? -ne 0 ]]; then #target directory exists
|
||||
echo "**Error** - failed to create directory structure"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#dump agency
|
||||
echo -n " writing agency dump ... "
|
||||
cat $filename | jq .agency | tee $outdir/agency.json > /dev/null
|
||||
echo done
|
||||
|
||||
#dump
|
||||
echo -n " writing agency analysis ... "
|
||||
cat $filename | jq .analysis | tee $outdir/agency-analysis.json > /dev/null
|
||||
echo done
|
||||
|
||||
#servers
|
||||
echo " writing servers ..."
|
||||
for i in $(cat $filename | jq .servers | jq 'keys[]'); do
|
||||
name=$(echo $i|sed s/\"//g)
|
||||
mkdir $outdir/$name
|
||||
echo -n " writing $i ... "
|
||||
for j in $(cat $filename | jq .servers[$i] | jq 'keys[]'); do
|
||||
what=$(echo $j|sed s/\"//g)
|
||||
cat $filename | jq -r .servers[$i][$j] | tee $outdir/$name/$what > /dev/null
|
||||
done
|
||||
echo done
|
||||
done
|
||||
echo " ... done "
|
||||
|
||||
else #invalid json
|
||||
echo "**Error** - failed to parse JSON, or got false/null"
|
||||
fi
|
||||
else
|
||||
echo "**Error** - file $filename does not exit"
|
||||
fi
|
||||
|
||||
echo "The report was unpacked successfully."
|
Loading…
Reference in New Issue