1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2012 Inktank Storage, Inc.
7 * Copyright (C) 2014 Red Hat <contact@redhat.com>
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
17 #include "common/Formatter.h"
18 #include "include/types.h"
20 int64_t unit_to_bytesize(string val
, ostream
*pss
);
22 struct ceph_data_stats
36 void dump(Formatter
*f
) const {
38 f
->dump_int("total", byte_total
);
39 f
->dump_int("used", byte_used
);
40 f
->dump_int("avail", byte_avail
);
41 f
->dump_int("avail_percent", avail_percent
);
44 void encode(bufferlist
&bl
) const {
45 ENCODE_START(1, 1, bl
);
46 ::encode(byte_total
, bl
);
47 ::encode(byte_used
, bl
);
48 ::encode(byte_avail
, bl
);
49 ::encode(avail_percent
, bl
);
53 void decode(bufferlist::iterator
&p
) {
55 ::decode(byte_total
, p
);
56 ::decode(byte_used
, p
);
57 ::decode(byte_avail
, p
);
58 ::decode(avail_percent
, p
);
62 static void generate_test_instances(list
<ceph_data_stats
*>& ls
) {
63 ls
.push_back(new ceph_data_stats
);
64 ls
.push_back(new ceph_data_stats
);
65 ls
.back()->byte_total
= 1024*1024;
66 ls
.back()->byte_used
= 512*1024;
67 ls
.back()->byte_avail
= 512*1024;
68 ls
.back()->avail_percent
= 50;
71 typedef struct ceph_data_stats ceph_data_stats_t
;
72 WRITE_CLASS_ENCODER(ceph_data_stats
)
74 int get_fs_stats(ceph_data_stats_t
&stats
, const char *path
);
76 /// collect info from @p uname(2), @p /proc/meminfo and @p /proc/cpuinfo
77 void collect_sys_info(map
<string
, string
> *m
, CephContext
*cct
);
79 /// dump service ids grouped by their host to the specified formatter
80 /// @param f formatter for the output
81 /// @param services a map from hostname to a list of service id hosted by this host
82 /// @param type the service type of given @p services, for example @p osd or @p mon.
83 void dump_services(Formatter
* f
, const map
<string
, list
<int> >& services
, const char* type
);
85 string
cleanbin(bufferlist
&bl
, bool &b64
);
86 string
cleanbin(string
&str
);
87 #endif /* CEPH_UTIL_H */