|
I want to write an SNMP extension agent for one of my applications, that run on a Windows 2000 server.
How do i return an array of values in a GET or GETNEXT request?
I made an MIB that looks like this:
What does the extension agent say when it gets a request for
enterprises.radical.software.apps.radicalserver.radicalserverinstance.serverconnections
since it actually points to a list of connection objects
Also how is the members of the connections array accessed. Is it like
enterprises.radical.software.apps.radicalserver.radicalserverinstance.serverconnections.0
enterprises.radical.software.apps.radicalserver.radicalserverinstance.serverconnections.1
etc....
RADICALSERVER-MIB DEFINITIONS ::= BEGIN
IMPORTS
enterprises
FROM RFC1155-SMI
OBJECT-TYPE
FROM RFC-1212
DisplayString
FROM RFC-1213;
radical OBJECT IDENTIFIER ::= { enterprises 15812 }
software OBJECT IDENTIFIER ::= { radical 1 }
apps OBJECT IDENTIFIER ::= { software 1 }
radicalserver OBJECT IDENTIFIER ::= { apps 1 }
radicalserverinstance OBJECT_TYPE
SYNTAX RadicalServerInstance
ACCESS not-accessible
STATUS mandatory
DESCRIPTION "Radical Server Instance"
::= { radicalserver 1 }
RadicalServerInstance ::=
SEQUENCE
{
serverstatus INTEGER,
serverinstancename DisplayString,
serverinstancetype DisplayString,
serverincomingmsgs INTEGER,
serveroutgoingmsgs INTEGER,
serverconnectcount INTEGER
}
serverstatus OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS mandatory
DESCRIPTION "The Status of the server 1 - up, 0 - down"
::= { radicalserverinstance 1 }
serverinstancename OBJECT-TYPE
SYNTAX DisplayString
ACCESS read-only
STATUS mandatory
DESCRIPTION "The name of the instance"
::= { radicalserverinstance 2 }
serverinstancetype OBJECT-TYPE
SYNTAX DisplayString
ACCESS read-only
STATUS mandatory
DESCRIPTION "The type of the instance"
::= { radicalserverinstance 3 }
serverincomingmsgs OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS mandatory
DESCRIPTION "No. of incoming messages per second"
::= { radicalserverinstance 4 }
serveroutgoingmsgs OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS mandatory
DESCRIPTION "No. of outgoing messages per second"
::= { radicalserverinstance 5 }
serverconnectcount OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS mandatory
DESCRIPTION "No. of outgoing messages per second"
::= { radicalserverinstance 6 }
serverconnections OBJECT-TYPE
SYNTAX SEQUENCE OF serverconnection
ACCESS not-accessible
STATUS mandatory
DESCRIPTION "Connection list on the server instance"
::= { radicalserverinstance 7 }
serverconnection OBJECT-TYPE
SYNTAX ServerConnection
ACCESS not-accessible
STATUS mandatory
DESCRIPTION "Connection on the server instance"
::= { serverconnections 1 }
ServerConnection ::=
{
serverconnectionid DisplayString
serverconnecttype INTEGER
serverconnectstatus INTEGER
serverincomingmsgs INTEGER
sreveroutgoingmsgs INTEGER
}
serverconnectionid OBJECT-TYPE
SYNTAX DisplayString
ACCESS read-only
STATUS mandatory
DESCRIPTION "Identifier of the connection"
::= { serverconnection 1 }
serverconnecttype OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS mandatory
DESCRIPTION "Type Incoming = 0, Outgoing = 1"
::= { serverconnection 2 }
serverconnectstatus OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS mandatory
DESCRIPTION "disconnected = 0, connected = 1"
::= { serverconnection 3 }
serverincomingmsgs OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS mandatory
DESCRIPTION "No of incoming messages per second"
::= { serverconnection 4 }
serveroutgoingmsgs OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS mandatory
DESCRIPTION "No of outgoing messages per second"
::= { serverconnection 5 }
----------------------------------------------------------------
END
Any help is greatly appreciated. I am a beginner in SNMP.
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
I have some code that does great:
CMenu* mmenu = ((CMainFrame*)AfxGetMainWnd())->GetMenu();
int pos = ((CMainFrame*)AfxGetMainWnd())->FindMenuItem(mmenu, "test dyn");
CMenu* submenu = mmenu->GetSubMenu(pos);
pos = ((CMainFrame*)AfxGetMainWnd())->FindMenuItem(submenu, "junk");
CMenu * flyOutMenu;
flyOutMenu->CreatePopupMenu();
<code>flyOutMenu->AppendMenu(MF_STRING, 0, "From View 1 butto");
pos = ((CMainFrame*)AfxGetMainWnd())->FindMenuItem(submenu, "junk");
submenu->ModifyMenu(pos,MF_BYPOSITION|MF_POPUP,(int)(flyOutMenu->m_hMenu),"&File");
submenu->AppendMenu(MF_POPUP,(int)(flyOutMenu->m_hMenu),"&File1");</code>
Now if I replace the section in red by the foll. it crashes at flyOutMenu->CreatePopupMenu(); !!!!! It doesnt even get to the replacement code. What have I done wrong?
CBKDoc * pDoc = (CBKDoc *)GetDocument();
DynaMenuMap::iterator itDyn = (pDoc->dynaMenuMap).begin();
for (; itDyn != (pDoc->dynaMenuMap).end(); itDyn++)
{
char * tempDyn;
CString tempCDyn = (*itDyn).first;
tempDyn = new char [tempCDyn.GetLength() + 1];
strcpy(tempDyn, tempCDyn);
SubMenuSet& subMenuSet = (pDoc->dynaMenuMap)[tempCDyn];
SubMenuSet::iterator itSub = subMenuSet.begin();
for (; itSub != subMenuSet.end(); itSub++)
{
char * tempSub;
CString tempCSub = *itSub;
tempSub = new char [tempCSub.GetLength() + 1];
strcpy(tempSub, tempCSub);
flyOutMenu->AppendMenu(MF_STRING, 0, tempSub);
delete tempSub;
}
if ( itDyn == pDoc->dynaMenuMap.begin())
{
submenu->ModifyMenu(pos,MF_BYPOSITION|MF_POPUP,(int)(flyOutMenu->m_hMenu),tempDyn);
}
else
{
submenu->AppendMenu(MF_POPUP,(int)(flyOutMenu->m_hMenu),tempDyn);
}
}
Appreciate your help,
ns
|
|
|
|
|
I'm pretty darn sure this is not good:
<br />
CMenu * flyOutMenu; <br />
flyOutMenu->CreatePopupMenu();<br />
since "flyOutMenu" is a pointer that is uninitialized . To fix, rename variable to "pFlyOutMenu" to indicate and remind you it is a pointer ... and change code to:
<br />
CMenu * pFlyOutMenu = new CMenu; <br />
if (pFlyOutMenu)<br />
{<br />
pFlyOutMenu->CreatePopupMenu();<br />
:<br />
:<br />
:<br />
pFlyOutMenu->DestroyMenu();<br />
delete pFlyOutMenu;<br />
}<br />
I could be wrong of course......
|
|
|
|
|
I have a project and it has two views (same document template used for both). The CBKView1 class has a GetDocument (MFC wrote it), and CBKView2 does not have this function.
YET the code compiles if I do
CBKDoc * pDoc = (CBKDoc *)GetDocument();
in CBKView2 class!!!!!!
Is this not most peculiar? It actually works too. How can this be?
Appreciate your help,
ns
|
|
|
|
|
GetDocument() just makes use of the pView->m_pDocument member variable. It could also be that the function is defined in a base class (CView etc) so that you don;t need to add it yourself.
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
Thanks.
Appreciate your help,
ns
|
|
|
|
|
Remember a while ago, when I was telling you to define this "GetDocument" function in your CBKView2? This is partially why.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
Indeed I do remember your words and did implement them. It just puzzled me greatly that it worked even if I didnt add GetDocument to CBKVIew2 as well. But yes, as soon as i ran into this facet...........needing the pDoc pointer in the second view, I immediately remembered your post (which is cut and pasted in my hints.doc collection of CP resolutions).
Appreciate your help,
ns
|
|
|
|
|
I have a dynamic submenu being created under a toplevel menu. THese submenus have no ID since I dont know how many there are. So to write handlers for these when clicked, it seems , can be achieved by capturing WM_MENUCOMMAND. BUt I havent figured out how to do this. If it were a resource with ID_MENU_A, then I could of course write the COMMAND handler for it> But I am rather lost in utilizing WM_MENUCOMMAND:
How to trrap it?
What all needs to be added to the code to get this to work?
THanks,
Appreciate your help,
ns
|
|
|
|
|
You may perhaps not know a specific value, but perhaps can you know the range of the IDs.
ON_COMMAND_RANGE(ID_MENU_START, ID_MENU_END, OnMenuRange)<br />
ON_UPDATE_COMMAND_UI_RANGE(ID_MENU_START, ID_MENU_END, OnUpdateMenuRange)
HTH,
Angels banished from heaven have no choice but to become demons
Cowboy Bebop
|
|
|
|
|
The menu keeps getting redone all the time. Lets say I have a maximum of 200 items I could possibly want. Then
if I put ID_MENU_START = 5000, and ID_MENU_END = ID_MENU_START + 200
(BTW how does one decide what number to assign to ID_MENU_START?)
Then if at a certain time I have only 50 menu items and I click one, then will the function OnMenuRange run without crashing?
i.e since the remaining 150 dont exist is that a problem?
The other question is: what if I needed a different handler to run for each menu item? ? I have no IDs
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
BTW how does one decide what number to assign to ID_MENU_START?
Take a look in your apps resource.h file and assign it there. Also make sure that none of the id's in the range are being used for anything else.
ns wrote:
Then if at a certain time I have only 50 menu items and I click one, then will the function OnMenuRange run without crashing?
This should be fine. The OnUpdateUI and OnCommand handlers only get called if the menu item actually exists. You can also tell for which item it is for by the parameter that is passed to the function. Just make sure you get the function prototypes right, as they are not done by class-wizard and have to be done manually.
ns wrote:
what if I needed a different handler to run for each menu item? ? I have no IDs
Farm the OnRanegCommand() id out to the correct function in this handler by looking at the command id passed to you.
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
Thanks !!
Troubling point: . Very luckily I found the prototype for the ON_COMMAND_RANGE handler in one of my books. I looked on the web , and found one place that showed me too. But MSDN didnt have a prototype under the index word ON_COMMAND_RANGE. Most of my books didnt have the prototype either.
Your respoinse was very informative and answered my questions very well. Thank you again.
Appreciate your help,
ns
|
|
|
|
|
This article[^] should help you
K.
Angels banished from heaven have no choice but to become demons
Cowboy Bebop
|
|
|
|
|
Thats a terrific link!!! MAny thanks for your input!
Appreciate your help,
ns
|
|
|
|
|
I "upgraded" to VS.net and I'm having trouble doing things that used to be simple...(I know, I'm old etc etc) I have to add a combobox to a property page in an existing modless dialog application ( built using Visual Studio & VC++ 6.0 )but my frustration level is about to blow! Do I need to go back to my old VS to get this done? What happened to my friend the Class Wizard??? Is there someplace that I can walk through the process of adding a dropdownlist with two items to my existing code?
Frustrated & cold ( it's 14 below today );P
The world is run by those who show up...and they usually have nothing else to do!
|
|
|
|
|
Hello,
Just wondering if its possible to put a simple timer in a console app? Would I have to create a invisible window to do this?
Any ideas?
Rob
|
|
|
|
|
In order to use WM_TIMER in a console app, you would need to create a hidden window and run a message loop. In other words, it wouldn't really be a console app; it would be a Windows application, whose main window was hidden.
A simpler solution that can be used in a console application is to use a thread that blocks on an event. The event is used to signal the thread to exit. When you block on the event (see WaitForSingleObject ), specify a timeout period. The wait function returns what caused the wait to expire. In this case, the timeout is what you're interested in.
Here's an example:
static CEvent ThreadTerminate;
...
<this is the main line code>
...
UINT ThreadFunction(LPVOID parameter)
{
CSyncObject *wait_list[] = { &ThreadTerminate };
for ( ; ; ) {
CMultiLock wait(wait_list,countof(wait_list));
DWORD wait_object = wait.Lock(1000,FALSE);
if (wait_object == WAIT_OBJECT_0) {
break;
}
else if (wait_object == WAIT_TIMEOUT) {
}
}
return 0;
}
Software Zen: delete this;
|
|
|
|
|
Do you know what header I need to include in my stdafx to use the countof?
|
|
|
|
|
Oops. That's one of my own. It's defined like this:
#define countof(array) (sizeof(array) / sizeof((array)[0])) It simply returns the number of elements in a fixed size array at compile time.
Software Zen: delete this;
|
|
|
|
|
cool, Thanks for all your help!
Rob
|
|
|
|
|
I am using your code like this... (Everything works perfect) but the problem is that I show a memory leak:
Detected memory leaks!
Dumping objects ->
thrdcore.cpp(166) : {55} client block at 0x00315208, subtype 0, 112 bytes long.
a CWinThread object at $00315208, 112 bytes long
Object dump complete.
AfxBeginThread(ThreadFunction, theApp);
UINT ThreadFunction(LPVOID lParam)
{
CSyncObject* wait_list[] = { &ThreadTerminate };
for(;;)
{
CMultiLock wait(wait_list, countof(wait_list));
DWORD wait_object = wait.Lock(30000, FALSE);
if( wait_object == WAIT_OBJECT_0)
break;
else if(wait_object == WAIT_TIMEOUT)
{
printf("HTTP Service Timed Out..\n");
ExitProcess(0);
}
}
return 0;
}
Am I missing something..
|
|
|
|
|
The leak is caused by the thread not being terminated. When you use AfxBeginThread , a CWinThread object is created. If you terminate the thread, the object deletes itself when the thread exits. Therefore, in your main program, before you exit, you need to terminate the thread and wait for it to exit:
HANDLE ThreadHandle = NULL;
CWinThread *thread = AfxBeginThread(ThreadFunction,parameter);
if (thread != NULL) {
ThreadHandle = thread->m_hThread;
}
<br>
...
<br>
<br>
if (ThreadHandle != NULL) {
ThreadTerminate.SetEvent();
::WaitForSingleObject(ThreadHandle);
}
Software Zen: delete this;
|
|
|
|
|
Is there any sample code available that will allow me to kill any connections to a particular share on my computer? I'd like to be able to kill all the connections to my source safe share and lock the database before an analyzer. Thanks.
Ron Ward
|
|
|
|
|
It looks like NetShareDel is the API function you need.
Software Zen: delete this;
|
|
|
|