Skip to content

Commit

Permalink
feat(api,view): add option to show specific virtual file mounts
Browse files Browse the repository at this point in the history
  • Loading branch information
MauriceNino committed Jul 7, 2022
1 parent 4d86c24 commit e5b2794
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 24 deletions.
5 changes: 4 additions & 1 deletion apps/api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export const CONFIG: Config = {
running_in_docker: penv('RUNNING_IN_DOCKER') === 'true',
accept_ookla_eula: penv('ACCEPT_OOKLA_EULA') === 'true',
use_network_interface: penv('USE_NETWORK_INTERFACE') ?? '',
fs_type_filter: lst(penv('FS_TYPE_FILTER') ?? ''),
fs_type_filter: lst(
penv('FS_TYPE_FILTER') ?? 'cifs,9p,fuse.rclone,fuse.mergerfs'
),
fs_virtual_mounts: lst(penv('FS_VIRTUAL_MOUNTS') ?? ''),
disable_integrations: penv('DISABLE_INTEGRATIONS') === 'true',

show_host: penv('SHOW_HOST') === 'true',
Expand Down
17 changes: 8 additions & 9 deletions apps/api/src/dynamic-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,6 @@ export const getDynamicServerInfo = () => {
}
);

const INVALID_FS_TYPES = [
'cifs',
'9p',
'fuse.rclone',
'fuse.mergerfs',
].concat(CONFIG.fs_type_filter);

