Skip to content

Commit

Permalink
Revert^2 "bigip: initiate all counters the first time round"
Browse files Browse the repository at this point in the history
This reverts commit 5276b32.

Reason for revert: test-plugins has been fixed. See change ID Ice0745182f096275e58dc72c4be80582fccee891

Change-Id: Iec59b4009f17d408694238e56f86c7fd1f2d6da1
  • Loading branch information
MatteoStifano committed Jan 22, 2025
1 parent 0c4eede commit a18a547
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
7 changes: 4 additions & 3 deletions cmk/base/legacy_checks/f5_bigip_conns.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ def inventory_f5_bigip_conns(info):
def check_f5_bigip_conns(item, params, info): # pylint: disable=too-many-branches
# Connection rate
now = time.time()
value_store = get_value_store()
total_native_compat_rate = 0.0
conns_dict = {}

for line in info:
if line[2] != "":
native_conn_rate = get_rate(
get_value_store(), "native", now, int(line[2]), raise_overflow=True
value_store, "native", now, int(line[2]), raise_overflow=True
)
else:
native_conn_rate = 0

if line[3] != "":
compat_conn_rate = get_rate(
get_value_store(), "compat", now, int(line[3]), raise_overflow=True
value_store, "compat", now, int(line[3]), raise_overflow=True
)
else:
compat_conn_rate = 0
Expand All @@ -47,7 +48,7 @@ def check_f5_bigip_conns(item, params, info): # pylint: disable=too-many-branch

if line[4] != "":
stat_http_req_rate = get_rate(
get_value_store(), "stathttpreqs", now, int(line[4]), raise_overflow=True
value_store, "stathttpreqs", now, int(line[4]), raise_overflow=True
)
else:
stat_http_req_rate = None
Expand Down
41 changes: 25 additions & 16 deletions cmk/base/legacy_checks/f5_bigip_vserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from cmk.base.check_legacy_includes.f5_bigip import DETECT

from cmk.agent_based.legacy.v0_unstable import check_levels, LegacyCheckDefinition
from cmk.agent_based.v2 import get_rate, get_value_store, render, SNMPTree
from cmk.agent_based.v2 import get_rate, get_value_store, GetRateError, render, SNMPTree

check_info = {}

Expand Down Expand Up @@ -104,26 +104,35 @@ def inventory_f5_bigip_vserver(parsed):
yield name, {}


_AGGREGATION_KEYS = {
"if_in_pkts",
"if_out_pkts",
"if_in_octets",
"if_out_octets",
"connections_rate",
"packet_velocity_asic",
}


def get_aggregated_values(vserver):
value_store = get_value_store()
now = time.time()

aggregation = {
k: 0.0
for k in (
"if_in_pkts",
"if_out_pkts",
"if_in_octets",
"if_out_octets",
"connections_rate",
"packet_velocity_asic",
)
if k in vserver
}
aggregation: dict[str, float] = {}

# Calculate counters
for what in aggregation:
for what in _AGGREGATION_KEYS.intersection(vserver):
this_aggregation = 0.0
raised = False
for idx, entry in enumerate(vserver[what]):
rate = get_rate(get_value_store(), f"{what}.{idx}", now, entry, raise_overflow=True)
aggregation[what] += rate
try:
this_aggregation += get_rate(
value_store, f"{what}.{idx}", now, entry, raise_overflow=True
)
except GetRateError:
raised = True
if not raised:
aggregation[what] = this_aggregation

# Calucate min/max/sum/mean values
for what, function in [
Expand Down

0 comments on commit a18a547

Please sign in to comment.