pdns  4.2.0-rc1
About: PowerDNS daemon - a high performance authoritative nameserver. Release candidate.
  Fossies Dox: pdns-4.2.0-rc1.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

StatBag Class Reference

use this to gather and query statistics More...

#include <statbag.hh>

Collaboration diagram for StatBag:

Public Member Functions

 StatBag ()
 Naked constructor. You need to declare keys before this class becomes useful. More...
 
 ~StatBag ()
 
void declare (const string &key, const string &descrip="")
 Before you can store or access a key, you need to declare it. More...
 
void declare (const string &key, const string &descrip, func_t func)
 Before you can store or access a key, you need to declare it. More...
 
void declareRing (const string &name, const string &title, unsigned int size=10000)
 
void declareComboRing (const string &name, const string &help, unsigned int size=10000)
 
vector< pair< string, unsigned int > > getRing (const string &name)
 
string getRingTitle (const string &name)
 
void ringAccount (const char *name, const string &item)
 
void ringAccount (const char *name, const ComboAddress &item)
 
void doRings ()
 
vector< string > listRings ()
 
bool ringExists (const string &name)
 
void resetRing (const string &name)
 
void resizeRing (const string &name, unsigned int newsize)
 
unsigned int getRingSize (const string &name)
 
string directory ()
 Returns a list of all data stored. More...
 
vector< string > getEntries ()
 returns a vector with datums (items) More...
 
string getDescrip (const string &item)
 Returns the description of this datum/item. More...
 
void exists (const string &key)
 call this function to throw an exception in case a key does not exist More...
 
void deposit (const string &key, int value)
 increment the statistics behind this key by value amount More...
 
void inc (const string &key)
 increase this key's value by one More...
 
void set (const string &key, unsigned long value)
 set this key's value More...
 
unsigned long read (const string &key)
 read the value behind this key More...
 
unsigned long readZero (const string &key)
 read the value behind this key, and zero it afterwards More...
 
AtomicCountergetPointer (const string &key)
 get a direct pointer to the value behind a key. Use this for high performance increments More...
 
string getValueStr (const string &key)
 read a value behind a key, and return it as a string More...
 
string getValueStrZero (const string &key)
 read a value behind a key, and return it as a string, and zero afterwards More...
 

Private Types

typedef boost::function< uint64_t(const std::string &)> func_t
 
typedef map< string, func_tfuncstats_t
 

Private Attributes

map< string, AtomicCounter * > d_stats
 
map< string, string > d_keyDescrips
 
map< string, StatRing< string > > d_rings
 
map< string, StatRing< SComboAddress > > d_comborings
 
funcstats_t d_funcstats
 
bool d_doRings
 

Detailed Description

use this to gather and query statistics

Definition at line 63 of file statbag.hh.

Member Typedef Documentation

◆ func_t

typedef boost::function<uint64_t(const std::string&)> StatBag::func_t
private

Definition at line 69 of file statbag.hh.

◆ funcstats_t

typedef map<string, func_t> StatBag::funcstats_t
private

Definition at line 70 of file statbag.hh.

Constructor & Destructor Documentation

◆ StatBag()

StatBag::StatBag ( )

Naked constructor. You need to declare keys before this class becomes useful.

Definition at line 38 of file statbag.cc.

References d_doRings.

◆ ~StatBag()

StatBag::~StatBag ( )

Definition at line 151 of file statbag.cc.

References d_stats.

Member Function Documentation

◆ declare() [1/2]

void StatBag::declare ( const string &  key,
const string &  descrip,
StatBag::func_t  func 
)

Before you can store or access a key, you need to declare it.

Definition at line 99 of file statbag.cc.

References d_funcstats, and d_keyDescrips.

◆ declare() [2/2]

void StatBag::declare ( const string &  key,
const string &  descrip = "" 
)

Before you can store or access a key, you need to declare it.

Definition at line 92 of file statbag.cc.

References d_keyDescrips, and d_stats.

Referenced by AuthPacketCache::AuthPacketCache(), AuthQueryCache::AuthQueryCache(), BOOST_AUTO_TEST_CASE(), declareStats(), loadMainConfig(), and main().

◆ declareComboRing()

void StatBag::declareComboRing ( const string &  name,
const string &  help,
unsigned int  size = 10000 
)

Definition at line 225 of file statbag.cc.

References d_comborings.

Referenced by declareStats().

◆ declareRing()

void StatBag::declareRing ( const string &  name,
const string &  title,
unsigned int  size = 10000 
)

Definition at line 219 of file statbag.cc.

References d_rings.

Referenced by declareStats().

◆ deposit()

void StatBag::deposit ( const string &  key,
int  value 
)
inline

increment the statistics behind this key by value amount

Definition at line 127 of file statbag.hh.

References d_stats, and exists().

Referenced by inc(), and PacketHandler::processUpdate().

◆ directory()

string StatBag::directory ( )

Returns a list of all data stored.

Definition at line 51 of file statbag.cc.

References d_funcstats, and d_stats.

Referenced by DLShowHandler().

◆ doRings()

void StatBag::doRings ( )
inline

Definition at line 102 of file statbag.hh.

References d_doRings.

