Exemplo n.º 1
0
def main(_, opts):
  stats = StatsServer(opts.iface,
                      opts.zookeeper_port,
                      opts.aggregation_depth,
                      opts.max_results,
                      opts.max_queued_requests,
                      opts.max_queued_replies,
                      opts.max_queued_events)

  log.info("Starting with opts: %s" % (opts))

  signal.signal(signal.SIGINT, signal.SIG_DFL)

  process = ProcessOptions()

  if opts.niceness >= 0:
    process.set_niceness(opts.niceness)

  if opts.cpu_affinity:
    process.set_cpu_affinity(opts.cpu_affinity)

  server = Server()
  server.mount_routes(DiagnosticsEndpoints())
  server.mount_routes(stats)
  server.run(opts.http_addr, opts.http_port)

  while True:
    time.sleep(10)
Exemplo n.º 2
0
def test_cpu_affinity_parsing():
    """
    Test CPU affinity list parsing
    """
    assert ProcessOptions.parse_cpu_affinity('0,1,2,3,4,5') == [
        0, 1, 2, 3, 4, 5
    ]
    assert ProcessOptions.parse_cpu_affinity('2') == [2]
Exemplo n.º 3
0
def main(_, opts):
    stats = StatsServer(opts.iface, opts.zookeeper_port,
                        opts.aggregation_depth, opts.max_results,
                        opts.max_queued_requests, opts.max_queued_replies,
                        opts.max_queued_events)

    log.info("Starting with opts: %s" % (opts))

    signal.signal(signal.SIGINT, signal.SIG_DFL)

    process = ProcessOptions()

    if opts.niceness >= 0:
        process.set_niceness(opts.niceness)

    if opts.cpu_affinity:
        process.set_cpu_affinity(opts.cpu_affinity)

    server = Server()
    server.mount_routes(DiagnosticsEndpoints())
    server.mount_routes(stats)
    server.run(opts.http_addr, opts.http_port)

    while True:
        time.sleep(10)
Exemplo n.º 4
0
def main(_, opts):

  if opts.version:
    sys.stdout.write("%s\n" % __version__)
    sys.exit(0)

  # set proc options before we spawn threads
  process = ProcessOptions()

  if opts.niceness >= 0:
    process.set_niceness(opts.niceness)

  if opts.cpu_affinity:
    process.set_cpu_affinity(opts.cpu_affinity)

  if opts.sampling < 0 or opts.sampling > 1:
    sys.stdout.write("--sampling takes values within [0, 1]\n")
    sys.exit(1)

  stats = StatsServer(opts.iface,
                      opts.zookeeper_port,
                      opts.aggregation_depth,
                      opts.max_results,
                      opts.max_queued_requests,
                      opts.max_queued_replies,
                      opts.max_queued_events,
                      sampling=opts.sampling,
                      include_bytes=not opts.exclude_bytes)

  log.info("Starting with opts: %s" % (opts))

  signal.signal(signal.SIGINT, signal.SIG_DFL)

  server = Server()
  server.mount_routes(DiagnosticsEndpoints())
  server.mount_routes(stats)
  server.run(opts.http_addr, opts.http_port)

  stats.sniffer.join()
Exemplo n.º 5
0
def main(_, opts):

    if opts.version:
        sys.stdout.write("%s\n" % __version__)
        sys.exit(0)

    # set proc options before we spawn threads
    process = ProcessOptions()

    if opts.niceness >= 0:
        process.set_niceness(opts.niceness)

    if opts.cpu_affinity:
        process.set_cpu_affinity(opts.cpu_affinity)

    if opts.sampling < 0 or opts.sampling > 1:
        sys.stdout.write("--sampling takes values within [0, 1]\n")
        sys.exit(1)

    stats = StatsServer(opts.iface,
                        opts.zookeeper_port,
                        opts.aggregation_depth,
                        opts.max_results,
                        opts.max_queued_requests,
                        opts.max_queued_replies,
                        opts.max_queued_events,
                        sampling=opts.sampling,
                        include_bytes=not opts.exclude_bytes)

    log.info("Starting with opts: %s" % (opts))

    signal.signal(signal.SIGINT, signal.SIG_DFL)

    server = Server()
    server.mount_routes(DiagnosticsEndpoints())
    server.mount_routes(stats)
    server.run(opts.http_addr, opts.http_port)

    stats.sniffer.join()
Exemplo n.º 6
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==================================================================================================

import mock
import os
import sys

from zktraffic.base.process import ProcessOptions

import psutil

proc = ProcessOptions()


def test_niceness():
    """
  Test CPU niceness calls
  """
    proc.set_niceness(15)
    assert proc.niceness == 15


def test_cpu_affinity_parsing():
    """
    Test CPU affinity list parsing
    """
    assert ProcessOptions.parse_cpu_affinity('0,1,2,3,4,5') == [
Exemplo n.º 7
0
def test_cpu_affinity_parsing():
    """
    Test CPU affinity list parsing
    """
    assert ProcessOptions.parse_cpu_affinity('0,1,2,3,4,5') == [0, 1, 2, 3, 4, 5]
    assert ProcessOptions.parse_cpu_affinity('2') == [2]
Exemplo n.º 8
0
 def json_info(self):
   """ general info about this instance """
   proc = ProcessOptions()
   return {
     "uptime": proc.uptime
   }