예제 #1
0
def main(argv):
    opts, loop_opts = parse_args(argv)

    if opts.root_setup:
        return root_setup.root_setup()

    def single_iteration():
        try:
            get_cpu_info()
            get_disk_info()
            get_mem_info()
            get_net_info()
            get_proc_info()
        finally:
            ts_mon.flush()
        return True

    # This returns a 0 value the first time it's called.  Call it now and discard
    # the return value.
    psutil.cpu_times_percent()

    # Wait a random amount of time before starting the loop in case sysmon is
    # started at exactly the same time on all machines.
    time.sleep(random.uniform(0, opts.interval))

    loop_results = outer_loop.loop(task=single_iteration,
                                   sleep_timeout=lambda: opts.interval,
                                   **loop_opts)

    return 0 if loop_results.success else 1
예제 #2
0
def main(argv):
  opts, loop_opts = parse_args(argv)

  if opts.root_setup:
    return root_setup.root_setup()

  def single_iteration():
    try:
      system_metrics.get_cpu_info()
      system_metrics.get_disk_info()
      system_metrics.get_mem_info()
      system_metrics.get_net_info()
      system_metrics.get_proc_info()
      puppet_metrics.get_puppet_summary()
    finally:
      ts_mon.flush()
    return True

  # This returns a 0 value the first time it's called.  Call it now and discard
  # the return value.
  psutil.cpu_times_percent()

  # Wait a random amount of time before starting the loop in case sysmon is
  # started at exactly the same time on all machines.
  time.sleep(random.uniform(0, opts.interval))

  loop_results = outer_loop.loop(
      task=single_iteration,
      sleep_timeout=lambda: opts.interval,
      **loop_opts)

  return 0 if loop_results.success else 1
예제 #3
0
 def test_writes_service(self):
   self.assertEquals(0, root_setup.root_setup())
   self.mock_write_service.assert_called_once_with(
       name='sysmon',
       root_directory='/opt/infra-python',
       tool='infra.services.sysmon',
       args=['--interval', '60'])
예제 #4
0
 def test_writes_service(self):
     self.assertEquals(0, root_setup.root_setup())
     self.mock_write_service.assert_called_once_with(
         name='sysmon',
         root_directory='/opt/infra-python',
         tool='infra.services.sysmon',
         args=['--interval', '60'])