Referenced by AuthWebServer::go().

◆ exists()

void StatBag::exists ( const string &  key)

call this function to throw an exception in case a key does not exist

Definition at line 43 of file statbag.cc.

References d_keyDescrips.

Referenced by deposit(), getDescrip(), getPointer(), read(), readZero(), and set().

◆ getDescrip()

string StatBag::getDescrip ( const string &  item)

Returns the description of this datum/item.

Definition at line 86 of file statbag.cc.

References d_keyDescrips, and exists().

Referenced by AuthWebServer::printvars().

◆ getEntries()

vector< string > StatBag::getEntries ( )

returns a vector with datums (items)

Definition at line 69 of file statbag.cc.

References d_funcstats, and d_stats.

Referenced by carbonDumpThread(), AuthWebServer::printvars(), and productServerStatisticsFetch().

◆ getPointer()

AtomicCounter * StatBag::getPointer ( const string &  key)

get a direct pointer to the value behind a key. Use this for high performance increments

Definition at line 145 of file statbag.cc.

References d_stats, and exists().

Referenced by AuthPacketCache::AuthPacketCache(), AuthQueryCache::AuthQueryCache(), BOOST_AUTO_TEST_CASE(), DNSProxy::DNSProxy(), fillOutRRSIG(), qthread(), PacketHandler::question(), and ResponseStats::submitResponse().

◆ getRing()

vector< pair< string, unsigned int > > StatBag::getRing ( const string &  name)

Definition at line 232 of file statbag.cc.

References d_comborings, and d_rings.

Referenced by apiServerStatistics(), DLRemotesHandler(), and printtable().

◆ getRingSize()

unsigned int StatBag::getRingSize ( const string &  name)

Definition at line 272 of file statbag.cc.

References d_comborings, and d_rings.

Referenced by apiServerStatistics(), and printtable().

◆ getRingTitle()

string StatBag::getRingTitle ( const string &  name)

Definition at line 280 of file statbag.cc.

References d_comborings, and d_rings.

Referenced by AuthWebServer::indexfunction().

◆ getValueStr()

string StatBag::getValueStr ( const string &  key)

read a value behind a key, and return it as a string

Definition at line 131 of file statbag.cc.

References read().

Referenced by DLShowHandler().

◆ getValueStrZero()

string StatBag::getValueStrZero ( const string &  key)

read a value behind a key, and return it as a string, and zero afterwards

Definition at line 138 of file statbag.cc.

References readZero().

◆ inc()

◆ listRings()

vector< string > StatBag::listRings ( )

Definition at line 288 of file statbag.cc.

References d_comborings, and d_rings.

Referenced by apiServerStatistics(), and AuthWebServer::indexfunction().

◆ read()

unsigned long StatBag::read ( const string &  key)

◆ readZero()

unsigned long StatBag::readZero ( const string &  key)

read the value behind this key, and zero it afterwards

Definition at line 122 of file statbag.cc.

References d_stats, and exists().

Referenced by getValueStrZero().

◆ resetRing()

void StatBag::resetRing ( const string &  name)

Definition at line 255 of file statbag.cc.

References d_comborings, and d_rings.

Referenced by AuthWebServer::indexfunction().

◆ resizeRing()

void StatBag::resizeRing ( const string &  name,
unsigned int  newsize 
)

Definition at line 263 of file statbag.cc.

References d_comborings, and d_rings.

Referenced by AuthWebServer::indexfunction().

◆ ringAccount() [1/2]

void StatBag::ringAccount ( const char *  name,
const ComboAddress item 
)
inline

Definition at line 93 of file statbag.hh.

References d_comborings, and d_doRings.

◆ ringAccount() [2/2]

◆ ringExists()

bool StatBag::ringExists ( const string &  name)

Definition at line 299 of file statbag.cc.

References d_comborings, and d_rings.

Referenced by AuthWebServer::indexfunction().

◆ set()

void StatBag::set ( const string &  key,
unsigned long  value 
)

set this key's value

Definition at line 107 of file statbag.cc.

References d_stats, and exists().

Referenced by BOOST_AUTO_TEST_CASE(), and doSecPoll().

Member Data Documentation

◆ d_comborings

map<string,StatRing<SComboAddress> > StatBag::d_comborings
private

◆ d_doRings

bool StatBag::d_doRings
private

Definition at line 72 of file statbag.hh.

Referenced by doRings(), ringAccount(), and StatBag().

◆ d_funcstats

funcstats_t StatBag::d_funcstats
private

Definition at line 71 of file statbag.hh.

Referenced by declare(), directory(), getEntries(), and read().

◆ d_keyDescrips

map<string, string> StatBag::d_keyDescrips
private

Definition at line 66 of file statbag.hh.

Referenced by declare(), exists(), and getDescrip().

◆ d_rings

map<string,StatRing<string> > StatBag::d_rings
private

◆ d_stats

map<string, AtomicCounter *> StatBag::d_stats
private

Definition at line 65 of file statbag.hh.

Referenced by declare(), deposit(), directory(), getEntries(), getPointer(), read(), readZero(), set(), and ~StatBag().


The documentation for this class was generated from the following files: