00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022 #include <plugin/protocol_dictionary/dictionary.h>
00023 #include <drizzled/plugin/listen.h>
00024
00025 using namespace drizzled;
00026
00027 ProtocolTool::ProtocolTool() :
00028 plugin::TableFunction("DATA_DICTIONARY", "PROTOCOL_COUNTERS")
00029 {
00030 add_field("PROTOCOL");
00031 add_field("COUNTER");
00032 add_field("VALUE", plugin::TableFunction::NUMBER, 0, false);
00033 }
00034
00035 ProtocolTool::Generator::Generator(Field **arg) :
00036 plugin::TableFunction::Generator(arg)
00037 {
00038 protocol_it= plugin::Listen::getListenProtocols().begin();
00039 protocol= *protocol_it;
00040 counter_it= protocol->getListenCounters().begin();
00041 }
00042
00043 bool ProtocolTool::Generator::populate()
00044 {
00045 if (protocol_it == plugin::Listen::getListenProtocols().end())
00046 return false;
00047
00048 protocol= *protocol_it;
00049
00050 while (counter_it == protocol->getListenCounters().end())
00051 {
00052 protocol_it++;
00053 if (protocol_it == plugin::Listen::getListenProtocols().end())
00054 return false;
00055 protocol= *protocol_it;
00056 counter_it= protocol->getListenCounters().begin();
00057 }
00058
00059 fill();
00060 counter_it++;
00061 return true;
00062 }
00063
00064 void ProtocolTool::Generator::fill()
00065 {
00066 protocol= *protocol_it;
00067 counter= *counter_it;
00068
00069 push(protocol->getName());
00070 push(*counter->first);
00071 push((uint64_t) *counter->second);
00072 }
00073
00074 static ProtocolTool *protocols;
00075
00076 static int init(drizzled::module::Context &context)
00077 {
00078 protocols= new(std::nothrow)ProtocolTool;
00079
00080 context.add(protocols);
00081
00082 return 0;
00083 }
00084
00085 DRIZZLE_DECLARE_PLUGIN
00086 {
00087 DRIZZLE_VERSION_ID,
00088 "protocol_dictionary",
00089 "1.0",
00090 "Andrew Hutchings",
00091 "Provides dictionary for protocol counters.",
00092 PLUGIN_LICENSE_GPL,
00093 init,
00094 NULL,
00095 NULL
00096 }
00097 DRIZZLE_DECLARE_PLUGIN_END;
00098