Menu

Show posts

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 Menu

Messages - Alex Kirhenshtein

#1
Well, we always mention that it's just for the tests and extremely simple setups. SQLite is great for some use cases, but not this one.
Consider it's not available.


Quote from: cwl on November 22, 2025, 11:10:02 AM
Quote from: Filipp Sudanov on November 21, 2025, 03:43:38 PMIs this still with SQLite?
But generally speaking if SQLite is provided as an option - it has work correctly.
#2
update alarms set alarm_state=3 where alarm_state <> 3;
Quote from: Argonauts on November 10, 2025, 09:50:21 AMАктивных алармов 187к -_-
Я могу их как-то скопом потушить? С момента развертывания не трогали алармы
#3
General Support / Re: Sending alarms to N8N?
October 21, 2025, 11:16:19 PM
also you don't need "function main()", just write code.

something like this:

source = FindObject($alarm.sourceObject());

j = JsonObject();
j.set("id", $alarm.id);
j.set("state", $alarm.state);
j.set("severity", $alarm.severity);
j.set("message", $alarm.message);
j.set("source", source ? source.name : "");
j.set("eventCode", $alarm.eventCode);
j.set("eventName", $alarm.eventName);

trace(0, j.serialize());

I highly recommend you to read https://www.netxms.org/documentation/nxsl-latest/.
#4
General Support / Re: Sending alarms to N8N?
October 21, 2025, 10:22:34 PM
There are no "Execute()" function in the NXSL, and you can't execute external commands in any way - that's by design.

What I'd do:
- create Action which runs external shell script to form  json and send query using curl. Pass required event fields as arguments to the script.
- add this Action to EPP (I'd create separate rule just for this integration - this way you can control what exactly being sent)

Or, you setup web service (Settings -> Web service definition), and call it from NXSL. But again, I'd use action for that, not hook.

Note on the json string escaping: instead of manual processing, you can use construct https://netxms.org/documentation/nxsl-latest/#class-jsonobject and produce perfectly valid json.
#6
General Support / Re: v5.1.3 Android Client
September 30, 2025, 10:38:21 PM
Quote from: tolimanjo on September 30, 2025, 05:41:40 AMI was getting the '500' error from the client when using HTTP, and a packet capture showed HTTPS style connection attempts to the server. Perhaps Android was trying to be helpful?
Anyway, putting an HTTPS-HTTP proxy in front of the server (and specifying https:// on the client) fixed the problem.

if protocol is not specified in the connection string, https:// is added.
#7
General Support / Re: "mysql.ddr"
September 26, 2025, 10:52:10 AM
apt install netxms-dbdrv-mariadb

then use DBDriver=mariadb
#8
General Support / Re: v5.1.3 Android Client
September 25, 2025, 01:42:14 AM
Quote from: cserzs on September 24, 2025, 10:40:58 PMWhat is the syntax of the "Hostname or IP" parameter in the mobile app?

You can check if endpoint is correct - it should return information about the API itself, something like:

{"description": "NetXMS web service API", "version": "5.2.3.21", "build": "5.2-366-g15daea330f", "apiVersion": 1}⏎                                                                         
#9
Announcements / Re: NetXMS 5.2 patch release 5
September 22, 2025, 01:33:28 PM
Quote from: johnnyva on September 16, 2025, 07:39:49 AMHey Alex, I'd imagine we should also be checking for dupes on the tdata tables too right?

Yes, if you have table DCIs configured.

But this issue is already sorted in 5.2.6
#10
General Support / Re: Alarm notification call API
September 21, 2025, 09:57:57 PM
Add "server action" in EPP rule where you are creating alarm
#11
Feature Requests / Re: IOS App
September 18, 2025, 07:58:55 PM
Quote 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

Thanks for the report, I'll check it. It supposed to be working.

BTW, you can screenshot app and send comments directly in the TestFlight
#12
Feature Requests / Re: IOS App
September 16, 2025, 11:20:57 AM
It's still in TestFlight, not released into store itself. You can get it here: https://testflight.apple.com/join/B677yBU2
#13
General Support / Re: NetXMS default templates
September 12, 2025, 11:28:02 AM
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

which version is it?
#14
Hi,

TL/DR: if you are using PostgreSQL - either wait for 5.2.6, or check that you don't have duplicate records in idata_* tables before the upgrade (scripts bellow).

in 5.2.5 we modified DB schema and added PK on the idata_* tables (which hold history of all collected metrics). It was done to resolve issues with active-active replication. Previously these tables had no PK for performance reasons (in really old verions of the postgres).

However, we got couple of reports, that schema upgrade failed due to duplicates. While it's not realy clear why there are duplicates, if breaks upgrade process. This will be automated in 5.2.6, but if you want to upgrade now, or already mid-process, do the following:

1) Check if you have any duplicates. If there are none - you are good to go, and can safely proceed with the upgrade.

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 $$;

2) If you have duplicates, you need to remove them before proceeding with the upgrade.

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 $$;
#15
Announcements / Re: NetXMS 5.2 patch release 5
September 05, 2025, 12:39:21 PM
Quote from: Spheron on September 05, 2025, 09:36:46 AMThe script is running about 1h bevor i canceld it.

It was rather inefficient.

Try this one instead:

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 $$;

And then to delete duplicates:
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 $$;