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

O

ophelie6989

@ophelie6989
Unfollow Follow
About
Posts
21
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Questions about UPS
    O ophelie6989
    Support

    Hi,
    i would like to manage UPS that are link to computer where an Agent is installed. I would like to have the infornations when the UPS is connected ( that s mean that power is gone off), and i would like to have also the informations about how many time that the UPS can still works?

    How can i do that with the console? I have create a new data collection but it don t work.

    Thank you


  • XML file
    O ophelie6989
    Support

    With the fake package it works! Than you.


  • XML file
    O ophelie6989
    Support

    Thank you , i am going to try to create a fake package


  • XML file
    O ophelie6989
    Support

    Hi, i would like to know if it was possible to deploy an xml file on an agent with the NetXMS Console?

    Thank you very much


  • Questions about Netxms Console
    O ophelie6989
    Support

    Thank you very much


  • Questions about Netxms Console
    O ophelie6989
    Support

    Hello,

    • I would like to know how i can do to send alarms or events in the form of SNMP Trap from the Agent?
    • Also, i would like to know how we can retrieve a custom attribute when we are on the server and that we receive an event. And how we can show it in the event log?

    Thank you very much


  • problem with development
    O ophelie6989
    Development

    Hi, thank you and Happy New Year!!
    I have done what you said to me but the message send from the agent didn t work again.

    I have that:
    -----------Envoi du message a l agent-----------
    code du message : A

    -----------Reception du message de l agent-----------
    ¨

    When i send CMD_GETPAREMETER, i receive ".." with the code that i show you previously.

    How can i do to see the parameters?

    Thank you again


  • problem with development
    O ophelie6989
    Development

    Thank you, i have tried what you told me. For the reception of a message from the agent i have done that:

    CSCPMessage *pMsg2=new CSCPMessage(); //classe
      CSCP_MESSAGE *pRawMsg2;//structure
      CSCP_BUFFER *pMsgBuffer;//structure buffer
     
      int iErr;
      TCHAR szBuffer[128];

     
      // Initialize raw message receiving function
      pMsgBuffer = (CSCP_BUFFER *)malloc(sizeof(CSCP_BUFFER));
      RecvNXCPMessage(socketId, pRawMsg2, pMsgBuffer, RECEIVER_BUFFER_SIZE,0,0,0);
     
      // Allocate space for raw message
      pRawMsg2 = (CSCP_MESSAGE *)malloc(RECEIVER_BUFFER_SIZE);
      pMsg2 = new CSCPMessage(pRawMsg2);
     
     
      DWORD rcc = pMsg2->GetVariableLong(VID_RCC);
     
      if (rcc == ERR_SUCCESS)
        {
       
        char buffer[256];
       
          pMsg2->GetVariableStr(VID_VALUE, buffer, 256);
          // Now buffer contains value of requested parameter
         
        int compteur;
            for(compteur=0;compteur<256;compteur++)
            {
         
                         printf("%c\n",buffer[compteur]);
         
                    }//fin du for
         
         
        }// fin if

    But i always don t managed to read informations. I have done a prinft  to see what informations are in the buffer but when i compiled nothing appeared in the buffer.
    What do i have to do in order to see the informations that i received from the Agent


  • problem with development
    O ophelie6989
    Development

    Thank you, it was what i had done. I have send to the Agent the code 0x0097 in order to get the server informations. But which variable did i have to read from the message object for having the information about the server?

    Thank you very much


  • problem with development
    O ophelie6989
    Development

    In fact i am not sure that the fonction SendFileOverNXCP is used to send a message to the agent.

    • How can i do to send a message to the agent and to receive it? I have used RecvNXCPMessage but i dont arrive to see the message sent by the agent.
    • What are the steps for the sending and the reception of message?

    Thank you very much


  • problem with development
    O ophelie6989
    Development

    Thank you, i am going to use the fonction SendFileOverNXCP to send a message to the agent and RecvNXCPMessage to receive a message from the agent.


  • problem with development
    O ophelie6989
    Development

    ok thank you. i have seen that RecvNXCPMessage take in parameters a CSCP_ENCRYPTION_CONTEXT. That means that the message that i receive from the agent is crypted and that i have to decrypted it?
    Thank you


  • problem with development
    O ophelie6989
    Development

    Thank you, but i dont understand the difference between RecvCSCPMessage() and RecvNXCPMessage()? I have used the fonction

     BOOL AgentConnection::SendMessage(CSCPMessage *pMsg)
    {
       CSCP_MESSAGE *pRawMsg;
       BOOL bResult;

       pRawMsg = pMsg->CreateMessage();
       bResult = (SendEx(m_hSocket, (char *)pRawMsg, ntohl(pRawMsg->dwSize), 0) == (int)ntohl(pRawMsg->dwSize));
       free(pRawMsg);
       return bResult;
    }

    to send a message to the agent and RecvCSCPMessage to receive a message from an agent. I have just seen the fonction Send NXCPMessage.
    Which fonction do i have to use to send and receive a message?

    Thank you very much


  • problem with development
    O ophelie6989
    Development

    Thank you, i have changed my code in consequences. I have done a sending and a receiving from the agent. I have again a question. I would like to know how i can test and display the message that i received from the agent by the fonction RecvCSCPMessage?
    Thank you very much


  • problem with development
    O ophelie6989
    Development

    Hi,
    I have another questions , in order to test just the sending, i have created a file named client3.cpp which enable to connect with the agent.I also added in the fonction that is in the file Agent and which enable to send a message to the agent;
        /*--Sending--*/
      CSCPMessage *pMsg;
      CSCP_MESSAGE *pRawMsg;
      BOOL bResult;

      pRawMsg = pMsg->CreateMessage();
      bResult = (SendEx(m_hSocket, (char *)pRawMsg, ntohl(pRawMsg->dwSize), 0) == (int)ntohl(pRawMsg->dwSize));
      free(pRawMsg);
      return bResult;

    In order to test. I create also a header where i have included the class and structure that i needed.

    #ifndef _CSCPMessage_h_
    #define _CSCPMessage_h_

    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>

    #include "nms_common.h"
    //#include "netxms-regex.h"
    #define VID_RCC                    ((float)28)    /* RCC == Request Completion Code */
    #define CMD_REQUEST_COMPLETED      0x001D
    #define CMD_KEEPALIVE              0x0003

    typedef struct
    {
      DWORD dwBufSize;
      DWORD dwBufPos;
      char szBuffer[10000000];
    } CSCP_BUFFER;

    /*--Structure CSCP_DF--*/
    typedef struct
    {
      DWORD dwVarId;      // Variable identifier
      BYTE  bType;        // Data type
      BYTE  bPadding;      // Padding
      WORD wInt16;
      union
      {
          DWORD dwInteger;
          //QWORD qwInt64;
          double dFloat;
          struct
          {
            DWORD dwLen;
            WORD szValue[1];
          } string;
      } data;
    } CSCP_DF;

    /*--Structure CSCP_MESSAGE--*/
    typedef struct
    {
      WORD wCode;      // Message (command) code
      WORD wFlags;      // Message flags
      DWORD dwSize;    // Message size (including header) in bytes
      DWORD dwId;      // Unique message identifier
      DWORD dwNumVars;  // Number of variables in message
      CSCP_DF df[1];    // Data fields
    } CSCP_MESSAGE;

    /*--Classe CSCPMessage--*/
    class LIBNETXMS_EXPORTABLE CSCPMessage
    {
    private:
      WORD m_wCode;
      WORD m_wFlags;
      DWORD m_dwId;
      DWORD m_dwNumVar;    // Number of variables
      CSCP_DF **m_ppVarList;  // List of variables
      int m_nVersion;      // Protocol version

      void *Set(DWORD dwVarId, BYTE bType, const void *pValue, DWORD dwSize = 0);
      void *Get(DWORD dwVarId, BYTE bType);
      DWORD FindVariable(DWORD dwVarId);
    public:
      CSCPMessage(int nVersion = NXCP_VERSION);
      CSCPMessage(CSCPMessage *pMsg);
      CSCPMessage(CSCP_MESSAGE *pMsg, int nVersion = NXCP_VERSION);
      CSCPMessage(const char *xml);
      ~CSCPMessage();

      CSCP_MESSAGE *CreateMessage(void);
      char *CreateXML(void);
        void ProcessXMLToken(void *state, const char **attrs);
        void ProcessXMLData(void *state);

      WORD GetCode(void) { return m_wCode; }
      void SetCode(WORD wCode) { m_wCode = wCode; }

      DWORD GetId(void) { return m_dwId; }
      void SetId(DWORD dwId) { m_dwId = dwId; }

      BOOL IsVariableExist(DWORD dwVarId) { return (FindVariable(dwVarId) != INVALID_INDEX) ? TRUE : FALSE; }
      BOOL IsEndOfSequence(void) { return (m_wFlags & MF_END_OF_SEQUENCE) ? TRUE : FALSE; }
      BOOL IsReverseOrder(void) { return (m_wFlags & MF_REVERSE_ORDER) ? TRUE : FALSE; }

      void SetVariable(DWORD dwVarId, WORD wValue) { Set(dwVarId, CSCP_DT_INT16, &wValue); }
      void SetVariable(DWORD dwVarId, DWORD dwValue) { Set(dwVarId, CSCP_DT_INTEGER, &dwValue); }
      void SetVariable(DWORD dwVarId, QWORD qwValue) { Set(dwVarId, CSCP_DT_INT64, &qwValue); }
      void SetVariable(DWORD dwVarId, double dValue) { Set(dwVarId, CSCP_DT_FLOAT, &dValue); }
      void SetVariable(DWORD dwVarId, const TCHAR *pszValue) { Set(dwVarId, CSCP_DT_STRING, pszValue); }
      void SetVariable(DWORD dwVarId, BYTE *pValue, DWORD dwSize) { Set(dwVarId, CSCP_DT_BINARY, pValue, dwSize); }
      void SetVariableToInt32Array(DWORD dwVarId, DWORD dwNumElements, DWORD *pdwData);
      BOOL SetVariableFromFile(DWORD dwVarId, const TCHAR *pszFileName);

      DWORD GetVariableLong(DWORD dwVarId);
      QWORD GetVariableInt64(DWORD dwVarId);
      WORD GetVariableShort(DWORD dwVarId);
      LONG GetVariableShortAsInt32(DWORD dwVarId);
      double GetVariableDouble(DWORD dwVarId);
      TCHAR *GetVariableStr(DWORD dwVarId, TCHAR *szBuffer = NULL, DWORD dwBufSize = 0);
      DWORD GetVariableBinary(DWORD dwVarId, BYTE *pBuffer, DWORD dwBufSize);
      DWORD GetVariableInt32Array(DWORD dwVarId, DWORD dwNumElements, DWORD *pdwBuffer);

      void DeleteAllVariables(void);

      void DisableEncryption(void) { m_wFlags |= MF_DONT_ENCRYPT; }
      void SetEndOfSequence(void) { m_wFlags |= MF_END_OF_SEQUENCE; }
      void SetReverseOrderFlag(void) { m_wFlags |= MF_REVERSE_ORDER; }
     
    };
    //
    // Message waiting queue class
    //

    class LIBNETXMS_EXPORTABLE MsgWaitQueue
    {
    private:
      MUTEX m_mutexDataAccess;
      CONDITION m_condStop;
      CONDITION m_condNewMsg;
      DWORD m_dwMsgHoldTime;
      DWORD m_dwNumElements;
      WAIT_QUEUE_ELEMENT *m_pElements;
      THREAD m_hHkThread;

      void Lock(void) { MutexLock(m_mutexDataAccess, INFINITE); }
      void Unlock(void) { MutexUnlock(m_mutexDataAccess); }
      void HousekeeperThread(void);
      void *WaitForMessageInternal(WORD wIsBinary, WORD wCode, DWORD dwId, DWORD dwTimeOut);
     
      static THREAD_RESULT THREAD_CALL MWQThreadStarter(void *);

    public:
      MsgWaitQueue();
      ~MsgWaitQueue();

      void Put(CSCPMessage *pMsg);
      void Put(CSCP_MESSAGE *pMsg);
      CSCPMessage *WaitForMessage(WORD wCode, DWORD dwId, DWORD dwTimeOut)
      {
          return (CSCPMessage *)WaitForMessageInternal(0, wCode, dwId, dwTimeOut);
      }
      CSCP_MESSAGE *WaitForRawMessage(WORD wCode, DWORD dwId, DWORD dwTimeOut)
      {
          return (CSCP_MESSAGE *)WaitForMessageInternal(1, wCode, dwId, dwTimeOut);
      }
     
      void Clear(void);
      void SetHoldTime(DWORD dwHoldTime) { m_dwMsgHoldTime = dwHoldTime; }
    };

    #endif  /* _CSCPMessage_h_ */

    I include in it the link to "nms_common.h" for the definition of the type DWORD, word ETC.

    In my makefile, i have integrated the file message.c
    When i compile, it didn t work.

    g++ client3.cpp -c -I /usr/local/include -I ./include -o client3.o
    In file included from client3.cpp:11:
    include/CSCPMessage.h:59: error: syntax error before `{' token
    include/CSCPMessage.h:71: error: syntax error before `public'
    In file included from client3.cpp:11:
    include/CSCPMessage.h:4:1: unterminated #ifndef
    *** Error code 1

    There is a problem with the class CSCPMessage. Do i have forget a header to include?
    I also wanted to know what is LIBNETXMS_EXPORTABLE?
    I searched in the header nms util but i dont understand the using of it.

    Sorry to disturb you :-
    Thank you


  • problem with development
    O ophelie6989
    Development

    Thank you, i am going to look at libnetxms. For the header, i had changed types of variables because i wanted to try so;ething easy in order to see if it works. I am going to try like you said.
    Thank you very much.


  • problem with development
    O ophelie6989
    Development

    Hi,
    i try to develop a monitoring in order to retrieve informations about agents. I have installed netxms agent on a computer and i try to communicate with him with an other. the communication between the two works but i have a problem for sending and receiving informations. I have looked at the code already developed by netxms and i tried to send and receive the same type of informations that the agents understand. i have done two files:  One with the code and the other with the include that i need.

    Here my file in c++:
    /*--Include--*/
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/socket.h>
    #include <sys/types.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <unistd.h>

    #include "./include/CSCPMessage.h"

    int main () {
       
        /*--création de la socket grâce à la fonction socket()--*/
        //socketId est un entier qui correspond à un descripteur de socket
        int socketId = socket(AF_INET,SOCK_STREAM,0);
        
        /*--Définition de la structure utilisée avec TCP/IP afin de pouvoir contacter l'hôte--*/
        struct sockaddr_in serveur;//adresse hôte à contacter
        serveur.sin_family = AF_INET;//Protocole internet
        serveur.sin_port = htons(4700);// Port d'écoute
        serveur.sin_addr.s_addr=inet_addr("192.168.0.142"); // inet_adrr permet de spécifier une IP spécifique à utiliser
        
        
        /*--Etablissement de la connexion avec le serveur--*/
        int taille = sizeof(serveur);
        int connexion = connect(socketId, (struct sockaddr *) &serveur,taille);
        // Gestion de l'erreur de la connexion
        if (connexion ==-1)
        {
            printf("Un probleme est survenu lors de la connexion au serveur");
        }
        
        
        
        /*--Envoi du message // Sending--*/
        CSCPMessage msg;//classe
        int dwRqId;
        int i=1;
        dwRqId = i++;
        msg.SetCode(0x0067);//classe
        msg.SetId(dwRqId);//classe
        CSCP_MESSAGE  pRawMsg;//structure
        pRawMsg = msg.CreateMessage();//createMesage fonction de la classe
       
        int message;
        message=send(socketId,&pRawMsg,sizeof(msg),0);// Ecriture du message msg dans la socket ayant pour descripteur socketId
        //Gestion de l'erreur de l'envoi
        if (message == -1)
        {
            printf("Un probleme est survenu lors de l'envoi du message au serveur");
        }
         
        printf("Message envoye par le manager : %s \n",&pRawMsg);
        printf("Message envoye par le manager : %s \n",&msg);
       
        /*--Reception du message // Reception--*/
        int retour;
        CSCP_MESSAGE msg2;
        CSCPMessage msg3;
         
        retour=recv(socketId,&msg2,sizeof(msg2),0);// Lecture du message renvoyé par le serveur dans la socketayant pour descripteur socketId
        
        //Gestion de l'erreur de la reception
        if (retour == -1)
        {
            printf("Un probleme est survenu lors de la reception du message du serveur");
        } 
        
        //Affichage
        printf("Message envoye par l agent : %s \n",&msg2);
        int r=msg2.wCode;
        printf("affichage du code du message structure: %d \n",&r);
        msg3.SetCode(msg2.wCode);
        printf("Message envoye par l agent : %s \n",&msg3);
        int t=msg3.GetCode()  ;
        printf("affichage du code du message classe : %d \n",&t);
       
        
        
        

        /*--Fermeture de la socket--*/
        close(socketId);

        return 0;
    }// fin du main

    Here my file in .h

    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>

    #ifndef _CSCPMessage_h_
    #define _CSCPMessage_h_

    #define VID_RCC                    ((float)28)    /* RCC == Request Completion Code */
    #define CMD_REQUEST_COMPLETED      0x001D
    #define CMD_KEEPALIVE              0x0003

    /*--Structure CSCP_DF--*/
    typedef struct
    {
      int dwVarId;      // Variable identifier
      char  bType;        // Data type
      char  bPadding;      // Padding
      int wInt16;
      union
      {
          int dwInteger;
          int qwInt64;
          double dFloat;
          struct
          {
            int dwLen;
            int szValue[1];
          } string;
      } data;
    } CSCP_DF;

    /*--Structure CSCP_MESSAGE--*/
    typedef struct
    {
      int wCode;      // Message (command) code
      int wFlags;      // Message flags
      int dwSize;    // Message size (including header) in bytes
      float dwId;      // Unique message identifier
      float dwNumVars;  // Number of variables in message
     
    } CSCP_MESSAGE;

    /*--Classe CSCPMessage--*/
    class  CSCPMessage
    {
    private:
      int m_wCode;
      int m_wFlags;
      float m_dwId;
      float m_dwNumVar;    // Number of variables
      CSCP_DF **m_ppVarList;  // List of variables
      int m_nVersion;      // Protocol version

     
    public:

      CSCP_MESSAGE CreateMessage(void){
                    CSCP_MESSAGE msg;
                    msg.wCode= m_wCode;
                    return msg;
                   
                    };
      int GetCode(void) { return m_wCode; }
      void SetCode(int wCode) { m_wCode = wCode; }

      // DWORD GetId(void) { return m_dwId; }
      void SetId(float dwId) { m_dwId = dwId; }

      float GetVariableLong(float dwVarId);

    };

    class  MsgWaitQueue
    {
    private:
     

      void *WaitForMessageInternal(int wIsBinary, int wCode, float dwId, float dwTimeOut);
     

    public:
      MsgWaitQueue();
      ~MsgWaitQueue();

     
      CSCPMessage *WaitForMessage(int wCode, int dwId, int dwTimeOut)
      {
          return (CSCPMessage *)WaitForMessageInternal(0, wCode, dwId, dwTimeOut);
      }
     
    };

    #endif  /* _CSCPMessage_h_ */

    When i compile, i have that message:

    # ./client3.e
    Message envoye par le manager : g
    Message envoye par le manager : g
    Message envoye par l agent : g
    affichage du code du message structure: -809671536
    Message envoye par l agent : g
    affichage du code du message classe : -809671540

    The sending didn t work. can you help me, i am on it for 5 days and i don t know how to do it.

    Thank you very much


  • API IN C for agent communication
    O ophelie6989
    Support

    Ok. Sorry for my misunderstanding. I just installed the agent and my (last) question is : if I configured the nxagentd.conf by myself, will I be able to communicate with the agent without installing the NetXMS Server and Console ?
    (for example I will put the IP address of the server running my own application in Servers and ControlServers fields).
    (I can see the agent running as a Windows Service and during the setup, I left the NetXMS Server field blank, so I guess I should be able to talk to the agent now..)

    Thank you again,


  • API IN C for agent communication
    O ophelie6989
    Support

    Ok, i'll look into it. The thing is, when we install agents, for example agent for Windows x86, during setup it asks for IP address of NetXMS server. But I just want to install the agent and communicate with it, without going through any NetXMS server. Is it possible ?


  • API IN C for agent communication
    O ophelie6989
    Support

    Ok thanks.

    Do you know if we can use this libnxsrv library on openBSD ? If so, i guess we can download it. It would be great.

    Thank you

  • 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