Module: check_mk
Branch: master
Commit: 5be217725b7c213cc1a3c975b928a12027d4d23e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5be217725b7c21…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Dec 20 16:12:00 2010 +0100
Livestatus: use Columns: instead of StatsGroupBy:
StatsGroupBy: is now deprecated. Columns: does the same
thing for you.
---
ChangeLog | 3 +++
livestatus/src/Query.cc | 31 ++++++++-----------------------
livestatus/src/Query.h | 3 ---
3 files changed, 11 insertions(+), 26 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 15fe292..ccef56e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@
* Multisite: removed (undocumented) view parameters show_buttons and show_controls.
Please use display_options instead.
* Finally removed deprecated filesystem_levels. Please use check_parameters instead.
+ * Livestatus: The StatsGroupBy: header is still working but now deprecated.
+ Please simply use Columns: instead. If your query contains at least one Stats:
+ header than Columns: has the meaning of the old StatsGroupBy: header
Core, Setup, etc.:
* Create alias 'cmk' for check_mk in bin/ (easier typing)
diff --git a/livestatus/src/Query.cc b/livestatus/src/Query.cc
index c9a3542..877b765 100644
--- a/livestatus/src/Query.cc
+++ b/livestatus/src/Query.cc
@@ -177,12 +177,12 @@ Column *Query::createDummyColumn(const char *name)
}
-
void Query::addColumn(Column *column)
{
_columns.push_back(column);
}
+
bool Query::hasNoColumns()
{
return _columns.size() == 0 && !doStats();
@@ -419,23 +419,8 @@ void Query::parseAuthUserHeader(char *line)
void Query::parseStatsGroupLine(char *line)
{
- if (!_table)
- return;
-
- char *column_name;
- while (column_name = next_field(&line)) {
- Column *column = _table->column(column_name);
- if (!column) {
- _output->setError(RESPONSE_CODE_INVALID_HEADER, "StatsGroupBy:
unknown column '%s'", column_name);
- return;
- }
- _stats_group_columns.push_back(column);
- }
-
- if (_stats_group_columns.size() == 0) {
- _output->setError(RESPONSE_CODE_INVALID_HEADER, "StatsGroupBy: missing an
argument");
- return;
- }
+ logger(LOG_WARNING, "Warning: StatsGroupBy is deprecated. Please use Columns
instead.");
+ parseColumnsLine(line);
}
@@ -645,7 +630,7 @@ void Query::start()
// if we have no StatsGroupBy: column, we allocate one only row of Aggregators,
// directly in _stats_aggregators. When grouping the rows of aggregators
// will be created each time a new group is found.
- if (_stats_group_columns.size() == 0)
+ if (_columns.size() == 0)
{
_stats_aggregators = new Aggregator *[_stats_columns.size()];
for (unsigned i=0; i<_stats_columns.size(); i++)
@@ -691,7 +676,7 @@ bool Query::processDataset(void *data)
Aggregator **aggr;
// When doing grouped stats, we need to fetch/create a row
// of aggregators for the current group
- if (_stats_group_columns.size() > 0) {
+ if (_columns.size() > 0) {
_stats_group_spec_t groupspec;
computeStatsGroupSpec(groupspec, data);
aggr = getStatsGroup(groupspec);
@@ -732,7 +717,7 @@ bool Query::processDataset(void *data)
void Query::finish()
{
// grouped stats
- if (doStats() && _stats_group_columns.size() > 0)
+ if (doStats() && _columns.size() > 0)
{
// output values of all stats groups (output has been post poned until now)
for (_stats_groups_t::iterator it = _stats_groups.begin();
@@ -984,8 +969,8 @@ Aggregator **Query::getStatsGroup(Query::_stats_group_spec_t
&groupspec)
void Query::computeStatsGroupSpec(Query::_stats_group_spec_t &groupspec, void *data)
{
- for (_stats_group_columns_t::iterator it = _stats_group_columns.begin();
- it != _stats_group_columns.end();
+ for (_columns_t::iterator it = _columns.begin();
+ it != _columns.end();
++it)
{
Column *column = *it;
diff --git a/livestatus/src/Query.h b/livestatus/src/Query.h
index 5cc1955..1a85b63 100644
--- a/livestatus/src/Query.h
+++ b/livestatus/src/Query.h
@@ -87,9 +87,6 @@ class Query
_stats_columns_t _stats_columns; // must also delete
Aggregator **_stats_aggregators;
- typedef vector <Column *> _stats_group_columns_t;
- _stats_group_columns_t _stats_group_columns;
-
typedef vector<string> _stats_group_spec_t;
typedef map<_stats_group_spec_t, Aggregator **> _stats_groups_t;
_stats_groups_t _stats_groups;