This was a thread on nv-l discussing changing the status of objects and their inclusion in
SmartSets?, based on a TRAP (or lack thereof!) from a device. With thanks to Jason, Leslie and Paul. All I have done is tidy up the order of the thread.
System information:
OS - AIX 5.1
NetView - 7.1.3
FixPack3?
We are currently using a Smartset to view Routers that are either down or
unreachable. Here is the Smartset rule: (('IP Status'='Critical') || ('IP
Status'='Unreachable')) && ('isRouter'=True)
Besides "Critical' and 'Unreachable', we would also like this Smartset to
display routers that send BGP traps to
NetView. Is there any way to have an
incoming SNMP trap change the value of 'IP Status', or any other object
attribute? Is this the wrong use of a Smartset?
_
It can be done (not sure how with smartsets though). The theory
being when a BGP trap arrives, set a certain status or set some other
attribute. However, when do you toggle the other way? Meaning, after what
interval do you want a router to be removed from the smartset?
_
I assumed that if we set attribute 'IP Status', then it would get reset the
next time
NetView polls the device. If we set another attribute, then I
assume we will have to reset manually, or use a clearing trap to reset the
attribute. Can an attribute be set to clear after a certain period of time?
How would you suggest that we do this
__
I do that sort of thing like this:
1) Add a field to my custom fields file /usr/OV/fields/C/My.fields
Field "My_Trap_Flag" {
Type String;
Flags locate, general;
}
Run 'ovw -fields' after messing with a fields file.
2) In trapd.conf, define the traps of interest as having a trap
source of 'Y' instead of the usual 'A' or 'u'
3) Make a Netview ruleset that with an Event Attribute cube
checks trap source for 'Y' and invokes an action
'<path>/TrapFlag.sh -set $NVA'
4) Make that ruleset run in the background by putting the ruleset
name in /usr/OV/conf/ESE.automation
5) Write a little script TrapFlag.sh that uses nvdbimport to set
the field 'My_Trap_Flag' to TRUE for the node that the trap is from.
6) On the reports menu (/usr/OV/reports/C) add two scripts to call
that script: TrapFlagSet.sh and TrapFlagClear.sh
Trap_Flag_Set.sh
#!/bin/ksh
# Set trap flag to True for the selected nodes.
name=$(basename $0)
xnmappmon -geometry 680x500 -commandTitle "$name" \
-commandHeading "Setting Trap Flag to TRUE for Selected Nodes " \
-cmd <path>/TrapFlag.sh -set $OVwSelections
Trap_Flag_Clear.sh
#!/bin/ksh
# Set Trap Flag to false for the selected nodes.
name=$(basename $0)
xnmappmon -geometry 680x500 -commandTitle "$name" \
-commandHeading "Setting Trap Flag to FALSE for Selected Nodes" \
-cmd <path>/TrapFlag.sh -clear $OVwSelections
Users can execute those functions against one or more nodes
selected on the map. Usually they would only use the clearing one.
But the setting one is handy for testing.
The job of the TrapFlag.sh script is to generate an import file
that looks like this:
Selection Name,My_Trap_Flag
nodename,TRUE (or FALSE on the clear)
and run nvdbimport to set the values for the nodes selected on the
map, or indicated by the rule. See the man page for nvdbimport.
There are samples in /usr/OV/conf/nvdbtools.
Then make your problem smartset include the criteria || My_Trap_Flag=TRUE
The operators will know that green things in the problem smartset
are there because of traps. They should look up the events for
that node to see what they are. I usually provide another function
on that reports menu that does a grep in trapd.log for the
selected node. You could do the grep right from the script in
/usr/OV/reports/C, but I usually have another one in my
custom scripts directory. The reason for this is so I can offer
the same function to web console users as I do to the Motif users.
__
There is a lot of good information in here. I guess my only question
would be is how are the devices removed from the smartset? Looking at
your information below it seems the operator needs to run the
Trap_Flag_Clear.sh (highlight nodes /
OVwSelections?) in order to clear
the condition. From what I understood from the original problem
statement is that after a period of time, the devices should be
removed automatically.
__
If membership in the smartset requires that flag to be set, once the
flag is removed the device should be removed from the smartset. I am
not sure of the timing of this,>> but I would think within 5 minutes
or so that device should be removed.
__
Agreed, but how is the flag on the device being removed/un-set? From
my understanding of Leslie's email, it takes an operator action to
un-set the flag. How does an operator know if X number of BGP traps
have been received in Y amount of time?
__
Well first we would want to know what event is going to create a situation where the flag should be removed, new traps, specfic traps, what? So if we receive BGP traps from a device in the smartset, run an action to remove the flag. This could easily be done from a ruleset, but we would need more information about what should cause the flag to be removed.
__
From Craig's second email, it seems our answer is "Can an attribute be
set to clear after a certain period of time?" That would mean we would
want the flag to be removed after a period of time that a specific trap
has not been received. I am far from knowledgeable about Smart Sets,
is this possible? What other ways can it be accomplished?
__
Missed that, well now things get interesting, I could write a script
that ran from cron that removed them every hour or something, but my
feeling is we are still missing information. What is the time limit they
want to use, do they want to base it on a per day basis? There are
several ways this could be addressed:
get the trap, set the flag, wait x minutes, remove the flag. I use a
pass on match node for this with no second input, so it acts as a timer
and then passes the event on. Later in the ruleset after the timer kicks
the flag could be removed.
You could remove them via a cron script, either hourly or daily.
There's just not enough information to determine exactly what he wants
to do, that is going to determine what kind of solutions fits best...
__
Then just for academic purposes, here is a problem statement: Remove
device from Smart Set when a BGP trap has not been received in 60
minutes from that device.
I see your solution regarding having a cron remove the device after a
certain period of time, but looking at the problem statement above, I
don't think that solution efficiently solves our problem statement
above. Are there mechanisms in
NetView that will solve the issue above,
either systematically or programmatically, i.e. through configuration or
scripts/programs?
I'm curious, as I don't see an easy way outisde of writing an external
timer.
__
How did it get placed in the smartset, was it a rule that captured
an original trap and then based on that trap, set the flag and placed
it in the smartset?
If that's the case you could do a ruleset like this:
This is ugly due to text contraints, but here goes
From the event Source we look for two traps, the original trigger
trap to set the flag, and BGP traps
Event Source
|
-------------------------------------------
| |
Original Trigger Trap BGP Trap
| |
Action(Set Flag) |
| |
Reset on Match(60min timer)---
|
Action(Unset Flag)
So in the rulest above, we wait for the trap that initiates the setting
of the flag, then we wait for 60 minutes, if the BGP trap does not show
up within the 60 minute timer, the flag will be unset. If the BGP trap
does come in during that period, both events will be dropped. The
only way the flag would be removed is if the BGP trap did not arrive
within 60 minutes. You could also make it so if the BGP trap does come
in, it also removes the flag(but I did not see that as a requirement.
I hope all that makes sense, let me know if I need to clarify!
--
JaneCurry - 15 Feb 2005