Skip to content

Commit

Permalink
Fixing #5203 - Script Server fail
Browse files Browse the repository at this point in the history
Scripts ss_net_snmp_device_io.php and ss_net_snmp_device_bytes.php break when using HMIB plugin and PHP8.1
  • Loading branch information
TheWitness committed Jan 28, 2023
1 parent f8f5de6 commit 377831e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Cacti CHANGELOG
-issue#5199: Failures to call fgets generate errors in the Cacti.log
-issue#5200: Cacti function throws errors when attempting to render classic images in PHP8
-issue#5201: Minor issues in modern and dark prevent weathermaps from rendering correctly
-issue#5203: Scripts ss_net_snmp_device_io.php and ss_net_snmp_device_bytes.php break when using HMIB plugin and PHP8.1

1.2.23
-security#4920: Add .htaccess file to scripts folder
Expand Down
24 changes: 20 additions & 4 deletions scripts/ss_net_snmp_disk_bytes.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,17 @@ function ss_net_snmp_disk_bytes($host_id_or_hostname = '') {
} elseif (!isset($previous["br$index"])) {
$bytesread = 'U';
} elseif ($previous["br$index"] > $measure['value']) {
$bytesread += $measure['value'] + 18446744073709551615 - $previous["br$index"] - $previous["br$index"];
if ($bytesread != 'U') {
$bytesread += $measure['value'] + 18446744073709551615 - $previous["br$index"] - $previous["br$index"];
} else {
$bytesread = $measure['value'] + 18446744073709551615 - $previous["br$index"] - $previous["br$index"];
}
} else {
$bytesread += $measure['value'] - $previous["br$index"];
if ($bytesread != 'U') {
$bytesread += $measure['value'] - $previous["br$index"];
} else {
$bytesread = $measure['value'] - $previous["br$index"];
}
}

$current["br$index"] = $measure['value'];
Expand Down Expand Up @@ -198,9 +206,17 @@ function ss_net_snmp_disk_bytes($host_id_or_hostname = '') {
} elseif (!isset($previous["bw$index"])) {
$byteswritten = 'U';
} elseif ($previous["bw$index"] > $measure['value']) {
$byteswritten += $measure['value'] + 18446744073709551615 - $previous["bw$index"] - $previous["bw$index"];
if ($byteswritten != 'U') {
$byteswritten += $measure['value'] + 18446744073709551615 - $previous["bw$index"] - $previous["bw$index"];
} else {
$byteswritten = $measure['value'] + 18446744073709551615 - $previous["bw$index"] - $previous["bw$index"];
}
} else {
$byteswritten += $measure['value'] - $previous["bw$index"];
if ($byteswritten != 'U') {
$byteswritten += $measure['value'] - $previous["bw$index"];
} else {
$byteswritten = $measure['value'] - $previous["bw$index"];
}
}

$current["bw$index"] = $measure['value'];
Expand Down
24 changes: 20 additions & 4 deletions scripts/ss_net_snmp_disk_io.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,17 @@ function ss_net_snmp_disk_io($host_id_or_hostname = '') {
} elseif (!isset($previous["dr$index"])) {
$reads = 'U';
} elseif ($previous["dr$index"] > $measure['value']) {
$reads += $measure['value'] + 4294967295 - $previous["dr$index"] - $previous["dr$index"];
if ($reads != 'U') {
$reads += intval($measure['value']) + 4294967295 - intval($previous["dr$index"]) - intval($previous["dr$index"]);
} else {
$reads = intval($measure['value']) + 4294967295 - intval($previous["dr$index"]) - intval($previous["dr$index"]);
}
} else {
$reads += $measure['value'] - $previous["dr$index"];
if ($reads != 'U') {
$reads += $measure['value'] - $previous["dr$index"];
} else {
$reads = $measure['value'] - $previous["dr$index"];
}
}

$current["dr$index"] = $measure['value'];
Expand Down Expand Up @@ -197,9 +205,17 @@ function ss_net_snmp_disk_io($host_id_or_hostname = '') {
} elseif (!isset($previous["dw$index"])) {
$writes = 'U';
} elseif ($previous["dw$index"] > $measure['value']) {
$writes += $measure['value'] + 4294967295 - $previous["dw$index"] - $previous["dw$index"];
if ($writes != 'U') {
$writes += $measure['value'] + 4294967295 - $previous["dw$index"] - $previous["dw$index"];
} else {
$writes = $measure['value'] + 4294967295 - $previous["dw$index"] - $previous["dw$index"];
}
} else {
$writes += $measure['value'] - $previous["dw$index"];
if ($writes != 'U') {
$writes += $measure['value'] - $previous["dw$index"];
} else {
$writes = $measure['value'] - $previous["dw$index"];
}
}

$current["dw$index"] = $measure['value'];
Expand Down

0 comments on commit 377831e

Please sign in to comment.