diff --git a/app/core/modules/get-uptime.ts b/app/core/modules/get-uptime.ts deleted file mode 100644 index 04f35da0e..000000000 --- a/app/core/modules/get-uptime.ts +++ /dev/null @@ -1,41 +0,0 @@ -/*! - * Copyright 2019-2020 Lime Technology Inc. All rights reserved. - * Written by: Alexis Tyler - */ - -import os from 'os'; -import { ensurePermission } from '../utils'; -import { CoreResult, CoreContext } from '../types'; - -interface Result extends CoreResult { - json: { - milliseconds: number; - timestamp: string; - }; -} - -/** - * OS uptime - * @returns The milliseconds since we booted. - */ -export const getUptime = async (context: CoreContext): Promise => { - const { user } = context; - - // Check permissions - ensurePermission(user, { - resource: 'uptime', - action: 'read', - possession: 'any' - }); - - const uptime = new Date(os.uptime()); - const humanFormat = uptime.getTime(); - - return { - text: `Uptime: ${humanFormat}`, - json: { - milliseconds: uptime.getTime(), - timestamp: uptime.toISOString() - } - }; -}; diff --git a/app/core/modules/index.ts b/app/core/modules/index.ts index a909dfb60..02e032110 100644 --- a/app/core/modules/index.ts +++ b/app/core/modules/index.ts @@ -27,7 +27,6 @@ export * from './get-permissions'; export * from './get-plugins'; export * from './get-services'; export * from './get-unassigned-devices'; -export * from './get-uptime'; export * from './get-users'; export * from './get-vars'; export * from './get-welcome'; diff --git a/app/core/modules/info/get-os.ts b/app/core/modules/info/get-os.ts index 64120c6a3..6d8118d7b 100644 --- a/app/core/modules/info/get-os.ts +++ b/app/core/modules/info/get-os.ts @@ -3,11 +3,14 @@ * Written by: Alexis Tyler */ -import uptime from 'os-uptime'; +import { uptime } from 'os'; import si from 'systeminformation'; import { CoreContext, CoreResult } from '../../types'; import { ensurePermission } from '../../utils'; +// Get uptime on boot and convert to date +const bootTimestamp = new Date(new Date().getTime() - (uptime() * 1000)); + /** * Get OS info * @@ -33,7 +36,7 @@ export const getOs = async function (context: CoreContext): Promise get json() { return { ...os, - uptime: uptime().toISOString() + uptime: bootTimestamp }; } }; diff --git a/app/core/states/var.ts b/app/core/states/var.ts index ee59e9bd4..4ed7d5e04 100644 --- a/app/core/states/var.ts +++ b/app/core/states/var.ts @@ -4,7 +4,6 @@ */ import path from 'path'; -import uptime from 'os-uptime'; import { paths } from '../paths'; import { Var } from '../types/states'; import { IniStringBooleanOrAuto, IniStringBoolean } from '../types/ini'; @@ -214,7 +213,6 @@ interface VarIni { sysFlashSlots: string; sysModel: string; timeZone: string; - uptime: string; useNtp: IniStringBoolean; useSsh: IniStringBoolean; useSsl: IniStringBooleanOrAuto; @@ -291,8 +289,7 @@ const parse = (state: VarIni): Var => { useNtp: iniBooleanToJsBoolean(state.useNtp), useSsh: iniBooleanToJsBoolean(state.useSsh), useSsl: iniBooleanOrAutoToJsBoolean(state.useSsl), - useTelnet: iniBooleanToJsBoolean(state.useTelnet), - uptime: uptime().toISOString() + useTelnet: iniBooleanToJsBoolean(state.useTelnet) }; }; diff --git a/app/core/types/states/var.ts b/app/core/types/states/var.ts index 1a1459d36..2f5de8de8 100644 --- a/app/core/types/states/var.ts +++ b/app/core/types/states/var.ts @@ -181,8 +181,6 @@ export interface Var { sysModel: string; /** Current timezone. {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones | Timezone list}. */ timeZone: string; - /** Time the host has been online in ms. */ - uptime: string; /** Should a NTP server be used for time sync. */ useNtp: boolean; /** Should SSH be enabled. */ diff --git a/app/graphql/index.ts b/app/graphql/index.ts index f0514c1ee..d9f292557 100644 --- a/app/graphql/index.ts +++ b/app/graphql/index.ts @@ -391,17 +391,6 @@ dee.on('*', async (data: { Type: string }) => { dee.listen(); -// OS uptime -run('uptime', 'UPDATED', { - moduleToRun: modules.getUptime, - context: { - user: internalServiceUser - }, - loop: Infinity -}).catch((error: unknown) => { - log.error('Failed getting "uptime" with "%s".', (error as Error).message); -}); - // Services run('services', 'UPDATED', { moduleToRun: modules.getServices, diff --git a/app/graphql/resolvers/query/info.ts b/app/graphql/resolvers/query/info.ts index 2f078d8ff..f842c3abd 100644 --- a/app/graphql/resolvers/query/info.ts +++ b/app/graphql/resolvers/query/info.ts @@ -3,14 +3,4 @@ * Written by: Alexis Tyler */ -import { uptime } from 'os'; - -// Get uptime on boot and convert to date -const bootTimestamp = new Date(new Date().getTime() - (uptime() * 1000)); - -export default () => ({ - os: { - // Timestamp of when the server booted - uptime: bootTimestamp - } -}); +export default () => ({}); diff --git a/app/graphql/resolvers/subscription/index.ts b/app/graphql/resolvers/subscription/index.ts index 8e965a795..4915bee61 100644 --- a/app/graphql/resolvers/subscription/index.ts +++ b/app/graphql/resolvers/subscription/index.ts @@ -51,9 +51,6 @@ export const Subscription = { unassignedDevices: { ...createSubscription('devices/unassigned') }, - uptime: { - ...createSubscription('uptime') - }, users: { ...createSubscription('users') }, diff --git a/app/graphql/schema/index.ts b/app/graphql/schema/index.ts index 42f56724c..5ed05c751 100644 --- a/app/graphql/schema/index.ts +++ b/app/graphql/schema/index.ts @@ -37,7 +37,6 @@ const files = [ './dist/types/graphql/schema/types/unassigned-devices/mount.graphql', './dist/types/graphql/schema/types/unassigned-devices/partition.graphql', './dist/types/graphql/schema/types/unassigned-devices/unassigned-device.graphql', - './dist/types/graphql/schema/types/uptime/uptime.graphql', './dist/types/graphql/schema/types/users/me.graphql', './dist/types/graphql/schema/types/users/user.graphql', './dist/types/graphql/schema/types/vars/vars.graphql', diff --git a/app/graphql/schema/types/uptime/uptime.graphql b/app/graphql/schema/types/uptime/uptime.graphql deleted file mode 100644 index 0b80744aa..000000000 --- a/app/graphql/schema/types/uptime/uptime.graphql +++ /dev/null @@ -1,12 +0,0 @@ -type Query { - uptime: Uptime @func(module: "getUptime") -} - -type Subscription { - uptime: Uptime -} - -type Uptime { - milliseconds: Int! - timestamp: String! -} \ No newline at end of file diff --git a/app/graphql/schema/types/vars/vars.graphql b/app/graphql/schema/types/vars/vars.graphql index 50014722d..ff1335bf8 100644 --- a/app/graphql/schema/types/vars/vars.graphql +++ b/app/graphql/schema/types/vars/vars.graphql @@ -166,7 +166,6 @@ type Vars { shareAfpCount: Int shareMoverActive: Boolean csrfToken: String - uptime: String! } enum mdState { diff --git a/dev/data/permissions.json b/dev/data/permissions.json index bbb90d86b..2c096050a 100644 --- a/dev/data/permissions.json +++ b/dev/data/permissions.json @@ -137,11 +137,6 @@ "action": "read:any", "attributes": "*" }, - { - "resource": "uptime", - "action": "read:any", - "attributes": "*" - }, { "resource": "user", "action": "read:any", diff --git a/package-lock.json b/package-lock.json index e992b27eb..9fc09d571 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10917,11 +10917,6 @@ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, - "os-uptime": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/os-uptime/-/os-uptime-2.0.2.tgz", - "integrity": "sha512-r9N4pWwi3wQpWrGKUjM0Lpj0CwC3jngofs5Bs3pP6+GUYeZxtYT+Msl1cPvqBn9ZYR+rHL/jhPJQghXzGLGFhw==" - }, "p-cancelable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", diff --git a/package.json b/package.json index 8c20919fd..579f3aea4 100644 --- a/package.json +++ b/package.json @@ -107,7 +107,6 @@ "node-window-polyfill": "^1.0.2", "number-to-color": "^0.5.0", "observable-to-promise": "^1.0.0", - "os-uptime": "^2.0.2", "p-iteration": "^1.1.8", "p-props": "^4.0.0", "p-wait-for": "^3.2.0", @@ -246,7 +245,6 @@ "node-window-polyfill", "number-to-color", "observable-to-promise", - "os-uptime", "p-iteration", "p-props", "p-wait-for", @@ -275,4 +273,4 @@ "uuid-apikey", "xhr2" ] -} +} \ No newline at end of file