Implement config support for arrays.

This commit is contained in:
Gunnar Beutner 2013-03-14 12:17:46 +01:00
parent 58f0c863a6
commit 07421751ad
23 changed files with 989 additions and 953 deletions

View File

@ -21,9 +21,12 @@ object HostGroup "all-hosts" {
display_name = "All Hosts"
}
abstract object Host "itl-host" {
hostgroups = { "all-hosts" },
template Host "itl-host" {
hostgroups = [ "all-hosts" ],
services["ping4"] = {
templates = [ "ping4" ]
},
services = { "ping4" },
hostcheck = "ping4"
}

View File

@ -18,7 +18,7 @@
******************************************************************************/
template Service "ping4" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_ping",
"-4",
"-H", "$address$",
@ -26,7 +26,7 @@ template Service "ping4" inherits "plugin-service" {
"-c", "$crta$,$cpl$%",
"-p", "$packets$",
"-t", "$timeout$"
},
],
macros = {
wrta = 100,
@ -41,7 +41,7 @@ template Service "ping4" inherits "plugin-service" {
}
template Service "ping6" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_ping",
"-6",
"-H", "$address6$",
@ -49,7 +49,7 @@ template Service "ping6" inherits "plugin-service" {
"-c", "$crta$,$cpl$%",
"-p", "$packets$",
"-t", "$timeout$"
},
],
macros = {
wrta = 100,
@ -64,11 +64,11 @@ template Service "ping6" inherits "plugin-service" {
}
template Service "dummy" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_dummy",
"$state$",
"$text$"
},
],
macros = {
state = 0,
@ -77,62 +77,62 @@ template Service "dummy" inherits "plugin-service" {
}
template Service "tcp" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_tcp",
"-H", "$address$",
"-p", "$port$"
}
]
}
template Service "udp" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_udp",
"-H", "$address$",
"-p", "$port$"
}
]
}
template Service "http_vhost" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_http",
"-H", "$vhost$"
},
],
}
template Service "http_ip" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_http",
"-I", "$address$"
}
]
}
template Service "https_vhost" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_http",
"-H", "$vhost", "-S"
},
],
}
template Service "https_ip" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_http",
"-I", "$address$", "-S"
},
],
}
template Service "smtp" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_smtp",
"-H", "$address$"
}
]
}
template Service "ssmtp" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_ssmtp",
"-H", "$address$",
"-p", "$port$"
},
],
macros += {
port = 465
@ -140,25 +140,25 @@ template Service "ssmtp" inherits "plugin-service" {
}
template Service "ntp_time" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_ntp_time",
"-H", "$address$"
}
]
}
template Service "ssh" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_ssh",
"$address$"
}
]
}
template Service "disk" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_disk",
"-w", "$wfree$",
"-c", "$cfree$"
},
],
macros += {
wfree = "20%",
@ -167,11 +167,11 @@ template Service "disk" inherits "plugin-service" {
}
template Service "users" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_users",
"-w", "$wgreater$",
"-c", "$cgreater$"
},
],
macros += {
wgreater = 20,
@ -180,11 +180,11 @@ template Service "users" inherits "plugin-service" {
}
template Service "processes" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_procs",
"-w", "$wgreater$",
"-c", "$cgreater$"
},
],
macros += {
wgreater = 250,
@ -194,11 +194,11 @@ template Service "processes" inherits "plugin-service" {
template Service "load" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_load",
"-w", "$wload1$,$wload5$,$wload15$",
"-c", "$cload1$,$cload5$,$cload15$"
},
],
macros = {
wload1 = 5.0,
@ -212,12 +212,12 @@ template Service "load" inherits "plugin-service" {
}
template Service "snmp" inherits "plugin-service" {
check_command = {
check_command = [
"$plugindir$/check_snmp",
"-H", "$address$",
"-o", "$oid$",
"-C", "$community$"
},
],
macros = {
community = "public"

View File

@ -22,7 +22,7 @@ object ServiceGroup "all-services" {
}
template Service "itl-service" {
servicegroups = { "all-services" }
servicegroups = [ "all-services" ]
}
template Service "null-service" inherits "itl-service" {

View File

@ -370,8 +370,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 55
#define YY_END_OF_BUFFER 56
#define YY_NUM_RULES 56
#define YY_END_OF_BUFFER 57
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@ -379,29 +379,29 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[193] =
static yyconst flex_int16_t yy_accept[197] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 56, 54,
21, 21, 1, 54, 54, 42, 54, 54, 54, 48,
54, 49, 42, 42, 42, 42, 42, 42, 42, 42,
42, 42, 42, 54, 18, 19, 12, 3, 2, 55,
15, 15, 21, 0, 0, 0, 0, 0, 42, 52,
50, 48, 51, 16, 20, 53, 0, 45, 46, 47,
0, 43, 42, 42, 42, 42, 42, 42, 42, 42,
42, 42, 42, 42, 42, 42, 0, 18, 17, 12,
11, 4, 5, 9, 10, 6, 8, 7, 0, 0,
0, 0, 0, 0, 20, 48, 44, 42, 27, 42,
0, 0, 0, 0, 0, 0, 0, 0, 57, 55,
21, 21, 1, 55, 55, 43, 55, 55, 55, 49,
55, 50, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 55, 18, 19, 12, 3, 2, 56,
15, 15, 21, 0, 0, 0, 0, 0, 43, 53,
51, 49, 52, 16, 20, 54, 0, 46, 47, 48,
0, 44, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 43, 43, 43, 43, 0, 18, 17,
12, 11, 4, 5, 9, 10, 6, 8, 7, 0,
0, 0, 0, 0, 0, 20, 49, 45, 43, 28,
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
42, 42, 13, 4, 5, 14, 0, 0, 0, 0,
0, 42, 42, 42, 42, 42, 38, 42, 42, 42,
42, 42, 42, 40, 22, 4, 0, 0, 0, 0,
0, 42, 42, 41, 42, 32, 42, 42, 42, 42,
42, 42, 0, 0, 0, 0, 0, 42, 42, 42,
24, 33, 42, 26, 25, 42, 0, 0, 0, 0,
0, 42, 42, 42, 39, 42, 35, 36, 0, 29,
0, 31, 42, 37, 34, 0, 0, 42, 30, 28,
23, 0
43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 43, 13, 4, 5, 14, 0, 0,
0, 0, 0, 43, 43, 43, 43, 43, 43, 39,
43, 43, 43, 43, 43, 43, 41, 22, 4, 0,
0, 0, 0, 0, 43, 24, 43, 42, 43, 33,
43, 43, 43, 43, 43, 43, 0, 0, 0, 0,
0, 43, 43, 43, 25, 34, 43, 27, 26, 43,
0, 0, 0, 0, 0, 43, 43, 43, 40, 43,
36, 37, 0, 30, 0, 32, 43, 38, 35, 0,
0, 43, 31, 29, 23, 0
} ;
@ -446,109 +446,110 @@ static yyconst flex_int32_t yy_meta[44] =
5, 1, 1
} ;
static yyconst flex_int16_t yy_base[202] =
static yyconst flex_int16_t yy_base[206] =
{ 0,
0, 0, 342, 341, 41, 43, 304, 303, 345, 350,
46, 48, 350, 24, 33, 328, 327, 43, 50, 55,
325, 350, 325, 42, 48, 55, 56, 54, 61, 62,
64, 63, 73, 298, 0, 328, 0, 350, 350, 103,
350, 295, 88, 305, 308, 297, 310, 313, 316, 350,
350, 86, 350, 350, 0, 350, 81, 350, 294, 350,
313, 350, 65, 79, 88, 89, 91, 90, 95, 92,
106, 111, 113, 114, 116, 117, 287, 0, 350, 0,
350, 124, 131, 350, 350, 350, 350, 350, 285, 305,
305, 287, 289, 293, 0, 134, 350, 118, 306, 122,
0, 0, 350, 349, 41, 43, 312, 311, 353, 358,
46, 48, 358, 24, 33, 336, 335, 43, 50, 55,
333, 358, 333, 42, 48, 55, 56, 54, 61, 63,
65, 67, 74, 306, 0, 336, 0, 358, 358, 104,
358, 303, 91, 313, 316, 305, 318, 321, 324, 358,
358, 91, 358, 358, 0, 358, 83, 358, 302, 358,
321, 358, 75, 83, 90, 86, 81, 93, 91, 103,
98, 105, 115, 107, 114, 116, 122, 295, 0, 358,
0, 358, 134, 136, 358, 358, 358, 358, 358, 293,
313, 313, 295, 297, 301, 0, 138, 358, 121, 314,
132, 134, 137, 124, 143, 146, 136, 147, 150, 151,
152, 156, 350, 169, 171, 350, 291, 284, 283, 279,
289, 157, 159, 170, 163, 172, 300, 173, 174, 175,
184, 176, 179, 299, 298, 193, 274, 292, 283, 282,
286, 191, 182, 292, 185, 291, 194, 196, 198, 200,
201, 203, 280, 258, 272, 254, 243, 204, 205, 206,
246, 245, 208, 244, 243, 209, 234, 216, 217, 230,
215, 212, 213, 215, 235, 216, 350, 350, 211, 350,
215, 230, 219, 229, 227, 218, 205, 223, 350, 350,
87, 350, 264, 269, 274, 276, 281, 286, 291, 296,
137, 123, 136, 138, 144, 128, 147, 150, 151, 154,
155, 156, 161, 162, 358, 167, 169, 358, 299, 292,
291, 287, 297, 160, 171, 172, 175, 177, 176, 308,
178, 179, 181, 187, 182, 188, 307, 306, 198, 282,
300, 291, 290, 294, 199, 300, 189, 299, 192, 298,
200, 201, 205, 207, 208, 210, 287, 265, 279, 261,
250, 211, 212, 213, 253, 252, 215, 251, 250, 216,
241, 223, 224, 237, 222, 219, 221, 222, 242, 224,
358, 358, 218, 358, 222, 237, 226, 236, 234, 225,
211, 230, 358, 358, 64, 358, 271, 276, 281, 283,
301
288, 293, 298, 303, 308
} ;
static yyconst flex_int16_t yy_def[202] =
static yyconst flex_int16_t yy_def[206] =
{ 0,
192, 1, 193, 193, 194, 194, 195, 195, 192, 192,
192, 192, 192, 192, 192, 196, 192, 192, 192, 192,
197, 192, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 192, 198, 192, 199, 192, 192, 200,
192, 192, 192, 192, 192, 192, 192, 192, 196, 192,
192, 192, 192, 192, 201, 192, 192, 192, 192, 192,
197, 192, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 196, 192, 198, 192, 199,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 201, 192, 192, 196, 196, 196,
196, 1, 197, 197, 198, 198, 199, 199, 196, 196,
196, 196, 196, 196, 196, 200, 196, 196, 196, 196,
201, 196, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 196, 202, 196, 203, 196, 196, 204,
196, 196, 196, 196, 196, 196, 196, 196, 200, 196,
196, 196, 196, 196, 205, 196, 196, 196, 196, 196,
201, 196, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 196, 202, 196,
203, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 205, 196, 196, 200, 200,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 192, 192, 192, 192, 192, 192, 192, 192,
192, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 192, 192, 192, 192, 192,
192, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 192, 192, 192, 192, 192, 196, 196, 196,
196, 196, 196, 196, 196, 196, 192, 192, 192, 192,
192, 196, 196, 196, 196, 196, 192, 192, 192, 192,
192, 196, 196, 196, 196, 192, 192, 196, 192, 192,
196, 0, 192, 192, 192, 192, 192, 192, 192, 192,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 196, 196, 196, 196, 196, 196,
196, 196, 196, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 196, 196,
196, 196, 196, 196, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 196, 196, 196, 196,
196, 200, 200, 200, 200, 200, 200, 200, 200, 200,
196, 196, 196, 196, 196, 200, 200, 200, 200, 200,
196, 196, 196, 196, 196, 200, 200, 200, 200, 196,
196, 200, 196, 196, 200, 0, 196, 196, 196, 196,
192
196, 196, 196, 196, 196
} ;
static yyconst flex_int16_t yy_nxt[394] =
static yyconst flex_int16_t yy_nxt[402] =
{ 0,
10, 11, 12, 13, 14, 15, 16, 17, 18, 10,
19, 20, 20, 10, 21, 22, 10, 23, 10, 24,
23, 23, 25, 23, 26, 23, 23, 27, 23, 28,
23, 29, 30, 31, 23, 23, 32, 33, 23, 23,
23, 34, 10, 38, 39, 38, 39, 43, 43, 43,
43, 44, 46, 45, 52, 52, 54, 192, 53, 40,
55, 40, 63, 192, 57, 56, 52, 52, 47, 192,
192, 192, 48, 64, 66, 65, 192, 192, 192, 192,
192, 58, 70, 71, 72, 59, 68, 67, 192, 43,
43, 60, 96, 96, 192, 57, 74, 52, 52, 69,
43, 44, 46, 45, 52, 52, 54, 196, 53, 40,
55, 40, 63, 196, 57, 56, 52, 52, 47, 196,
196, 196, 48, 64, 67, 66, 196, 65, 196, 196,
196, 58, 196, 71, 72, 59, 69, 68, 73, 196,
196, 60, 43, 43, 97, 97, 196, 75, 196, 70,
73, 98, 192, 192, 192, 192, 192, 192, 75, 100,
192, 103, 58, 76, 82, 83, 59, 102, 101, 99,
106, 192, 60, 84, 104, 105, 192, 85, 192, 192,
108, 192, 192, 192, 86, 114, 115, 192, 87, 192,
88, 107, 115, 115, 110, 96, 96, 192, 109, 192,
112, 192, 192, 127, 111, 122, 126, 125, 192, 123,
58, 192, 192, 128, 59, 192, 192, 192, 124, 129,
60, 192, 192, 130, 192, 134, 131, 132, 192, 135,
136, 115, 115, 115, 133, 192, 143, 192, 192, 192,
192, 192, 142, 144, 192, 148, 147, 192, 145, 192,
57, 196, 52, 52, 74, 196, 196, 102, 196, 76,
103, 99, 105, 196, 77, 83, 84, 58, 196, 104,
196, 59, 196, 100, 85, 101, 108, 60, 86, 196,
196, 196, 106, 107, 110, 87, 196, 196, 196, 88,
109, 89, 111, 196, 112, 116, 117, 117, 117, 97,
97, 196, 196, 196, 113, 114, 125, 130, 124, 196,
126, 128, 196, 129, 58, 196, 196, 131, 59, 196,
196, 196, 127, 132, 60, 196, 196, 196, 139, 117,
117, 117, 135, 134, 137, 138, 196, 196, 133, 136,
196, 196, 196, 196, 196, 145, 196, 196, 148, 147,
192, 146, 149, 150, 115, 115, 192, 151, 152, 192,
158, 192, 160, 192, 159, 192, 192, 163, 192, 192,
192, 192, 166, 192, 192, 172, 165, 192, 192, 161,
192, 192, 183, 162, 192, 164, 173, 175, 192, 185,
190, 189, 192, 174, 192, 192, 176, 187, 186, 182,
192, 184, 181, 180, 188, 179, 178, 177, 192, 192,
192, 192, 171, 191, 35, 35, 35, 35, 35, 37,
37, 37, 37, 37, 41, 41, 41, 41, 41, 49,
49, 61, 61, 61, 61, 61, 78, 78, 78, 170,
78, 80, 169, 168, 80, 80, 81, 81, 81, 81,
152, 151, 196, 196, 196, 150, 154, 196, 153, 117,
117, 146, 149, 155, 196, 196, 196, 156, 162, 164,
196, 163, 196, 196, 167, 196, 196, 196, 196, 170,
196, 196, 176, 169, 196, 165, 196, 196, 166, 196,
187, 196, 168, 177, 179, 196, 194, 189, 193, 196,
178, 196, 196, 180, 191, 190, 186, 196, 188, 185,
184, 192, 183, 182, 181, 196, 196, 196, 196, 175,
195, 35, 35, 35, 35, 35, 37, 37, 37, 37,
37, 41, 41, 41, 41, 41, 49, 49, 61, 61,
61, 61, 61, 79, 79, 79, 174, 79, 81, 173,
81, 95, 167, 95, 95, 95, 192, 192, 157, 156,
155, 154, 153, 192, 192, 192, 141, 140, 139, 138,
137, 192, 121, 120, 119, 118, 117, 116, 113, 62,
97, 192, 94, 93, 92, 91, 90, 89, 79, 77,
192, 62, 51, 50, 192, 42, 42, 36, 36, 9,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192
172, 81, 81, 82, 82, 82, 82, 82, 96, 171,
96, 96, 96, 196, 196, 196, 161, 160, 159, 158,
157, 196, 196, 196, 144, 143, 142, 141, 140, 196,
123, 122, 121, 120, 119, 118, 115, 62, 98, 196,
95, 94, 93, 92, 91, 90, 80, 78, 196, 62,
51, 50, 196, 42, 42, 36, 36, 9, 196, 196,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196
} ;
static yyconst flex_int16_t yy_chk[394] =
static yyconst flex_int16_t yy_chk[402] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -557,51 +558,52 @@ static yyconst flex_int16_t yy_chk[394] =
1, 1, 1, 5, 5, 6, 6, 11, 11, 12,
12, 14, 15, 14, 18, 18, 19, 24, 18, 5,
19, 6, 24, 25, 20, 19, 20, 20, 15, 28,
26, 27, 15, 24, 26, 25, 29, 30, 32, 31,
63, 20, 30, 31, 32, 20, 28, 27, 33, 43,
43, 20, 57, 57, 64, 52, 33, 52, 52, 29,
26, 27, 15, 24, 26, 25, 29, 24, 30, 195,
31, 20, 32, 30, 31, 20, 28, 27, 32, 33,
63, 20, 43, 43, 57, 57, 67, 33, 64, 29,
32, 63, 191, 65, 66, 68, 67, 70, 33, 65,
69, 68, 52, 33, 40, 40, 52, 67, 66, 64,
70, 71, 52, 40, 69, 69, 72, 40, 73, 74,
72, 75, 76, 98, 40, 82, 82, 100, 40, 104,
40, 71, 83, 83, 74, 96, 96, 101, 73, 102,
76, 107, 103, 104, 75, 98, 103, 102, 105, 100,
96, 106, 108, 105, 96, 109, 110, 111, 101, 106,
96, 112, 122, 107, 123, 111, 108, 109, 125, 112,
114, 114, 115, 115, 110, 124, 123, 126, 128, 129,
130, 132, 122, 124, 133, 129, 128, 143, 125, 131,
52, 66, 52, 52, 32, 65, 69, 66, 68, 33,
67, 63, 69, 71, 33, 40, 40, 52, 70, 68,
72, 52, 74, 64, 40, 65, 71, 52, 40, 75,
73, 76, 70, 70, 73, 40, 99, 77, 102, 40,
72, 40, 74, 106, 75, 83, 83, 84, 84, 97,
97, 103, 101, 104, 76, 77, 101, 106, 99, 105,
102, 104, 107, 105, 97, 108, 109, 107, 97, 110,
111, 112, 103, 108, 97, 124, 113, 114, 116, 116,
117, 117, 111, 110, 113, 114, 125, 126, 109, 112,
127, 129, 128, 131, 132, 124, 133, 135, 127, 126,
145, 126, 130, 131, 136, 136, 142, 132, 133, 147,
142, 148, 145, 149, 143, 150, 151, 149, 152, 158,
159, 160, 152, 163, 166, 158, 151, 172, 173, 147,
174, 176, 173, 148, 183, 150, 159, 163, 188, 176,
187, 186, 185, 160, 184, 182, 166, 181, 179, 172,
175, 174, 171, 170, 183, 169, 168, 167, 165, 164,
162, 161, 157, 188, 193, 193, 193, 193, 193, 194,
194, 194, 194, 194, 195, 195, 195, 195, 195, 196,
196, 197, 197, 197, 197, 197, 198, 198, 198, 156,
198, 199, 155, 154, 199, 199, 200, 200, 200, 200,
132, 131, 134, 136, 147, 129, 134, 149, 133, 139,
139, 125, 128, 135, 145, 151, 152, 136, 145, 149,
153, 147, 154, 155, 153, 156, 162, 163, 164, 156,
167, 170, 162, 155, 176, 151, 177, 178, 152, 180,
177, 187, 154, 163, 167, 192, 191, 180, 190, 189,
164, 188, 186, 170, 185, 183, 176, 179, 178, 175,
174, 187, 173, 172, 171, 169, 168, 166, 165, 161,
192, 197, 197, 197, 197, 197, 198, 198, 198, 198,
198, 199, 199, 199, 199, 199, 200, 200, 201, 201,
201, 201, 201, 202, 202, 202, 160, 202, 203, 159,
200, 201, 153, 201, 201, 201, 146, 144, 141, 140,
139, 138, 137, 135, 134, 127, 121, 120, 119, 118,
117, 99, 94, 93, 92, 91, 90, 89, 77, 61,
59, 49, 48, 47, 46, 45, 44, 42, 36, 34,
23, 21, 17, 16, 9, 8, 7, 4, 3, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192
158, 203, 203, 204, 204, 204, 204, 204, 205, 157,
205, 205, 205, 150, 148, 146, 144, 143, 142, 141,
140, 138, 137, 130, 123, 122, 121, 120, 119, 100,
95, 94, 93, 92, 91, 90, 78, 61, 59, 49,
48, 47, 46, 45, 44, 42, 36, 34, 23, 21,
17, 16, 9, 8, 7, 4, 3, 196, 196, 196,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
196
} ;
/* Table of booleans, true if rule could match eol. */
static yyconst flex_int32_t yy_rule_can_match_eol[56] =
static yyconst flex_int32_t yy_rule_can_match_eol[57] =
{ 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
@ -695,7 +697,7 @@ static void lb_append_char(lex_buf *lb, char new_char)
#line 699 "config_lexer.cc"
#line 701 "config_lexer.cc"
#define INITIAL 0
#define C_COMMENT 1
@ -952,7 +954,7 @@ YY_DECL
lex_buf string_buf;
#line 956 "config_lexer.cc"
#line 958 "config_lexer.cc"
yylval = yylval_param;
@ -1009,13 +1011,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 193 )
if ( yy_current_state >= 197 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_current_state != 192 );
while ( yy_current_state != 196 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@ -1222,123 +1224,123 @@ YY_RULE_SETUP
case 24:
YY_RULE_SETUP
#line 182 "config_lexer.ll"
{ yylval->type = TypeNumber; return T_TYPE_NUMBER; }
{ yylval->type = TypeArray; return T_TYPE_ARRAY; }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 183 "config_lexer.ll"
{ yylval->type = TypeString; return T_TYPE_STRING; }
{ yylval->type = TypeNumber; return T_TYPE_NUMBER; }
YY_BREAK
case 26:
YY_RULE_SETUP
#line 184 "config_lexer.ll"
{ yylval->type = TypeScalar; return T_TYPE_SCALAR; }
{ yylval->type = TypeString; return T_TYPE_STRING; }
YY_BREAK
case 27:
YY_RULE_SETUP
#line 185 "config_lexer.ll"
{ yylval->type = TypeAny; return T_TYPE_ANY; }
{ yylval->type = TypeScalar; return T_TYPE_SCALAR; }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 186 "config_lexer.ll"
{ return T_VALIDATOR; }
{ yylval->type = TypeAny; return T_TYPE_ANY; }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 187 "config_lexer.ll"
{ return T_REQUIRE; }
{ return T_VALIDATOR; }
YY_BREAK
case 30:
YY_RULE_SETUP
#line 188 "config_lexer.ll"
{ return T_ATTRIBUTE; }
{ return T_REQUIRE; }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 189 "config_lexer.ll"
return T_ABSTRACT;
{ return T_ATTRIBUTE; }
YY_BREAK
case 32:
YY_RULE_SETUP
#line 190 "config_lexer.ll"
return T_LOCAL;
return T_ABSTRACT;
YY_BREAK
case 33:
YY_RULE_SETUP
#line 191 "config_lexer.ll"
return T_OBJECT;
return T_LOCAL;
YY_BREAK
case 34:
YY_RULE_SETUP
#line 192 "config_lexer.ll"
return T_TEMPLATE;
return T_OBJECT;
YY_BREAK
case 35:
YY_RULE_SETUP
#line 193 "config_lexer.ll"
return T_INCLUDE;
return T_TEMPLATE;
YY_BREAK
case 36:
YY_RULE_SETUP
#line 194 "config_lexer.ll"
return T_LIBRARY;
return T_INCLUDE;
YY_BREAK
case 37:
YY_RULE_SETUP
#line 195 "config_lexer.ll"
return T_INHERITS;
return T_LIBRARY;
YY_BREAK
case 38:
YY_RULE_SETUP
#line 196 "config_lexer.ll"
return T_NULL;
return T_INHERITS;
YY_BREAK
case 39:
YY_RULE_SETUP
#line 197 "config_lexer.ll"
return T_PARTIAL;
return T_NULL;
YY_BREAK
case 40:
YY_RULE_SETUP
#line 198 "config_lexer.ll"
{ yylval->num = 1; return T_NUMBER; }
return T_PARTIAL;
YY_BREAK
case 41:
YY_RULE_SETUP
#line 199 "config_lexer.ll"
{ yylval->num = 0; return T_NUMBER; }
{ yylval->num = 1; return T_NUMBER; }
YY_BREAK
case 42:
YY_RULE_SETUP
#line 200 "config_lexer.ll"
{ yylval->text = strdup(yytext); return T_IDENTIFIER; }
{ yylval->num = 0; return T_NUMBER; }
YY_BREAK
case 43:
/* rule 43 can match eol */
YY_RULE_SETUP
#line 201 "config_lexer.ll"
{ yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING_ANGLE; }
{ yylval->text = strdup(yytext); return T_IDENTIFIER; }
YY_BREAK
case 44:
/* rule 44 can match eol */
YY_RULE_SETUP
#line 202 "config_lexer.ll"
{ yylval->num = strtod(yytext, NULL) / 1000; return T_NUMBER; }
{ yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING_ANGLE; }
YY_BREAK
case 45:
YY_RULE_SETUP
#line 203 "config_lexer.ll"
{ yylval->num = strtod(yytext, NULL) * 60 * 60; return T_NUMBER; }
{ yylval->num = strtod(yytext, NULL) / 1000; return T_NUMBER; }
YY_BREAK
case 46:
YY_RULE_SETUP
#line 204 "config_lexer.ll"
{ yylval->num = strtod(yytext, NULL) * 60; return T_NUMBER; }
{ yylval->num = strtod(yytext, NULL) * 60 * 60; return T_NUMBER; }
YY_BREAK
case 47:
YY_RULE_SETUP
#line 205 "config_lexer.ll"
{ yylval->num = strtod(yytext, NULL); return T_NUMBER; }
{ yylval->num = strtod(yytext, NULL) * 60; return T_NUMBER; }
YY_BREAK
case 48:
YY_RULE_SETUP
@ -1348,40 +1350,45 @@ YY_RULE_SETUP
case 49:
YY_RULE_SETUP
#line 207 "config_lexer.ll"
{ yylval->op = OperatorSet; return T_EQUAL; }
{ yylval->num = strtod(yytext, NULL); return T_NUMBER; }
YY_BREAK
case 50:
YY_RULE_SETUP
#line 208 "config_lexer.ll"
{ yylval->op = OperatorPlus; return T_PLUS_EQUAL; }
{ yylval->op = OperatorSet; return T_EQUAL; }
YY_BREAK
case 51:
YY_RULE_SETUP
#line 209 "config_lexer.ll"
{ yylval->op = OperatorMinus; return T_MINUS_EQUAL; }
{ yylval->op = OperatorPlus; return T_PLUS_EQUAL; }
YY_BREAK
case 52:
YY_RULE_SETUP
#line 210 "config_lexer.ll"
{ yylval->op = OperatorMultiply; return T_MULTIPLY_EQUAL; }
{ yylval->op = OperatorMinus; return T_MINUS_EQUAL; }
YY_BREAK
case 53:
YY_RULE_SETUP
#line 211 "config_lexer.ll"
{ yylval->op = OperatorMultiply; return T_MULTIPLY_EQUAL; }
YY_BREAK
case 54:
YY_RULE_SETUP
#line 212 "config_lexer.ll"
{ yylval->op = OperatorDivide; return T_DIVIDE_EQUAL; }
YY_BREAK
case 54:
YY_RULE_SETUP
#line 214 "config_lexer.ll"
return yytext[0];
YY_BREAK
case 55:
YY_RULE_SETUP
#line 216 "config_lexer.ll"
#line 215 "config_lexer.ll"
return yytext[0];
YY_BREAK
case 56:
YY_RULE_SETUP
#line 217 "config_lexer.ll"
ECHO;
YY_BREAK
#line 1385 "config_lexer.cc"
#line 1392 "config_lexer.cc"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(C_COMMENT):
case YY_STATE_EOF(STRING):
@ -1679,7 +1686,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 193 )
if ( yy_current_state >= 197 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@ -1708,11 +1715,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 193 )
if ( yy_current_state >= 197 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 192);
yy_is_jam = (yy_current_state == 196);
return yy_is_jam ? 0 : yy_current_state;
}
@ -2571,7 +2578,7 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 216 "config_lexer.ll"
#line 217 "config_lexer.ll"

