Compare commits

...

46 commits

Author SHA1 Message Date
97fc51d3ab Aggiunge link GreasyFork nella sezione Installation del README 2026-07-01 20:03:19 +02:00
efd2fdec0b v2.15.3 - Aggiungi @license CC-BY-NC-4.0 all'header UserScript 2026-07-01 20:01:14 +02:00
764e370ce5 v2.15.3 - Aggiorna homepageURL a GitHub 2026-07-01 19:42:13 +02:00
668985aff5 v2.15.2 - Fix: menu WATO assente su view.py senza sidebar quando non ci sono pending changes
hasWatoAccess ora cerca qualsiasi link wato.py nel documento, non solo
mode=changelog. I link mode=inventory iniettati dalla colonna Extra
garantiscono la detection anche con pending changes vuoti.
README: aggiunta tabella panoramica feature con nomi, descrizioni e funzioni.
2026-07-01 19:12:59 +02:00
eede70f16a v2.15.1 - Bump @version header 2026-07-01 16:24:32 +02:00
3a8ffdd824 v2.15.1 - Fix: pulsanti Collapse/Expand non compaiono su view.py (solo wato.py) 2026-07-01 16:23:06 +02:00
419ae557b7 v2.15.0 - Aggiunti pulsanti Collapse All / Expand All nel menu bar degli accordion
Funziona su edit_host, bulkedit, editfolder (table.nform) e edit_ruleset
(div.foldable). Usa getTargetDoc() per compatibilità con e senza sidebar.
2026-07-01 16:20:46 +02:00
957cd7e686 Aggiorna README: colonna Extra con 4 pulsanti (aggiunto IP), rinominata sezione feature 2026-07-01 15:57:44 +02:00
93fe834c8e v2.14.0 - Colonna Extra dedicata per pulsanti host: discovery, copia FQDN, copia hostname corto, copia IP (da tooltip) 2026-07-01 15:55:09 +02:00
6b7cbea1d3 Aggiorna README: menu WATO UX aggiornata, aggiunta feature auto-check foreign changes 2026-07-01 10:14:31 +02:00
3d17eb3141 v2.13.3 - Aggiorna @version header 2026-06-30 18:23:24 +02:00
ba50830ede v2.13.3 - Auto-check 'Activate foreign changes' su pagina changelog all'apertura 2026-06-30 18:23:03 +02:00
2d1112cc44 v2.13.2 - Menu WATO view.py: select più visibile, placeholder 'Select hosts (n)', pulsante Apri disabilitato/grigio → abilitato/blu alla selezione 2026-06-30 17:37:21 +02:00
ff907e5770 Aggiorna l'anno di copyright nel file LICENSE 2026-06-25 09:22:00 +02:00
32e3bf11da Aggiungi licenza CC BY-NC 4.0 2026-06-25 09:21:24 +02:00
c006b52b15 v2.13.1 - Traduci commenti in inglese, aggiungi README pubblico 2026-06-25 09:17:17 +02:00
641fd5a20a v2.13.0 - Aggiunto menu WATO su view.py: select paginata + pulsante Apri per bulk-edit host in WATO 2026-06-23 16:10:55 +02:00
54c313353a v2.12.4 - Normalizza separatori nella ricerca folder: >, / e › sono equivalenti 2026-06-23 14:41:45 +02:00
14f83533fa v2.12.3 - Estendi folder select enhancement al filtro Folder nelle viste di monitoraggio (wato_folder) 2026-06-23 14:36:27 +02:00
a9be5d2a40 v2.12.2 - Aggiungi accordion badge su pagina editfolder (proprietà folder) 2026-06-23 14:17:37 +02:00
603ed33b71 v2.12.1 - Fix contatori monitorati/disabilitati e rimozione corruzione encoding 2026-06-23 13:17:16 +02:00
29065be314 fix: aggiorna @version a 2.12.0 nell'header UserScript 2026-06-23 13:02:54 +02:00
ade0c65b12 v2.12.0 - Aggiunge contatori host monitorati/disabilitati in heading folder 2026-06-23 13:01:52 +02:00
50f003ba09 v2.11.0 - Aggiunge pulsante monitoring su pagine WATO folder
Nelle pagine wato.py?mode=folder, aggiunge un pulsante occhio verde (20x20px)
accanto all'hostname di ogni host attivo (non disabilitato). Il pulsante apre
la vista di monitoraggio host (view_name=host) in una nuova tab, supportando
middle-click. Gli host con title="This host is disabled" vengono saltati.
Il pulsante occupa lo stesso spazio dell'icona X dei disabled per mantenere
l'allineamento. Funziona sia con sidebar (iframe) che senza.
Aggiunto tag @checkmk 2.3.x per indicare la versione testata.
2026-06-23 12:53:23 +02:00
6788d233ba v2.10.0 - Ripristina <a> per pulsante discovery, supporto middle-click
Il pulsante Service Discovery torna ad essere un tag <a> con href/target/_blank
per supportare il middle-click nativo del browser (apri in background tab).
I due pulsanti copia restano <button> perché non hanno un URL di destinazione.
Il CSS con !important su margin/box-sizing/display ora protegge l'<a> dagli
override della pagina, risolvendo il problema che aveva portato alla conversione
a <button> nella 2.9.7. Aggiunto :visited per mantenere il colore arancio.
2026-06-19 16:08:29 +02:00
fa1b0ec8ce v2.9.9 - Generalizza rilevamento hostname in addInventoryButtons
Sostituisce il selettore fisso a[href*="view_name=hoststatus"] con ricerca
generica su a[href*="host="] + URLSearchParams.get('host'), in modo che
i tre pulsanti compaiano su qualsiasi vista view.py con una colonna host
indipendentemente dal view_name usato nel link.
2026-06-17 18:25:53 +02:00
a141d7d114 v2.9.8 - Aggiunto margin 1px ai pulsanti azioni host in view.py 2026-06-17 18:15:54 +02:00
22c0c3f38c v2.9.7 - Converti pulsante discovery da <a> a <button> in addInventoryButtons
Il tag <a> ereditava CSS della pagina (margin, box-sizing) che sovrascrivevano
le regole dello script, causando disallineamento visivo specie con la sidebar.
Conversione a <button type="button"> con window.open() rende tutti e tre i
pulsanti stilisticamente uniformi. Aggiunti !important sulle proprietà critiche
del gruppo per blindarle contro override della pagina.
2026-06-17 18:10:13 +02:00
58684f0c66 v2.9.6 - Fix spaziatura terzo pulsante azioni host in view.py
Aggiunto margin: 0 ai pulsanti .cmk-sk-inv-btn/.cmk-sk-copy-btn/.cmk-sk-copy-short-btn
per azzerare il margin di default del browser sui button element e ottenere
spaziatura uniforme (gap: 2px) tra tutte e tre le icone nel gruppo.
2026-06-17 18:00:36 +02:00
4a17668e9e feat: aggiungi terzo pulsante copia hostname corto e refactor spacing
Terzo pulsante viola copia l'hostname senza dominio (prima parte prima
del primo punto). I tre pulsanti sono ora in un wrapper flex con gap:2px
e margin-right:4px verso il nome host, eliminando le irregolarità di
spacing tra icone inline.

