Implemented host and service groups.

This commit is contained in:
Gunnar Beutner 2012-06-30 13:39:55 +02:00
parent 6c153d8e8e
commit b576bb5ecc
10 changed files with 363 additions and 314 deletions

View File

@ -82,7 +82,6 @@ void CompatComponent::DumpHostObject(ofstream& fp, Host host)
{ {
fp << "define host {" << "\n" fp << "define host {" << "\n"
<< "\t" << "host_name" << "\t" << host.GetName() << "\n" << "\t" << "host_name" << "\t" << host.GetName() << "\n"
<< "\t" << "hostgroups" << "\t" << "all-hosts" << "\n"
<< "\t" << "check_interval" << "\t" << 1 << "\n" << "\t" << "check_interval" << "\t" << 1 << "\n"
<< "\t" << "retry_interval" << "\t" << 1 << "\n" << "\t" << "retry_interval" << "\t" << 1 << "\n"
<< "\t" << "max_check_attempts" << "\t" << 1 << "\n" << "\t" << "max_check_attempts" << "\t" << 1 << "\n"
@ -154,6 +153,20 @@ void CompatComponent::DumpServiceObject(ofstream& fp, Service service)
<< "\n"; << "\n";
} }
void CompatComponent::DumpStringList(ofstream& fp, const vector<string>& list)
{
vector<string>::const_iterator it;
bool first = true;
for (it = list.begin(); it != list.end(); it++) {
if (!first)
fp << ",";
else
first = false;
fp << *it;
}
}
/** /**
* Periodically writes the status.dat and objects.cache files. * Periodically writes the status.dat and objects.cache files.
*/ */
@ -194,40 +207,96 @@ void CompatComponent::StatusTimerHandler(void)
<< "# This file is auto-generated. Do not modify this file." << "\n" << "# This file is auto-generated. Do not modify this file." << "\n"
<< "\n"; << "\n";
objectfp << "define hostgroup {" << "\n" map<string, vector<string> > hostgroups;
<< "\t" << "hostgroup_name" << "\t" << "all-hosts" << "\n";
ConfigObject::TMap::Range range; ConfigObject::TMap::Range range;
range = ConfigObject::GetObjects("host"); range = ConfigObject::GetObjects("host");
ConfigObject::TMap::Iterator it; ConfigObject::TMap::Iterator it;
for (it = range.first; it != range.second; it++) {
Host host = it->second;
Dictionary::Ptr dict;
DictionaryIterator dt;
dict = host.GetGroups();
if (dict) {
for (dt = dict->Begin(); dt != dict->End(); dt++)
hostgroups[dt->second].push_back(host.GetName());
}
DumpHostStatus(statusfp, host);
DumpHostObject(objectfp, host);
}
map<string, vector<string> >::iterator hgt;
for (hgt = hostgroups.begin(); hgt != hostgroups.end(); hgt++) {
objectfp << "define hostgroup {" << "\n"
<< "\t" << "hostgroup_name" << "\t" << hgt->first << "\n";
if (HostGroup::Exists(hgt->first)) {
HostGroup hg = HostGroup::GetByName(hgt->first);
objectfp << "\t" << "alias" << "\t" << hg.GetAlias() << "\n"
<< "\t" << "notes_url" << "\t" << hg.GetNotesUrl() << "\n"
<< "\t" << "action_url" << "\t" << hg.GetActionUrl() << "\n";
}
if (range.first != range.second) {
objectfp << "\t" << "members" << "\t"; objectfp << "\t" << "members" << "\t";
for (it = range.first; it != range.second; it++) {
Host host(it->second);
objectfp << host.GetName(); DumpStringList(objectfp, hgt->second);
if (distance(it, range.second) != 1) objectfp << "\n"
objectfp << ","; << "}" << "\n";
}
objectfp << "\n";
}
objectfp << "\t" << "}" << "\n"
<< "\n";
for (it = range.first; it != range.second; it++) {
DumpHostStatus(statusfp, it->second);
DumpHostObject(objectfp, it->second);
} }
range = ConfigObject::GetObjects("service"); range = ConfigObject::GetObjects("service");
map<string, vector<Service> > servicegroups;
for (it = range.first; it != range.second; it++) { for (it = range.first; it != range.second; it++) {
DumpServiceStatus(statusfp, it->second); Service service = it->second;
DumpServiceObject(objectfp, it->second);
Dictionary::Ptr dict;
DictionaryIterator dt;
dict = service.GetGroups();
if (dict) {
for (dt = dict->Begin(); dt != dict->End(); dt++)
servicegroups[dt->second].push_back(service);
}
DumpServiceStatus(statusfp, service);
DumpServiceObject(objectfp, service);
}
map<string, vector<Service > >::iterator sgt;
for (sgt = servicegroups.begin(); sgt != servicegroups.end(); sgt++) {
objectfp << "define servicegroup {" << "\n"
<< "\t" << "servicegroup_name" << "\t" << sgt->first << "\n";
if (ServiceGroup::Exists(sgt->first)) {
ServiceGroup sg = ServiceGroup::GetByName(sgt->first);
objectfp << "\t" << "alias" << "\t" << sg.GetAlias() << "\n"
<< "\t" << "notes_url" << "\t" << sg.GetNotesUrl() << "\n"
<< "\t" << "action_url" << "\t" << sg.GetActionUrl() << "\n";
}
objectfp << "\t" << "members" << "\t";
vector<string> sglist;
vector<Service>::iterator vt;
for (vt = sgt->second.begin(); vt != sgt->second.end(); vt++) {
sglist.push_back(vt->GetHost().GetName());
sglist.push_back(vt->GetName());
}
DumpStringList(objectfp, sglist);
objectfp << "\n"
<< "}" << "\n";
} }
statusfp.close(); statusfp.close();

