Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / perfglue / cpu_profiler.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2011 New Dream Network
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software
11  * Foundation.  See file COPYING.
12  *
13  */
14
15 #include "acconfig.h"
16
17 #include <gperftools/profiler.h>
18
19 #include "common/LogClient.h"
20 #include "perfglue/cpu_profiler.h"
21
22 void cpu_profiler_handle_command(const std::vector<std::string> &cmd,
23                                  ostream& out)
24 {
25   if (cmd[1] == "status") {
26     ProfilerState st;
27     ProfilerGetCurrentState(&st);
28     out << "cpu_profiler " << (st.enabled ? "enabled":"not enabled")
29         << " start_time " << st.start_time
30         << " profile_name " << st.profile_name
31         << " samples " << st.samples_gathered;
32   }
33   else if (cmd[1] == "flush") {
34     ProfilerFlush();
35     out << "cpu_profiler: flushed";
36   }
37   else {
38     out << "cpu_profiler: unrecognized command " << cmd
39         << "; expected one of status, flush.";
40   }
41 }