bump version to 2.9.5
2026-06-17 17:55:49 +02:00
4a92b46f22 fix: icona clipboard blu e spacing uniforme tra i due pulsanti host
Colore clipboard cambiato da grigio a #5ab4d6 (blu). Ridotto il gap
tra le due icone a 2px (da 5px) per raggrupparle visivamente, mantenendo
5px di distanza dal nome host.

bump version to 2.9.4
2026-06-17 17:52:54 +02:00
503284419d feat: aggiungi pulsante copia hostname in clipboard su view.py
Accanto al pulsante Service Discovery, aggiunge un secondo pulsante
con icona clipboard che copia il nome host negli appunti al click.
Feedback visivo verde per 900ms al click confermato.

bump version to 2.9.3
2026-06-17 17:50:01 +02:00
8d40ccc511 fix: pulsante inventory con icona monitor+spunta arancione prima del nome host
Sostituita lente con icona monitor+checkmark, colore arancione #e5a500,
posizionata prima del nome host (prepend invece di append).

bump version to 2.9.2
2026-06-17 17:39:30 +02:00
7915571ff4 fix: sostituisci testo 'disco' con icona SVG sul pulsante inventory
Il pulsante Service Discovery usa ora un'icona lente SVG inline con
bordino blu al posto del testo. Dimensione 16x16px, trasparente,
con hover che aumenta l'opacità e schiarisce il bordo.

