Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
*.swp
.DS_Store
locales/po/*.mo
.omc/
26 changes: 14 additions & 12 deletions includes/arrays.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2025 The Cacti Group |
Expand Down Expand Up @@ -73,7 +75,7 @@
'mqtt_mqtt' => __('MQTT plaintext, default port 1883', 'servcheck'),
);

$service_types_ports = array(
$service_types_ports = [

'web_http' => 80,
'web_https' => 443,
Expand Down Expand Up @@ -106,7 +108,7 @@

// 'telnet_telnet' => 23,
'mqtt_mqtt' => 1883,
);
];


$graph_interval = array (
Expand Down Expand Up @@ -186,10 +188,10 @@
10 => __('%d Seconds', 10, 'servcheck'),
);

$servcheck_notify_formats = array(
$servcheck_notify_formats = [
SERVCHECK_FORMAT_HTML => 'html',
SERVCHECK_FORMAT_PLAIN => 'plain',
);
];

if (db_table_exists('plugin_servcheck_contacts')) {
$servcheck_contact_users = db_fetch_assoc("SELECT pwc.id, pwc.data, pwc.type, ua.full_name
Expand All @@ -198,10 +200,10 @@
ON ua.id=pwc.user_id
WHERE pwc.data != ''");
} else {
$servcheck_contact_users = array();
$servcheck_contact_users = [];
}

$servcheck_notify_accounts = array();
$servcheck_notify_accounts = [];
if (!empty($servcheck_contact_users)) {
foreach ($servcheck_contact_users as $servcheck_contact_user) {
$servcheck_notify_accounts[$servcheck_contact_user['id']] = $servcheck_contact_user['full_name'] . ' - ' . ucfirst($servcheck_contact_user['type']);
Expand Down Expand Up @@ -298,14 +300,14 @@
'size' => '40',
'default' => ''
),
'id' => array(
'id' => [
'method' => 'hidden_zero',
'value' => '|arg1:id|'
),
'save_component_proxy' => array(
],
'save_component_proxy' => [
'method' => 'hidden',
'value' => '1'
)
]
);

$servcheck_test_fields = array(
Expand Down Expand Up @@ -542,10 +544,10 @@
'max_length' => '20',
'value' => '|arg1:external_id|',
),
'id' => array(
'id' => [
'method' => 'hidden_zero',
'value' => '|arg1:id|'
),
],
);

$curl_error = array(
Expand Down
2 changes: 2 additions & 0 deletions includes/constants.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2025 The Cacti Group |
Expand Down
40 changes: 21 additions & 19 deletions includes/functions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2025 The Cacti Group |
Expand Down Expand Up @@ -65,7 +67,7 @@ function servcheck_show_tab($current_tab) {
function plugin_servcheck_remove_old_users () {
$users = db_fetch_assoc('SELECT id FROM user_auth');

$u = array();
$u = [];

foreach ($users as $user) {
$u[] = $user['id'];
Expand All @@ -75,7 +77,7 @@ function plugin_servcheck_remove_old_users () {

foreach ($contacts as $c) {
if (!in_array($c['user_id'], $u)) {
db_execute_prepared('DELETE FROM plugin_servcheck_contacts WHERE user_id = ?', array($c['user_id']));
db_execute_prepared('DELETE FROM plugin_servcheck_contacts WHERE user_id = ?', [$c['user_id']]);
}
}
}
Expand Down Expand Up @@ -124,7 +126,7 @@ function plugin_servcheck_graph ($id, $interval) {
FROM plugin_servcheck_log
WHERE test_id = ? AND
lastcheck > DATE_SUB(NOW(), INTERVAL ? HOUR)
ORDER BY id", array($id, $interval));
ORDER BY id", [$id, $interval]);

if (cacti_sizeof($result) < 5) {
print __('No data', 'servcheck');
Expand All @@ -144,44 +146,44 @@ function plugin_servcheck_graph ($id, $interval) {
// Start chart attributes
$chart = array(
'bindto' => "#line_$xid",
'size' => array(
'size' => [
'height' => 300,
'width'=> 600
),
'point' => array (
],
'point' => [
'r' => 1.5
),
'data' => array(
],
'data' => [
'type' => 'area',
'x' => 'x',
'xFormat' => '%Y-%m-%d %H:%M:%S' // rikam mu, jaky je format te timeserie
)
]
);

$columns = array();
$axis = array();
$axes = array();
$columns = [];
$axis = [];
$axes = [];

// Add the X Axis first
$columns[] = array_merge(array('x'), $lastcheck);
$columns[] = array_merge(array('Total'), $total_time);
$columns[] = array_merge(array('Connect'), $connect_time);
$columns[] = array_merge(array('DNS '), $namelookup_time);
$columns[] = array_merge(['x'], $lastcheck);
$columns[] = array_merge(['Total'], $total_time);
$columns[] = array_merge(['Connect'], $connect_time);
$columns[] = array_merge(['DNS '], $namelookup_time);

// Setup the Axis
$axis['x'] = array(
'type' => 'timeseries',
'tick' => array(
'format'=> '%m-%d %H:%M',
'culling' => array('max' => 6),
'culling' => ['max' => 6],
)
);

$axis['y'] = array(
'tick' => array(
'label' => array(
'label' => [
'text' => 'Response in ms',
),
],
'show' => true
)
);
Expand Down
2 changes: 2 additions & 0 deletions includes/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2025 The Cacti Group |
Expand Down
8 changes: 5 additions & 3 deletions includes/mxlookup.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2025 The Cacti Group |
Expand Down Expand Up @@ -28,7 +30,7 @@ class mxlookup {
var $dns_packet = NULL;
var $ANCOUNT = 0;
var $cIx = 0;
var $arrMX = array();
var $arrMX = [];
var $dns_repl_domain;
var $dns_reply = '';

Expand Down Expand Up @@ -68,7 +70,7 @@ function __construct($domain, $dns = '4.2.2.1') {

//$mxPref = ord($this->gdi($this->cIx));
//$this->parse_data($curmx);
//$this->arrMX[] = array('MX_Pref' => $mxPref, 'MX' => $curmx);
//$this->arrMX[] = ['MX_Pref' => $mxPref, 'MX' => $curmx];
//$this->cIx += 3;
}
}
Expand All @@ -78,7 +80,7 @@ function __destruct() {
}

function parse_data(&$retval) {
$arName = array();
$arName = [];
$byte = ord($this->gdi($this->cIx));

while($byte !== 0) {
Expand Down
38 changes: 20 additions & 18 deletions includes/tests.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2025 The Cacti Group |
Expand Down Expand Up @@ -28,23 +30,23 @@
function curl_try ($test) {
global $user_agent, $config, $ca_info, $service_types_ports;

$cert_info = array();
$cert_info = [];

// default result
$results['result'] = 'ok';
$results['time'] = time();
$results['error'] = '';
$results['result_search'] = 'not tested';

$options = array(
$options = [
CURLOPT_HEADER => true,
CURLOPT_USERAGENT => $user_agent,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 4,
CURLOPT_TIMEOUT => $test['timeout_trigger'],
CURLOPT_CAINFO => $ca_info,
);
];

if (($test['type'] == 'web_http' || $test['type'] == 'web_https') && empty($test['path'])) {
cacti_log('Empty path, nothing to test');
Expand Down Expand Up @@ -116,7 +118,7 @@ function curl_try ($test) {
plugin_servcheck_debug('Preparing own CA chain file ' . $ca_info , $test);

$cert = db_fetch_cell_prepared('SELECT cert FROM plugin_servcheck_ca WHERE id = ?',
array($test['ca']));
[$test['ca']]);

$cert_file = fopen($ca_info, 'a');
if ($cert_file) {
Expand All @@ -139,7 +141,7 @@ function curl_try ($test) {
$proxy = db_fetch_row_prepared('SELECT *
FROM plugin_servcheck_proxies
WHERE id = ?',
array($test['proxy_server']));
[$test['proxy_server']]);

if (cacti_sizeof($proxy)) {
$options[CURLOPT_PROXY] = $proxy['hostname'];
Expand Down Expand Up @@ -190,12 +192,12 @@ function curl_try ($test) {

plugin_servcheck_debug('cURL options: ' . clean_up_lines(var_export($options, true)));

curl_setopt_array($process,$options);
curl_setopt_array($process, $options);

plugin_servcheck_debug('Executing curl request', $test);

$data = curl_exec($process);
$data = str_replace(array("'", "\\"), array(''), $data);
$data = str_replace(["'", "\\"], [''], $data);
$results['data'] = $data;

// Get information regarding a specific transfer, cert info too
Expand All @@ -208,7 +210,7 @@ function curl_try ($test) {
plugin_servcheck_debug('Data: ' . clean_up_lines(var_export($data, true)));

if ($results['curl_return'] > 0) {
$results['error'] = str_replace(array('"', "'"), '', (curl_error($process)));
$results['error'] = str_replace(['"', "'"], '', (curl_error($process)));
}

if ($test['ca'] > 0) {
Expand Down Expand Up @@ -419,14 +421,14 @@ function mqtt_try ($test) {

plugin_servcheck_debug('cURL options: ' . clean_up_lines(var_export($options, true)));

curl_setopt_array($process,$options);
curl_setopt_array($process, $options);

plugin_servcheck_debug('Executing curl request', $test);

curl_exec($process);
$x = fclose($file);

$data = str_replace(array("'", "\\"), array(''), file_get_contents($filename));
$data = str_replace(["'", "\\"], [''], file_get_contents($filename));
$results['data'] = $data;

// Get information regarding a specific transfer
Expand All @@ -442,7 +444,7 @@ function mqtt_try ($test) {
if ($results['curl_return'] == 42) {
$results['curl_return'] = 0;
} elseif ($results['curl_return'] > 0) {
$results['error'] = str_replace(array('"', "'"), '', (curl_error($process)));
$results['error'] = str_replace(['"', "'"], '', (curl_error($process)));
}

curl_close($process);
Expand Down Expand Up @@ -506,23 +508,23 @@ function mqtt_try ($test) {
function doh_try ($test) {
global $user_agent, $config, $ca_info, $service_types_ports;

$cert_info = array();
$cert_info = [];

// default result
$results['result'] = 'ok';
$results['time'] = time();
$results['error'] = '';
$results['result_search'] = 'not tested';

$options = array(
$options = [
CURLOPT_HEADER => true,
CURLOPT_USERAGENT => $user_agent,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 4,
CURLOPT_TIMEOUT => $test['timeout_trigger'],
CURLOPT_CAINFO => $ca_info,
);
];

if (empty($test['hostname']) || empty($test['dns_query'])) {
cacti_log('Empty hsotname or dns_query, nothing to test');
Expand All @@ -548,7 +550,7 @@ function doh_try ($test) {
plugin_servcheck_debug('Preparing own CA chain file ' . $ca_info , $test);

$cert = db_fetch_cell_prepared('SELECT cert FROM plugin_servcheck_ca WHERE id = ?',
array($test['ca']));
[$test['ca']]);

$cert_file = fopen($ca_info, 'a');
if ($cert_file) {
Expand Down Expand Up @@ -577,12 +579,12 @@ function doh_try ($test) {

plugin_servcheck_debug('cURL options: ' . clean_up_lines(var_export($options, true)));

curl_setopt_array($process,$options);
curl_setopt_array($process, $options);

plugin_servcheck_debug('Executing curl request', $test);

$data = curl_exec($process);
$data = str_replace(array("'", "\\"), array(''), $data);
$data = str_replace(["'", "\\"], [''], $data);
$results['data'] = $data;

// Get information regarding a specific transfer, cert info too
Expand All @@ -595,7 +597,7 @@ function doh_try ($test) {
plugin_servcheck_debug('Data: ' . clean_up_lines(var_export($data, true)));

if ($results['curl_return'] > 0) {
$results['error'] = str_replace(array('"', "'"), '', (curl_error($process)));
$results['error'] = str_replace(['"', "'"], '', (curl_error($process)));
}

if ($test['ca'] > 0) {
Expand Down
2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2025 The Cacti Group |
Expand Down
Loading