Subversion Repositories oidplus

Rev

Rev 1180 | Rev 1189 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1180 Rev 1182
Line 74... Line 74...
74
 
74
 
75
                        $notifications_by_sev = array();
75
                        $notifications_by_sev = array();
76
 
76
 
77
                        foreach (OIDplus::getAllPlugins() as $plugin) {
77
                        foreach (OIDplus::getAllPlugins() as $plugin) {
78
                                if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8) {
78
                                if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8) {
-
 
79
                                        try {
79
                                        $notifications = $plugin->getNotifications($ra_email);
80
                                                $notifications = $plugin->getNotifications($ra_email);
-
 
81
                                        } catch (\Exception $e) {
-
 
82
                                                $notifications = array(
-
 
83
                                                        ['CRIT', _L('The plugin %1 crashed during the notification-check. Message: %2', get_class($plugin), $e->getMessage())]
-
 
84
                                                );
-
 
85
                                        }
80
                                        if ($notifications) {
86
                                        if ($notifications) {
81
                                                foreach ($notifications as $notification) {
87
                                                foreach ($notifications as $notification) {
82
                                                        list($severity, $htmlMessage) = $notification;
88
                                                        list($severity, $htmlMessage) = $notification;
83
 
89
 
84
                                                        // Same severities as the log plugin (also same CSS classes)
90
                                                        // Same severities as the log plugin (also same CSS classes)
85
                                                        if ($severity == 'OK')   $severity = 1; // (this makes no sense)
91
                                                        if ($severity == 'OK')   $severity = 1; // (this makes no sense)
86
                                                        if ($severity == 'INFO') $severity = 2;
92
                                                        else if ($severity == 'INFO') $severity = 2;
87
                                                        if ($severity == 'WARN') $severity = 3;
93
                                                        else if ($severity == 'WARN') $severity = 3;
88
                                                        if ($severity == 'ERR')  $severity = 4;
94
                                                        else if ($severity == 'ERR')  $severity = 4;
89
                                                        if ($severity == 'CRIT') $severity = 5;
95
                                                        else if ($severity == 'CRIT') $severity = 5;
-
 
96
                                                        else {
-
 
97
                                                                $htmlMessage = _L('The plugin %1 returned an invalid severity (%2). Message: %3', get_class($plugin), $severity, $htmlMessage);
-
 
98
                                                                $severity = 5; // CRIT
-
 
99
                                                        }
90
 
100
 
91
                                                        if (!isset($notifications_by_sev[$severity])) $notifications_by_sev[$severity] = array();
101
                                                        if (!isset($notifications_by_sev[$severity])) $notifications_by_sev[$severity] = array();
92
                                                        $notifications_by_sev[$severity][] = $htmlMessage;
102
                                                        $notifications_by_sev[$severity][] = $htmlMessage;
93
                                                }
103
                                                }
94
                                        }
104
                                        }
Line 108... Line 118...
108
                                        if ($severity == 1) $sev_hf = _L('OK');
118
                                        if ($severity == 1) $sev_hf = _L('OK');
109
                                        else if ($severity == 2) $sev_hf = _L('Informational');
119
                                        else if ($severity == 2) $sev_hf = _L('Informational');
110
                                        else if ($severity == 3) $sev_hf = _L('Warnings');
120
                                        else if ($severity == 3) $sev_hf = _L('Warnings');
111
                                        else if ($severity == 4) $sev_hf = _L('Errors');
121
                                        else if ($severity == 4) $sev_hf = _L('Errors');
112
                                        else if ($severity == 5) $sev_hf = _L('Critical issues');
122
                                        else if ($severity == 5) $sev_hf = _L('Critical issues');
113
                                        else $sev_hf = _L('Severity %1', $severity-1); // TODO: actually, this should raise an Exception?
123
                                        else assert(false);
114
 
124
 
115
                                        $out['text'] .= '<h2><span class="severity_'.$severity.'">'.$sev_hf.' ('.count($htmlMessages).')</span></h2>';
125
                                        $out['text'] .= '<h2><span class="severity_'.$severity.'">'.$sev_hf.' ('.count($htmlMessages).')</span></h2>';
116
                                        $out['text'] .= '<span class="severity_'.$severity.'"><ol>';
126
                                        $out['text'] .= '<span class="severity_'.$severity.'"><ol>';
117
                                        foreach ($htmlMessages as $htmlMessage) {
127
                                        foreach ($htmlMessages as $htmlMessage) {
118
                                                $out['text'] .= '<li>'.$htmlMessage.'</li>';
128
                                                $out['text'] .= '<li>'.$htmlMessage.'</li>';
Line 166... Line 176...
166
         * @return false|string
176
         * @return false|string
167
         * @throws OIDplusException
177
         * @throws OIDplusException
168
         */
178
         */
169
        private function webAccessWorks(string $dir) {
179
        private function webAccessWorks(string $dir) {
170
                $url = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).$dir;
180
                $url = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).$dir;
-
 
181
                $require_ssl = str_starts_with(strtolower($url),'https:');
-
 
182
                if (!url_get_contents_available($require_ssl)) return false;
171
                $access_worked = url_get_contents($url) !== false;
183
                $access_worked = url_get_contents($url) !== false;
172
                if ($access_worked) return $url;
184
                if ($access_worked) return $url;
173
 
185
 
174
                if (!$access_worked) {
186
                if (!$access_worked) {
175
                        $url_alt = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE).$dir;
187
                        $url_alt = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE).$dir;