View File

@ -179,6 +179,7 @@ static void lb_append_char(lex_buf *lb, char new_char)
<INITIAL>{
type return T_TYPE;
dictionary { yylval->type = TypeDictionary; return T_TYPE_DICTIONARY; }
array { yylval->type = TypeArray; return T_TYPE_ARRAY; }
number { yylval->type = TypeNumber; return T_TYPE_NUMBER; }
string { yylval->type = TypeString; return T_TYPE_STRING; }
scalar { yylval->type = TypeScalar; return T_TYPE_SCALAR; }

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,8 @@
/* A Bison parser, made by GNU Bison 2.5. */
/* A Bison parser, made by GNU Bison 2.4.1. */
/* Bison interface for Yacc-like parsers in C
/* 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.
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
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
@ -34,7 +32,7 @@
/* "%code requires" blocks. */
/* Line 1676 of yacc.c */
/* Line 2068 of yacc.c */
#line 1 "config_parser.yy"
/******************************************************************************
@ -65,8 +63,8 @@ using namespace icinga;
/* Line 1676 of yacc.c */
#line 70 "config_parser.h"
/* Line 2068 of yacc.c */
#line 68 "config_parser.h"
/* Tokens. */
#ifndef YYTOKENTYPE
@ -85,22 +83,23 @@ using namespace icinga;
T_MULTIPLY_EQUAL = 266,
T_DIVIDE_EQUAL = 267,
T_TYPE_DICTIONARY = 268,
T_TYPE_NUMBER = 269,
T_TYPE_STRING = 270,
T_TYPE_SCALAR = 271,
T_TYPE_ANY = 272,
T_VALIDATOR = 273,
T_REQUIRE = 274,
T_ATTRIBUTE = 275,
T_TYPE = 276,
T_ABSTRACT = 277,
T_LOCAL = 278,
T_OBJECT = 279,
T_TEMPLATE = 280,
T_INCLUDE = 281,
T_LIBRARY = 282,
T_INHERITS = 283,
T_PARTIAL = 284
T_TYPE_ARRAY = 269,
T_TYPE_NUMBER = 270,
T_TYPE_STRING = 271,
T_TYPE_SCALAR = 272,
T_TYPE_ANY = 273,
T_VALIDATOR = 274,
T_REQUIRE = 275,
T_ATTRIBUTE = 276,
T_TYPE = 277,
T_ABSTRACT = 278,
T_LOCAL = 279,
T_OBJECT = 280,
T_TEMPLATE = 281,
T_INCLUDE = 282,
T_LIBRARY = 283,
T_INHERITS = 284,
T_PARTIAL = 285
};
#endif
/* Tokens. */
@ -115,22 +114,23 @@ using namespace icinga;
#define T_MULTIPLY_EQUAL 266
#define T_DIVIDE_EQUAL 267
#define T_TYPE_DICTIONARY 268
#define T_TYPE_NUMBER 269
#define T_TYPE_STRING 270
#define T_TYPE_SCALAR 271
#define T_TYPE_ANY 272
#define T_VALIDATOR 273
#define T_REQUIRE 274
#define T_ATTRIBUTE 275
#define T_TYPE 276
#define T_ABSTRACT 277
#define T_LOCAL 278
#define T_OBJECT 279
#define T_TEMPLATE 280
#define T_INCLUDE 281
#define T_LIBRARY 282
#define T_INHERITS 283
#define T_PARTIAL 284
#define T_TYPE_ARRAY 269
#define T_TYPE_NUMBER 270
#define T_TYPE_STRING 271
#define T_TYPE_SCALAR 272
#define T_TYPE_ANY 273
#define T_VALIDATOR 274
#define T_REQUIRE 275
#define T_ATTRIBUTE 276
#define T_TYPE 277
#define T_ABSTRACT 278
#define T_LOCAL 279
#define T_OBJECT 280
#define T_TEMPLATE 281
#define T_INCLUDE 282
#define T_LIBRARY 283
#define T_INHERITS 284
#define T_PARTIAL 285
@ -139,7 +139,7 @@ using namespace icinga;
typedef union YYSTYPE
{
/* Line 1676 of yacc.c */
/* Line 2068 of yacc.c */
#line 38 "config_parser.yy"
char *text;
@ -150,7 +150,7 @@ typedef union YYSTYPE
/* Line 1676 of yacc.c */
/* Line 2068 of yacc.c */
#line 155 "config_parser.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1

View File

@ -54,6 +54,7 @@ using namespace icinga;
%token <op> T_MULTIPLY_EQUAL
%token <op> T_DIVIDE_EQUAL
%token <type> T_TYPE_DICTIONARY
%token <type> T_TYPE_ARRAY
%token <type> T_TYPE_NUMBER
%token <type> T_TYPE_STRING
%token <type> T_TYPE_SCALAR
@ -71,6 +72,7 @@ using namespace icinga;
%token T_INHERITS
%token T_PARTIAL
%type <text> identifier
%type <variant> array
%type <variant> simplevalue
%type <variant> value
%type <variant> expressionlist
@ -94,7 +96,7 @@ void yyerror(YYLTYPE *locp, ConfigCompiler *, const char *err)
int yyparse(ConfigCompiler *context);
static stack<ExpressionList::Ptr> m_ExpressionLists;
static Dictionary::Ptr m_Array;
static stack<Array::Ptr> m_Arrays;
static ConfigItemBuilder::Ptr m_Item;
static bool m_Abstract;
static bool m_Local;
@ -244,6 +246,7 @@ type_inherits_specifier: /* empty */
;
type: T_TYPE_DICTIONARY
| T_TYPE_ARRAY
| T_TYPE_NUMBER
| T_TYPE_STRING
| T_TYPE_SCALAR
@ -361,13 +364,6 @@ expression: identifier operator value
m_ExpressionLists.top()->AddExpression(expr);
}
| value
{
Expression expr(String(), OperatorSet, *$1, yylloc);
delete $1;
m_ExpressionLists.top()->AddExpression(expr);
}
;
operator: T_EQUAL
@ -380,6 +376,32 @@ operator: T_EQUAL
}
;
array: '['
{
m_Arrays.push(boost::make_shared<Array>());
}
array_items
']'
{
$$ = new Value(m_Arrays.top());
m_Arrays.pop();
}
;
array_items: array_items_inner
| array_items_inner ','
array_items_inner: /* empty */
| value
{
m_Arrays.top()->Add(*$1);
}
| array_items_inner ',' value
{
m_Arrays.top()->Add(*$3);
}
;
simplevalue: T_STRING
{
$$ = new Value($1);
@ -393,6 +415,10 @@ simplevalue: T_STRING
{
$$ = new Value();
}
| array
{
$$ = $1;
}
;
value: simplevalue

View File

@ -62,8 +62,10 @@ bool TypeRule::MatchValue(const Value& value) const
case TypeDictionary:
return value.IsObjectType<Dictionary>();
case TypeArray:
return value.IsObjectType<Array>();
default:
return false;
}
}

