/
exec_generate_config.php.patch
76 lines (73 loc) · 3.05 KB
/
exec_generate_config.php.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--- exec_generate_config.php.orig 2012-05-08 12:16:03.607988620 +0200
+++ exec_generate_config.php 2012-05-08 13:40:52.848160516 +0200
@@ -52,15 +52,23 @@
// check if the Nagios / Icinga binary is executable
exec(NAGIOS_BIN,$bin_out);
- if(!preg_match('/Nagios|Icinga/',implode(' ',$bin_out))){
- $content = "Error accessing or executing Nagios / Icinga binary '".NAGIOS_BIN."'. <br>Cannot run the mandatory syntax check.";
+ $engine = "nagios";
+ if(!preg_match('/Nagios|Icinga|Shinken/',implode(' ',$bin_out))){
+
+ $content = "Error accessing or executing Nagios / Icinga / Shinken binary '".NAGIOS_BIN."'. <br>Cannot run the mandatory syntax check.";
NConf_DEBUG::set($content, 'ERROR');
echo NConf_HTML::limit_space(
NConf_HTML::show_error('Error')
);
remove_lock();
exit;
- }
+ }else{
+ if (preg_match('/Shinken/',implode(' ',$bin_out))){
+ $engine = "shinken";
+ }else{
+ $engine = "nagios";
+ }
+ }
// check if existing "output/NagiosConfig.tgz" is writable
if(file_exists(NCONFDIR."/output/NagiosConfig.tgz" and !is_writable(NCONFDIR."/output/NagiosConfig.tgz"))){
@@ -103,7 +111,7 @@
$renamed = preg_replace('/-|\s/','_',$entry["attr_value"]);
if($entry["config_class"] == 'nagios-collector'){
- $renamed = preg_replace('/Nagios|Icinga/i','collector',$renamed);
+ $renamed = preg_replace('/Nagios|Icinga|Shinken/i','collector',$renamed);
}
array_push($servers, $renamed);
}
@@ -177,14 +185,24 @@
$count=0;
$i = 0;
foreach($srv_summary[$server] as $line){
- if( preg_match("/^Total/",$line) ){
- # add splitter between messages
+ if ($engine == "shinken"){
$total_msg .= ( $i > 0 ) ? $break : '';
$i++;
$total_msg .= $line;
$count++;
- if( preg_match("/Errors/",$line) && !preg_match('/Total Errors:\s+0/',$line)){
- $status = "error";
+ if( preg_match("/Error/",$line)){
+ $status = "error";
+ }
+ }else{
+ if( preg_match("/^Total/",$line) ){
+ # add splitter between messages
+ $total_msg .= ( $i > 0 ) ? $break : '';
+ $i++;
+ $total_msg .= $line;
+ $count++;
+ if( preg_match("/Errors/",$line) && !preg_match('/Total Errors:\s+0/',$line)){
+ $status = "error";
+ }
}
}
}
@@ -271,7 +289,7 @@
}
// Remove generated config
system("rm -rf ".NCONFDIR."/temp/*");
- $content = "Deployment not possible due to errors in configuration.";
+ $content = "Deployment not possible due to errors in configuration. (".$engine.")";
echo NConf_HTML::limit_space(
NConf_HTML::show_error('Error', $content)
);