bump version to 2.9.1
2026-06-17 17:32:45 +02:00
44e68acf22 feat: aggiungi pulsante disco su view.py per aprire Service Discovery host
Nelle monitoring views (view.py), aggiunge un badge 'disco' accanto
a ogni hostname nella colonna Host. Il click apre in nuova tab la pagina
wato.py?host=HOSTNAME&mode=inventory per il Service Discovery diretto.
Esteso @include a coprire anche view.py.

bump version to 2.9.0
2026-06-17 17:29:06 +02:00
b99d5a8583 fix: nascondi toggle su pagine edit_ruleset senza ricerca attiva
Il toggle "Solo rilevanti" non deve apparire su viste normali del ruleset
dove nessuna riga è evidenziata (nessuna ricerca per tag, host o ineffective).
Controllo anticipato su relevantCount === 0 prima di marcare righe e folder.

bump version to 2.8.1
2026-06-17 17:12:11 +02:00
d76fe201d8 feat: aggiungi toggle filtra/mostra righe irrilevanti su edit_ruleset
Aggiunge una barra in cima alle pagine edit_ruleset con un pulsante
"Solo rilevanti" / "Mostra tutto" che nasconde le righe e i folder
senza regole rilevanti (match, no-match, ineffective). Utile quando
su centinaia di regole solo poche sono evidenziate dalla ricerca.

bump version to 2.8.0
2026-06-17 15:38:33 +02:00
8093f2f1c8 feat: estendi badge match alle ricerche per tag su edit_ruleset
Le pagine edit_ruleset aperte da una ricerca per hosttag usano
title="Matches" invece di title^="This rule matches". Esteso il
selettore CSS per coprire entrambi i casi.

bump version to 2.7.1
2026-06-17 15:17:31 +02:00
40878df517 feat: highlight match/no-match nelle pagine edit_ruleset con contesto host
Aggiunge badge verde (checkmark) alle regole che matchano e badge grigio
dimmed alle regole che non matchano, sostituendo le icone poco visibili.
La funzione tryHighlightRuleset ora gestisce entrambe le feature ruleset
(ineffective + match status) sulle pagine mode=edit_ruleset.
2026-06-17 15:11:22 +02:00
0b5bfb78b2 chore: migrazione versioning a SemVer major.minor.patch (2.6.0) 2026-06-17 15:01:40 +02:00
7a39b5e3f8 feat: highlight visivo regole ineffective in pagine edit_ruleset
Aggiunge badge arancione 'ineffective' e bordo sinistro alle righe
marcate con icon_hyphen.svg (title='Ineffective rule'). Funziona sia
su wato.py diretto che dentro index.py con sidebar. Aggiunto helper
getTargetDoc() per gestire entrambi i casi. Attivazione via guard URL
mode=edit_ruleset.
2026-06-17 15:01:00 +02:00
1e0e9a4b16 feat: aggiunto badge rosso con conteggio valori in conflitto tra host (bulkedit)
Terzo badge con simbolo neq N (rosso) che conta le proprieta con This value differs
between the selected hosts. Appare solo sulla pagina bulkedit dove ha
senso. Aggiunto updateDiffBadge() e CSS .cmk-sk-diff-count.
2026-06-16 17:56:47 +02:00
cf30ac2024 feat: estesi accordion badge anche alla pagina bulkedit
Aggiunta costante ACCORDION_MODES (Set con 'edit_host' e 'bulkedit') per
centralizzare il guard URL. I badge di conteggio checkbox e valori ereditati
ora si attivano su entrambe le pagine di modifica host, singola e massiva.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 17:51:35 +02:00
f642f805d7 fix: guard URL-based per attivare le feature solo sulle pagine target
Aggiunto helper getPageMode(iDoc) che legge il parametro "mode" dall'URL
senza toccare il DOM. Accordion badges ora si attiva solo su mode=edit_host
(guard in tryInitAccordionCounts, init e MutationObserver), evitando
operazioni inutili e potenziali errori in console sulle altre pagine.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 17:43:33 +02:00
5169505140 feat: aggiunto badge blu con conteggio valori ereditati da folder parent negli accordion
Accanto al badge arancione (checkbox spuntate), compare ora un badge blu
"↑N" che conta le proprietà con valore esplicitamente ereditato da una
cartella padre ("Inherited from X"), escludendo i semplici "(Default value)".
Il contatore si aggiorna in tempo reale al cambio delle checkbox.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 17:36:57 +02:00
761ca89cc9 feat: aggiunto badge con conteggio checkbox attive per ogni accordion in edit_host
Ogni titolo di gruppo (es. "Services - DB") mostra ora il numero di
checkbox spuntate tra parentesi arancioni. Il contatore si aggiorna
in tempo reale al cambio delle checkbox. Aggiornato anche homepageURL
dal vecchio GitLab al nuovo Forgejo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 17:24:54 +02:00
3 changed files with 1152 additions and 37 deletions