View File

@ -34,7 +34,8 @@ enum TypeSpecifier
TypeScalar,
TypeNumber,
TypeString,
TypeDictionary
TypeDictionary,
TypeArray
};
/**

View File

@ -82,7 +82,7 @@ Host::Ptr Host::GetByName(const String& name)
return dynamic_pointer_cast<Host>(configObject);
}
Dictionary::Ptr Host::GetGroups(void) const
Array::Ptr Host::GetGroups(void) const
{
return m_HostGroups;;
}
@ -92,12 +92,12 @@ Dictionary::Ptr Host::GetMacros(void) const
return m_Macros;
}
Dictionary::Ptr Host::GetHostDependencies(void) const
Array::Ptr Host::GetHostDependencies(void) const
{
return m_HostDependencies;;
}
Dictionary::Ptr Host::GetServiceDependencies(void) const
Array::Ptr Host::GetServiceDependencies(void) const
{
return m_ServiceDependencies;
}
@ -242,28 +242,22 @@ void Host::UpdateSlaveServices(void)
CopyServiceAttributes<false>(this, builder);
if (svcdesc.IsScalar()) {
builder->AddParent(svcdesc);
} else if (svcdesc.IsObjectType<Dictionary>()) {
if (!svcdesc.IsObjectType<Dictionary>())
BOOST_THROW_EXCEPTION(invalid_argument("Service description must be either a string or a dictionary."));
Dictionary::Ptr service = svcdesc;
Dictionary::Ptr templates = service->Get("templates");
Array::Ptr templates = service->Get("templates");
if (templates) {
ObjectLock olock(templates);
String tmpl;
BOOST_FOREACH(tie(tuples::ignore, tmpl), templates) {
BOOST_FOREACH(const Value& tmpl, templates) {
builder->AddParent(tmpl);
}
} else {
builder->AddParent(svcname);
}
CopyServiceAttributes<true>(service, builder);
} else {
BOOST_THROW_EXCEPTION(invalid_argument("Service description must be either a string or a dictionary."));
}
ConfigItem::Ptr serviceItem = builder->Compile();
DynamicObject::Ptr dobj = serviceItem->Commit();
@ -392,20 +386,19 @@ void Host::ValidateServiceDictionary(const ScriptTask::Ptr& task, const vector<V
BOOST_FOREACH(tie(key, value), attrs) {
vector<String> templates;
if (value.IsScalar()) {
templates.push_back(value);
} else if (value.IsObjectType<Dictionary>()) {
if (!value.IsObjectType<Dictionary>())
BOOST_THROW_EXCEPTION(invalid_argument("Service description must be a dictionary."));
Dictionary::Ptr serviceDesc = value;
Dictionary::Ptr templatesDict = serviceDesc->Get("templates");
ObjectLock tlock(templatesDict);
Array::Ptr templatesArray = serviceDesc->Get("templates");
Value tmpl;
BOOST_FOREACH(tie(tuples::ignore, tmpl), templatesDict) {
if (templatesArray) {
ObjectLock tlock(templatesArray);
BOOST_FOREACH(const Value& tmpl, templatesArray) {
templates.push_back(tmpl);
}
} else {
continue;
}
BOOST_FOREACH(const String& name, templates) {
@ -464,13 +457,12 @@ set<Host::Ptr> Host::GetParentHosts(void) const
{
set<Host::Ptr> parents;
Dictionary::Ptr dependencies = GetHostDependencies();
Array::Ptr dependencies = GetHostDependencies();
if (dependencies) {
ObjectLock olock(dependencies);
Value value;
BOOST_FOREACH(tie(tuples::ignore, value), dependencies) {
BOOST_FOREACH(const Value& value, dependencies) {
if (value == GetName())
continue;
@ -500,13 +492,12 @@ set<Service::Ptr> Host::GetParentServices(void) const
{
set<Service::Ptr> parents;
Dictionary::Ptr dependencies = GetServiceDependencies();
Array::Ptr dependencies = GetServiceDependencies();
if (dependencies) {
ObjectLock olock(dependencies);
Value value;
BOOST_FOREACH(tie(tuples::ignore, value), dependencies) {
BOOST_FOREACH(const Value& value, dependencies) {
parents.insert(GetServiceByShortName(value));
}
}

View File

@ -65,11 +65,11 @@ public:
static Host::Ptr GetByName(const String& name);
String GetDisplayName(void) const;
Dictionary::Ptr GetGroups(void) const;
Array::Ptr GetGroups(void) const;
Dictionary::Ptr GetMacros(void) const;
Dictionary::Ptr GetHostDependencies(void) const;
Dictionary::Ptr GetServiceDependencies(void) const;
Array::Ptr GetHostDependencies(void) const;
Array::Ptr GetServiceDependencies(void) const;
String GetHostCheck(void) const;
Dictionary::Ptr CalculateDynamicMacros(void) const;
@ -102,10 +102,10 @@ protected:
private:
Attribute<String> m_DisplayName;
Attribute<Dictionary::Ptr> m_HostGroups;
Attribute<Array::Ptr> m_HostGroups;
Attribute<Dictionary::Ptr> m_Macros;
Attribute<Dictionary::Ptr> m_HostDependencies;
Attribute<Dictionary::Ptr> m_ServiceDependencies;
Attribute<Array::Ptr> m_HostDependencies;
Attribute<Array::Ptr> m_ServiceDependencies;
Attribute<String> m_HostCheck;
Dictionary::Ptr m_SlaveServices;

View File

@ -155,14 +155,13 @@ void HostGroup::RefreshMembersCache(void)
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Host")) {
const Host::Ptr& host = static_pointer_cast<Host>(object);
Dictionary::Ptr dict;
dict = host->GetGroups();
Array::Ptr groups;
groups = host->GetGroups();
if (dict) {
ObjectLock mlock(dict);
Value hostgroup;
BOOST_FOREACH(tie(tuples::ignore, hostgroup), dict) {
newMembersCache[hostgroup].push_back(host);
if (groups) {
ObjectLock mlock(groups);
BOOST_FOREACH(const Value& group, groups) {
newMembersCache[group].push_back(host);
}
}
}

View File

@ -20,30 +20,14 @@
type Host {
%attribute string "display_name",
%attribute string "hostcheck",
%attribute dictionary "hostgroups" {
%attribute string "*"
},
%attribute dictionary "hostdependencies" {
%attribute string "*"
},
%attribute dictionary "servicedependencies" {
%attribute string "*",
%attribute dictionary "*" {
%require "host",
%attribute string "host",
%require "service",
%attribute string "service"
}
},
%attribute array "hostgroups",
%attribute array "hostdependencies",
%attribute array "servicedependencies",
%attribute dictionary "services" {
%validator "ValidateServiceDictionary",
%attribute string "*",
%attribute dictionary "*" {
%attribute dictionary "templates" {
%attribute string "*"
},
%attribute array "templates",
%attribute string "short_name",
@ -55,46 +39,23 @@ type Host {
%attribute number "check_interval",
%attribute number "retry_interval",
%attribute dictionary "servicegroups" {
%attribute string "*"
},
%attribute dictionary "checkers" {
%attribute string "*"
},
%attribute dictionary "hostdependencies" {
%attribute string "*"
},
%attribute dictionary "servicedependencies" {
%attribute string "*",
%attribute dictionary "*" {
%require "host",
%attribute string "host",
%require "service",
%attribute string "service"
}
}
%attribute array "servicegroups",
%attribute array "checkers",
%attribute array "hostdependencies",
%attribute array "servicedependencies"
}
},
%attribute dictionary "notifications" {
%attribute string "*",
%attribute dictionary "*" {
%attribute dictionary "templates" {
%attribute string "*"
},
%attribute array "templates",
%attribute dictionary "macros" {
%attribute string "*"
},
%attribute dictionary "users" {
%attribute string "*"
},
%attribute dictionary "groups" {
%attribute string "*"
}
%attribute array "users",
%attribute array "groups"
}
},
@ -107,12 +68,8 @@ type Host {
%attribute dictionary "macros" {
%attribute string "*"
},
%attribute dictionary "servicegroups" {
%attribute string "*"
},
%attribute dictionary "checkers" {
%attribute string "*"
}
%attribute array "servicegroups",
%attribute array "checkers"
}
type HostGroup {
@ -141,33 +98,16 @@ type Service {
%attribute dictionary "macros" {
%attribute string "*"
},
%attribute dictionary "check_command" {
%attribute string "_*"
},
%attribute array "check_command",
%attribute string "check_command",
%attribute number "max_check_attempts",
%attribute string "check_period",
%attribute number "check_interval",
%attribute number "retry_interval",
%attribute dictionary "hostdependencies" {
%attribute string "*"
},
%attribute dictionary "servicedependencies" {
%attribute string "*",
%attribute dictionary "*" {
%require "host",
%attribute string "host",
%require "service",
%attribute string "service"
}
},
%attribute dictionary "servicegroups" {
%attribute string "*"
},
%attribute dictionary "checkers" {
%attribute string "*"
},
%attribute array "hostdependencies",
%attribute array "servicedependencies",
%attribute array "servicegroups",
%attribute array "checkers",
%require "methods",
%attribute dictionary "methods" {
@ -176,23 +116,15 @@ type Service {
},
%attribute dictionary "notifications" {
%attribute string "*",
%attribute dictionary "*" {
%attribute dictionary "templates" {
%attribute string "*"
},
%attribute array "templates",
%attribute dictionary "macros" {
%attribute string "*"
},
%attribute dictionary "users" {
%attribute string "*"
},
%attribute dictionary "groups" {
%attribute string "*"
}
%attribute array "users",
%attribute array "groups"
}
},
@ -220,17 +152,10 @@ type Notification {
%attribute string "*"
},
%attribute dictionary "users" {
%attribute string "*"
},
%attribute array "users",
%attribute array "groups",
%attribute dictionary "groups" {
%attribute string "*"
},
%attribute dictionary "notification_command" {
%attribute string "_*"
},
%attribute array "notification_command",
%attribute string "notification_command"
}
@ -241,9 +166,7 @@ type User {
%attribute string "*"
},
%attribute dictionary "groups" {
%attribute string "*"
}
%attribute array "groups"
}
type UserGroup {

View File

@ -32,20 +32,19 @@ Value MacroProcessor::ResolveMacros(const Value& cmd, const Dictionary::Ptr& mac
if (cmd.IsScalar()) {
result = InternalResolveMacros(cmd, macros);
} else if (cmd.IsObjectType<Dictionary>()) {
Dictionary::Ptr resultDict = boost::make_shared<Dictionary>();
Dictionary::Ptr dict = cmd;
} else if (cmd.IsObjectType<Array>()) {
Array::Ptr resultArr = boost::make_shared<Array>();
Array::Ptr arr = cmd;
ObjectLock olock(dict);
ObjectLock olock(arr);
Value arg;
BOOST_FOREACH(tie(tuples::ignore, arg), dict) {
resultDict->Add(InternalResolveMacros(arg, macros));
BOOST_FOREACH(const Value& arg, arr) {
resultArr->Add(InternalResolveMacros(arg, macros));
}
result = resultDict;
result = resultArr;
} else {
BOOST_THROW_EXCEPTION(invalid_argument("Command is not a string or dictionary."));
BOOST_THROW_EXCEPTION(invalid_argument("Command is not a string or array."));
}
return result;

View File

@ -80,7 +80,7 @@ double Service::GetRetryInterval(void) const
/**
* @threadsafety Always.
*/
Dictionary::Ptr Service::GetCheckers(void) const
Array::Ptr Service::GetCheckers(void) const
{
return m_Checkers;
}
@ -560,15 +560,14 @@ String Service::StateTypeToString(StateType type)
*/
bool Service::IsAllowedChecker(const String& checker) const
{
Dictionary::Ptr checkers = GetCheckers();
Array::Ptr checkers = GetCheckers();
if (!checkers)
return true;
ObjectLock olock(checkers);
Value pattern;
BOOST_FOREACH(tie(tuples::ignore, pattern), checkers) {
BOOST_FOREACH(const Value& pattern, checkers) {
if (Utility::Match(pattern, checker))
return true;
}

View File

@ -221,9 +221,6 @@ void Service::UpdateSlaveNotifications(void)
String nfcname;
Value nfcdesc;
BOOST_FOREACH(tie(nfcname, nfcdesc), notificationDescs) {
if (nfcdesc.IsScalar())
nfcname = nfcdesc;
stringstream namebuf;
namebuf << GetName() << "-" << nfcname;
String name = namebuf.str();
@ -236,28 +233,22 @@ void Service::UpdateSlaveNotifications(void)
CopyNotificationAttributes(this, builder);
if (nfcdesc.IsScalar()) {
builder->AddParent(nfcdesc);
} else if (nfcdesc.IsObjectType<Dictionary>()) {
if (!nfcdesc.IsObjectType<Dictionary>())
BOOST_THROW_EXCEPTION(invalid_argument("Notification description must be a dictionary."));
Dictionary::Ptr notification = nfcdesc;
Dictionary::Ptr templates = notification->Get("templates");
Array::Ptr templates = notification->Get("templates");
if (templates) {
ObjectLock tlock(templates);
String tmpl;
BOOST_FOREACH(tie(tuples::ignore, tmpl), templates) {
BOOST_FOREACH(const Value& tmpl, templates) {
builder->AddParent(tmpl);
}
} else {
builder->AddParent(nfcname);
}
CopyNotificationAttributes(notification, builder);
} else {
BOOST_THROW_EXCEPTION(invalid_argument("Notification description must be either a string or a dictionary."));
}
ConfigItem::Ptr notificationItem = builder->Compile();
notificationItem->Commit();

View File

@ -148,7 +148,7 @@ Dictionary::Ptr Service::GetMacros(void) const
/**
* @threadsafety Always.
*/
Dictionary::Ptr Service::GetHostDependencies(void) const
Array::Ptr Service::GetHostDependencies(void) const
{
return m_HostDependencies;
}
@ -156,7 +156,7 @@ Dictionary::Ptr Service::GetHostDependencies(void) const
/**
* @threadsafety Always.
*/
Dictionary::Ptr Service::GetServiceDependencies(void) const
Array::Ptr Service::GetServiceDependencies(void) const
{
return m_ServiceDependencies;
}
@ -164,7 +164,7 @@ Dictionary::Ptr Service::GetServiceDependencies(void) const
/**
* @threadsafety Always.
*/
Dictionary::Ptr Service::GetGroups(void) const
Array::Ptr Service::GetGroups(void) const
{
return m_ServiceGroups;
}
@ -381,14 +381,13 @@ set<Host::Ptr> Service::GetParentHosts(void) const
if (host)
parents.insert(host);
Dictionary::Ptr dependencies = GetHostDependencies();
Array::Ptr dependencies = GetHostDependencies();
if (dependencies) {
ObjectLock olock(dependencies);
String key;
BOOST_FOREACH(tie(key, tuples::ignore), dependencies) {
Host::Ptr host = Host::GetByName(key);
BOOST_FOREACH(const Value& dependency, dependencies) {
Host::Ptr host = Host::GetByName(dependency);
if (!host)
continue;
@ -408,13 +407,11 @@ set<Service::Ptr> Service::GetParentServices(void) const
set<Service::Ptr> parents;
Host::Ptr host = GetHost();
Dictionary::Ptr dependencies = GetServiceDependencies();
Array::Ptr dependencies = GetServiceDependencies();
if (host && dependencies) {
String key;
Value value;
BOOST_FOREACH(tie(key, value), dependencies) {
Service::Ptr service = host->GetServiceByShortName(value);
BOOST_FOREACH(const Value& dependency, dependencies) {
Service::Ptr service = host->GetServiceByShortName(dependency);
if (!service)
continue;

View File

@ -89,9 +89,9 @@ public:
String GetDisplayName(void) const;
Host::Ptr GetHost(void) const;
Dictionary::Ptr GetMacros(void) const;
Dictionary::Ptr GetHostDependencies(void) const;
Dictionary::Ptr GetServiceDependencies(void) const;
Dictionary::Ptr GetGroups(void) const;
Array::Ptr GetHostDependencies(void) const;
Array::Ptr GetServiceDependencies(void) const;
Array::Ptr GetGroups(void) const;
String GetHostName(void) const;
String GetShortName(void) const;
@ -107,7 +107,7 @@ public:
void SetAcknowledgement(AcknowledgementType acknowledgement);
/* Checks */
Dictionary::Ptr GetCheckers(void) const;
Array::Ptr GetCheckers(void) const;
Value GetCheckCommand(void) const;
long GetMaxCheckAttempts(void) const;
TimePeriod::Ptr GetCheckPeriod(void) const;
@ -254,9 +254,9 @@ private:
Attribute<String> m_DisplayName;
Attribute<Dictionary::Ptr> m_Macros;
Attribute<Dictionary::Ptr> m_HostDependencies;
Attribute<Dictionary::Ptr> m_ServiceDependencies;
Attribute<Dictionary::Ptr> m_ServiceGroups;
Attribute<Array::Ptr> m_HostDependencies;
Attribute<Array::Ptr> m_ServiceDependencies;
Attribute<Array::Ptr> m_ServiceGroups;
Attribute<String> m_ShortName;
Attribute<long> m_Acknowledgement;
Attribute<double> m_AcknowledgementExpiry;
@ -269,7 +269,7 @@ private:
Attribute<double> m_CheckInterval;
Attribute<double> m_RetryInterval;
Attribute<double> m_NextCheck;
Attribute<Dictionary::Ptr> m_Checkers;
Attribute<Array::Ptr> m_Checkers;
Attribute<String> m_CurrentChecker;
Attribute<long> m_CheckAttempt;
Attribute<long> m_State;

View File

@ -155,14 +155,12 @@ void ServiceGroup::RefreshMembersCache(void)
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Service")) {
const Service::Ptr& service = static_pointer_cast<Service>(object);
Dictionary::Ptr dict;
dict = service->GetGroups();
Array::Ptr groups = service->GetGroups();
if (dict) {
ObjectLock mlock(dict);
Value servicegroup;
BOOST_FOREACH(tie(tuples::ignore, servicegroup), dict) {
newMembersCache[servicegroup].push_back(service);
if (groups) {
ObjectLock mlock(groups);
BOOST_FOREACH(const Value& group, groups) {
newMembersCache[group].push_back(service);
}
}
}

View File

@ -71,7 +71,7 @@ String User::GetDisplayName(void) const
/**
* @threadsafety Always.
*/
Dictionary::Ptr User::GetGroups(void) const
Array::Ptr User::GetGroups(void) const
{
return m_Groups;
}

View File

@ -40,7 +40,7 @@ public:
static User::Ptr GetByName(const String& name);
String GetDisplayName(void) const;
Dictionary::Ptr GetGroups(void) const;
Array::Ptr GetGroups(void) const;
Dictionary::Ptr GetMacros(void) const;
Dictionary::Ptr CalculateDynamicMacros(void) const;
@ -51,7 +51,7 @@ protected:
private:
Attribute<String> m_DisplayName;
Attribute<Dictionary::Ptr> m_Macros;
Attribute<Dictionary::Ptr> m_Groups;
Attribute<Array::Ptr> m_Groups;
};
}

View File

@ -137,14 +137,12 @@ void UserGroup::RefreshMembersCache(void)
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("User")) {
const User::Ptr& user = static_pointer_cast<User>(object);
Dictionary::Ptr dict;
dict = user->GetGroups();
Array::Ptr groups = user->GetGroups();
if (dict) {
ObjectLock mlock(dict);
Value UserGroup;
BOOST_FOREACH(tie(tuples::ignore, UserGroup), dict) {
newMembersCache[UserGroup].push_back(user);
if (groups) {
ObjectLock mlock(groups);
BOOST_FOREACH(const Value& group, groups) {
newMembersCache[group].push_back(user);
}
}
}