Skip to content

Commit 0387d74

Browse files
authored
Merge pull request #1634 from netalertx/next_release
Next release
2 parents 198ca5d + 1108534 commit 0387d74

47 files changed

Lines changed: 1106 additions & 250 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/skills/code-standards/SKILL.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ description: NetAlertX coding standards and conventions. Use this when writing c
88
- ask me to review before going to each next step (mention n step out of x) (AI only)
99
- before starting, prepare implementation plan (AI only)
1010
- ask me to review it and ask any clarifying questions first
11-
- add test creation as last step - follow repo architecture patterns - do not place in the root of /test
11+
- add test creation as last step - follow repo architecture patterns - do not place in the root of `/test`
1212
- code has to be maintainable, no duplicate code
1313
- follow DRY principle - maintainability of code is more important than speed of implementation
1414
- code files should be less than 500 LOC for better maintainability
1515
- DB columns must not contain underscores, use camelCase instead (e.g., deviceInstanceId, not device_instance_id)
16-
- treat DB as temporary storage for stats, long term configuration should be stored in the /config folder, the /config folder should allow you to restore most of your functionality (excluding historical data)
16+
- treat DB as temporary storage for stats, long-term configuration should be stored in the `/config` folder, the `/config` folder should allow you to restore most of your functionality (excluding historical data)
17+
- never access DB directly from application layers, always use helper functions in `server/db/db_helper.py` and implement new functionality in handlers (e.g., `DeviceInstance` in `server/models/device_instance.py`)
18+
- always validate and normalize MAC addresses before writing to DB (use `normalize_mac` from `plugin_helper.py`)
19+
- all subprocess calls must set explicit timeouts
20+
- use `timeNowUTC` from `utils.datetime_utils` for all time-related operations and DB timestamps (store all timestamps in UTC)
21+
- use sanitizers from `server/helper.py` for user input before storing in DB
22+
- reuse shared mocks and factories from `test/db_test_helpers.py` for tests, never redefine them locally
23+
- use environment variables for runtime paths, never hardcode paths or use relative paths
24+
- follow existing code style and structure, and ensure backward compatibility with existing installations when submitting PRs
25+
- all code needs to be scalable to handle large networks with thousands of devices (10k+) without performance degradation
26+
1727

