[Date Prev]   [Date Next] [Thread Prev]   [Thread Next] [Date Index]   [Thread Index]

 

     RE: [snips-users] Proper procedure

I hope you are using SNIPS to do this. If you look at all the examples under
perl-monitors/, for most monitors you only need to define two functions:

  1) readconf()
	mainly creates the initial

  2) dotest()

Then you just call &snips_main() and it takes care of the rest. take a look
at 'sqlmon' or 'apcmon' (more complex) or 'bgpmon' (most complex).

The flow of the monitors is described in
http://www.navya.com/snips/design.html#clibrary. The 'monitor' specific
stuff is reading the config and doing the poll/test.

	-vikas

> -----Original Message-----
> From: owner-snips-users at navya com [mailto:owner-snips-users at navya com]On
> Behalf Of Tuc
> Sent: Tuesday, March 04, 2003 12:37 PM
> To: nocol-users at navya com
> Subject: [snips-users] Proper procedure
>
>
> Hi,
>
> 	Trying to finish writing a new monitor for myself, and I have
> it 90% done. The final steps are updating the records, and reporting.
> (This is using perl)
>
> 	I'm having the hardest time figuring out the proper procedure. I've
> taken a look at some of the other monitors, and I just can't figure out
> what the right way to go about it is.
>
> 	I load all the targets into a string, do what I need to do,
> cycle through them....etc.
>
>
> 	So lets say after I clear the file, etc, I poll my first object.
> Its fine. Ok, so I want to update the event I guess, right? I look at
> update_event , and I pass it the index (which is the same for all records
> here, this is a nsmon replacement so its the site name. The status/value
> will go to "1,1". And the maxsev is "$E_CRITICAL".
>
> 	I get to the code where it says :
>
>         if (!($nocop{$i} & $n_UP))                      # recent
> state change
>         {
>             $nocop{$i} = $nocop{$i} & ~($n_UP | $n_DOWN |
> $n_UNKNOWN) | $n_UP;
>             $loglevel{$i} = $severity{$i} ;     # loglevel set to
> old level
>             $severity{$i} = $E_INFO;
>             &eventlog(&packevent($i)) ;         # log to noclogd daemon
>         }
>
> 	ok, my question is where did it get the $nocop{$i} info? I don't see
> anywhere where it gets it out of the file. Same thing for $severity{$i}.
> Ok, so then it eventlogs, thats great.
>
> 	If its down, though, it :
>
>     {
>         local($oseverity) = $severity{$i} ;
>         # escalate severity
>         $severity{$i}= ($severity{$i} > $maxsev) ? ($severity{$i}
> - 1) : $maxsev
> ;
>
>         $nocop{$i}= $nocop{$i} & ~($n_UP | $n_DOWN | $n_UNKNOWN)
> | $n_DOWN;
>
>         if ($oseverity != $severity{$i}) # severity change
>         {
>             ($mon{$i},$day{$i},$hour{$i},$min{$i}) = &gettime ;
>             # smaller severity is more severe... set  that as loglevel
>             $loglevel{$i}= $severity{$i} < $oseverity ?
> $severity{$i}:$oseverity
> ;
>             &eventlog(&packevent($i));
>         }
>     }
>
> 	same questions. Where is it getting severity? nocop? Ok,
> then it logs.
> BUT, now, how do I update the data file?
>
> 	I looked at "writeevent", and all it is is :
>
> sub writeevent {
>     local($fd, $index) = @_ ;   # open file descriptor & index
>     local($event) = &packevent($index);
>     print $fd $event ;
> }
>
>
> 	How does it know which of the records to log to?
>
> 	Then I look at something like novellmon, which looks like it
> keeps everything in an array, does all its tests, setting all sorts of
> globals depending on the item. When done it again cycles and does all
> the updates, again using previously set globals. Then when thats done,
> it opens the data file and just dumps everything out to it.
>
> 	Is that really how things should be done? Globals hanging out
> all over the place?
>
> 		Tuc/TTSG Internet Services, Inc.
>
>



Zyrion Traverse Network Monitoring & Network Management Software