class MOSDBoot : public PaxosServiceMessage {
- static const int HEAD_VERSION = 4;
+ static const int HEAD_VERSION = 5;
static const int COMPAT_VERSION = 2;
public:
entity_addr_t hb_back_addr, hb_front_addr;
entity_addr_t cluster_addr;
epoch_t boot_epoch; // last epoch this daemon was added to the map (if any)
+ map<string,string> metadata; ///< misc metadata about this osd
MOSDBoot()
: PaxosServiceMessage(MSG_OSD_BOOT, 0, HEAD_VERSION, COMPAT_VERSION),
::encode(cluster_addr, payload);
::encode(boot_epoch, payload);
::encode(hb_front_addr, payload);
+ ::encode(metadata, payload);
}
void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(boot_epoch, p);
if (header.version >= 4)
::decode(hb_front_addr, p);
+ if (header.version >= 5)
+ ::decode(metadata, p);
}
};
#include <iostream>
#include <errno.h>
#include <sys/stat.h>
+#include <sys/utsname.h>
#include <signal.h>
#include <ctype.h>
#include <boost/scoped_ptr.hpp>
<< ", hb_back_addr " << hb_back_addr
<< ", hb_front_addr " << hb_front_addr
<< dendl;
+ _collect_metadata(&mboot->metadata);
monc->send_mon_message(mboot);
}
+void OSD::_collect_metadata(map<string,string> *pm)
+{
+ (*pm)["ceph_version"] = pretty_version_to_str();
+
+ // kernel info
+ struct utsname u;
+ int r = uname(&u);
+ if (r >= 0) {
+ (*pm)["os"] = u.sysname;
+ (*pm)["kernel_version"] = u.release;
+ (*pm)["kernel_description"] = u.version;
+ (*pm)["hostname"] = u.nodename;
+ (*pm)["arch"] = u.machine;
+ }
+
+ // memory
+ FILE *f = fopen("/proc/meminfo", "r");
+ if (f) {
+ char buf[100];
+ while (!feof(f)) {
+ char *line = fgets(buf, sizeof(buf), f);
+ if (!line)
+ break;
+ char key[40];
+ long long value;
+ int r = sscanf(line, "%s %lld", key, &value);
+ if (r == 2) {
+ if (strcmp(key, "MemTotal:") == 0)
+ (*pm)["mem_total_kb"] = stringify(value);
+ else if (strcmp(key, "SwapTotal:") == 0)
+ (*pm)["mem_swap_kb"] = stringify(value);
+ }
+ }
+ fclose(f);
+ }
+
+ // distro info
+ f = fopen("/etc/lsb-release", "r");
+ if (f) {
+ char buf[100];
+ while (!feof(f)) {
+ char *line = fgets(buf, sizeof(buf), f);
+ if (!line)
+ break;
+ char *eq = strchr(buf, '=');
+ if (!eq)
+ break;
+ *eq = '\0';
+ ++eq;
+ while (*eq == '\"')
+ ++eq;
+ while (*eq && (eq[strlen(eq)-1] == '\n' ||
+ eq[strlen(eq)-1] == '\"'))
+ eq[strlen(eq)-1] = '\0';
+ if (strcmp(buf, "DISTRIB_ID") == 0)
+ (*pm)["distro"] = eq;
+ else if (strcmp(buf, "DISTRIB_RELEASE") == 0)
+ (*pm)["distro_version"] = eq;
+ else if (strcmp(buf, "DISTRIB_CODENAME") == 0)
+ (*pm)["distro_codename"] = eq;
+ else if (strcmp(buf, "DISTRIB_DESCRIPTION") == 0)
+ (*pm)["distro_description"] = eq;
+ }
+ fclose(f);
+ }
+
+ dout(10) << __func__ << " " << *pm << dendl;
+}
+
void OSD::queue_want_up_thru(epoch_t want)
{
map_lock.get_read();