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 - ophelie6989

#16
General / Re: problem with development
November 18, 2009, 04:13:04 PM
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.
#17
General / problem with development
November 17, 2009, 06:52:50 PM
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
#18
General Support / Re: API IN C for agent communication
November 11, 2009, 05:18:12 PM
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,
#19
General Support / Re: API IN C for agent communication
November 10, 2009, 11:57:45 PM
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 ?
#20
General Support / Re: API IN C for agent communication
November 10, 2009, 11:22:24 PM
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
#21
General Support / API IN C for agent communication
November 10, 2009, 09:33:15 PM
Hello,

I want to know if there is an API in C to develop our own communication channel with the agents. I mean, without using the dashboard. We have a custom application (for customer use) which does snmp requests to collect information on servers/workstations and we want to use the data collected by GFI Max agents to get more detailed informations that we cannot collect with snmp (like hard drive usage, services running, etc...). Is there a way to do that ? Will there be a way to do that in the future ?

Thanks,