mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 16:14:09 +02:00
parent
af621214d4
commit
5030bab4f3
@ -22,6 +22,7 @@
|
|||||||
#include "icinga/checkcommand.h"
|
#include "icinga/checkcommand.h"
|
||||||
#include "icinga/eventcommand.h"
|
#include "icinga/eventcommand.h"
|
||||||
#include "icinga/notificationcommand.h"
|
#include "icinga/notificationcommand.h"
|
||||||
|
#include "icinga/compatutility.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/convert.h"
|
#include "base/convert.h"
|
||||||
@ -40,6 +41,9 @@ void CommandsTable::AddColumns(Table *table, const String& prefix,
|
|||||||
{
|
{
|
||||||
table->AddColumn(prefix + "name", Column(&CommandsTable::NameAccessor, objectAccessor));
|
table->AddColumn(prefix + "name", Column(&CommandsTable::NameAccessor, objectAccessor));
|
||||||
table->AddColumn(prefix + "line", Column(&CommandsTable::LineAccessor, objectAccessor));
|
table->AddColumn(prefix + "line", Column(&CommandsTable::LineAccessor, objectAccessor));
|
||||||
|
table->AddColumn(prefix + "custom_variable_names", Column(&CommandsTable::CustomVariableNamesAccessor, objectAccessor));
|
||||||
|
table->AddColumn(prefix + "custom_variable_values", Column(&CommandsTable::CustomVariableValuesAccessor, objectAccessor));
|
||||||
|
table->AddColumn(prefix + "custom_variables", Column(&CommandsTable::CustomVariablesAccessor, objectAccessor));
|
||||||
}
|
}
|
||||||
|
|
||||||
String CommandsTable::GetName(void) const
|
String CommandsTable::GetName(void) const
|
||||||
@ -111,3 +115,90 @@ Value CommandsTable::LineAccessor(const Value& row)
|
|||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Value CommandsTable::CustomVariableNamesAccessor(const Value& row)
|
||||||
|
{
|
||||||
|
Command::Ptr command = static_cast<Command::Ptr>(row);
|
||||||
|
|
||||||
|
if (!command)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
Dictionary::Ptr vars;
|
||||||
|
|
||||||
|
{
|
||||||
|
ObjectLock olock(command);
|
||||||
|
vars = CompatUtility::GetCustomAttributeConfig(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
Array::Ptr cv = make_shared<Array>();
|
||||||
|
|
||||||
|
String key;
|
||||||
|
Value value;
|
||||||
|
BOOST_FOREACH(tie(key, value), vars) {
|
||||||
|
cv->Add(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cv;
|
||||||
|
}
|
||||||
|
|
||||||
|
Value CommandsTable::CustomVariableValuesAccessor(const Value& row)
|
||||||
|
{
|
||||||
|
Command::Ptr command = static_cast<Command::Ptr>(row);
|
||||||
|
|
||||||
|
if (!command)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
Dictionary::Ptr vars;
|
||||||
|
|
||||||
|
{
|
||||||
|
ObjectLock olock(command);
|
||||||
|
vars = CompatUtility::GetCustomAttributeConfig(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
Array::Ptr cv = make_shared<Array>();
|
||||||
|
|
||||||
|
String key;
|
||||||
|
Value value;
|
||||||
|
BOOST_FOREACH(tie(key, value), vars) {
|
||||||
|
cv->Add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cv;
|
||||||
|
}
|
||||||
|
|
||||||
|
Value CommandsTable::CustomVariablesAccessor(const Value& row)
|
||||||
|
{
|
||||||
|
Command::Ptr command = static_cast<Command::Ptr>(row);
|
||||||
|
|
||||||
|
if (!command)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
Dictionary::Ptr vars;
|
||||||
|
|
||||||
|
{
|
||||||
|
ObjectLock olock(command);
|
||||||
|
vars = CompatUtility::GetCustomAttributeConfig(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
Array::Ptr cv = make_shared<Array>();
|
||||||
|
|
||||||
|
String key;
|
||||||
|
Value value;
|
||||||
|
BOOST_FOREACH(tie(key, value), vars) {
|
||||||
|
Array::Ptr key_val = make_shared<Array>();
|
||||||
|
key_val->Add(key);
|
||||||
|
key_val->Add(value);
|
||||||
|
cv->Add(key_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cv;
|
||||||
|
}
|
||||||
|
@ -47,6 +47,9 @@ protected:
|
|||||||
|
|
||||||
static Value NameAccessor(const Value& row);
|
static Value NameAccessor(const Value& row);
|
||||||
static Value LineAccessor(const Value& row);
|
static Value LineAccessor(const Value& row);
|
||||||
|
static Value CustomVariableNamesAccessor(const Value& row);
|
||||||
|
static Value CustomVariableValuesAccessor(const Value& row);
|
||||||
|
static Value CustomVariablesAccessor(const Value& row);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
4
test/livestatus/queries/command/command
Normal file
4
test/livestatus/queries/command/command
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
GET commands
|
||||||
|
Columns: name line custom_variables
|
||||||
|
ResponseHeader: fixed16
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user