Jérôme BELLEGARDE | 2 Aug 2012 15:44

Problème String into OID

Hello,

 

 

I got the following code found on your wiki to store long and int value into an oid (file .c).

 

#include <net-snmp/net-snmp-config.h>

#include <net-snmp/net-snmp-includes.h>

#include <net-snmp/agent/net-snmp-agent-includes.h>

#include "adspFAFtp.h"

 

/*

* the variable we want to tie an OID to.  The agent will handle all

* * GET and SET requests to this variable changing it's value as needed.

*/

 

static long      adspFAFtp = 1;

 

/*

* our initialization routine, automatically called by the agent

* (to get called, the function name must match init_FILENAME())

*/

void

init_adspFAFtp(void)

{

    static oid      adspFAFtp_oid[] =

        { 1, 3, 6, 1, 4, 1, 39387, 1, 1 };

 

    /*

     * a debugging statement.  Run the agent with -DnstAgentModuleObject to see

     * the output of this debugging statement.

     */

    DEBUGMSGTL(("adspFAFtp",

                "Initializing the adspFAFtp module\n"));

 

 

    /*

     * the line below registers our variables defined above as

     * accessible and makes it writable.  A read only version of any

     * of these registration would merely call

     * register_read_only_int_instance() instead.  The functions

     * called below should be consistent with your MIB, however.

     *

     * If we wanted a callback when the value was retrieved or set

     * (even though the details of doing this are handled for you),

     * you could change the NULL pointer below to a valid handler

     * function.

     */

    DEBUGMSGTL(("adspFAFtp",

                "Initalizing adspFAFtp scalar integer.  Default value = %d\n",

                adspFAFtp));

 

    netsnmp_register_long_instance("adspFAFtp",

                                  adspFAFtp_oid,

                                  OID_LENGTH(adspFAFtp_oid),

                                  &adspFAFtp, NULL);

 

    DEBUGMSGTL(("adspFAFtp",

                "Done initalizing adspFAFtp module\n"));

}

 

 

My question is now, how can I store a string into an OID (like 500/1000 char or so).

If you can give me an exemple of it.

 

Thank you J

 

Cordialy

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users <at> lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
Dave Shield | 2 Aug 2012 16:05
Picon
Favicon

Re: Problème String into OID

On 2 August 2012 14:44, Jérôme BELLEGARDE
<j.bellegarde <at> alpha-direct-services.com> wrote:
> My question is now, how can I store a string into an OID

Please see the code in 'agent/mibgroup/examples/watched.c'
which does exactly this.

Dave

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users <at> lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Jérôme BELLEGARDE | 2 Aug 2012 17:03

RE: Problème String into OID

Thank you, work nicely.

Just one last things, when i compile my mib each time, I do it like that :

./configure --with-default-snmp-version="2" --with-sys-contact=" <at>  <at> no.where"
--with-sys-location="Unknown" --with-logfile="/var/log/snmpd.log"
--with-persistent-directory="/var/net-snmp"
--with-mibs="SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:HOST-RESOURCES-TYPES:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-FRAMEWORK-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IP-FORWARD-MIB:NET-SNMP-PASS-MIB:NET-SNMP-EXTEND-MIB:UCD-DLMOD-MIB:SNMP-NOTIFICATION-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB:ADSP-MIB"
--with-mib-modules="adspFAFtp adspFASql adspFAConnexionFtp adspFAFichierPresent
adspFARecupFichier adspFAPresenceFacture adspBAYFtp adspBAYSql adspBAYConnexionFtp
adspBAYFichierPresent adspBAYRecupFichier adspBAYPresenceFacture SupervisionTSEClient"

By adding all the things, my MIB and my module from my mib

Is there is a better solution to get this work :) ?

Cordialy,

-----Message d'origine-----
De : Dave Shield [mailto:D.T.Shield <at> liverpool.ac.uk] 
Envoyé : jeudi 2 août 2012 16:05
À : Jérôme BELLEGARDE
Cc : net-snmp-users <at> lists.sourceforge.net
Objet : Re: Problème String into OID

