33# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
44# conditions defined in the file COPYING, which is part of this source code package.
55
6+ import time
7+
68from cmk .agent_based .v2 import AgentSection , StringTable
79from cmk .plugins .lib import interfaces
810
@@ -20,6 +22,7 @@ def _consume_down_interfaces(string_table: StringTable) -> tuple[list[str], int]
2022
2123def _parse_aix_common ( # pylint: disable=too-many-branches
2224 string_table : StringTable ,
25+ timestamp : float ,
2326) -> tuple [dict [str , interfaces .InterfaceWithCounters ], dict [str , list [str ]]]:
2427 ifaces = {}
2528 flags = {}
@@ -36,6 +39,7 @@ def _parse_aix_common( # pylint: disable=too-many-branches
3639 type = "24" if nic .startswith ("lo" ) else "6" ,
3740 ),
3841 interfaces .Counters (),
42+ timestamp = timestamp ,
3943 )
4044 elif line [0 ] == "Bytes:" and line [2 ] == "Bytes:" :
4145 iface .counters .out_octets = interfaces .saveint (line [1 ])
@@ -69,9 +73,10 @@ def _parse_aix_common( # pylint: disable=too-many-branches
6973
7074def _parse_aix_if_ifconfig_augmented (
7175 string_table : StringTable ,
76+ timestamp : float ,
7277) -> interfaces .Section [interfaces .InterfaceWithCounters ]:
7378 interfaces_in_down_state , idx = _consume_down_interfaces (string_table )
74- ifaces , flags = _parse_aix_common (string_table [idx :])
79+ ifaces , flags = _parse_aix_common (string_table [idx :], timestamp )
7580 for nic , iface in ifaces .items ():
7681 iface .attributes .oper_status = "2" if nic in interfaces_in_down_state else "1"
7782 iface .attributes .finalize ()
@@ -80,8 +85,9 @@ def _parse_aix_if_ifconfig_augmented(
8085
8186def _parse_aix_if_entstat_only (
8287 string_table : StringTable ,
88+ timestamp : float ,
8389) -> interfaces .Section [interfaces .InterfaceWithCounters ]:
84- ifaces , flags = _parse_aix_common (string_table )
90+ ifaces , flags = _parse_aix_common (string_table , timestamp )
8591
8692 for nic , iface in ifaces .items ():
8793 iface_flags = flags .get (nic , [])
@@ -99,12 +105,21 @@ def _parse_aix_if_entstat_only(
99105 return list (ifaces .values ())
100106
101107
108+ def parse_aix_if_pure (
109+ string_table : StringTable ,
110+ timestamp : float ,
111+ ) -> interfaces .Section [interfaces .InterfaceWithCounters ]:
112+ return (
113+ _parse_aix_if_ifconfig_augmented (string_table , timestamp )
114+ if string_table [0 ][0 ] == "[interfaces_in_down_state]"
115+ else _parse_aix_if_entstat_only (string_table , timestamp )
116+ )
117+
118+
102119def parse_aix_if (
103120 string_table : StringTable ,
104121) -> interfaces .Section [interfaces .InterfaceWithCounters ]:
105- if string_table [0 ][0 ] == "[interfaces_in_down_state]" :
106- return _parse_aix_if_ifconfig_augmented (string_table )
107- return _parse_aix_if_entstat_only (string_table )
122+ return parse_aix_if_pure (string_table , time .time ())
108123
109124
110125agent_section_aix_if = AgentSection (
0 commit comments