]> granicus.if.org Git - icinga2/blob - components/livestatus/commandstable.cpp
livestatus: add commands table (thruk now shows extinfo)
[icinga2] / components / livestatus / commandstable.cpp
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
4  *                                                                            *
5  * This program is free software; you can redistribute it and/or              *
6  * modify it under the terms of the GNU General Public License                *
7  * as published by the Free Software Foundation; either version 2             *
8  * of the License, or (at your option) any later version.                     *
9  *                                                                            *
10  * This program is distributed in the hope that it will be useful,            *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
13  * GNU General Public License for more details.                               *
14  *                                                                            *
15  * You should have received a copy of the GNU General Public License          *
16  * along with this program; if not, write to the Free Software Foundation     *
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
18  ******************************************************************************/
19
20 #include "livestatus/commandstable.h"
21 #include "icinga/icingaapplication.h"
22 #include "icinga/checkcommand.h"
23 #include "icinga/eventcommand.h"
24 #include "icinga/notificationcommand.h"
25 #include "base/dynamictype.h"
26 #include <boost/foreach.hpp>
27
28 using namespace icinga;
29 using namespace livestatus;
30
31 CommandsTable::CommandsTable(void)
32 {
33         AddColumns(this);
34 }
35
36 void CommandsTable::AddColumns(Table *table, const String& prefix,
37     const Column::ObjectAccessor& objectAccessor)
38 {
39         table->AddColumn(prefix + "name", Column(&CommandsTable::NameAccessor, objectAccessor));
40         table->AddColumn(prefix + "line", Column(&CommandsTable::LineAccessor, objectAccessor));
41 }
42
43 String CommandsTable::GetName(void) const
44 {
45         return "command";
46 }
47
48 void CommandsTable::FetchRows(const AddRowFunction& addRowFn)
49 {
50         BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("CheckCommand")) {
51                 addRowFn(object);
52         }
53         BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("EventCommand")) {
54                 addRowFn(object);
55         }
56         BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("NotificationCommand")) {
57                 addRowFn(object);
58         }
59 }
60
61 Value CommandsTable::NameAccessor(const Object::Ptr& object)
62 {
63         /* TODO */
64         return Value();
65 }
66
67 Value CommandsTable::LineAccessor(const Object::Ptr& object)
68 {
69         /* TODO */
70         return Value();
71 }