@volter/supercode-health 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/linux.mjs CHANGED
@@ -15,7 +15,11 @@ export async function memory() {
15
15
  try {
16
16
  const text = read('/proc/pressure/memory');
17
17
  psi = { someAvg10: Number(/some avg10=([\d.]+)/.exec(text)?.[1]), fullAvg10: Number(/full avg10=([\d.]+)/.exec(text)?.[1]) };
18
- } catch (error) { noPsi = error.code === 'ENOENT' || error.code === 'EOPNOTSUPP'; /* a kernel without PSI, or with it off at boot (psi=0), has no pressure to read; any other failure is unknown */ }
18
+ } catch (error) {
19
+ // a kernel without PSI, or with it off at boot (psi=0: errno 95, which Node names ENOTSUP), has no pressure to read;
20
+ // any other failure is unknown
21
+ noPsi = error.code === 'ENOENT' || error.code === 'ENOTSUP';
22
+ }
19
23
  const total = meminfo.MemTotal;
20
24
  const level = psi ? (psi.fullAvg10 >= 10 ? 'critical' : psi.someAvg10 >= 10 ? 'warn' : 'normal') : null;
21
25
  return {
package/lib/sample.mjs CHANGED
@@ -352,7 +352,7 @@ export class Sampler {
352
352
  // (never gone): an alarm raised on one holds, unknown, with why; one never raised costs nothing.
353
353
  const denied = vols.denied ?? [];
354
354
  if (denied.length) slow.readings.diskDenied = denied;
355
- for (const mount of denied) for (const prefix of ['disk.free:', 'disk.filling:']) slow.observations.push({ unreadPrefix: `${prefix}${mount}`, family: 'disk', why: `${mount} can no longer be read by this user (statfs: EACCES)` });
355
+ for (const mount of denied) for (const prefix of ['disk.free:', 'disk.filling:']) slow.observations.push({ unreadPrefix: `${prefix}${mount}`, exact: true, family: 'disk', why: `${mount} can no longer be read by this user (statfs: EACCES)` });
356
356
  if (vols.unread) for (const prefix of ['disk.free:', 'disk.filling:']) slow.observations.push({ unreadPrefix: prefix, family: 'disk', why: vols.unread });
357
357
  else slow.observations.push({ enumerated: 'disk', family: 'disk', by: 'suffix', entities: new Set([...vols.map((v) => v.mount), ...denied]) });
358
358
  // a mount's filling is judged once it has a rate (10 min of readings)
@@ -88,7 +88,7 @@ export function judge(state, observations, families, now, unknowns = {}) {
88
88
  else if (o.enumerated) enumerated.set(o.enumerated, o);
89
89
  else if (o.off) off.add(o.off);
90
90
  }
91
- const why = (key, family) => unreadFamilies.get(family) ?? unreadKeys.get(key)?.why ?? unreadPrefixes.find((p) => p.family === family && key.startsWith(p.unreadPrefix))?.why ?? null;
91
+ const why = (key, family) => unreadFamilies.get(family) ?? unreadKeys.get(key)?.why ?? unreadPrefixes.find((p) => p.family === family && (p.exact ? key === p.unreadPrefix : key.startsWith(p.unreadPrefix)))?.why ?? null;
92
92
  // an entity is a pid (a number) or a name: a key's suffix matches either form
93
93
  const holds = (set, entity) => set.has(entity) || (/^\d+$/.test(entity) && set.has(Number(entity)));
94
94
  const under = (key, family) => covered.some((c) => c.family === family && key.startsWith(c.covered) && (c.all || (c.entities && holds(c.entities, key.slice(c.covered.length)))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-health",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "Optional machine pack: a cheap, deterministic probe of a machine's vitals that mails the machine's maintainer when a threshold is crossed. Each feature sits behind its own permission barrier.",
6
6
  "license": "MIT",