const storageObs = createBufferedInterval(
'Storage',
CONFIG.widget_list.includes('storage'),
Expand All @@ -109,7 +102,8 @@ export const getDynamicServerInfo = () => {
const storageLayout = layout.storage.layout;
const validMounts = sizes.filter(
({ mount, type }) =>
mount.startsWith('/mnt/host/') && !INVALID_FS_TYPES.includes(type)
mount.startsWith('/mnt/host/') &&
!CONFIG.fs_type_filter.includes(type)
);
const hostMountUsed =
(
Expand All @@ -122,7 +116,12 @@ export const getDynamicServerInfo = () => {

return {
layout: storageLayout
.map(({ device }) => {
.map(({ device, virtual }) => {
if (virtual) {
const size = sizes.find(s => s.fs === device);
return size?.used ?? 0;
}

const deviceParts = validParts.filter(({ name }) =>
name.startsWith(device)
);
Expand Down
21 changes: 19 additions & 2 deletions apps/api/src/static-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ const loadRamInfo = async (): Promise<void> => {
};

const loadStorageInfo = async (): Promise<void> => {
const [disks, blocks] = await Promise.all([
const [disks, blocks, sizes] = await Promise.all([
si.diskLayout(),
si.blockDevices(),
si.fsSize(),
]);

const raidMembers = blocks.filter(block => block.fsType.endsWith('_member'));
Expand Down Expand Up @@ -155,10 +156,26 @@ const loadStorageInfo = async (): Promise<void> => {
})
.filter(d => d != null);

const sizesLayout = CONFIG.fs_virtual_mounts
.map(mount => {
const size = sizes.find(s => s.fs === mount);

return size
? {
device: size.fs,
brand: size.fs,
type: 'VIRTUAL',
size: size.size,
virtual: true,
}
: undefined;
})
.filter(d => d != null);

STATIC_INFO.next({
...STATIC_INFO.getValue(),
storage: {
layout: blockLayout,
layout: blockLayout.concat(sizesLayout),
},
});
};
Expand Down
34 changes: 25 additions & 9 deletions apps/docs/docs/config/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,27 @@ If dash. detects the wrong gateway as your default interface, you can provide a

### `DASHDOT_FS_TYPE_FILTER`

If dash. detects network drives as internal drives, you can provide a list of ignored FS types here (e.g. `cifs,9p`).
If dash. detects network drives as internal drives, you can provide a list of ignored FS types here.
Please also create a [bug ticket](https://github.com/MauriceNino/dashdot/issues/new/choose) on the
repository though, so that we can fix this problem for everyone.

- type: `string`
- type: `string (comma separated list)`
- default: `cifs,9p,fuse.rclone,fuse.mergerfs`

### `DASHDOT_FS_VIRTUAL_MOUNTS`

If you want to show a virtual mount in the storage split view, that is ignored in the filter above.
Can be used for example to show `fuse.mergerfs` mounts, which is basically a grouping of other mounts.

You need to pass the names of the filesystems you want to use. To find out what the name is, execute `df`
and look at the first column.

Note that this will only be shown in the storage split view (enabled with the
[`DASHDOT_ENABLE_STORAGE_SPLIT_VIEW`](./config#dashdot_enable_storage_split_view) flag).
The normal pie chart will not be affected and there will also be no disk shown in the list of the storage
widget.

- type: `string (comma separated list)`
- default: `unset`

### `DASHDOT_DISABLE_INTEGRATIONS`
Expand All @@ -119,7 +135,7 @@ These options are passed as comma separated lists - you can remove and add widge

The available options are: `os`, `cpu`, `storage`, `ram`, `network`, `gpu`.

- type: `string`
- type: `string (comma separated list)`
- default: `os,cpu,storage,ram,network`

| `os,cpu,storage,ram,network` | `ram,cpu,storage,network` |
Expand All @@ -130,42 +146,42 @@ The available options are: `os`, `cpu`, `storage`, `ram`, `network`, `gpu`.

The available options are: `os`, `arch`, `up_since`.

- type: `string`
- type: `string (comma separated list)`
- default: `os,arch,up_since`

### `DASHDOT_CPU_LABEL_LIST`

The available options are: `brand`, `model`, `cores`, `threads`, `frequency`.

- type: `string`
- type: `string (comma separated list)`
- default: `brand,model,cores,threads,frequency`

### `DASHDOT_STORAGE_LABEL_LIST`

The available options are: `brand`, `size`, `type`.

- type: `string`
- type: `string (comma separated list)`
- default: `brand,size,type`

### `DASHDOT_RAM_LABEL_LIST`

The available options are: `brand`, `size`, `type`, `frequency`.

- type: `string`
- type: `string (comma separated list)`
- default: `brand,size,type,frequency`

### `DASHDOT_NETWORK_LABEL_LIST`

The available options are: `type`, `speed_up`, `speed_down`, `interface_speed`, `public_ip`.

- type: `string`
- type: `string (comma separated list)`
- default: `type,speed_up,speed_down,interface_speed`

### `DASHDOT_GPU_LABEL_LIST`

The available options are: `brand`, `model`, `memory`.

- type: `string`
- type: `string (comma separated list)`
- default: `brand, model, memory`

## Widget Options and Styles
Expand Down
12 changes: 9 additions & 3 deletions apps/view/src/widgets/storage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const useStorageLayout = (data: StorageInfo, config: Config) => {
types: [override.storage_types[i] ?? curr.type],
size: override.storage_sizes[i] ?? curr.size,
raidGroup: curr.raidGroup,
virtual: curr.virtual,
});
}

Expand All @@ -70,6 +71,7 @@ const useStorageLayout = (data: StorageInfo, config: Config) => {
types: string[];
size: number;
raidGroup?: string;
virtual?: boolean;
}[]
),
[
Expand Down Expand Up @@ -97,13 +99,17 @@ export const StorageChart: FC<StorageChartProps> = ({
}) => {
const theme = useTheme();
const layout = useStorageLayout(data, config);
const layoutNoVirtual = layout.filter(l => !l.virtual);

const totalSize = Math.max(
layout.reduce((acc, s) => (acc = acc + s.size), 0),
layoutNoVirtual.reduce((acc, s) => (acc = acc + s.size), 0),
1
);
const totalAvailable = Math.max(
totalSize - (load?.layout.reduce((acc, { load }) => acc + load, 0) ?? 0),
totalSize -
(load?.layout
.slice(0, layoutNoVirtual.length)
.reduce((acc, { load }) => acc + load, 0) ?? 0),
1
);
const totalUsed = totalSize - totalAvailable;
Expand Down Expand Up @@ -275,7 +281,7 @@ export const StorageWidget: FC<StorageWidgetProps> = ({
}) => {
const theme = useTheme();
const isMobile = useIsMobile();
const layout = useStorageLayout(data, config);
const layout = useStorageLayout(data, config).filter(s => !s.virtual);

const [splitView, setSplitView] = useSetting('splitStorage', false);
const canHaveSplitView =
Expand Down
2 changes: 2 additions & 0 deletions libs/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type StorageInfo = {
size: number;
type: string;
raidGroup?: string;
virtual?: boolean;
}[];
};
export type StorageLoad = {
Expand Down Expand Up @@ -87,6 +88,7 @@ export type Config = {
use_network_interface: string;
accept_ookla_eula: boolean;
fs_type_filter: string[];
fs_virtual_mounts: string[];
disable_integrations: boolean;

show_host: boolean;
Expand Down

0 comments on commit e5b2794

Please sign in to comment.