Skip to content

Commit e5b2794

Browse files
committed
feat(api,view): add option to show specific virtual file mounts
1 parent 4d86c24 commit e5b2794

File tree

6 files changed

+67
-24
lines changed

6 files changed

+67
-24
lines changed

apps/api/src/config.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export const CONFIG: Config = {
1616
running_in_docker: penv('RUNNING_IN_DOCKER') === 'true',
1717
accept_ookla_eula: penv('ACCEPT_OOKLA_EULA') === 'true',
1818
use_network_interface: penv('USE_NETWORK_INTERFACE') ?? '',
19-
fs_type_filter: lst(penv('FS_TYPE_FILTER') ?? ''),
19+
fs_type_filter: lst(
20+
penv('FS_TYPE_FILTER') ?? 'cifs,9p,fuse.rclone,fuse.mergerfs'
21+
),
22+
fs_virtual_mounts: lst(penv('FS_VIRTUAL_MOUNTS') ?? ''),
2023
disable_integrations: penv('DISABLE_INTEGRATIONS') === 'true',
2124

2225
show_host: penv('SHOW_HOST') === 'true',

apps/api/src/dynamic-info.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,6 @@ export const getDynamicServerInfo = () => {
8787
}
8888
);
8989

90-
const INVALID_FS_TYPES = [
91-
'cifs',
92-
'9p',
93-
'fuse.rclone',
94-
'fuse.mergerfs',
95-
].concat(CONFIG.fs_type_filter);
96-
9790
const storageObs = createBufferedInterval(
9891
'Storage',
9992
CONFIG.widget_list.includes('storage'),
@@ -109,7 +102,8 @@ export const getDynamicServerInfo = () => {
109102
const storageLayout = layout.storage.layout;
110103
const validMounts = sizes.filter(
111104
({ mount, type }) =>
112-
mount.startsWith('/mnt/host/') && !INVALID_FS_TYPES.includes(type)
105+
mount.startsWith('/mnt/host/') &&
106+
!CONFIG.fs_type_filter.includes(type)
113107
);
114108
const hostMountUsed =
115109
(
@@ -122,7 +116,12 @@ export const getDynamicServerInfo = () => {
122116

123117
return {
124118
layout: storageLayout
125-
.map(({ device }) => {
119+
.map(({ device, virtual }) => {
120+
if (virtual) {
121+
const size = sizes.find(s => s.fs === device);
122+
return size?.used ?? 0;
123+
}
124+
126125
const deviceParts = validParts.filter(({ name }) =>
127126
name.startsWith(device)
128127
);

apps/api/src/static-info.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,10 @@ const loadRamInfo = async (): Promise<void> => {
113113
};
114114

115115
const loadStorageInfo = async (): Promise<void> => {
116-
const [disks, blocks] = await Promise.all([
116+
const [disks, blocks, sizes] = await Promise.all([
117117
si.diskLayout(),
118118
si.blockDevices(),
119+
si.fsSize(),
119120
]);
120121

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

159+
const sizesLayout = CONFIG.fs_virtual_mounts
160+
.map(mount => {
161+
const size = sizes.find(s => s.fs === mount);
162+
163+
return size
164+
? {
165+
device: size.fs,
166+
brand: size.fs,
167+
type: 'VIRTUAL',
168+
size: size.size,
169+
virtual: true,
170+
}
171+
: undefined;
172+
})
173+
.filter(d => d != null);
174+
158175
STATIC_INFO.next({
159176
...STATIC_INFO.getValue(),
160177
storage: {
161-
layout: blockLayout,
178+
layout: blockLayout.concat(sizesLayout),
162179
},
163180
});
164181
};

apps/docs/docs/config/index.mdx

+25-9
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,27 @@ If dash. detects the wrong gateway as your default interface, you can provide a
9797

9898
### `DASHDOT_FS_TYPE_FILTER`
9999

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

104-
- type: `string`
104+
- type: `string (comma separated list)`
105+
- default: `cifs,9p,fuse.rclone,fuse.mergerfs`
106+
107+
### `DASHDOT_FS_VIRTUAL_MOUNTS`
108+
109+
If you want to show a virtual mount in the storage split view, that is ignored in the filter above.
110+
Can be used for example to show `fuse.mergerfs` mounts, which is basically a grouping of other mounts.
111+
112+
You need to pass the names of the filesystems you want to use. To find out what the name is, execute `df`
113+
and look at the first column.
114+
115+
Note that this will only be shown in the storage split view (enabled with the
116+
[`DASHDOT_ENABLE_STORAGE_SPLIT_VIEW`](./config#dashdot_enable_storage_split_view) flag).
117+
The normal pie chart will not be affected and there will also be no disk shown in the list of the storage
118+
widget.
119+
120+
- type: `string (comma separated list)`
105121
- default: `unset`
106122

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

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

122-
- type: `string`
138+
- type: `string (comma separated list)`
123139
- default: `os,cpu,storage,ram,network`
124140

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

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

133-
- type: `string`
149+
- type: `string (comma separated list)`
134150
- default: `os,arch,up_since`
135151

136152
### `DASHDOT_CPU_LABEL_LIST`
137153

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

140-
- type: `string`
156+
- type: `string (comma separated list)`
141157
- default: `brand,model,cores,threads,frequency`
142158

143159
### `DASHDOT_STORAGE_LABEL_LIST`
144160

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

147-
- type: `string`
163+
- type: `string (comma separated list)`
148164
- default: `brand,size,type`
149165

150166
### `DASHDOT_RAM_LABEL_LIST`
151167

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

154-
- type: `string`
170+
- type: `string (comma separated list)`
155171
- default: `brand,size,type,frequency`
156172

157173
### `DASHDOT_NETWORK_LABEL_LIST`
158174

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

161-
- type: `string`
177+
- type: `string (comma separated list)`
162178
- default: `type,speed_up,speed_down,interface_speed`
163179

164180
### `DASHDOT_GPU_LABEL_LIST`
165181

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

168-
- type: `string`
184+
- type: `string (comma separated list)`
169185
- default: `brand, model, memory`
170186

171187
## Widget Options and Styles

apps/view/src/widgets/storage.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const useStorageLayout = (data: StorageInfo, config: Config) => {
6060
types: [override.storage_types[i] ?? curr.type],
6161
size: override.storage_sizes[i] ?? curr.size,
6262
raidGroup: curr.raidGroup,
63+
virtual: curr.virtual,
6364
});
6465
}
6566

@@ -70,6 +71,7 @@ const useStorageLayout = (data: StorageInfo, config: Config) => {
7071
types: string[];
7172
size: number;
7273
raidGroup?: string;
74+
virtual?: boolean;
7375
}[]
7476
),
7577
[
@@ -97,13 +99,17 @@ export const StorageChart: FC<StorageChartProps> = ({
9799
}) => {
98100
const theme = useTheme();
99101
const layout = useStorageLayout(data, config);
102+
const layoutNoVirtual = layout.filter(l => !l.virtual);
100103

101104
const totalSize = Math.max(
102-
layout.reduce((acc, s) => (acc = acc + s.size), 0),
105+
layoutNoVirtual.reduce((acc, s) => (acc = acc + s.size), 0),
103106
1
104107
);
105108
const totalAvailable = Math.max(
106-
totalSize - (load?.layout.reduce((acc, { load }) => acc + load, 0) ?? 0),
109+
totalSize -
110+
(load?.layout
111+
.slice(0, layoutNoVirtual.length)
112+
.reduce((acc, { load }) => acc + load, 0) ?? 0),
107113
1
108114
);
109115
const totalUsed = totalSize - totalAvailable;
@@ -275,7 +281,7 @@ export const StorageWidget: FC<StorageWidgetProps> = ({
275281
}) => {
276282
const theme = useTheme();
277283
const isMobile = useIsMobile();
278-
const layout = useStorageLayout(data, config);
284+
const layout = useStorageLayout(data, config).filter(s => !s.virtual);
279285

280286
const [splitView, setSplitView] = useSetting('splitStorage', false);
281287
const canHaveSplitView =

libs/common/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type StorageInfo = {
2828
size: number;
2929
type: string;
3030
raidGroup?: string;
31+
virtual?: boolean;
3132
}[];
3233
};
3334
export type StorageLoad = {
@@ -87,6 +88,7 @@ export type Config = {
8788
use_network_interface: string;
8889
accept_ookla_eula: boolean;
8990
fs_type_filter: string[];
91+
fs_virtual_mounts: string[];
9092
disable_integrations: boolean;
9193

9294
show_host: boolean;

0 commit comments

Comments
 (0)