Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Development
  3. Can't make AppAgent work

Can't make AppAgent work

Scheduled Pinned Locked Moved Development
2 Posts 2 Posters 30.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    M
    MarkusW
    wrote on last edited by
    #1

    I'm trying to integrate AppAgent into a small C app. I'm doing a successful AppAgentInit, and then a AppAgentStart call. There are no obvious indications that it doesn't work, except that "nxappget" says "ERROR: Cannot connect to application agent" when I run it with the app name supplied in the APPAGENT_INIT struct. When configuring the local nxagentd with an AppAgent, it outputs the same error message in the logs periodically.

    I've narrowed it down to the fact that it doesn't create a named pipe in /tmp as I would expect from reading the source. But I get no indication as to why. I've tried as root as well without success, so it doesn't seem to be a permission issue.

    There's no helpful log output anywhere.

    I'm using the libraries from NetXMS 3.5.152 source package on a Ubuntu 18.04 machine.

    Init data:

    static APPAGENT_INIT m_info =
    {
            _T("VRECLIENT"),
            _T("root"),
            handleMessage,
            logger,
            1,
            m_parameters,
            0,
            NULL,
            0,
            NULL
    };
    

    The call in main():

            printf("Initializing AppAgent...\n");
            if (!AppAgentInit(&m_info))
            {
                    printf("Init failed!\n");
            }
            printf("Starting AppAgent...\n");
            AppAgentStart();
    

    At this point I start the rest of the application logic, which works well. But the AppAgent part just won't work. I'm not even sure that the pipe listener thread is running at all, and I'm not sure how to check it.

    Do you have any hints on where to look for faults?

    Thank you in advance!

    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      Hi!

      Most likely problem is with UNICODE. By default NetXMS is build in UNICODE mode, so it uses wchar_t for all characters. I suppose that your program built as non-UNICODE, so it actually passes char to functions from libappagent that actually expects wchar_t. I'd recommend to build app agent separately with UNICODE disabled and link that version with your application.

      For example, you can configure NetXMS sources like this:

      ./configure --with-sdk --disable-unicode --prefix=/opt/nxsdk
      

      and then build you application adding

      -I /opt/nxsdk/include -L /opt/nxsdk/lib -lappagent -lnetxms
      

      You can get slightly more diagnostic from app agent by setting nxlolg debug callback:

          nxlog_set_debug_writer(DebugWriter);
          nxlog_set_debug_level(9);
      

      With debug writer similar to this:

      static void DebugWriter(const TCHAR *tag, const TCHAR *format, va_list args)
      {
          if (tag != nullptr)
              printf("[%s] ",tag);
          vprintf(format, args);
          printf("\n");
      }
      

      Attached is functional example for reference. I've compiled it as following:
      g++ -o demoapp demoapp.cpp -I /opt/nxsdk/include -L /opt/nxsdk/lib -lappagent -lnetxms

      Sample app output:

      victor@xps13:~/Source/appagentdemo$ LD_LIBRARY_PATH=/opt/nxsdk/lib ./demoapp
      Initializing AppAgent...
      Starting AppAgent...
      Application agent startedApp started
      NamedPipeListener(appagent.DEMOAPP): waiting for connection
      NamedPipeListener(appagent.DEMOAPP): accepted connection by user victor
      

      nxappget output:

      victor@xps13:~$ /opt/netxms/bin/nxappget DEMOAPP DemoApp.Metric1
      OK
      victor@xps13:~$
      

      Hope this helps!

      Best regards,
      Victor


      demoapp.cpp

      1 Reply Last reply
      0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      Powered by NodeBB Contributors
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups