mirror of
https://github.com/Retropex/apolloapi-v2.git
synced 2025-05-28 13:02:35 +02:00
Added fake actions for mcu stats, reboot, shutdown
This commit is contained in:
parent
2dbcfe297c
commit
84d0b69725
@ -62,6 +62,7 @@ JSON="{
|
||||
\"memory\":
|
||||
{
|
||||
\"total\": $memTotal,
|
||||
\"available\": $memAvailable,
|
||||
\"used\": $memUsed,
|
||||
\"cache\": $memCached,
|
||||
\"swap\": $swapUsed
|
||||
|
33
scripts/os_stats_fake
Executable file
33
scripts/os_stats_fake
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
cat << EOF
|
||||
{
|
||||
"hostname": "orangepizero",
|
||||
"operatingSystem": "Ubuntu 18.04 bionic",
|
||||
"uptime": "2018-11-06 14:01:22",
|
||||
"loadAverage": "0.00 0.00 0.00 1/120 2859",
|
||||
"architecture": "armv7l",
|
||||
"temperature": "40656",
|
||||
"memory":
|
||||
{
|
||||
"total": 245760,
|
||||
"available": 127384,
|
||||
"used": 207276,
|
||||
"cache": 90348,
|
||||
"swap": 256
|
||||
},
|
||||
"cpu":
|
||||
{
|
||||
"threads": 4,
|
||||
"usedPercent": 0
|
||||
},
|
||||
"disks": [
|
||||
{"total":7678936,
|
||||
"used":1468092,
|
||||
"mountPoint":"/"},
|
||||
{"total":49584,
|
||||
"used":4312,
|
||||
"mountPoint":"/var/log"}
|
||||
]
|
||||
}
|
||||
EOF
|
@ -27,6 +27,7 @@ module.exports.typeDefs = `
|
||||
|
||||
type MemoryStats {
|
||||
total: Float
|
||||
available: Float
|
||||
used: Float
|
||||
cache: Float
|
||||
swap: Float
|
||||
|
@ -2,7 +2,8 @@ const { exec } = require('child_process')
|
||||
|
||||
module.exports = ({ define }) => {
|
||||
define('reboot', async (payload, { knex, errors, utils }) => {
|
||||
exec('sudo shutdown -r now')
|
||||
if (process.env.NODE_ENV === 'production') return exec('sudo shutdown -r now');
|
||||
return;
|
||||
}, {
|
||||
auth: true
|
||||
})
|
||||
|
@ -2,7 +2,8 @@ const { exec } = require('child_process')
|
||||
|
||||
module.exports = ({ define }) => {
|
||||
define('shutdown', async (payload, { knex, errors, utils }) => {
|
||||
exec('sudo shutdown now')
|
||||
if (process.env.NODE_ENV === 'production') return exec('sudo shutdown now')
|
||||
return;
|
||||
}, {
|
||||
auth: true
|
||||
})
|
||||
|
@ -13,7 +13,8 @@ module.exports = ({ define }) => {
|
||||
|
||||
function getOsStats () {
|
||||
return new Promise((resolve, reject) => {
|
||||
const scriptPath = join(__dirname, '..', '..', '..', '..', 'scripts', 'os_stats')
|
||||
const scriptName = (process.env.NODE_ENV === 'production') ? 'os_stats' : 'os_stats_fake'
|
||||
const scriptPath = join(__dirname, '..', '..', '..', '..', 'scripts', scriptName)
|
||||
exec(scriptPath, {}, (err, stdout) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
|
Loading…
Reference in New Issue
Block a user