hi Venelin,
about :
> BTW it does not work on 0.5.1 since much of the module architecture has
been changed
yes effectively, this is mainly for clarity / consistency / factorization
purposes.
So since 0.5.1 : every shinken module need (will be a *has* very soon) to be
subclass of the class BaseModule defined in shinken/basemodule.py.
What really changed: I think mainly only the 'from_q' & 'to_q' new
attributes for storing the 2 queues of the module ; instead of having them
set in the "properties" dict associated with each module as previously done.
Otherwise it should be all the same but you may use the new main &
do_loop_turn methods (and so signal handler) ; or not as it's will also
work correctly if you redefine the main() method.
So if you adapt your module to use these attributes instead of
"self.properties['from_queue|to_queue']" it should be ok..
For the problem with the custom variable I let the others continue to help
you ;)
regards,
greg.
2011/2/8 Venelin Petkov <petkov.vene...@gmail.com>
> Hi,
>
> I finally came to the bottom of the problem. It turns out that it
> may really be a shinken bug. Using your suggestion (BTW it does not
> work on 0.5.1 since much of the module architecture has been changed)
> I implemented the testing classes for my module and it worked! The
> custom variable that is defined in the test configuration
> (test/etc/1r_1h_1s/services.cfg) showed up, which left me baffled,
> since I expected it to be faulty. Obviously it was a configuration
> problem, so I systematically compared the test configuration with our
> current Shinken configuration and found out that no custom variables
> show up when the service definition contains only the 'hostgroup'
> parameter, while services which have the 'host_name' parameter are
> handled fine:
>
> define service{
> use local-service
> hostgroup_name print
> service_description cups
> check_command check_cups
> _udp_template test
> }
>
> vs.
>
> define service{
> use generic-service
> service_description test_service
> check_command check_service!ok
> check_interval 1
> host_name test_host_0
> # hostgroup_name cups
> _template 'test x'
> }
>
> Since all our services are defined by using hostgroups, it is no
> wonder that nothing showed up at my first test of the module. If I
> may suggest, extending the testing service definition to include more
> varied cases could catch some odd issues like this one. Thanks for the
> example, it has been quite useful for testing the code.
>
> Best regards,
> Venelin
>
>
>
>
> On Mon, Feb 7, 2011 at 5:47 PM, Gerhard Lausser
> <gerhard.laus...@consol.de> wrote:
> > Hi,
> >
> > i could not reproduce it.
> > Maybe this snippet can help you.
> >
> > def test_venelin(self):
> > self.print_header()
> > now = time.time()
> > objlist = []
> > for host in self.sched.hosts:
> > objlist.append([host, 0, 'UP'])
> > for service in self.sched.services:
> > objlist.append([service, 0, 'OK'])
> > self.scheduler_loop(1, objlist)
> > self.update_broker()
> > for service in self.livestatus_broker.services.values():
> > print "list of customs", service.customs
> >
> > I added it to test_livestatus and i got the custom vars as expected.
> > You should create a test_venelinsmodule.py where you can play around with
> > your module.
> >
> > Start with:
> >
> > ....beginning of file like test_livestatus...
> > ...
> > modconf = Module()
> > modconf.module_name = "livestatus"
> > modconf.module_type = livestatus_broker.properties['type']
> > modconf.properties = livestatus_broker.properties.copy()
> >
> > class TestConfig(ShinkenTest):
> > def update_broker(self):
> > ids = self.sched.broks.keys()
> > ids.sort()
> > for brok_id in ids:
> > brok = self.sched.broks[brok_id]
> > self.livestatus_broker.manage_brok(brok)
> > self.sched.broks = {}
> >
> > class TestConfigSmall(TestConfig):
> > def setUp(self):
> > self.setup_with_file('etc/nagios_1r_1h_1s.cfg')
> > self.livestatus_broker = Livestatus_broker(modconf,
> > your_own_params.....)
> > self.livestatus_broker.create_queues()
> > self.livestatus_broker.init()
> > self.sched.fill_initial_broks()
> > self.update_broker()
> >
> >
> > and then the test_venelin from above
> > ....
> >
> > Change all the livestatus stuff with your own module's name. The
> > update_broker() routine puts broks to the broker module and calls all the
> > manage_* methods.
> >
> >
> > Gerhard
> >
> >
> >
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Venelin Petkov [mailto:petkov.vene...@gmail.com]
> >> Gesendet: Montag, 7. Februar 2011 09:31
> >> An: shinken-devel@lists.sourceforge.net
> >> Betreff: Re: [Shinken-devel] How to access the configuration
> >> settings in a broker module
> >>
> >> Hi Gerhard,
> >>
> >> Here is exactly what I am doing:
> >>
> >> Excerpt from the conf (I defined custom variables for all 9
> >> services in this test configuration, just to be sure):
> >>
> >> define service{
> >> use local-service
> >> hostgroup_name print
> >> service_description cups
> >> check_command check_cups
> >> _udp_template test
> >> _myvar 9
> >> }
> >>
> >> define service{
> >> use local-service
> >> hostgroup_name printer
> >> service_description Printer
> >> check_command check_hpjd
> >> _udp_template test
> >> _myvar 10
> >> }
> >>
> >> Then I am trying the following (eprint is a lambda shortcut for
> >> sys.stderr.write):
> >>
> >> def manage_initial_service_status_brok(self, b):
> >> data = b.data
> >> eprint('customs: '+str(data['customs']))
> >>
> >> # template = data['customs'].get('_udp_template')
> >> # if template:
> >> # self.template_hash[data['service_description']] =
> >> data['customs']['_udp_template']
> >>
> >>
> >> I see 'customs' in broker output, but it is empty! Here is a
> >> partial broker output:
> >>
> >> ...
> >> We received modules [<shinken.module.Module object at
> >> 0x2895050>, <shinken.module.Module object at 0x2895150>,
> >> <shinken.module.Module object at 0
> >> x2895190>, <shinken.module.Module object at 0x2895250>]
> >> I am simple log Broker
> >> I am the nocdmod broker for pnp
> >> I am simple syslog Broker
> >> I am Livestatus Broker
> >> I am Service Perfdata Broker
> >> I am IWR UDP Host Perfdata Broker
> >> I am Host Perfdata Broker
> >> I am IWR UDP Service Perfdata Broker
> >> I am Couchdb Broker
> >> I am Status Dat Broker
> >> I am Generic Merlin Broker
> >> I am Ndo Mysql Broker
> >> I am Ndo Broker for Oracle
> >> Get a Status Dat broker for plugin Status-Dat
> >> {'status_update_interval': '15', 'object_cache_file':
> >> '/home/shinken/src/var/objects.cache', 'customs': {}, 'plus': {},
> >> 'status_file': '/home/shinken/src/va
> >> r/status.data', 'module_name': 'Status-Dat', 'module_type':
> >> 'status_dat', 'id': 2}
> >> Get a Simple log broker for plugin Simple-log Get a Host
> >> Perfdata broker for plugin IWR-Host-Perfdata Get a Service
> >> Perfdata broker for plugin IWR-Service-Perfdata Load 4 module
> >> instances I am init Starting external process (pid:30310) for
> >> instance Status-Dat
> >> customs: {}
> >> customs: {}
> >> customs: {}
> >> customs: {}
> >> customs: {}
> >> customs: {}
> >> customs: {}
> >>
> >> ...
> >>
> >> customs: {}
> >> customs: {}
> >> customs: {}
> >> Starting external process (pid:30311) for instance Simple-log
> >> I not open the host-perfdata file
> >> '/home/shinken/src/var/iwr-host-perfdata'
> >> [IWR-Service-Perfdata] I open the service-perfdata file
> >> '/home/shinken/src/var/iwr-service-perfdata'
> >> [broker-1] I correctly load the modules : ['Status-Dat',
> >> 'Simple-log', 'IWR-Host-Perfdata', 'IWR-Service-Perfdata']
> >> [broker-1] New running id for the scheduler scheduler-1 :
> >> 0.877694073146 (was 0) [broker-1] I ask for a broks
> >> generation to the scheduler scheduler-1 [broker-1] Connexion
> >> OK to the scheduler scheduler-1 [broker-1] New running id for
> >> the poller poller-1 : 0.263251106803 (was 0) [broker-1]
> >> Connexion OK to the poller poller-1 [broker-1] New running id
> >> for the reactionner reactionner-1 :
> >> 0.471794279887 (was 0)
> >> [broker-1] Connexion OK to the reactionner reactionner-1
> >> Begin Loop : manage broks 0 Got a new conf Begin Loop :
> >> manage broks 510 Begin Loop : manage broks 0 Begin Loop :
> >> manage broks 0 Begin Loop : manage broks 0 ...
> >>
> >>
> >>
> >> BTW, this is the 0.5.1 official release, but I am going to
> >> try it with the latest stuff from the repository, to make
> >> sure it is the same.
> >>
> >> Best Regards,
> >> Venelin Petkov
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Fri, Feb 4, 2011 at 7:22 PM, Gerhard Lausser
> >> <gerhard.laus...@consol.de> wrote:
> >> >
> >> >
> >> >> need, but somehow the custom variable that I have defined in each
> >> >> service, namely _udp_template, does not appear in
> >> > So if you fill a sevice-dict like in livestatus_broker.py and then
> >> > look at the elements
> >> >
> >> > for svc in service-list.values():
> >> > print "list of customs", get_customs_keys(svc.customs)
> >> >
> >> > you don't see anything?
> >> >
> >> > Gerhard
> >> >
> >> >
>
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Shinken-devel mailing list
Shinken-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shinken-devel