Exemplo n.º 1
0
def main(argv):
  current_epoch_sec = utils.datetime_to_sec_since_epoch(datetime.datetime.now())
  c = client.VARZClient()
  dump = c.all_dump()
  print "SAMPLERS"
  print_samplers(sort_vars_by_name(dump["mht_samplers"]), current_epoch_sec)
  print ""
  print "COUNTERS"
  print_counters(sort_vars_by_name(dump["mht_counters"]), current_epoch_sec)
Exemplo n.º 2
0
 def counter_increment(self, counter_name, amt=1, time=None, mode=None):
   '''Increment a varz counter variable on the remote hosts.
   Arguments
     counter_name: A name for a counter, must be less than 128 characters. Cannot have whitespace.
     amt (optional): The amount to increment the counter by, defaults to 1
     time (optional): The time of the event as a datetime.datetime, defaults to current time. Should
         be utc time.
     mode (optional): Can be used to force either UDP or TCP mode
   Returns: None'''
   counter_name, time, mode = self._defaults_for_name_time_and_mode(counter_name, time, mode)
   sec_since_epoch = utils.datetime_to_sec_since_epoch(time)
   command = "MHTCOUNTERADD %s %d %d;" % (counter_name, sec_since_epoch, amt)
   self._send_with_mode(command, mode)
Exemplo n.º 3
0
 def sampler_add(self, sampler_name, value, time=None, mode=None):
   '''Add a sample to the specified sampler. The varz daemon will of course only add the sample
      if its sampling requirements are satisfied.
   Arguments:
     sampler_name: A name for the sampler, must be less than 128 characters. Cannot have whitespace
     value: The value of the sample
     time (optional): The time of the event as a datetime.datetime, defaults to current time. Should
         be utc time.
     mode (optional): Can be used to force either UDP or TCP mode
   Returns: None'''
   sampler_name, time, mode = self._defaults_for_name_time_and_mode(sampler_name, time, mode)
   sec_since_epoch = utils.datetime_to_sec_since_epoch(time)
   command = "MHTSAMPLEADD %s %d %d;" % (sampler_name, sec_since_epoch, value)
   self._send_with_mode(command, mode)
Exemplo n.º 4
0
 def counter_increment(self, counter_name, amt=1, time=None, mode=None):
     '''Increment a varz counter variable on the remote hosts.
 Arguments
   counter_name: A name for a counter, must be less than 128 characters. Cannot have whitespace.
   amt (optional): The amount to increment the counter by, defaults to 1
   time (optional): The time of the event as a datetime.datetime, defaults to current time. Should
       be utc time.
   mode (optional): Can be used to force either UDP or TCP mode
 Returns: None'''
     counter_name, time, mode = self._defaults_for_name_time_and_mode(
         counter_name, time, mode)
     sec_since_epoch = utils.datetime_to_sec_since_epoch(time)
     command = "MHTCOUNTERADD %s %d %d;" % (counter_name, sec_since_epoch,
                                            amt)
     self._send_with_mode(command, mode)
Exemplo n.º 5
0
 def sampler_add(self, sampler_name, value, time=None, mode=None):
     '''Add a sample to the specified sampler. The varz daemon will of course only add the sample
    if its sampling requirements are satisfied.
 Arguments:
   sampler_name: A name for the sampler, must be less than 128 characters. Cannot have whitespace
   value: The value of the sample
   time (optional): The time of the event as a datetime.datetime, defaults to current time. Should
       be utc time.
   mode (optional): Can be used to force either UDP or TCP mode
 Returns: None'''
     sampler_name, time, mode = self._defaults_for_name_time_and_mode(
         sampler_name, time, mode)
     sec_since_epoch = utils.datetime_to_sec_since_epoch(time)
     command = "MHTSAMPLEADD %s %d %d;" % (sampler_name, sec_since_epoch,
                                           value)
     self._send_with_mode(command, mode)