Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support for nanosecond part when using trapper #150

Open
samarko opened this issue Sep 15, 2022 · 1 comment
Open

Feature request: Support for nanosecond part when using trapper #150

samarko opened this issue Sep 15, 2022 · 1 comment

Comments

@samarko
Copy link

samarko commented Sep 15, 2022

Same feature as is implemented in zabbix_sender -N or --with-ns. Useful when converting snmp traps to zabbix trapper and snmp traps are arriving within same second.

@samarko
Copy link
Author

samarko commented Sep 16, 2022

I've created patch for sender.py, it adds ns parameter to data which is sent to zabbix server/proxy.
`--- sender.py.20220916_01 2022-09-16 08:20:25.632689524 +0300
+++ sender.py 2022-09-16 08:31:13.880987429 +0300
@@ -109,11 +109,14 @@
:type clock: int
:param clock: Unix timestamp. Current time will used if not specified.

  • :type ns: int
  • :param ns: Unix timestamp, nanosecond part. Current time will used if not specified.
  • from pyzabbix import ZabbixMetric
    ZabbixMetric('localhost', 'cpu[usage]', 20)
    """

  • def init(self, host, key, value, clock=None):
  • def init(self, host, key, value, clock=None, ns=None):
    self.host = str(host)
    self.key = str(key)
    self.value = str(value)
    @@ -122,6 +125,11 @@
    self.clock = int(clock)
    else:
    raise ValueError('Clock must be time in unixtime format')

  •    if ns:
    
  •        if isinstance(ns, (float, int)):
    
  •            self.ns = int(ns)
    
  •        else:
    
  •            raise ValueError('Clock ns must be time in unixtime format')
    

    def repr(self):
    """Represent detailed ZabbixMetric view."""
    `
    Seems to be working on my installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant