John Haverlack
3 years ago
20 changed files with 151 additions and 98 deletions
-
2.gitignore
-
25analyze-data.sh
-
66itam-data-analyzer.js
-
16web/root/site/bootstrap.html
-
6web/root/site/build.html
-
9web/root/site/cloning.html
-
52web/root/site/code.html
-
3web/root/site/editing.html
-
9web/root/site/equations.html
-
3web/root/site/footnotes.html
-
3web/root/site/icons.html
-
14web/root/site/install.html
-
10web/root/site/menu.html
-
12web/root/site/optional.html
-
3web/root/site/pdf.html
-
2web/root/site/search.html
-
BINweb/root/site/sitemap.xml.gz
-
2web/root/site/swipe.html
-
9web/root/site/test.html
-
3web/root/site/version.html
@ -0,0 +1,25 @@ |
|||
#!/usr/bin/env bash |
|||
|
|||
# Detect POSIX Environment |
|||
os=`uname -s | tr '[:upper:]' '[:lower:]'` |
|||
arch=`uname -m | sed -r 's/x86_64/x64/'` |
|||
#echo $os |
|||
#echo $arch |
|||
|
|||
rundir=`echo $0 |sed -r 's/\/analyze-data\.sh$//'` |
|||
#echo $rundir |
|||
|
|||
node_ver='v14.17.1' |
|||
node_path="$rundir/nodejs/node-$node_ver-$os-$arch/bin/node" |
|||
npm_path="$rundir/nodejs/node-$node_ver-$os-$arch/bin/npm" |
|||
export PATH="$rundir/nodejs/node-$node_ver-$os-$arch/bin:"$PATH |
|||
|
|||
# My need to grow if client Payload get larger |
|||
max_http_header_size='40000000000' |
|||
|
|||
if [ -x "$node_path" ]; then |
|||
$node_path $rundir/itam-data-analyzer.js |
|||
else |
|||
echo "ERROR: Missing Node.JS: $node_path" |
|||
exit 1 |
|||
fi |
@ -0,0 +1,66 @@ |
|||
var path = require('path') |
|||
var fs = require('fs') |
|||
var skqlib = require('./skq_modules/skq-lib') |
|||
|
|||
// GLOBAL CONFIG
|
|||
process['CONFIG'] = JSON.parse(fs.readFileSync(path.join(__dirname, 'config','skqitam-server-config.json'), 'utf8')) |
|||
process['CONFIG']['GLOBAL']['RUN_DIR'] = __dirname |
|||
process['CONFIG']['LOCAL']= skqlib.it_am_init() |
|||
|
|||
// console.log(JSON.stringify(process['CONFIG'], null, 2))
|
|||
|
|||
console.log('Data Dir: ' + path.join(__dirname, process['CONFIG']['GLOBAL']['ITAM_DATA_DIR'])) |
|||
|
|||
let hostdir_base = path.join(__dirname, process['CONFIG']['GLOBAL']['ITAM_DATA_DIR'], 'hosts') |
|||
let hostdirs = fs.readdirSync(hostdir_base) |
|||
|
|||
// console.log(JSON.stringify(hostdirs, null, 2))
|
|||
|
|||
try { |
|||
fs.mkdirSync(path.join(__dirname, process['CONFIG']['GLOBAL']['ITAM_DATA_DIR'], 'reports'), { recursive: true }) |
|||
} catch (e) { |
|||
console.log('ERROR: Could not mkdir: ' + path.join(__dirname, process['CONFIG']['GLOBAL']['ITAM_DATA_DIR'], 'reports')) |
|||
process.exit(1) |
|||
} |
|||
|
|||
try { |
|||
fs.mkdirSync(path.join(__dirname, process['CONFIG']['GLOBAL']['ITAM_DATA_DIR'], 'proc'), { recursive: true }) |
|||
} catch (e) { |
|||
console.log('ERROR: Could not mkdir: ' + path.join(__dirname, process['CONFIG']['GLOBAL']['ITAM_DATA_DIR'], 'indexed-data')) |
|||
process.exit(1) |
|||
} |
|||
|
|||
let index_data_file = path.join(__dirname, process['CONFIG']['GLOBAL']['ITAM_DATA_DIR'], 'proc', 'index-data.json') |
|||
let index_data = {} |
|||
|
|||
try { |
|||
index_data = JSON.parse(fs.readFileSync(index_data_file, 'utf8')) |
|||
} catch (e) { |
|||
// Do Nothing
|
|||
} |
|||
|
|||
|
|||
for (hd in hostdirs) { |
|||
let data_files = fs.readdirSync(path.join(__dirname, process['CONFIG']['GLOBAL']['ITAM_DATA_DIR'], 'hosts', hostdirs[hd], 'raw')) |
|||
|
|||
console.log ("LATEST DATA: " + path.join(__dirname, process['CONFIG']['GLOBAL']['ITAM_DATA_DIR'], 'hosts', hostdirs[hd], 'raw', data_files[0])) |
|||
|
|||
let host_data = JSON.parse(fs.readFileSync(path.join(__dirname, process['CONFIG']['GLOBAL']['ITAM_DATA_DIR'], 'hosts', hostdirs[hd], 'raw', data_files[0]), 'utf8')) |
|||
|
|||
// console.log(JSON.stringify(host_data, null, 2))
|
|||
|
|||
if (!index_data.hasOwnProperty(host_data['ITAM']['ID'])) { |
|||
index_data[ host_data['ITAM']['ID'] ] = {} |
|||
} |
|||
|
|||
index_data[ host_data['ITAM']['ID'] ]['LATEST_DATA'] = host_data['ITAM']['STARTTIME'] |
|||
index_data[ host_data['ITAM']['ID'] ]['HOSTNAME'] = host_data['ITAM']['HOSTNAME'] |
|||
index_data[ host_data['ITAM']['ID'] ]['LOCAL_HOSTNAME'] = host_data['SOURCE']['NODEJS']['HOST']['HOSTNAME'] |
|||
index_data[ host_data['ITAM']['ID'] ]['IP_ADDR'] = host_data['SOURCE']['NODEJS']['HOST']['IP_ADDR'][0]['address'] |
|||
index_data[ host_data['ITAM']['ID'] ]['OS'] = host_data['SOURCE']['NODEJS']['OS']['DISTRO'] |
|||
index_data[ host_data['ITAM']['ID'] ]['OS_VERSION'] = host_data['SOURCE']['NODEJS']['OS']['DISTRO_VERSION'] |
|||
index_data[ host_data['ITAM']['ID'] ]['OS_INSTALL_DATE'] = host_data['SOURCE']['OS_INSTALL_ISO_DATE'] |
|||
|
|||
} |
|||
|
|||
fs.writeFileSync(index_data_file, JSON.stringify(index_data, null, 2), 'utf8') |
Write
Preview
Loading…
Cancel
Save
Reference in new issue