On 2 August 2012 14:44, Jérôme BELLEGARDE <j.bellegarde <at> alpha-direct-services.com> wrote:
> My question is now, how can I store a string into an OID

Please see the code in 'agent/mibgroup/examples/watched.c'
which does exactly this.

Dave

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users <at> lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Dave Shield | 2 Aug 2012 17:17
Picon
Favicon

Re: Problème String into OID

On 2 August 2012 16:03, Jérôme BELLEGARDE
<j.bellegarde <at> alpha-direct-services.com> wrote:
> ./configure --with-default-snmp-version="2" --with-sys-contact=" <at>  <at> no.where"
--with-sys-location="Unknown" --with-logfile="/var/log/snmpd.log"
--with-persistent-directory="/var/net-snmp"
--with-mibs="SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:HOST-RESOURCES-TYPES:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-FRAMEWORK-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IP-FORWARD-MIB:NET-SNMP-PASS-MIB:NET-SNMP-EXTEND-MIB:UCD-DLMOD-MIB:SNMP-NOTIFICATION-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB:ADSP-MIB"
--with-mib-modules="adspFAFtp adspFASql adspFAConnexionFtp adspFAFichierPresent
adspFARecupFichier adspFAPresenceFacture adspBAYFtp adspBAYSql adspBAYConnexionFtp
adspBAYFichierPresent adspBAYRecupFichier adspBAYPresenceFacture SupervisionTSEClient"
>
> By adding all the things, my MIB and my module from my mib
>
> Is there is a better solution to get this work :) ?

Yes

Dave

   Oh - you want to know what it is?   :-)
Create a file   'agent/mibgroup/adsp.h'  containing the following:

     config_require( adspFAFtp )
     config_require( adspFASql )
        :
     config_require( adspBAYPresenceFacture )
     config_add_mib(  ADSP-MIB )

and then run

     ./configure  --with-default-snmp-version="2"  --with-defaults
--with-mib-modules=adsp

and that should pull in the other modules codes automatically ('config_require')
as well as adding the relevant MIB file(s) to the default list.

Dave

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users <at> lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Jérôme BELLEGARDE | 2 Aug 2012 18:07

RE: Problème String into OID

Strong :)

One last thing, do you know the tool call "Getif" ?
Do you know a better tool than it (to browse mib, walk ect ...) on windows 7?

Also, I use getif to browse the MIB, and I cannot get the description I added on an OID (into my mib :
DESCRIPTION "Test description")

Cordialement,

Jérôme BELLEGARDE
Apprenti ingénieur en Informatique
 
ADS Picardie
PAE du Haut Villé Rue Hippolyte Bayard  60000 Beauvais
Tél : 03.60.36.40.21
E-mail : j.bellegarde <at> alpha-direct-services.com
Site Web : www.alpha-d-s.net

---------------------------------------------------------------------------

-----Message d'origine-----
De : Dave Shield [mailto:D.T.Shield <at> liverpool.ac.uk] 
Envoyé : jeudi 2 août 2012 17:18
À : Jérôme BELLEGARDE
Cc : net-snmp-users <at> lists.sourceforge.net
Objet : Re: Problème String into OID

On 2 August 2012 16:03, Jérôme BELLEGARDE <j.bellegarde <at> alpha-direct-services.com> wrote:
> ./configure --with-default-snmp-version="2" --with-sys-contact=" <at>  <at> no.where"
--with-sys-location="Unknown" --with-logfile="/var/log/snmpd.log"
--with-persistent-directory="/var/net-snmp"
--with-mibs="SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:HOST-RESOURCES-TYPES:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-FRAMEWORK-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IP-FORWARD-MIB:NET-SNMP-PASS-MIB:NET-SNMP-EXTEND-MIB:UCD-DLMOD-MIB:SNMP-NOTIFICATION-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB:ADSP-MIB"
--with-mib-modules="adspFAFtp adspFASql adspFAConnexionFtp adspFAFichierPresent
adspFARecupFichier adspFAPresenceFacture adspBAYFtp adspBAYSql adspBAYConnexionFtp
adspBAYFichierPresent adspBAYRecupFichier adspBAYPresenceFacture SupervisionTSEClient"
>
> By adding all the things, my MIB and my module from my mib
>
> Is there is a better solution to get this work :) ?