1828
## File Length
1929

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Check the [GitHub Issues](https://github.com/netalertx/NetAlertX/issues) for the
157157
## Everything else
158158
<!--- --------------------------------------------------------------------- --->
159159

160-
<a href="https://trendshift.io/repositories/12670" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12670" alt="jokob-sk%2FNetAlertX | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
160+
<a href="https://trendshift.io/repositories/19712" target="_blank"><img src="https://trendshift.io/api/badge/repositories/19712" alt="jokob-sk%2FNetAlertX | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
161161

162162
### 📧 Get notified what's new
163163

@@ -170,6 +170,7 @@ Get notified about a new release, what new functionality you can use and about b
170170
- [Fing](https://www.fing.com/) - Network scanner app for your Internet security (Commercial, Phone App, Proprietary hardware)
171171
- [NetBox](https://netboxlabs.com/) - The gold standard for Network Source of Truth (NSoT) and IPAM.
172172
- [Zabbix](https://www.zabbix.com/) or [Nagios](https://www.nagios.org/) - Strong focus on infrastructure monitoring.
173+
- [Domotz](https://www.domotz.com/) - Commercial network monitoring and remote management platform aimed at MSPs, IT teams, and multi-site environments.
173174
- [NetAlertX](https://netalertx.com) - The streamlined, discovery-focused choice for real-time asset intelligence and noise-free alerting.
174175

175176
### 💙 Donations

back/app.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ REPORT_DASHBOARD_URL='update_REPORT_DASHBOARD_URL_setting'
3030
INTRNT_RUN='schedule'
3131
ARPSCAN_RUN='schedule'
3232
NSLOOKUP_RUN='before_name_updates'
33+
DIGSCAN_RUN='before_name_updates'
3334
AVAHISCAN_RUN='before_name_updates'
3435
NBTSCAN_RUN='before_name_updates'
3536

docs/ADVISORY_EYES_ON_GLASS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ For Managed Service Providers (MSPs) and Network Operations Centers (NOC), "Eyes
44

55
![filters](./img/ADVISORIES/filters.png)
66

7+
> [!TIP]
8+
> If you are using Grafana check the `/metrics` endpoint that exposes **Prometheus-compatible metrics** for NetAlertX, including aggregate device counts and per-device status. See the [Metrics API endpoint](./API_METRICS.md) documentation for details.
9+
710
---
811

912
### 1. Configure Auto-Refresh for Live Monitoring

docs/ADVISORY_MULTI_NETWORK.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,25 @@ Effective multi-network monitoring starts with understanding how NetAlertX "sees
1212
* **Manual Entry:** For static assets where only ICMP (ping) status is needed.
1313

1414
> [!TIP]
15-
> Explore the [remote networks](./REMOTE_NETWORKS.md) documentation for more details on how to set up the approaches menationed above.
15+
> Explore the [remote networks](./REMOTE_NETWORKS.md) documentation for more details on how to set up the approaches mentioned above.
1616
1717
---
1818

1919
### 2. Automating IT Asset Inventory with Workflows
2020

21-
[Workflows](./WORKFLOWS.md) are the "engine" of NetAlertX, reducing manual overhead as your device list grows.
21+
[Workflows](./WORKFLOWS.md) are the "engine" of NetAlertX, reducing manual overhead as your device list grows. See some examples below:
22+
23+
#### A. Logical Ownership & VLAN Tagging
24+
25+
Create a workflow triggered on **Device Creation** to:
2226

23-
* **A. Logical Ownership & VLAN Tagging:** Create a workflow triggered on **Device Creation** to:
2427
1. Inspect the IP/Subnet.
2528
2. Set `devVlan` or `devOwner` custom fields automatically.
2629

30+
#### B. Auto-Grouping:
31+
32+
Use conditional logic to categorize devices.
2733

28-
* **B. Auto-Grouping:** Use conditional logic to categorize devices.
2934
* *Example:* If `devLastIP == 10.10.20.*`, then `Set devLocation = "BranchOffice"`.
3035

3136
```json
@@ -56,9 +61,9 @@ Effective multi-network monitoring starts with understanding how NetAlertX "sees
5661
]
5762
}
5863
```
64+
#### C. Sync Node Tracking
5965

60-
61-
* **C. Sync Node Tracking:** When using multiple instances, ensure all synchub nodes have a descriptive `SYNC_node_name` name to distinguish between sites.
66+
When using multiple instances, ensure all sync hub nodes have a descriptive `SYNC_node_name` name to distinguish between sites.
6267

6368
> [!TIP]
6469
> Always test new workflows in a "Staging" instance. A misconfigured workflow can trigger thousands of unintended updates across your database.
@@ -107,6 +112,7 @@ As your environment grows, tuning the underlying engine is vital to maintain a s
107112
* **Plugin Scheduling:** Avoid "Scan Storms" by staggering plugin execution. Running intensive tasks like `NMAP` or `MASS_DNS` simultaneously can spike CPU and cause database locks.
108113
* **Database Health:** Large-scale monitoring generates massive event logs. Use the **[DBCLNP (Database Cleanup)](https://www.google.com/search?q=https://docs.netalertx.com/PLUGINS/%23dbclnp)** plugin to prune old records and keep the SQLite database performant.
109114
* **Resource Management:** For high-device counts, consider increasing the memory limit for the container and utilizing `tmpfs` for temporary files to reduce SD card/disk I/O bottlenecks.
115+
* Enable the `DEEP_SLEEP` setting.
110116

111117
> [!IMPORTANT]
112118
> For a deep dive into hardware requirements, database vacuuming, and specific environment variables for high-load instances, refer to the full **[Performance Optimization Guide](https://docs.netalertx.com/PERFORMANCE/)**.

docs/DEVICE_FIELD_LOCK.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Quick Reference Guide - Device Field Lock/Unlock System
22

3+
> For how scan overwrite rules (`SET_ALWAYS`, `SET_EMPTY`) and source tracking work under the hood, see [Device Source Fields](./DEVICE_SOURCE_FIELDS.md).
4+
35
## Overview
46

57
![Field source and locks](./img/DEVICE_MANAGEMENT/field_sources_and_locks.png)

docs/DEVICE_SOURCE_FIELDS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Understanding Device Source Fields and Field Updates
22

3+
> For the UI guide on locking and unlocking individual fields, see [Device Field Lock/Unlock](./DEVICE_FIELD_LOCK.md).
4+
35
When the system scans a network, it finds various details about devices (like names, IP addresses, and manufacturers). To ensure the data remains accurate without accidentally overwriting manual changes, the system uses a set of "Source Rules."
46

57
![Field source and locks](./img/DEVICE_MANAGEMENT/field_sources_and_locks.png)
@@ -17,6 +19,8 @@ Every piece of information for a device has a **Source**. This source determines
1719
| **NEWDEV** | This value was initialized from `NEWDEV` plugin settings. | **Always** |
1820
| **(Plugin Name)** | The value was found by a specific scanner (e.g., `NBTSCAN`). | **Only if specific rules are met** |
1921

22+
> For how `USER` and `LOCKED` sources are set through the UI (lock/unlock buttons), see [Device Field Lock/Unlock](./DEVICE_FIELD_LOCK.md).
23+
2024
---
2125

2226
## How Scans Update Information
@@ -34,6 +38,8 @@ Some plugins are configured to be "authoritative." If a field is in the **SET_AL
3438
* The scanner will **always** overwrite the current value with the new one.
3539
* *Note: It will still never overwrite a `USER` or `LOCKED` field.*
3640

41+
> On large networks, enabling `SET_ALWAYS` on name-resolution fields (e.g., `devName`) widens the resolution scope and increases DNS query volume. See [Performance — Plugin Field Authority](./PERFORMANCE.md#plugin-field-authority-set_always-and-set_empty) for details.
42+
3743
### 3. SET_EMPTY
3844

3945
If a field is in the **SET_EMPTY** list:

docs/PERFORMANCE.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,41 @@ For example, the **ICMP plugin** allows scanning only IPs that match a specific
9595

9696
---
9797

98+
## Plugin Field Authority: `SET_ALWAYS` and `SET_EMPTY`
99+
100+
Plugins can be configured to control how aggressively they overwrite existing device field values via two settings:
101+
102+
| Setting | Behaviour |
103+
|---|---|
104+
| `<PLUGIN>_SET_ALWAYS` | Plugin always overwrites the field, as long as it can resolve a value and the field is not `USER`/`LOCKED` |
105+
| `<PLUGIN>_SET_EMPTY` | Plugin only writes when the field is currently empty |
106+
107+
Both settings accept a list of field names (e.g., `devName`, `devFQDN`). See [Name resolution](./NAME_RESOLUTION.md) and [Field locking](./DEVICE_SOURCE_FIELDS.md) docs for details.
108+
109+
### Performance Impact of `SET_ALWAYS` on Name Resolution
110+
111+
By default, name resolution (DIGSCAN, NBTSCAN, NSLOOKUP, AVAHISCAN) only runs against **devices that have no name yet**. This keeps DNS query volume proportional to new devices discovered, not the total inventory.
112+
113+
When **any** name-resolution plugin has `devName` in its `SET_ALWAYS` list, the system additionally runs a second resolution pass against **all devices whose name is not `USER`/`LOCKED` protected**. This allows a higher-priority plugin (e.g., DIGSCAN) to overwrite names previously set by a lower-priority one (e.g., NBTSCAN).
114+
115+
**Cost:** one DNS query per unprotected, already-named device per name-resolution cycle.
116+
117+
| Scenario | Devices resolved per cycle |
118+
|---|---|
119+
| No `SET_ALWAYS` on `devName` | Only new/unknown devices |
120+
| `SET_ALWAYS: devName` on any plugin | New/unknown devices **+** all unprotected named devices |
121+
122+
> [!WARNING]
123+
> On large installations (thousands of devices), enabling `SET_ALWAYS: devName` significantly increases DNS query volume and cycle duration. To mitigate:
124+
>
125+
> * Increase the scan interval of name-resolution plugins (`DIGSCAN_RUN_SCHD`, `NBTSCAN_RUN_SCHD`, etc.).
126+
> * Mark devices whose name should never change as `USER` or `LOCKED` — they are excluded from the re-resolve pass entirely.
127+
> * Use `SET_ALWAYS` only on the highest-priority plugin; leave lower-priority plugins without it.
128+
129+
The actual number of DB rows updated is logged at `verbose` level under `[Update Device Name] SET_ALWAYS re-resolve - DB rows updated`.
130+
131+
---
132+
98133
## Storing Temporary Files in Memory
99134

100135
On devices with slower I/O, you can improve performance by storing temporary files (and optionally the database) in memory using `tmpfs`.

docs/PLUGINS_DEV_UI_COMPONENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Configure how your plugin's data is displayed in the NetAlertX web interface.
77
Plugin results are displayed in the UI via the **Plugins page** and **Device details tabs**. You control the appearance and functionality of these displays by defining `database_column_definitions` in your plugin's `config.json`.
88

99
Each column definition specifies:
10+
1011
- Which data field to display
1112
- How to render it (label, link, color-coded badge, etc.)
1213
- What CSS classes to apply
@@ -275,6 +276,7 @@ Replaces specific values with display strings or HTML.
275276
```
276277

277278
**Output Examples:**
279+
278280
- `"online"` → 🟢 Online
279281
- `"offline"` → 🔴 Offline
280282
- `"idle"` → 🟡 Idle

docs/WORKFLOW_EXAMPLES.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ Sometimes devices are manually archived (e.g., no longer expected on the network
4545
],
4646
"enabled": "Yes"
4747
}
48-
```
48+
````
4949

5050
### 🔍 Explanation
5151

52-
- Trigger: Listens for updates to device records.
53-
- Conditions:
54-
- `devIsArchived` is `1` (archived).
55-
- `devPresentLastScan` is `1` (device was detected in the latest scan).
56-
- Action: Updates the device to set `devIsArchived` to `0` (unarchived).
52+
* **Trigger**: Listens for updates to device records.
53+
* **Conditions**:
5754

58-
### ✅ Result
55+
* `devIsArchived` is `1` (archived).
56+
* `devPresentLastScan` is `1` (device was detected in the latest scan).
57+
* **Action**:
5958

60-
Whenever a previously archived device shows up during a network scan, it will be automatically unarchived — allowing it to reappear in your device lists and dashboards.
59+
* Updates the device to set `devIsArchived` to `0` (unarchived).
6160

61+
### ✅ Result
6262

63-
Here is your updated version of **Example 2** and **Example 3**, fully aligned with the format and structure of **Example 1** for consistency and professionalism:
63+
Whenever a previously archived device shows up during a network scan, it will be automatically unarchived — allowing it to reappear in your device lists and dashboards.
6464

6565
---
6666

@@ -107,7 +107,7 @@ When new devices join your network, assigning them to the correct network node i
107107
### 🔍 Explanation
108108

109109
* **Trigger**: Activates when a new device is added.
110-
* **Condition**:
110+
* **Conditions**:
111111

112112
* `devLastIP` contains `192.168.1.` (matches subnet).
113113
* **Action**:
@@ -173,12 +173,12 @@ You may want to automatically clear out newly detected Google devices (such as C
173173
* **Trigger**: Runs on device updates.
174174
* **Conditions**:
175175

176-
* Vendor contains `Google`.
177-
* Device is marked as new (`devIsNew` is `1`).
176+
* `devVendor` contains `Google`.
177+
* `devIsNew` is `1` (device marked as new).
178178
* **Actions**:
179179

180-
1. Set `devIsNew` to `0` (mark as not new).
181-
2. Delete the device.
180+
1. Sets `devIsNew` to `0` (mark as not new).
181+
2. Deletes the device.
182182

183183
### ✅ Result
184184

0 commit comments

Comments
 (0)