#!/usr/bin/python2

'''
collector.py - statistics collector service for sagator

(c) 2003-2004 Jan ONDREJ (SAL) <ondrejj(at)salstar.sk>

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

'''

from aglib import *
from stats import *

__all__=['collector']

class collector(service):
  '''
  Statistics collector service for sagator.
  
  This service can be used to collect some data for statistics.
  
  Usage: collector(name,port)
  
  Example: collector('0.0.0.0',28)
  '''
  name='collector()'
  def __init__(self,host,port):
      self.HOST=host
      self.PORT=port
  def main(self):
      globals.stat_coll=stats.collector((self.HOST,self.PORT))
      debug.dup()
      pid=globals.stat_coll.main()
      if pid>0:
        return [pid]
      else:
        return []