Yes

Dave

   Oh - you want to know what it is?   :-)
Create a file   'agent/mibgroup/adsp.h'  containing the following:

     config_require( adspFAFtp )
     config_require( adspFASql )
        :
     config_require( adspBAYPresenceFacture )
     config_add_mib(  ADSP-MIB )

and then run

     ./configure  --with-default-snmp-version="2"  --with-defaults --with-mib-modules=adsp

and that should pull in the other modules codes automatically ('config_require') as well as adding the
relevant MIB file(s) to the default list.

Dave

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users <at> lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Jérôme BELLEGARDE | 3 Aug 2012 14:13

RE: Problème String into OID

I'm afraid i got a new problem.
I can insert any string on my MIB with basic snmpset on my linux OS.

I use the NetMgrVb dll to work with windows, so far no problem until now.
After some test, it appear that I can't add a string superior to 8 char on m MIB, dunno why.

When I debug log message, I found that problem appear :

[NetMgrVB.Mod.SnmpAgentRequest][WAPI]=5

On http://msdn.microsoft.com/en-us/library/windows/desktop/aa378241(v=vs.85).aspx, I guess
it's the :

SNMPAPI_ENTITY_INVALID
One or both of the entity parameters is invalid.
SNMPAPI_CONTEXT_INVALID
The context parameter is invalid.

I dunno how to get it work then, can you help me out with that ?

---------------------------------------------------------------------------

-----Message d'origine-----
De : Dave Shield [mailto:D.T.Shield <at> liverpool.ac.uk] 
Envoyé : jeudi 2 août 2012 16:05
À : Jérôme BELLEGARDE
Cc : net-snmp-users <at> lists.sourceforge.net
Objet : Re: Problème String into OID

On 2 August 2012 14:44, Jérôme BELLEGARDE <j.bellegarde <at> alpha-direct-services.com> wrote:
> My question is now, how can I store a string into an OID

Please see the code in 'agent/mibgroup/examples/watched.c'
which does exactly this.

Dave

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users <at> lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Jérôme BELLEGARDE | 14 Jan 2013 17:23

RE: Problème String into OID

Hello,

I'm trying to re-build a new installation of net-snmp because we are changing our server.

I have compil the package, with this :

./configure --prefix=/usr --with-mibdirs="/usr/share/snmp/mibs"
--with-default-snmp-version="2" --with-defaults --with-mib-modules="adsp"
make
make install prefix=/usr

Everything works fine, I don't have error I guess.

But when I restart my snmpd services, there is no way to contact server by any community.

I have seen that snmpd in /usr/bin change to the date of today, but I dunno whats wrong with it.

I'm running it into Centos // net-snmp-5.6.2

Thanks for your help :).

Cordialement,

Jérôme BELLEGARDE
Ingénieur Projets Réseaux
 
ADS Picardie
PAE du Haut Villé Rue Hippolyte Bayard  60000 Beauvais
Tél : 03 60 36 41 16
E-mail : j.bellegarde <at> alpha-direct-services.com
Site Web : www.alpha-d-s.net

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users <at> lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Dave Shield | 14 Jan 2013 17:29
Picon
Favicon

Re: Problème String into OID

On 14 January 2013 16:23, Jérôme BELLEGARDE
<j.bellegarde <at> alpha-direct-services.com> wrote:
> But when I restart my snmpd services, there is no way to contact server by any community.

What are the access configuration settings in your snmpd.conf file?
Is there anything logged when you start the agent?

Dave

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users <at> lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


Gmane