View File

@ -39,6 +39,8 @@ private:
void DumpHostStatus(ofstream& fp, Host host); void DumpHostStatus(ofstream& fp, Host host);
void DumpHostObject(ofstream& fp, Host host); void DumpHostObject(ofstream& fp, Host host);
void DumpStringList(ofstream& fp, const vector<string>& list);
void DumpServiceStatus(ofstream& fp, Service service); void DumpServiceStatus(ofstream& fp, Service service);
void DumpServiceObject(ofstream& fp, Service service); void DumpServiceObject(ofstream& fp, Service service);

View File

@ -1,8 +1,10 @@
/* A Bison parser, made by GNU Bison 2.5. */
/* Bison implementation for Yacc-like parsers in C /* A Bison parser, made by GNU Bison 2.4.1. */
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. /* Skeleton implementation for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -44,7 +46,7 @@
#define YYBISON 1 #define YYBISON 1
/* Bison version. */ /* Bison version. */
#define YYBISON_VERSION "2.5" #define YYBISON_VERSION "2.4.1"
/* Skeleton name. */ /* Skeleton name. */
#define YYSKELETON_NAME "yacc.c" #define YYSKELETON_NAME "yacc.c"
@ -66,8 +68,8 @@
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
/* Line 268 of yacc.c */ /* Line 189 of yacc.c */
#line 71 "config_parser.cc" #line 73 "config_parser.cc"
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
@ -89,7 +91,7 @@
/* "%code requires" blocks. */ /* "%code requires" blocks. */
/* Line 288 of yacc.c */ /* Line 209 of yacc.c */
#line 1 "config_parser.yy" #line 1 "config_parser.yy"
/****************************************************************************** /******************************************************************************
@ -120,8 +122,8 @@ using namespace icinga;
/* Line 288 of yacc.c */ /* Line 209 of yacc.c */
#line 125 "config_parser.cc" #line 127 "config_parser.cc"
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
@ -170,7 +172,7 @@ using namespace icinga;
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 293 of yacc.c */ /* Line 214 of yacc.c */
#line 38 "config_parser.yy" #line 38 "config_parser.yy"
char *text; char *text;
@ -180,8 +182,8 @@ typedef union YYSTYPE
/* Line 293 of yacc.c */ /* Line 214 of yacc.c */
#line 185 "config_parser.cc" #line 187 "config_parser.cc"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
@ -204,7 +206,7 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */ /* Copy the second part of user declarations. */
/* Line 343 of yacc.c */ /* Line 264 of yacc.c */
#line 67 "config_parser.yy" #line 67 "config_parser.yy"
@ -244,8 +246,8 @@ void ConfigCompiler::Compile(void)
/* Line 343 of yacc.c */ /* Line 264 of yacc.c */
#line 249 "config_parser.cc" #line 251 "config_parser.cc"
#ifdef short #ifdef short
# undef short # undef short
@ -295,7 +297,7 @@ typedef short int yytype_int16;
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_ #ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS # if YYENABLE_NLS
# if ENABLE_NLS # if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid) # define YY_(msgid) dgettext ("bison-runtime", msgid)
@ -348,11 +350,11 @@ YYID (yyi)
# define alloca _alloca # define alloca _alloca
# else # else
# define YYSTACK_ALLOC alloca # define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS # ifndef _STDLIB_H
# define EXIT_SUCCESS 0 # define _STDLIB_H 1
# endif # endif
# endif # endif
# endif # endif
@ -375,24 +377,24 @@ YYID (yyi)
# ifndef YYSTACK_ALLOC_MAXIMUM # ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif # endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \ # if (defined __cplusplus && ! defined _STDLIB_H \
&& ! ((defined YYMALLOC || defined malloc) \ && ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free))) && (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS # ifndef _STDLIB_H
# define EXIT_SUCCESS 0 # define _STDLIB_H 1
# endif # endif
# endif # endif
# ifndef YYMALLOC # ifndef YYMALLOC
# define YYMALLOC malloc # define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif # endif
# endif # endif
# ifndef YYFREE # ifndef YYFREE
# define YYFREE free # define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
void free (void *); /* INFRINGES ON USER NAME SPACE */ void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif # endif
@ -423,7 +425,23 @@ union yyalloc
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ 2 * YYSTACK_GAP_MAXIMUM) + 2 * YYSTACK_GAP_MAXIMUM)
# define YYCOPY_NEEDED 1 /* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (YYID (0))
# endif
# endif
/* Relocate STACK from its old location to the new one. The /* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of local variables YYSIZE and YYSTACKSIZE give the old and new number of
@ -443,26 +461,6 @@ union yyalloc
#endif #endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (YYID (0))
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */ /* YYFINAL -- State number of the termination state. */
#define YYFINAL 2 #define YYFINAL 2
/* YYLAST -- Last index in YYTABLE. */ /* YYLAST -- Last index in YYTABLE. */
@ -606,8 +604,8 @@ static const yytype_uint8 yyr2[] =
1, 0, 4, 1, 1, 2, 0, 1, 3 1, 0, 4, 1, 1, 2, 0, 1, 3
}; };
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
Performed when YYTABLE doesn't specify something else to do. Zero STATE-NUM when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */ means the default is an error. */
static const yytype_uint8 yydefact[] = static const yytype_uint8 yydefact[] =
{ {
@ -652,7 +650,8 @@ static const yytype_int8 yypgoto[] =
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which positive, shift that token. If negative, reduce the rule which
number is the opposite. If YYTABLE_NINF, syntax error. */ number is the opposite. If zero, do what YYDEFACT says.
If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -1 #define YYTABLE_NINF -1
static const yytype_uint8 yytable[] = static const yytype_uint8 yytable[] =
{ {
@ -663,12 +662,6 @@ static const yytype_uint8 yytable[] =
51, 59, 24, 61, 52, 62, 0, 27, 60 51, 59, 24, 61, 52, 62, 0, 27, 60
}; };
#define yypact_value_is_default(yystate) \
((yystate) == (-46))
#define yytable_value_is_error(yytable_value) \
YYID (0)
static const yytype_int8 yycheck[] = static const yytype_int8 yycheck[] =
{ {
3, 4, 5, 7, 8, 9, 10, 11, 53, 0, 3, 4, 5, 7, 8, 9, 10, 11, 53, 0,
@ -703,18 +696,9 @@ static const yytype_uint8 yystos[] =
/* Like YYERROR except do call yyerror. This remains here temporarily /* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC. to ease the transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. However, Once GCC version 2 has supplanted version 1, this can go. */
YYFAIL appears to be in use. Nevertheless, it is formally deprecated
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
discussed. */
#define YYFAIL goto yyerrlab #define YYFAIL goto yyerrlab
#if defined YYFAIL
/* This is here to suppress warnings from the GCC cpp's
-Wunused-macros. Normally we don't worry about that warning, but
some users do, and we want to make it easy for users to remove
YYFAIL uses, which will produce warnings from Bison 2.5. */
#endif
#define YYRECOVERING() (!!yyerrstatus) #define YYRECOVERING() (!!yyerrstatus)
@ -724,6 +708,7 @@ do \
{ \ { \
yychar = (Token); \ yychar = (Token); \
yylval = (Value); \ yylval = (Value); \
yytoken = YYTRANSLATE (yychar); \
YYPOPSTACK (1); \ YYPOPSTACK (1); \
goto yybackup; \ goto yybackup; \
} \ } \
@ -770,7 +755,7 @@ while (YYID (0))
we won't break user code: when these are the locations we know. */ we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT #ifndef YY_LOCATION_PRINT
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # if YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \ # define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \ fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \ (Loc).first_line, (Loc).first_column, \
@ -979,6 +964,7 @@ int yydebug;
# define YYMAXDEPTH 10000 # define YYMAXDEPTH 10000
#endif #endif
#if YYERROR_VERBOSE #if YYERROR_VERBOSE
@ -1081,142 +1067,115 @@ yytnamerr (char *yyres, const char *yystr)
} }
# endif # endif
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message /* Copy into YYRESULT an error message about the unexpected token
about the unexpected token YYTOKEN for the state stack whose top is YYCHAR while in state YYSTATE. Return the number of bytes copied,
YYSSP. including the terminating null byte. If YYRESULT is null, do not
copy anything; just return the number of bytes that would be
Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is copied. As a special case, return 0 if an ordinary "syntax error"
not large enough to hold the message. In that case, also set message will do. Return YYSIZE_MAXIMUM if overflow occurs during
*YYMSG_ALLOC to the required number of bytes. Return 2 if the size calculation. */
required number of bytes is too large to store. */ static YYSIZE_T
static int yysyntax_error (char *yyresult, int yystate, int yychar)
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken)
{ {
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); int yyn = yypact[yystate];
if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
return 0;
else
{
int yytype = YYTRANSLATE (yychar);
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
YYSIZE_T yysize = yysize0; YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1; YYSIZE_T yysize1;
int yysize_overflow = 0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = 0;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per int yyx;
"expected"). */
int yycount = 0; # if 0
/* This is so xgettext sees the translatable formats that are
constructed on the fly. */
YY_("syntax error, unexpected %s");
YY_("syntax error, unexpected %s, expecting %s");
YY_("syntax error, unexpected %s, expecting %s or %s");
YY_("syntax error, unexpected %s, expecting %s or %s or %s");
YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
# endif
char *yyfmt;
char const *yyf;
static char const yyunexpected[] = "syntax error, unexpected %s";
static char const yyexpecting[] = ", expecting %s";
static char const yyor[] = " or %s";
char yyformat[sizeof yyunexpected
+ sizeof yyexpecting - 1
+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
* (sizeof yyor - 1))];
char const *yyprefix = yyexpecting;
/* There are many possibilities here to consider:
- Assume YYFAIL is not used. It's too flawed to consider. See
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
for details. YYERROR is fine as it does not invoke this
function.
- If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in yychar) is if
this state is a consistent state with a default action. Thus,
detecting the absence of a lookahead is sufficient to determine
that there is no unexpected or expected token to report. In that
case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this state is a
consistent state with a default action. There might have been a
previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated yychar.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (yytoken != YYEMPTY)
{
int yyn = yypact[*yyssp];
yyarg[yycount++] = yytname[yytoken];
if (!yypact_value_is_default (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in /* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for YYCHECK. */
this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0; int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */ /* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1; int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx; int yycount = 1;
yyarg[0] = yytname[yytype];
yyfmt = yystpcpy (yyformat, yyunexpected);
for (yyx = yyxbegin; yyx < yyxend; ++yyx) for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
&& !yytable_value_is_error (yytable[yyx + yyn]))
{ {
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{ {
yycount = 1; yycount = 1;
yysize = yysize0; yysize = yysize0;
yyformat[sizeof yyunexpected - 1] = '\0';
break; break;
} }
yyarg[yycount++] = yytname[yyx]; yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize1 = yysize + yytnamerr (0, yytname[yyx]);
if (! (yysize <= yysize1 yysize_overflow |= (yysize1 < yysize);
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1; yysize = yysize1;
} yyfmt = yystpcpy (yyfmt, yyprefix);
} yyprefix = yyor;
} }
switch (yycount) yyf = YY_(yyformat);
{ yysize1 = yysize + yystrlen (yyf);
# define YYCASE_(N, S) \ yysize_overflow |= (yysize1 < yysize);
case N: \
yyformat = S; \
break
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
}
yysize1 = yysize + yystrlen (yyformat);
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1; yysize = yysize1;
if (*yymsg_alloc < yysize) if (yysize_overflow)
{ return YYSIZE_MAXIMUM;
*yymsg_alloc = 2 * yysize;
if (! (yysize <= *yymsg_alloc
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
return 1;
}
if (yyresult)
{
/* Avoid sprintf, as that infringes on the user's name space. /* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */ produced a string with the wrong number of "%s"s. */
{ char *yyp = yyresult;
char *yyp = *yymsg;
int yyi = 0; int yyi = 0;
while ((*yyp = *yyformat) != '\0') while ((*yyp = *yyf) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) {
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
{ {
yyp += yytnamerr (yyp, yyarg[yyi++]); yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2; yyf += 2;
} }
else else
{ {
yyp++; yyp++;
yyformat++; yyf++;
} }
} }
return 0; }
return yysize;
}
} }
#endif /* YYERROR_VERBOSE */ #endif /* YYERROR_VERBOSE */
/*-----------------------------------------------. /*-----------------------------------------------.
| Release the memory associated to this symbol. | | Release the memory associated to this symbol. |
@ -1253,7 +1212,6 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, context)
} }
} }
/* Prevent warnings from -Wmissing-prototypes. */ /* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM #ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus #if defined __STDC__ || defined __cplusplus
@ -1270,9 +1228,12 @@ int yyparse ();
#endif /* ! YYPARSE_PARAM */ #endif /* ! YYPARSE_PARAM */
/*----------.
| yyparse. |
`----------*/
/*-------------------------.
| yyparse or yypush_parse. |
`-------------------------*/
#ifdef YYPARSE_PARAM #ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \ #if (defined __STDC__ || defined __C99__FUNC__ \
@ -1336,7 +1297,7 @@ YYLTYPE yylloc;
YYLTYPE *yylsp; YYLTYPE *yylsp;
/* The locations where the error started and ended. */ /* The locations where the error started and ended. */
YYLTYPE yyerror_range[3]; YYLTYPE yyerror_range[2];
YYSIZE_T yystacksize; YYSIZE_T yystacksize;
@ -1383,7 +1344,7 @@ YYLTYPE yylloc;
yyvsp = yyvs; yyvsp = yyvs;
yylsp = yyls; yylsp = yyls;
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL #if YYLTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */ /* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = 1; yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = 1; yylloc.first_column = yylloc.last_column = 1;
@ -1485,7 +1446,7 @@ yybackup:
/* First try to decide what to do without reference to lookahead token. */ /* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate]; yyn = yypact[yystate];
if (yypact_value_is_default (yyn)) if (yyn == YYPACT_NINF)
goto yydefault; goto yydefault;
/* Not known => get a lookahead token if don't already have one. */ /* Not known => get a lookahead token if don't already have one. */
@ -1516,7 +1477,7 @@ yybackup:
yyn = yytable[yyn]; yyn = yytable[yyn];
if (yyn <= 0) if (yyn <= 0)
{ {
if (yytable_value_is_error (yyn)) if (yyn == 0 || yyn == YYTABLE_NINF)
goto yyerrlab; goto yyerrlab;
yyn = -yyn; yyn = -yyn;
goto yyreduce; goto yyreduce;
@ -1573,7 +1534,7 @@ yyreduce:
{ {
case 7: case 7:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 117 "config_parser.yy" #line 117 "config_parser.yy"
{ {
m_Abstract = false; m_Abstract = false;
@ -1583,7 +1544,7 @@ yyreduce:
case 8: case 8:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 122 "config_parser.yy" #line 122 "config_parser.yy"
{ {
m_Object = boost::make_shared<ConfigItem>((yyvsp[(4) - (5)].text), (yyvsp[(5) - (5)].text), yylloc); m_Object = boost::make_shared<ConfigItem>((yyvsp[(4) - (5)].text), (yyvsp[(5) - (5)].text), yylloc);
@ -1594,7 +1555,7 @@ yyreduce:
case 9: case 9:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 128 "config_parser.yy" #line 128 "config_parser.yy"
{ {
Object::Ptr exprl_object = *(yyvsp[(8) - (8)].variant); Object::Ptr exprl_object = *(yyvsp[(8) - (8)].variant);
@ -1625,7 +1586,7 @@ yyreduce:
case 12: case 12:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 160 "config_parser.yy" #line 160 "config_parser.yy"
{ {
m_Abstract = true; m_Abstract = true;
@ -1634,7 +1595,7 @@ yyreduce:
case 13: case 13:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 164 "config_parser.yy" #line 164 "config_parser.yy"
{ {
m_Temporary = true; m_Temporary = true;
@ -1643,7 +1604,7 @@ yyreduce:
case 14: case 14:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 168 "config_parser.yy" #line 168 "config_parser.yy"
{ {
m_Local = true; m_Local = true;
@ -1652,7 +1613,7 @@ yyreduce:
case 17: case 17:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 178 "config_parser.yy" #line 178 "config_parser.yy"
{ {
m_Object->AddParent((yyvsp[(1) - (1)].text)); m_Object->AddParent((yyvsp[(1) - (1)].text));
@ -1662,7 +1623,7 @@ yyreduce:
case 20: case 20:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 189 "config_parser.yy" #line 189 "config_parser.yy"
{ {
m_ExpressionLists.push(boost::make_shared<ExpressionList>()); m_ExpressionLists.push(boost::make_shared<ExpressionList>());
@ -1671,7 +1632,7 @@ yyreduce:
case 21: case 21:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 194 "config_parser.yy" #line 194 "config_parser.yy"
{ {
(yyval.variant) = new Variant(m_ExpressionLists.top()); (yyval.variant) = new Variant(m_ExpressionLists.top());
@ -1681,7 +1642,7 @@ yyreduce:
case 27: case 27:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 209 "config_parser.yy" #line 209 "config_parser.yy"
{ {
Expression expr((yyvsp[(1) - (3)].text), (yyvsp[(2) - (3)].op), *(yyvsp[(3) - (3)].variant), yylloc); Expression expr((yyvsp[(1) - (3)].text), (yyvsp[(2) - (3)].op), *(yyvsp[(3) - (3)].variant), yylloc);
@ -1694,7 +1655,7 @@ yyreduce:
case 28: case 28:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 217 "config_parser.yy" #line 217 "config_parser.yy"
{ {
Expression subexpr((yyvsp[(3) - (6)].text), (yyvsp[(5) - (6)].op), *(yyvsp[(6) - (6)].variant), yylloc); Expression subexpr((yyvsp[(3) - (6)].text), (yyvsp[(5) - (6)].op), *(yyvsp[(6) - (6)].variant), yylloc);
@ -1713,7 +1674,7 @@ yyreduce:
case 29: case 29:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 231 "config_parser.yy" #line 231 "config_parser.yy"
{ {
Expression expr((yyvsp[(1) - (1)].text), OperatorSet, (yyvsp[(1) - (1)].text), yylloc); Expression expr((yyvsp[(1) - (1)].text), OperatorSet, (yyvsp[(1) - (1)].text), yylloc);
@ -1725,7 +1686,7 @@ yyreduce:
case 34: case 34:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 244 "config_parser.yy" #line 244 "config_parser.yy"
{ {
(yyval.op) = (yyvsp[(1) - (1)].op); (yyval.op) = (yyvsp[(1) - (1)].op);
@ -1734,7 +1695,7 @@ yyreduce:
case 35: case 35:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 250 "config_parser.yy" #line 250 "config_parser.yy"
{ {
(yyval.variant) = new Variant((yyvsp[(1) - (1)].text)); (yyval.variant) = new Variant((yyvsp[(1) - (1)].text));
@ -1744,7 +1705,7 @@ yyreduce:
case 36: case 36:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 255 "config_parser.yy" #line 255 "config_parser.yy"
{ {
(yyval.variant) = new Variant((yyvsp[(1) - (1)].num)); (yyval.variant) = new Variant((yyvsp[(1) - (1)].num));
@ -1753,7 +1714,7 @@ yyreduce:
case 37: case 37:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 259 "config_parser.yy" #line 259 "config_parser.yy"
{ {
(yyval.variant) = new Variant(); (yyval.variant) = new Variant();
@ -1762,7 +1723,7 @@ yyreduce:
case 40: case 40:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 267 "config_parser.yy" #line 267 "config_parser.yy"
{ {
(yyval.variant) = (yyvsp[(1) - (1)].variant); (yyval.variant) = (yyvsp[(1) - (1)].variant);
@ -1771,7 +1732,7 @@ yyreduce:
case 41: case 41:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 273 "config_parser.yy" #line 273 "config_parser.yy"
{ {
m_Array = boost::make_shared<Dictionary>(); m_Array = boost::make_shared<Dictionary>();
@ -1780,7 +1741,7 @@ yyreduce:
case 42: case 42:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 278 "config_parser.yy" #line 278 "config_parser.yy"
{ {
(yyval.variant) = new Variant(m_Array); (yyval.variant) = new Variant(m_Array);
@ -1790,7 +1751,7 @@ yyreduce:
case 43: case 43:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 285 "config_parser.yy" #line 285 "config_parser.yy"
{ {
m_Array->AddUnnamedProperty(*(yyvsp[(1) - (1)].variant)); m_Array->AddUnnamedProperty(*(yyvsp[(1) - (1)].variant));
@ -1800,21 +1761,10 @@ yyreduce:
/* Line 1806 of yacc.c */ /* Line 1455 of yacc.c */
#line 1805 "config_parser.cc" #line 1766 "config_parser.cc"
default: break; default: break;
} }
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen); YYPOPSTACK (yylen);
@ -1843,10 +1793,6 @@ yyreduce:
| yyerrlab -- here on detecting error | | yyerrlab -- here on detecting error |
`------------------------------------*/ `------------------------------------*/
yyerrlab: yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */ /* If not already recovering from an error, report this error. */
if (!yyerrstatus) if (!yyerrstatus)
{ {
@ -1854,40 +1800,41 @@ yyerrlab:
#if ! YYERROR_VERBOSE #if ! YYERROR_VERBOSE
yyerror (&yylloc, context, YY_("syntax error")); yyerror (&yylloc, context, YY_("syntax error"));
#else #else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{ {
char const *yymsgp = YY_("syntax error"); YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
int yysyntax_error_status; if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
yysyntax_error_status = YYSYNTAX_ERROR;
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == 1)
{ {
YYSIZE_T yyalloc = 2 * yysize;
if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
yyalloc = YYSTACK_ALLOC_MAXIMUM;
if (yymsg != yymsgbuf) if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg); YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); yymsg = (char *) YYSTACK_ALLOC (yyalloc);
if (!yymsg) if (yymsg)
yymsg_alloc = yyalloc;
else
{ {
yymsg = yymsgbuf; yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf; yymsg_alloc = sizeof yymsgbuf;
yysyntax_error_status = 2; }
}
if (0 < yysize && yysize <= yymsg_alloc)
{
(void) yysyntax_error (yymsg, yystate, yychar);
yyerror (&yylloc, context, yymsg);
} }
else else
{ {
yysyntax_error_status = YYSYNTAX_ERROR; yyerror (&yylloc, context, YY_("syntax error"));
yymsgp = yymsg; if (yysize != 0)
}
}
yyerror (&yylloc, context, yymsgp);
if (yysyntax_error_status == 2)
goto yyexhaustedlab; goto yyexhaustedlab;
} }
# undef YYSYNTAX_ERROR }
#endif #endif
} }
yyerror_range[1] = yylloc; yyerror_range[0] = yylloc;
if (yyerrstatus == 3) if (yyerrstatus == 3)
{ {
@ -1924,7 +1871,7 @@ yyerrorlab:
if (/*CONSTCOND*/ 0) if (/*CONSTCOND*/ 0)
goto yyerrorlab; goto yyerrorlab;
yyerror_range[1] = yylsp[1-yylen]; yyerror_range[0] = yylsp[1-yylen];
/* Do not reclaim the symbols of the rule which action triggered /* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */ this YYERROR. */
YYPOPSTACK (yylen); YYPOPSTACK (yylen);
@ -1943,7 +1890,7 @@ yyerrlab1:
for (;;) for (;;)
{ {
yyn = yypact[yystate]; yyn = yypact[yystate];
if (!yypact_value_is_default (yyn)) if (yyn != YYPACT_NINF)
{ {
yyn += YYTERROR; yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
@ -1958,7 +1905,7 @@ yyerrlab1:
if (yyssp == yyss) if (yyssp == yyss)
YYABORT; YYABORT;
yyerror_range[1] = *yylsp; yyerror_range[0] = *yylsp;
yydestruct ("Error: popping", yydestruct ("Error: popping",
yystos[yystate], yyvsp, yylsp, context); yystos[yystate], yyvsp, yylsp, context);
YYPOPSTACK (1); YYPOPSTACK (1);
@ -1968,10 +1915,10 @@ yyerrlab1:
*++yyvsp = yylval; *++yyvsp = yylval;
yyerror_range[2] = yylloc; yyerror_range[1] = yylloc;
/* Using YYLLOC is tempting, but would change the location of /* Using YYLLOC is tempting, but would change the location of
the lookahead. YYLOC is available though. */ the lookahead. YYLOC is available though. */
YYLLOC_DEFAULT (yyloc, yyerror_range, 2); YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
*++yylsp = yyloc; *++yylsp = yyloc;
/* Shift the error token. */ /* Shift the error token. */
@ -2007,13 +1954,8 @@ yyexhaustedlab:
yyreturn: yyreturn:
if (yychar != YYEMPTY) if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead", yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, &yylloc, context); yytoken, &yylval, &yylloc, context);
}
/* Do not reclaim the symbols of the rule which action triggered /* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */ this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen); YYPOPSTACK (yylen);
@ -2038,7 +1980,7 @@ yyreturn:
/* Line 2067 of yacc.c */ /* Line 1675 of yacc.c */
#line 298 "config_parser.yy" #line 298 "config_parser.yy"

View File

@ -1,8 +1,10 @@
/* A Bison parser, made by GNU Bison 2.5. */
/* Bison interface for Yacc-like parsers in C /* A Bison parser, made by GNU Bison 2.4.1. */
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. /* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -32,7 +34,7 @@
/* "%code requires" blocks. */ /* "%code requires" blocks. */
/* Line 2068 of yacc.c */ /* Line 1676 of yacc.c */
#line 1 "config_parser.yy" #line 1 "config_parser.yy"
/****************************************************************************** /******************************************************************************
@ -63,8 +65,8 @@ using namespace icinga;
/* Line 2068 of yacc.c */ /* Line 1676 of yacc.c */
#line 68 "config_parser.h" #line 70 "config_parser.h"
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
@ -113,7 +115,7 @@ using namespace icinga;
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 2068 of yacc.c */ /* Line 1676 of yacc.c */
#line 38 "config_parser.yy" #line 38 "config_parser.yy"
char *text; char *text;
@ -123,8 +125,8 @@ typedef union YYSTYPE
/* Line 2068 of yacc.c */ /* Line 1676 of yacc.c */
#line 128 "config_parser.h" #line 130 "config_parser.h"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */

View File

@ -21,6 +21,8 @@ libicinga_la_SOURCES = \
icingaapplication.h \ icingaapplication.h \
host.cpp \ host.cpp \
host.h \ host.h \
hostgroup.cpp \
hostgroup.h \
i2-icinga.h \ i2-icinga.h \
jsonrpcendpoint.cpp \ jsonrpcendpoint.cpp \
jsonrpcendpoint.h \ jsonrpcendpoint.h \
@ -30,6 +32,8 @@ libicinga_la_SOURCES = \
nagioschecktask.h \ nagioschecktask.h \
service.cpp \ service.cpp \
service.h \ service.h \
servicegroup.cpp \
servicegroup.h \
virtualendpoint.cpp \ virtualendpoint.cpp \
virtualendpoint.h virtualendpoint.h

View File

@ -2,17 +2,22 @@
using namespace icinga; using namespace icinga;
string Host::GetDisplayName(void) const string Host::GetAlias(void) const
{ {
string value; string value;
if (GetConfigObject()->GetProperty("displayname", &value)) if (GetConfigObject()->GetProperty("alias", &value))
return value; return value;
return GetName(); return GetName();
} }
Host Host::GetByName(string name) bool Host::Exists(const string& name)
{
return (ConfigObject::GetObject("host", name));
}
Host Host::GetByName(const string& name)
{ {
ConfigObject::Ptr configObject = ConfigObject::GetObject("host", name); ConfigObject::Ptr configObject = ConfigObject::GetObject("host", name);
@ -21,3 +26,10 @@ Host Host::GetByName(string name)
return Host(configObject); return Host(configObject);
} }
Dictionary::Ptr Host::GetGroups(void) const
{
Dictionary::Ptr value;
GetConfigObject()->GetProperty("hostgroups", &value);
return value;
}

View File

@ -11,9 +11,11 @@ public:
: ConfigObjectAdapter(configObject) : ConfigObjectAdapter(configObject)
{ } { }
static Host GetByName(string name); static bool Exists(const string& name);
static Host GetByName(const string& name);
string GetDisplayName(void) const; string GetAlias(void) const;
Dictionary::Ptr GetGroups(void) const;
}; };
} }

View File

@ -48,7 +48,9 @@ using boost::algorithm::is_any_of;
#include "configobjectadapter.h" #include "configobjectadapter.h"
#include "host.h" #include "host.h"
#include "hostgroup.h"
#include "service.h" #include "service.h"
#include "servicegroup.h"
#include "cib.h" #include "cib.h"

View File

@ -12,6 +12,11 @@ string Service::GetAlias(void) const
return GetName(); return GetName();
} }
bool Service::Exists(const string& name)
{
return (ConfigObject::GetObject("service", name));
}
Service Service::GetByName(const string& name) Service Service::GetByName(const string& name)
{ {
ConfigObject::Ptr configObject = ConfigObject::GetObject("service", name); ConfigObject::Ptr configObject = ConfigObject::GetObject("service", name);
@ -86,6 +91,13 @@ Dictionary::Ptr Service::GetDependencies(void) const
return value; return value;
} }
Dictionary::Ptr Service::GetGroups(void) const
{
Dictionary::Ptr value;
GetConfigObject()->GetProperty("servicegroups", &value);
return value;
}
void Service::SetNextCheck(time_t nextCheck) void Service::SetNextCheck(time_t nextCheck)
{ {
GetConfigObject()->SetTag("next_check", (long)nextCheck); GetConfigObject()->SetTag("next_check", (long)nextCheck);

View File

@ -29,6 +29,7 @@ public:
: ConfigObjectAdapter(configObject) : ConfigObjectAdapter(configObject)
{ } { }
static bool Exists(const string& name);
static Service GetByName(const string& name); static Service GetByName(const string& name);
string GetAlias(void) const; string GetAlias(void) const;
@ -40,6 +41,7 @@ public:
long GetCheckInterval(void) const; long GetCheckInterval(void) const;
long GetRetryInterval(void) const; long GetRetryInterval(void) const;
Dictionary::Ptr GetDependencies(void) const; Dictionary::Ptr GetDependencies(void) const;
Dictionary::Ptr GetGroups(void) const;
void SetNextCheck(time_t nextCheck); void SetNextCheck(time_t nextCheck);
time_t GetNextCheck(void); time_t GetNextCheck(void);