From cfb3c9cf9f4a23c09c75fcdd3df1bebdc2713ab2 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 12 Jul 2013 12:07:32 +0200 Subject: [PATCH] livestatus: implement avg,min,max,std,invsum,invavg stats aggregators fixes #4398 --- components/livestatus/Makefile.am | 12 +++++ components/livestatus/avgaggregator.cpp | 43 ++++++++++++++++ components/livestatus/avgaggregator.h | 50 ++++++++++++++++++ components/livestatus/invavgaggregator.cpp | 43 ++++++++++++++++ components/livestatus/invavgaggregator.h | 50 ++++++++++++++++++ components/livestatus/invsumaggregator.cpp | 42 +++++++++++++++ components/livestatus/invsumaggregator.h | 49 ++++++++++++++++++ components/livestatus/livestatus.vcxproj | 12 +++++ .../livestatus/livestatus.vcxproj.filters | 36 +++++++++++++ components/livestatus/maxaggregator.cpp | 43 ++++++++++++++++ components/livestatus/maxaggregator.h | 49 ++++++++++++++++++ components/livestatus/minaggregator.cpp | 43 ++++++++++++++++ components/livestatus/minaggregator.h | 49 ++++++++++++++++++ components/livestatus/query.cpp | 18 ++++--- components/livestatus/stdaggregator.cpp | 45 ++++++++++++++++ components/livestatus/stdaggregator.h | 51 +++++++++++++++++++ 16 files changed, 629 insertions(+), 6 deletions(-) create mode 100644 components/livestatus/avgaggregator.cpp create mode 100644 components/livestatus/avgaggregator.h create mode 100644 components/livestatus/invavgaggregator.cpp create mode 100644 components/livestatus/invavgaggregator.h create mode 100644 components/livestatus/invsumaggregator.cpp create mode 100644 components/livestatus/invsumaggregator.h create mode 100644 components/livestatus/maxaggregator.cpp create mode 100644 components/livestatus/maxaggregator.h create mode 100644 components/livestatus/minaggregator.cpp create mode 100644 components/livestatus/minaggregator.h create mode 100644 components/livestatus/stdaggregator.cpp create mode 100644 components/livestatus/stdaggregator.h diff --git a/components/livestatus/Makefile.am b/components/livestatus/Makefile.am index aaac41339..4fdd7939c 100644 --- a/components/livestatus/Makefile.am +++ b/components/livestatus/Makefile.am @@ -16,6 +16,8 @@ liblivestatus_la_SOURCES = \ attributefilter.h \ andfilter.cpp \ andfilter.h \ + avgaggregator.cpp \ + avgaggregator.h \ column.cpp \ column.h \ combinerfilter.cpp \ @@ -40,9 +42,17 @@ liblivestatus_la_SOURCES = \ hostgroupstable.h \ hoststable.cpp \ hoststable.h \ + invavgaggregator.cpp \ + invavgaggregator.h \ + invsumaggregator.cpp \ + invsumaggregator.h \ livestatus-type.cpp \ logtable.cpp \ logtable.h \ + maxaggregator.cpp \ + maxaggregator.h \ + minaggregator.cpp \ + minaggregator.h \ negatefilter.cpp \ negatefilter.h \ orfilter.cpp \ @@ -55,6 +65,8 @@ liblivestatus_la_SOURCES = \ servicestable.h \ statustable.cpp \ statustable.h \ + stdaggregator.cpp \ + stdaggregator.h \ sumaggregator.cpp \ sumaggregator.h \ timeperiodstable.cpp \ diff --git a/components/livestatus/avgaggregator.cpp b/components/livestatus/avgaggregator.cpp new file mode 100644 index 000000000..b9eb187b8 --- /dev/null +++ b/components/livestatus/avgaggregator.cpp @@ -0,0 +1,43 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "livestatus/avgaggregator.h" + +using namespace livestatus; + +AvgAggregator::AvgAggregator(const String& attr) + : m_Avg(0), m_AvgCount(0) +{ + m_AvgAttr = attr; +} + +void AvgAggregator::Apply(const Table::Ptr& table, const Value& row) +{ + Column column = table->GetColumn(m_AvgAttr); + + Value value = column.ExtractValue(row); + + m_Avg += value; + m_AvgCount++; +} + +double AvgAggregator::GetResult(void) const +{ + return (m_Avg / m_AvgCount); +} diff --git a/components/livestatus/avgaggregator.h b/components/livestatus/avgaggregator.h new file mode 100644 index 000000000..a27bf8065 --- /dev/null +++ b/components/livestatus/avgaggregator.h @@ -0,0 +1,50 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef AVGAGGREGATOR_H +#define AVGAGGREGATOR_H + +#include "livestatus/table.h" +#include "livestatus/aggregator.h" + +namespace livestatus +{ + +/** + * @ingroup livestatus + */ +class AvgAggregator : public Aggregator +{ +public: + DECLARE_PTR_TYPEDEFS(AvgAggregator); + + AvgAggregator(const String& attr); + + virtual void Apply(const Table::Ptr& table, const Value& row); + virtual double GetResult(void) const; + +private: + double m_Avg; + double m_AvgCount; + String m_AvgAttr; +}; + +} + +#endif /* AVGAGGREGATOR_H */ diff --git a/components/livestatus/invavgaggregator.cpp b/components/livestatus/invavgaggregator.cpp new file mode 100644 index 000000000..d80cb6cd0 --- /dev/null +++ b/components/livestatus/invavgaggregator.cpp @@ -0,0 +1,43 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "livestatus/invavgaggregator.h" + +using namespace livestatus; + +InvAvgAggregator::InvAvgAggregator(const String& attr) + : m_InvAvg(0), m_InvAvgCount(0) +{ + m_InvAvgAttr = attr; +} + +void InvAvgAggregator::Apply(const Table::Ptr& table, const Value& row) +{ + Column column = table->GetColumn(m_InvAvgAttr); + + Value value = column.ExtractValue(row); + + m_InvAvg += (1.0 / value); + m_InvAvgCount++; +} + +double InvAvgAggregator::GetResult(void) const +{ + return (m_InvAvg / m_InvAvgCount); +} diff --git a/components/livestatus/invavgaggregator.h b/components/livestatus/invavgaggregator.h new file mode 100644 index 000000000..cffd3051c --- /dev/null +++ b/components/livestatus/invavgaggregator.h @@ -0,0 +1,50 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef INVAVGAGGREGATOR_H +#define INVAVGAGGREGATOR_H + +#include "livestatus/table.h" +#include "livestatus/aggregator.h" + +namespace livestatus +{ + +/** + * @ingroup livestatus + */ +class InvAvgAggregator : public Aggregator +{ +public: + DECLARE_PTR_TYPEDEFS(InvAvgAggregator); + + InvAvgAggregator(const String& attr); + + virtual void Apply(const Table::Ptr& table, const Value& row); + virtual double GetResult(void) const; + +private: + double m_InvAvg; + double m_InvAvgCount; + String m_InvAvgAttr; +}; + +} + +#endif /* INVAVGAGGREGATOR_H */ diff --git a/components/livestatus/invsumaggregator.cpp b/components/livestatus/invsumaggregator.cpp new file mode 100644 index 000000000..c0ee0def5 --- /dev/null +++ b/components/livestatus/invsumaggregator.cpp @@ -0,0 +1,42 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "livestatus/invsumaggregator.h" + +using namespace livestatus; + +InvSumAggregator::InvSumAggregator(const String& attr) + : m_InvSum(0) +{ + m_InvSumAttr = attr; +} + +void InvSumAggregator::Apply(const Table::Ptr& table, const Value& row) +{ + Column column = table->GetColumn(m_InvSumAttr); + + Value value = column.ExtractValue(row); + + m_InvSum += (1.0 / value); +} + +double InvSumAggregator::GetResult(void) const +{ + return m_InvSum; +} diff --git a/components/livestatus/invsumaggregator.h b/components/livestatus/invsumaggregator.h new file mode 100644 index 000000000..b912a5b8e --- /dev/null +++ b/components/livestatus/invsumaggregator.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef INVSUMAGGREGATOR_H +#define INVSUMAGGREGATOR_H + +#include "livestatus/table.h" +#include "livestatus/aggregator.h" + +namespace livestatus +{ + +/** + * @ingroup livestatus + */ +class InvSumAggregator : public Aggregator +{ +public: + DECLARE_PTR_TYPEDEFS(InvSumAggregator); + + InvSumAggregator(const String& attr); + + virtual void Apply(const Table::Ptr& table, const Value& row); + virtual double GetResult(void) const; + +private: + double m_InvSum; + String m_InvSumAttr; +}; + +} + +#endif /* INVSUMAGGREGATOR_H */ diff --git a/components/livestatus/livestatus.vcxproj b/components/livestatus/livestatus.vcxproj index 96c391fdb..e01505d22 100644 --- a/components/livestatus/livestatus.vcxproj +++ b/components/livestatus/livestatus.vcxproj @@ -22,6 +22,12 @@ + + + + + + @@ -50,6 +56,12 @@ + + + + + + diff --git a/components/livestatus/livestatus.vcxproj.filters b/components/livestatus/livestatus.vcxproj.filters index f65abb3d8..41854e11c 100644 --- a/components/livestatus/livestatus.vcxproj.filters +++ b/components/livestatus/livestatus.vcxproj.filters @@ -51,6 +51,24 @@ Headerdateien + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Headerdateien + Headerdateien @@ -131,6 +149,24 @@ Quelldateien + + Quelldateien + + + Quelldateien + + + Quelldateien + + + Quelldateien + + + Quelldateien + + + Quelldateien + Quelldateien diff --git a/components/livestatus/maxaggregator.cpp b/components/livestatus/maxaggregator.cpp new file mode 100644 index 000000000..51575123a --- /dev/null +++ b/components/livestatus/maxaggregator.cpp @@ -0,0 +1,43 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "livestatus/maxaggregator.h" + +using namespace livestatus; + +MaxAggregator::MaxAggregator(const String& attr) + : m_Max(0) +{ + m_MaxAttr = attr; +} + +void MaxAggregator::Apply(const Table::Ptr& table, const Value& row) +{ + Column column = table->GetColumn(m_MaxAttr); + + Value value = column.ExtractValue(row); + + if (value > m_Max) + m_Max = value; +} + +double MaxAggregator::GetResult(void) const +{ + return m_Max; +} diff --git a/components/livestatus/maxaggregator.h b/components/livestatus/maxaggregator.h new file mode 100644 index 000000000..391873b91 --- /dev/null +++ b/components/livestatus/maxaggregator.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef MAXAGGREGATOR_H +#define MAXAGGREGATOR_H + +#include "livestatus/table.h" +#include "livestatus/aggregator.h" + +namespace livestatus +{ + +/** + * @ingroup livestatus + */ +class MaxAggregator : public Aggregator +{ +public: + DECLARE_PTR_TYPEDEFS(MaxAggregator); + + MaxAggregator(const String& attr); + + virtual void Apply(const Table::Ptr& table, const Value& row); + virtual double GetResult(void) const; + +private: + double m_Max; + String m_MaxAttr; +}; + +} + +#endif /* MAXAGGREGATOR_H */ diff --git a/components/livestatus/minaggregator.cpp b/components/livestatus/minaggregator.cpp new file mode 100644 index 000000000..a18fda831 --- /dev/null +++ b/components/livestatus/minaggregator.cpp @@ -0,0 +1,43 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "livestatus/minaggregator.h" + +using namespace livestatus; + +MinAggregator::MinAggregator(const String& attr) + : m_Min(0) +{ + m_MinAttr = attr; +} + +void MinAggregator::Apply(const Table::Ptr& table, const Value& row) +{ + Column column = table->GetColumn(m_MinAttr); + + Value value = column.ExtractValue(row); + + if (value < m_Min) + m_Min = value; +} + +double MinAggregator::GetResult(void) const +{ + return m_Min; +} diff --git a/components/livestatus/minaggregator.h b/components/livestatus/minaggregator.h new file mode 100644 index 000000000..d410e703b --- /dev/null +++ b/components/livestatus/minaggregator.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef MINAGGREGATOR_H +#define MINAGGREGATOR_H + +#include "livestatus/table.h" +#include "livestatus/aggregator.h" + +namespace livestatus +{ + +/** + * @ingroup livestatus + */ +class MinAggregator : public Aggregator +{ +public: + DECLARE_PTR_TYPEDEFS(MinAggregator); + + MinAggregator(const String& attr); + + virtual void Apply(const Table::Ptr& table, const Value& row); + virtual double GetResult(void) const; + +private: + double m_Min; + String m_MinAttr; +}; + +} + +#endif /* MINAGGREGATOR_H */ diff --git a/components/livestatus/query.cpp b/components/livestatus/query.cpp index 6fd8f47d9..9c19b3ac1 100644 --- a/components/livestatus/query.cpp +++ b/components/livestatus/query.cpp @@ -20,6 +20,12 @@ #include "livestatus/query.h" #include "livestatus/countaggregator.h" #include "livestatus/sumaggregator.h" +#include "livestatus/minaggregator.h" +#include "livestatus/maxaggregator.h" +#include "livestatus/avgaggregator.h" +#include "livestatus/stdaggregator.h" +#include "livestatus/invsumaggregator.h" +#include "livestatus/invavgaggregator.h" #include "livestatus/attributefilter.h" #include "livestatus/negatefilter.h" #include "livestatus/orfilter.h" @@ -116,17 +122,17 @@ Query::Query(const std::vector& lines) if (aggregate_arg == "sum") { aggregator = boost::make_shared(aggregate_attr); } else if (aggregate_arg == "min") { - /* TODO */ + aggregator = boost::make_shared(aggregate_attr); } else if (aggregate_arg == "max") { - /* TODO */ + aggregator = boost::make_shared(aggregate_attr); } else if (aggregate_arg == "avg") { - /* TODO */ + aggregator = boost::make_shared(aggregate_attr); } else if (aggregate_arg == "std") { - /* TODO */ + aggregator = boost::make_shared(aggregate_attr); } else if (aggregate_arg == "suminv") { - /* TODO */ + aggregator = boost::make_shared(aggregate_attr); } else if (aggregate_arg == "avginv") { - /* TODO */ + aggregator = boost::make_shared(aggregate_attr); } else { filter = ParseFilter(params); diff --git a/components/livestatus/stdaggregator.cpp b/components/livestatus/stdaggregator.cpp new file mode 100644 index 000000000..f7ba5213d --- /dev/null +++ b/components/livestatus/stdaggregator.cpp @@ -0,0 +1,45 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "livestatus/stdaggregator.h" +#include + +using namespace livestatus; + +StdAggregator::StdAggregator(const String& attr) + : m_StdSum(0), m_StdQSum(0), m_StdCount(0) +{ + m_StdAttr = attr; +} + +void StdAggregator::Apply(const Table::Ptr& table, const Value& row) +{ + Column column = table->GetColumn(m_StdAttr); + + Value value = column.ExtractValue(row); + + m_StdSum += value; + m_StdQSum += pow(value, 2); + m_StdCount++; +} + +double StdAggregator::GetResult(void) const +{ + return sqrt((m_StdQSum - (1 / m_StdCount) * pow(m_StdSum, 2)) / (m_StdCount - 1)); +} diff --git a/components/livestatus/stdaggregator.h b/components/livestatus/stdaggregator.h new file mode 100644 index 000000000..118823ab1 --- /dev/null +++ b/components/livestatus/stdaggregator.h @@ -0,0 +1,51 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef STDAGGREGATOR_H +#define STDAGGREGATOR_H + +#include "livestatus/table.h" +#include "livestatus/aggregator.h" + +namespace livestatus +{ + +/** + * @ingroup livestatus + */ +class StdAggregator : public Aggregator +{ +public: + DECLARE_PTR_TYPEDEFS(StdAggregator); + + StdAggregator(const String& attr); + + virtual void Apply(const Table::Ptr& table, const Value& row); + virtual double GetResult(void) const; + +private: + double m_StdSum; + double m_StdQSum; + double m_StdCount; + String m_StdAttr; +}; + +} + +#endif /* STDAGGREGATOR_H */ -- 2.40.0