Displaystring and DateAndTime
cscs nnn <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Hello there, I've concentrated on getting to know SNMP and Net-SNMP this month, and now I'd like to ask for your help. My story: I've got the purpose, to be able to get and set hostname and date from a new, own MIB on my localhost. It doesn't sound so difficult, but I can't manage it unfortunately. Until now I could only get and set an integer type from my MIB. -this is my MIB: UHMIB.txt There are three nodes/objects in it: hostname, date and a number. 1. Have I defined them well? 2. What is DEFVAL for? 3. Should I use it for hostname and date, too? 4. Do I have to write .c and .h files for every single one object? (One for the hostname and one for date and so on...?) Isn't there any other methods? I guess there is, only I don't know it yet.. I've written a .c and .h for the number object, it's like the .c and .h files in the tutorial, and it works. I tried the same with the hostname: here it is: mfmHostname.c, .h. I've put these to agent/mibgroup, and gave the commands './configure --with-mib-modules="mfmHostname" ', (v2c) make, make install, /usr/local/sbin/snmpd, export MIBS=+UHMIB . snmptranslate .1.3.6.1.4.1.30000.1.2 -> UHMIB::mfmHostname snmpget -v2c -c public localhost UHMIB::mfmHostname.0 -> No such object available on this agent at this OID. snmpset -v2c -c private localhost UHMIB::mfmHostname.0 = "bla" -> Error in packet. -> Reason: notWritable (supports no modification) So, here I stand now. 5. ? :) What did I wrong? 6. Where could I find the .c files for the objects already existing and functioning? For example, I stole my mfmHostname from SNMPv2-MIB::sysName.0. I defined it the same way, I had to get it the same way, too... Any suggestions? 7. How would the .c file for the date look? (Isn't there anybody wanting to do my job for me?: ) ...was a joke) Forgive me that I'm so badly a beginner. But at least I'm very snoopy, too, and eager to do it right. Thanks a lot and best wishes, Nikolett ______________________________________________________________ Névreszóló takarók - kíváló ajándék születésre, szülinapra, névnapra. http://www.takoo.hu ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Net-snmp-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users
UHMIB.txt
(text/plain, 1.1 KB)
UHMIB DEFINITIONS ::= BEGIN
IMPORTS
OBJECT-TYPE, Integer32,
MODULE-IDENTITY FROM SNMPv2-SMI
DisplayString, DateAndTime FROM SNMPv2-TC;
uhmib MODULE-IDENTITY
LAST-UPDATED "200707180000Z"
ORGANIZATION "SSI Schaefer PEEM"
CONTACT-INFO
" SSI Schaefer PEEM
Postal:
Tel:
E-mail: "
DESCRIPTION
"The Structure of Management Information for the
First MIB."
REVISION "200707200000Z"
DESCRIPTION
"Initial version of this MIB module."
::= { enterprises 30000}
internet OBJECT IDENTIFIER ::= {iso(1) org(3) dod(6) 1}
enterprises OBJECT IDENTIFIER ::= {internet(1) private(4) 1}
sysInfo OBJECT IDENTIFIER ::= {uhmib 1}
mfmUhrzeit OBJECT-TYPE
SYNTAX DateAndTime
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"hrSystemDate.0"
::={sysInfo 1}
mfmHostname OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"sysName.0"
::={sysInfo 2}
mfmNumber OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION "just an integer"
DEFVAL { 6 }
::= { sysInfo 3}
END
mfmHostname.c
(application/octet-stream, 953 B)
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "mfmHostname.h"
//static int nstAgentModuleObject = 1;
static string mfmHostname = "mfmHostname";
void
//init_nstAgentModuleObject(void)
init_mfmHostname(void)
{
static oid mfmHostname_oid[] =
{ 1, 3, 6, 1, 4, 1, 30000, 1, 2, 0 };
DEBUGMSGTL(("mfmHostname",
"Initializing the mfmHostname module\n"));
DEBUGMSGTL(("mfmHostname",
"Initalizing mfmHostname displaystring. Default value = %s\n",
mfmHostname));
netsnmp_register_int_instance("mfmHostname",
mfmHostname_oid,
OID_LENGTH(mfmHostname_oid),
&mfmHostname, NULL);
DEBUGMSGTL(("mfmHostname",
"Done initalizing mfmHostname module\n"));
}
mfmHostname.h
(application/octet-stream, 82 B)
#ifndef MFMHOSTNAME_H #define MFMHOSTNAME_H void init_mfmHostname(void); #endif