Add "server action" in EPP rule where you are creating alarm
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: richard21 on September 18, 2025, 07:40:29 PMVery Nice I have it working one Observation / Issue it doesn't let you logon if you have MFA enabled on the account
Quote from: maliodpalube on September 12, 2025, 11:14:39 AMOk, thx, but when trying to import xml template nothing happens it just stands like this indefinitely, can click on ok, only browse or cancel
DO $$
DECLARE
node_record RECORD;
tbl_name TEXT;
dup_count INTEGER;
total_duplicates INTEGER := 0;
BEGIN
FOR node_record IN SELECT id FROM nodes
LOOP
tbl_name := 'idata_' || node_record.id;
IF EXISTS (
SELECT 1
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = tbl_name
) THEN
RAISE NOTICE 'Processing table %', tbl_name;
EXECUTE format('
WITH ranked AS (
SELECT ctid,
ROW_NUMBER() OVER (PARTITION BY item_id, idata_timestamp ORDER BY ctid) as rn
FROM public.%I
)
SELECT COUNT(*)
FROM ranked
WHERE rn > 1
', tbl_name) INTO dup_count;
IF dup_count > 0 THEN
RAISE NOTICE 'Table % has % duplicate rows', tbl_name, dup_count;
total_duplicates := total_duplicates + dup_count;
END IF;
END IF;
END LOOP;
RAISE NOTICE 'Total duplicate rows found: %', total_duplicates;
END $$;
DO $$
DECLARE
node_record RECORD;
tbl_name TEXT;
deleted_count INTEGER;
total_deleted INTEGER := 0;
BEGIN
FOR node_record IN SELECT id FROM nodes
LOOP
tbl_name := 'idata_' || node_record.id;
IF EXISTS (
SELECT 1
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = tbl_name
) THEN
RAISE NOTICE 'Processing table %', tbl_name;
EXECUTE format('
WITH duplicates AS (
SELECT ctid,
ROW_NUMBER() OVER (
PARTITION BY item_id, idata_timestamp
ORDER BY ctid
) as rn
FROM public.%I
)
DELETE FROM public.%I
WHERE ctid IN (
SELECT ctid
FROM duplicates
WHERE rn > 1
)', tbl_name, tbl_name);
GET DIAGNOSTICS deleted_count = ROW_COUNT;
IF deleted_count > 0 THEN
RAISE NOTICE 'Deleted % duplicate rows from table %', deleted_count, tbl_name;
total_deleted := total_deleted + deleted_count;
ELSE
RAISE NOTICE 'Table % has no duplicates', tbl_name;
END IF;
END IF;
END LOOP;
RAISE NOTICE 'Total duplicate rows deleted: %', total_deleted;
END $$;
Quote from: Spheron on September 05, 2025, 09:36:46 AMThe script is running about 1h bevor i canceld it.
DO $$
DECLARE
node_record RECORD;
tbl_name TEXT;
dup_count INTEGER;
total_duplicates INTEGER := 0;
BEGIN
FOR node_record IN SELECT id FROM nodes
LOOP
tbl_name := 'idata_' || node_record.id;
IF EXISTS (
SELECT 1
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = tbl_name
) THEN
RAISE NOTICE 'Processing table %', tbl_name;
EXECUTE format('
WITH ranked AS (
SELECT ctid,
ROW_NUMBER() OVER (PARTITION BY item_id, idata_timestamp ORDER BY ctid) as rn
FROM public.%I
)
SELECT COUNT(*)
FROM ranked
WHERE rn > 1
', tbl_name) INTO dup_count;
IF dup_count > 0 THEN
RAISE NOTICE 'Table % has % duplicate rows', tbl_name, dup_count;
total_duplicates := total_duplicates + dup_count;
END IF;
END IF;
END LOOP;
RAISE NOTICE 'Total duplicate rows found: %', total_duplicates;
END $$;
DO $$
DECLARE
node_record RECORD;
tbl_name TEXT;
deleted_count INTEGER;
total_deleted INTEGER := 0;
BEGIN
FOR node_record IN SELECT id FROM nodes
LOOP
tbl_name := 'idata_' || node_record.id;
IF EXISTS (
SELECT 1
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = tbl_name
) THEN
RAISE NOTICE 'Processing table %', tbl_name;
EXECUTE format('
WITH duplicates AS (
SELECT ctid,
ROW_NUMBER() OVER (
PARTITION BY item_id, idata_timestamp
ORDER BY ctid
) as rn
FROM public.%I
)
DELETE FROM public.%I
WHERE ctid IN (
SELECT ctid
FROM duplicates
WHERE rn > 1
)', tbl_name, tbl_name);
GET DIAGNOSTICS deleted_count = ROW_COUNT;
IF deleted_count > 0 THEN
RAISE NOTICE 'Deleted % duplicate rows from table %', deleted_count, tbl_name;
total_deleted := total_deleted + deleted_count;
ELSE
RAISE NOTICE 'Table % has no duplicates', tbl_name;
END IF;
END IF;
END LOOP;
RAISE NOTICE 'Total duplicate rows deleted: %', total_deleted;
END $$;
Quote from: Spheron on September 04, 2025, 12:09:30 PMIf i run then nxdbmgr background-upgrade i get the following errors:DROP INDEX idx_tdata_7035
SQL query failed (42P16 FEHLER: mehrere Primärschlüssel für Tabelle »idata_7046« nicht erlaubt):
ALTER TABLE idata_7046 ADD PRIMARY KEY (item_id,idata_timestamp)
SQL query failed (42P16 FEHLER: mehrere Primärschlüssel für Tabelle »tdata_7046« nicht erlaubt):
ALTER TABLE tdata_7046 ADD PRIMARY KEY (item_id,tdata_timestamp)
SQL query failed (42704 FEHLER: Index »idx_idata_7052_id_timestamp« existiert nicht):
DROP INDEX idx_idata_7052_id_timestamp
SQL query failed (42P16 FEHLER: mehrere Primärschlüssel für Tabelle »tdata_7052« nicht erlaubt):
ALTER TABLE tdata_7052 ADD PRIMARY KEY (item_id,tdata_timestamp)
SQL query failed (42P16 FEHLER: mehrere Primärschlüssel für Tabelle »idata_7089« nicht erlaubt):
ALTER TABLE idata_7089 ADD PRIMARY KEY (item_id,idata_timestamp)
SQL query failed (42704 FEHLER: Index »idx_tdata_7089« existiert nicht):
DROP INDEX idx_tdata_7089
SQL query failed (42P16 FEHLER: mehrere Primärschlüssel für Tabelle »idata_7096« nicht erlaubt):
ALTER TABLE idata_7096 ADD PRIMARY KEY (item_id,idata_timestamp)
SQL query failed (42P16 FEHLER: mehrere Primärschlüssel für Tabelle »tdata_7096« nicht erlaubt):
ALTER TABLE tdata_7096 ADD PRIMARY KEY (item_id,tdata_timestamp)
SQL query failed (42704 FEHLER: Index »idx_idata_7127_id_timestamp« existiert nicht):
DO $$
DECLARE
node_record RECORD;
tbl_name TEXT;
dup_count INTEGER;
total_duplicates INTEGER := 0;
BEGIN
FOR node_record IN SELECT id FROM nodes
LOOP
tbl_name := 'idata_' || node_record.id;
IF EXISTS (
SELECT 1
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = tbl_name
) THEN
EXECUTE format('
SELECT COUNT(*) FROM public.%I
WHERE ctid NOT IN (
SELECT MIN(ctid)
FROM public.%I
GROUP BY item_id, idata_timestamp
)', tbl_name, tbl_name) INTO dup_count;
IF dup_count > 0 THEN
RAISE NOTICE 'Table % has % duplicate rows', tbl_name, dup_count;
total_duplicates := total_duplicates + dup_count;
END IF;
END IF;
END LOOP;
RAISE NOTICE 'Total duplicate rows found: %', total_duplicates;
END $$;
Quote from: nichky on August 07, 2025, 12:21:44 AMdo we have that option , greate. Whenever you're ready - Thankscontact [email protected]
Quote from: nichky on August 05, 2025, 02:07:09 PMhave you spotted anything?
2025.08.05 15:09:23.447 *I* [logger ] Log file opened (rotation policy 2, max size 16777216)
2025.08.05 15:09:23.447 *I* [startup ] Starting NetXMS server version 5.2.4 build tag 5.2-396-gbe46bc94fe
2025.08.05 15:09:23.452 *I* [startup ] System time zone is AUS+10AUSEDT
2025.08.05 15:09:23.452 *I* [logger ] Debug level set to 3
2025.08.05 15:09:23.454 *I* [config ] Main configuration file: C:\NetXMS\etc\netxmsd.conf
2025.08.05 15:09:23.454 *I* [config ] Configuration tree:
2025.08.05 15:09:23.454 *I* [config ] config
2025.08.05 15:09:23.455 *I* [config ] +- server
2025.08.05 15:09:23.455 *I* [config ] +- DBDriver
2025.08.05 15:09:23.455 *I* [config ] | value: pgsql.ddr
2025.08.05 15:09:23.455 *I* [config ] +- DBServer
2025.08.05 15:09:23.456 *I* [config ] | value: 127.0.0.1
2025.08.05 15:09:23.456 *I* [config ] +- LogFile
2025.08.05 15:09:23.456 *I* [config ] value: C:\NetXMS\log\netxmsd.log
2025.08.05 15:09:23.457 *D* [startup ] LIB directory set to C:\NetXMS\lib
2025.08.05 15:09:23.458 *I* [startup ] System hardware ID 7769846E7CDDD8444067E3FFB9220D396182B9A6
2025.08.05 15:09:23.465 *I* [db.drv ] Database driver "pgsql.ddr" loaded and initialized successfully
2025.08.05 15:09:23.469 *D* [comm.listener ] SocketListener/LocalAdmin: Trying to bind on 127.0.0.1:21784/tcp
2025.08.05 15:09:23.469 *D* [comm.listener ] SocketListener/LocalAdmin: Trying to bind on [::1]:21784/tcp
2025.08.05 15:09:23.470 *I* [comm.listener ] SocketListener/LocalAdmin: listening on 127.0.0.1:21784
2025.08.05 15:09:23.470 *I* [comm.listener ] SocketListener/LocalAdmin: listening on [127.0.0.1]:21784
2025.08.05 15:09:23.470 *D* [localadmin ] Local administration interface listener initialized
2025.08.05 15:10:00.783 *E* [db ] Unable to establish connection with database (could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?)