17
LICENSE Normal file
View file

@ -0,0 +1,17 @@
Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
Copyright (c) 2026 Luigi D'Acunto
You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the
license, and indicate if changes were made.
NonCommercial — You may not use the material for commercial purposes.
No additional restrictions — You may not apply legal terms or technological
measures that legally restrict others from doing anything the license permits.
Full license text: https://creativecommons.org/licenses/by-nc/4.0/legalcode

139
README.md Normal file
View file

@ -0,0 +1,139 @@
# Checkmk SwissKnife
A [Tampermonkey](https://www.tampermonkey.net/) userscript that enhances the Checkmk 2.3.x web interface with quality-of-life improvements for WATO configuration and monitoring views.
## Installation
1. Install the [Tampermonkey](https://www.tampermonkey.net/) browser extension.
2. Install the script from one of these sources:
- [**GreasyFork**](https://greasyfork.org/en/scripts/585184-checkmk-swissknife) *(recommended)*
- [**Direct install**](https://luigidacunto.com/scripts/checkmk-swissknife/user_script/checkmk_swissknife.user.js)
3. Tampermonkey will detect the `@downloadURL` and prompt for updates automatically.
**Compatibility:** Checkmk 2.3.x · Chrome · Firefox · Edge
## Features
| Feature | Description | Code function |
|---------|-------------|---------------|
| **Folder Path Search** | Replaces the folder dropdown with a searchable overlay — type any path segment to filter instantly | `initSelect2Enhanced` |
| **Accordion Badge Counts** | Shows inline counters in each accordion header: enabled checkboxes (orange), inherited values (blue), differing values vs folder default (red) | `initAccordionCheckedCounts` |
| **Ineffective Rule Highlight** | Replaces the hard-to-spot hyphen icon on ineffective rules with a visible ⚠ badge and amber row border | `highlightIneffectiveRules` |
| **Rule Match Status** | Colors each rule row green (match) or dimmed (no match) when a ruleset is opened with host/service context | `highlightRuleMatchStatus` |
| **Relevant Only Filter** | Adds a "Relevant only" toggle above the rule list to hide all non-matching and non-highlighted rows | `addRulesetFilterToggle` |
| **Extra Column — Host Actions** | Inserts an Extra column in monitoring tables with per-host buttons: Service Discovery, copy FQDN, copy short hostname, copy IP | `addInventoryButtons` |
| **Monitor Button in WATO Folder** | Adds a green eye icon next to each active host in WATO folder listings to open its monitoring view in a new tab | `addWatoFolderMonitorButtons` |
| **Configure in WATO Menu** | Adds a host-selector dropdown and Open button to the monitoring view menu bar for bulk-opening hosts in WATO | `addViewWatoMenu` |
| **Auto-check Foreign Changes** | Automatically ticks the "Activate foreign changes" checkbox on the pending changes page | `tryAutoCheckForeignActivation` |
| **Collapse All / Expand All** | Adds two buttons to the menu bar to collapse or expand all accordion sections at once | `addAccordionToggleButtons` |
---
### Folder Path Search
Replaces the default WATO folder dropdown with a searchable overlay. Type any segment of the folder path to filter — separators `>`, ``, and `/` are treated as equivalent.
Applies to: rule condition editor (`explicit_conditions_p_folder_path`) and monitoring view folder filter (`wato_folder`).
---
### Accordion Badge Counts
Displays inline counters in each accordion section header on host edit pages:
| Badge | Meaning |
|-------|---------|
| **orange `(N)`** | N checkboxes enabled in this section |
| **blue `↑N`** | N values inherited from a parent folder |
| **red `≠N`** | N values that differ from the folder default *(bulk edit only)* |
Applies to: `edit_host`, `bulkedit`, `editfolder`.
---
### Ineffective Rule Highlight
Replaces the low-visibility hyphen icon on ineffective rules with a prominent **`⚠ ineffective`** badge and adds an amber left border to the row.
Applies to: `mode=edit_ruleset`.
---
### Rule Match Status Highlight
When a ruleset is opened in context (URL contains `host=` and/or `service=`), colors each rule row:
- **Green + `✓ match`** — rule applies to the given host/service
- **Dimmed + `✗ no match`** — rule does not apply
Applies to: `mode=edit_ruleset` with host/service context.
---
### Ruleset Filter Toggle
After match/ineffective highlighting runs, a **"Relevant only"** button appears above the rule list. Clicking it hides all non-highlighted rows and empty folders, leaving only the rules that matter for the current context.
Applies to: `mode=edit_ruleset` (when at least one highlighted row exists).
---
### Extra Column with Host Actions
Adds a dedicated **Extra** column before the Host column in all monitoring view tables. Each row gets up to four icon buttons:
| Button | Color | Action |
|--------|-------|--------|
| Screen icon | Amber | Opens **Service Discovery** for the host in a new tab |
| Clipboard icon | Blue | Copies the full FQDN to clipboard |
| Clipboard icon | Purple | Copies the short hostname (first label) to clipboard |
| Clipboard icon | Green | Copies the host **IP address** to clipboard *(shown only when available)* |
The IP address is read from the tooltip Checkmk places on the hostname cell. Clicking any clipboard button briefly turns it green to confirm the copy.
Applies to: `view.py` host and service views.
---
### Monitor Button on WATO Folder Pages
Adds a green eye icon next to each active (non-disabled) host in WATO folder listings, opening the host's monitoring view in a new tab. A summary badge on the section header shows monitored vs disabled host counts.
Applies to: `wato.py?mode=folder`.
---
### "Configure in WATO" Menu
Adds a **Select hosts (N)** dropdown and an **Open** button to the monitoring view menu bar. Select a page of hosts, then click **Open** — WATO opens in a new tab with exactly those hosts pre-filtered via regex search, ready for bulk configuration.
- Up to 50 hosts per page (keeps URLs within safe length limits)
- Deduplicates hostnames automatically (useful on service views where hosts repeat)
- **Open** button is disabled (gray) until a page is selected; turns blue when active; resets after opening
- Only visible for users with WATO configuration access
Applies to: `view.py` (admin/configuration role required).
---
### Auto-check "Activate Foreign Changes"
On the **Activate pending changes** page, automatically checks the *Activate foreign changes* checkbox as soon as the page is ready, so you never have to remember to tick it manually before activating.
Applies to: `wato.py?mode=changelog` (with or without sidebar).
---
### Collapse All / Expand All
Adds two buttons to the top menu bar on any page with expandable sections:
| Button | Color | Action |
|--------|-------|--------|
| **Collapse All** | Orange | Collapses all open accordion sections at once |
| **Expand All** | Green | Expands all collapsed accordion sections at once |
Works on both host-edit pages (accordion sections are `table.nform` elements) and ruleset pages (accordion sections are `div.foldable` elements).
Applies to: `edit_host`, `bulkedit`, `editfolder`, `edit_ruleset` (with or without sidebar).
## How it works
The script injects enhancements at page load and re-applies them on SPA navigation (Checkmk reloads content inside an `<iframe>` without a full page reload). Each feature is independent — a feature that does not apply to the current page does nothing and stops polling.
## License
[CC BY-NC 4.0](LICENSE) — free to use, share, and adapt for non-commercial purposes.
Commercial use or resale is not permitted.

File diff suppressed because it is too large Load diff