Skip to content

Commit de02447

Browse files
authored
Uptime Robot Changes
1 parent 418a883 commit de02447

3 files changed

Lines changed: 39 additions & 17 deletions

File tree

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# EngineScript Uptime Robot Configuration
2-
#
3-
# This file contains the configuration for Uptime Robot API integration
4-
# Get your API key from UptimeRobot dashboard Settings > API Settings
5-
# Create a main API key for integration
6-
#
7-
# Security: This file contains sensitive information
8-
# Ensure proper file permissions: chmod 600 /etc/enginescript/uptimerobot.conf
1+
; EngineScript Uptime Robot Configuration
2+
;
3+
; This file contains the configuration for Uptime Robot API integration
4+
; Get your API key from UptimeRobot dashboard Settings > API Settings
5+
; Create a main API key for integration
6+
;
7+
; Security: This file contains sensitive information
8+
; Ensure proper file permissions: chmod 600 /etc/enginescript/uptimerobot.conf
99

10-
# Your Uptime Robot Main API Key
11-
# Format: api_key=m123456789-abcdef1234567890abcdef12
12-
# Will be populated from main credentials file during installation
10+
; Your Uptime Robot Main API Key
11+
; Format: api_key=m123456789-abcdef1234567890abcdef12
12+
; Will be populated from main credentials file during installation
1313
api_key=
1414

15-
# Optional: Monitor refresh interval in seconds (default: 300)
16-
# refresh_interval=300
15+
; Optional: Monitor refresh interval in seconds (default: 300)
16+
; refresh_interval=300
1717

18-
# Optional: Maximum number of monitors to display (default: 50)
19-
# max_monitors=50
18+
; Optional: Maximum number of monitors to display (default: 50)
19+
; max_monitors=50

config/var/www/admin/control-panel/classes/UptimeRobotAPI.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,21 @@ private function makeRequest($endpoint, array $params = [])
169169
// codacy:ignore - curl_close() required for cleanup
170170
curl_close($curlHandle);
171171

172+
// DEBUG: Log raw response
173+
error_log("UptimeRobotAPI: HTTP Code: " . $httpCode);
174+
error_log("UptimeRobotAPI: Response: " . substr($response, 0, 500)); // First 500 chars
175+
172176
// Check for cURL errors
173177
if ($response === false) {
174178
$this->logError('cURL request failed', ['error' => $error]);
179+
error_log("UptimeRobotAPI: cURL ERROR - " . $error);
175180
return false;
176181
}
177182

178183
// Check HTTP status code
179184
if ($httpCode !== 200) {
180185
$this->logError('API returned non-200 status', ['http_code' => $httpCode]);
186+
error_log("UptimeRobotAPI: Non-200 HTTP code - " . $httpCode);
181187
return false;
182188
}
183189

@@ -186,9 +192,11 @@ private function makeRequest($endpoint, array $params = [])
186192

187193
if (json_last_error() !== JSON_ERROR_NONE) {
188194
$this->logError('Invalid JSON response', ['error' => json_last_error_msg()]);
195+
error_log("UptimeRobotAPI: JSON decode error - " . json_last_error_msg());
189196
return false;
190197
}
191198

199+
error_log("UptimeRobotAPI: Successful response, stat: " . ($decoded['stat'] ?? 'unknown'));
192200
return $decoded;
193201
}
194202

config/var/www/admin/control-panel/controllers/UptimeController.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,20 @@ private function getUptimeApi()
4444
if (file_exists($configPath)) {
4545
// codacy:ignore - parse_ini_file() required for config parsing in standalone service
4646
$config = parse_ini_file($configPath);
47-
if ($config && !empty($config['api_key'])) {
48-
$this->uptimeApi = new UptimeRobotAPI($config['api_key']);
47+
48+
// Debug logging
49+
error_log("UptimeRobot config parse result: " . print_r($config, true));
50+
51+
if ($config && isset($config['api_key']) && !empty(trim($config['api_key']))) {
52+
error_log("UptimeRobot API key found: " . substr(trim($config['api_key']), 0, 10) . "...");
53+
$this->uptimeApi = new UptimeRobotAPI(trim($config['api_key']));
54+
} else {
55+
error_log("UptimeRobot API key validation failed - config: " . ($config ? 'exists' : 'false') .
56+
", isset: " . (isset($config['api_key']) ? 'yes' : 'no') .
57+
", empty: " . (isset($config['api_key']) ? (empty(trim($config['api_key'])) ? 'yes' : 'no') : 'n/a'));
4958
}
59+
} else {
60+
error_log("UptimeRobot config file not found at: " . $configPath);
5061
}
5162
}
5263
return $this->uptimeApi;
@@ -75,6 +86,7 @@ public function getStatus()
7586
$api = $this->getUptimeApi();
7687

7788
if (!$api) {
89+
error_log("UptimeController: API instance is null");
7890
$result = [
7991
'enabled' => false,
8092
'reason' => 'UptimeRobot API not configured'
@@ -84,7 +96,9 @@ public function getStatus()
8496
return;
8597
}
8698

99+
error_log("UptimeController: About to call getMonitors()");
87100
$monitors = $api->getMonitors();
101+
error_log("UptimeController: getMonitors() returned: " . ($monitors === false ? 'FALSE' : (is_array($monitors) ? count($monitors) . ' monitors' : 'unknown')));
88102

89103
if (!$monitors) {
90104
$result = [

0 commit comments

Comments
 (0)