fixes
This commit is contained in:
1 parent
cc62f108ce
commit
8886b70fb9
7 files changed
+23
-57
No files matched your search
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
echo -en "\e[31m"
|
||||
figlet $HOSTNAME -cf slant;#
|
||||
echo -en $(echo "process.stdout.write(require('./config.json').theme)" | node)
|
||||
figlet $HOSTNAME -f slant;#
|
||||
echo -en "\e[0m"
|
||||
@@ -6,7 +6,6 @@ const config = require('./config.json'),
|
||||
|
||||
var stats = {}
|
||||
|
||||
|
||||
Promise.all([
|
||||
ex('uptime -p').then(out => {
|
||||
stats.uptime = out.slice(3, -1)
|
||||
@@ -66,8 +65,8 @@ Promise.all([
|
||||
}
|
||||
console.log()
|
||||
|
||||
console.log(`Memory: ${readable(stats.memory.used)} MB out of ${readable(stats.memory.total)} MB\n${bar(stats.memory.used, stats.memory.total, 55, ['\x1b[93m=', '-'])}`)
|
||||
console.log(`Swap: ${readable(stats.swap.used)} MB out of ${readable(stats.swap.total)} MB\n${bar(stats.swap.used, stats.swap.total, 55, ['\x1b[93m=', '-'])}`)
|
||||
console.log(`Memory: ${readable(stats.memory.used)} MB out of ${readable(stats.memory.total)} MB\n${bar(stats.memory.used, stats.memory.total, ['\x1b[93m=', '-'])}`)
|
||||
console.log(`Swap: ${readable(stats.swap.used)} MB out of ${readable(stats.swap.total)} MB\n${bar(stats.swap.used, stats.swap.total, ['\x1b[93m=', '-'])}`)
|
||||
console.log()
|
||||
|
||||
console.log(`Public IP: \x1b[36m${stats.public}\x1b[0m`)
|
||||
|
||||
@@ -1,26 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
const { exec } = require('child_process'),
|
||||
const config = require('./config.json'),
|
||||
ex = require('./execute'),
|
||||
bar = require('./bar'),
|
||||
readable = require('./readable')
|
||||
|
||||
function ex(com) {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(com, (err, stdout, stderr) => {
|
||||
resolve(`/dev/sda2 41022688 10558944 28350208 28% /
|
||||
/dev/sda3 102687672 9977612 87450796 11% /home
|
||||
/dev/sda4 815881720 335298544 439068888 44% /media`)
|
||||
if (stderr) reject(stderr)
|
||||
resolve(stdout)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
ex('df').then(out => {// | grep dev/sd
|
||||
out.split('\n').forEach(drive => {
|
||||
grep = /\/dev\/(sd[a-z]\d)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+%) (\/\S*)$/gm.exec(drive)
|
||||
if(grep == null) return
|
||||
console.log()
|
||||
console.log(`\x1b[96m${grep[1]}\x1b[0m mounted on \x1b[34m${grep[6]}\x1b[0m \x1b[33m${readable(grep[4], 2)}GB\x1b[0m of ${readable(grep[2], 2)}GB`)
|
||||
console.log(bar(grep[4], grep[2], 40, ['\x1b[94m=', '-']))
|
||||
console.log(bar(grep[4], grep[2], ['\x1b[94m=', '-']))
|
||||
})
|
||||
})
|
||||
+9
-24
@@ -1,27 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
const { exec } = require('child_process')
|
||||
|
||||
function getStatus(name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(`systemctl status ${name}`, (err, stdout, stderr) => {
|
||||
resolve(`Loaded: loaded (/lib/systemd/system/isc-dhcp-server6.service; enabled; vendor preset:
|
||||
Active: active (Result: exit-code) since Wed 2020-02-19 15:40:57 CET; 1 day 22h ago
|
||||
Memory: 6.8M
|
||||
Docs: man:dhcpd(8)
|
||||
Main PID: 726 (code=exited, status=1/FAILURE)`)
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
resolve(stdout)
|
||||
});
|
||||
}).then(stdout => {
|
||||
return {
|
||||
active: /Active: (.+?) .*; (.*) ago$/gm.exec(stdout).slice(1, 3),
|
||||
memory: (/Memory: (\S+)$/gm.exec(stdout) || []).slice(1, 2),
|
||||
loaded: /Loaded: (.+?) .*?; (.*?); .*$/gm.exec(stdout).slice(1, 3)
|
||||
}
|
||||
})
|
||||
}
|
||||
const config = require('./config.json'),
|
||||
ex = require('./execute')
|
||||
|
||||
const services = [
|
||||
'nginx',
|
||||
@@ -39,7 +18,13 @@ for (let service of services) {
|
||||
if (typeof service == 'string') service = [service, service]
|
||||
if (service[1].length > spaces) spaces = service[1].length+1
|
||||
|
||||
promises.push(getStatus(service[0]).then(status => {
|
||||
promises.push(ex(`systemctl status ${service[0]}`).then(stdout => {
|
||||
return {
|
||||
active: /Active: (.+?) .*; (.*) ago$/gm.exec(stdout).slice(1, 3),
|
||||
memory: (/Memory: (\S+)$/gm.exec(stdout) || []).slice(1, 2),
|
||||
loaded: /Loaded: (.+?) .*?; (.*?); .*$/gm.exec(stdout).slice(1, 3)
|
||||
}
|
||||
}).then(status => {
|
||||
return [service[1], status]
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
#!/usr/bin/env node
|
||||
const { exec } = require('child_process')
|
||||
|
||||
function ex(com) {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(com, (err, stdout, stderr) => {
|
||||
resolve(`[{"pid":21716,"name":"ovh-dynhost","pm2_env":{"env_production":{"NODE_ENV":"production"},"kill_retry_time":100,"windowsHide":true,"username":"mathias","treekill":true,"automation":true,"pmx":true,"instance_var":"NODE_APP_INSTANCE","watch":false,"autorestart":true,"vizion":true,"instances":1,"max_memory_restart":1073741824,"env":{"PM2_JSON_PROCESSING":"true","PM2_USAGE":"CLI","OLDPWD":"/home/mathias","_":"/home/mathias/.nvm/versions/node/v9.11.2/bin/pm2","SSH_TTY":"/dev/pts/1","NVM_BIN":"/home/mathias/.nvm/versions/node/v9.11.2/bin","DBUS_SESSION_BUS_ADDRESS":"unix:path=/run/user/1000/bus","PATH":"/home/mathias/.local/bin:/home/mathias/.nvm/versions/node/v9.11.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","XDG_DATA_DIRS":"/usr/local/share:/usr/share:/var/lib/snapd/desktop","SSH_CLIENT":"192.168.1.4 49633 22","XDG_RUNTIME_DIR":"/run/user/1000","XDG_SESSION_ID":"305","NVM_CD_FLAGS":"","SHLVL":"1","USER":"mathias","LESSOPEN":"| /usr/bin/lesspipe %s","TERM":"xterm-256color","XDG_SESSION_CLASS":"user","LESSCLOSE":"/usr/bin/lesspipe %s %s","NVM_DIR":"/home/mathias/.nvm","SSH_CONNECTION":"192.168.1.4 49633 192.168.1.2 22","LS_COLORS":"rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:","LANG":"en_US.UTF-8","HOME":"/home/mathias","MOTD_SHOWN":"pam","XDG_SESSION_TYPE":"tty","LOGNAME":"mathias","PWD":"/home/mathias/git/ovh-dynhost","EDITOR":"vim","THEME":"e[32m","SHELL":"/bin/bash","NODE_ENV":"development","PM2_HOME":"/home/mathias/.pm2","ovh-dynhost":"{}","unique_id":"f2f806c0-6470-4011-8194-c34a6be62413"},"name":"ovh-dynhost","node_args":[],"pm_exec_path":"/home/mathias/git/ovh-dynhost/index.js","pm_cwd":"/home/mathias/git/ovh-dynhost","exec_interpreter":"node","exec_mode":"fork_mode","pm_out_log_path":"/home/mathias/.pm2/logs/ovh-dynhost-out-0.log","pm_err_log_path":"/home/mathias/.pm2/logs/ovh-dynhost-error-0.log","pm_pid_path":"/home/mathias/.pm2/pids/ovh-dynhost-0.pid","km_link":false,"vizion_running":false,"NODE_APP_INSTANCE":0,"PM2_JSON_PROCESSING":"true","PM2_USAGE":"CLI","OLDPWD":"/home/mathias","_":"/home/mathias/.nvm/versions/node/v9.11.2/bin/pm2","SSH_TTY":"/dev/pts/1","NVM_BIN":"/home/mathias/.nvm/versions/node/v9.11.2/bin","DBUS_SESSION_BUS_ADDRESS":"unix:path=/run/user/1000/bus","PATH":"/home/mathias/.local/bin:/home/mathias/.nvm/versions/node/v9.11.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","XDG_DATA_DIRS":"/usr/local/share:/usr/share:/var/lib/snapd/desktop","SSH_CLIENT":"192.168.1.4 49633 22","XDG_RUNTIME_DIR":"/run/user/1000","XDG_SESSION_ID":"305","NVM_CD_FLAGS":"","SHLVL":"1","USER":"mathias","LESSOPEN":"| /usr/bin/lesspipe %s","TERM":"xterm-256color","XDG_SESSION_CLASS":"user","LESSCLOSE":"/usr/bin/lesspipe %s %s","NVM_DIR":"/home/mathias/.nvm","SSH_CONNECTION":"192.168.1.4 49633 192.168.1.2 22","LS_COLORS":"rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cLine truncated
|
||||
if (stderr) reject(stderr)
|
||||
resolve(stdout)
|
||||
})
|
||||
})
|
||||
}
|
||||
const config = require('./config.json'),
|
||||
ex = require('./execute')
|
||||
|
||||
ex('pm2 jlist').then(out => {
|
||||
out = JSON.parse(out)
|
||||
|
||||
|
||||
console.log()
|
||||
console.log(`PM2 Services:`)
|
||||
for(let service of out){
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = function bar(used, total, max = 40, chars = ['#', '-']) {
|
||||
module.exports = function bar(used, total, chars = ['#', '-'], max = 40) {
|
||||
|
||||
var percent = used / total,
|
||||
len = Math.round(percent * max),
|
||||
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
{
|
||||
"publicip": "/home/mathias/git/ovh-dynhost/logs/short.log"
|
||||
"publicip": "/home/mathias/git/ovh-dynhost/logs/short.log",
|
||||
"theme": "\\e[32m",
|
||||
"hostname": "odin"
|
||||
}
|
||||
Reference in new issue
Block a user