Git Product home page Git Product logo

weewx-zabbix's Introduction

weewx-zabbix

Allow weewx (open source software for your weather station) to push data to zabbix (open source monitoring software).

Installation

Should I really say that a working weewx and zabbix setup are requiered?

Dependencies

This plugins uses the zabbix_sender command, so it must be available on the host running weewx.

Build the package, or get it from here

mkdir -p ~/git/ && cd ~/git && git clone https://github.com/RandomReaper/weewx-zabbix.git
cd weewx-zabbix
./gen-tar.sh

Install the weewx extension

sudo wee_extension --install weewx-zabbix.tgz

Configure the weewx extension

# Options for extension 'zabbix'
[ZABBIX]
    # service can be disabled
    enable = true
    
    # zabbix_sender full name+path
    zabbix_sender = /usr/bin/zabbix_sender

    # Zabbix server IP
    server = 127.0.0.1

    # Zabbix host to store the values
    host = server-home
    
    # Prefix for generating the zabbix key name
    prefix = weewx_

Add the key to zabbix

Add a key of type "Zabbix trapper", with the key name weewx_outTemp (formed with the prefix set in the config file + the weewx key name).

Availables key

Here is a list of the key pushed on my system, probably configuration dependant.

weewx_altimeter
weewx_heatindex
weewx_radiation
weewx_inDewpoint
weewx_inTemp
weewx_barometer
weewx_windchill
weewx_dewpoint
weewx_rain
weewx_humidex
weewx_pressure
weewx_rainRate
weewx_usUnits
weewx_txBatteryStatus
weewx_appTemp
weewx_UV
weewx_dateTime
weewx_windDir
weewx_outTemp
weewx_windSpeed
weewx_inHumidity
weewx_windGust
weewx_windGustDir
weewx_cloudbase

My setup

WH2600

The WH2600 weather station pushes data to zabbix using weewx-interceptor, then weewx-zabbix pushes data to zabbix.

weewx-zabbix's People

Contributors

randomreaper avatar wilsonwaters avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

weewx-zabbix's Issues

Adopt Weewx 4x new logging function - Enhancement

Hello.
Logger function changed since Weewx 4.x,. You can make it backwards compatible and adopt the new one by changing from line 38 to 48

def logmsg(dst, msg):
    syslog.syslog(dst, 'zabbix: %s' % msg)

def logdbg(msg):
    logmsg(syslog.LOG_DEBUG, msg)

def loginf(msg):
    logmsg(syslog.LOG_INFO, msg)

def logerr(msg):
    logmsg(syslog.LOG_ERR, msg)

with this

# Test for new-style weewx v4 logging by trying to import weeutil.logger
import weeutil.logger
import logging

try:
    log = logging.getLogger(__name__)

    def logdbg(msg):
        log.debug(msg)

    def loginf(msg):
        log.info(msg)

    def logerr(msg):
        log.error(msg)

except ImportError:
    # Old-style weewx logging
    import syslog

    def logmsg(level, msg):
        syslog.syslog(level, 'Zabbix Extension: %s' % msg)

    def logdbg(msg):
        logmsg(syslog.LOG_DEBUG, msg)

    def loginf(msg):
        logmsg(syslog.LOG_INFO, msg)

    def logerr(msg):
        logmsg(syslog.LOG_ERR, msg)

Thanks

rainTotal is not pulling correct data

RainTotal is currently showing 55 every day, even without raining. It rained 0.4" the other day and the value did not increase.

Feb 15 09:44:55 john-PS583AA-ABA-a1020n weewx[4213]: zabbix: sandvine.lan weewx_rain_total 55.245

Weewx 3.9.1

The rest of the values seem to be correct and are updating properly from the correct sources.

memoryview: a bytes-like object is required, not 'str'

Hello.
Zabbix extension fails to run.

Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: loop data:
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_usUnits 16
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_dateTime 1608039616
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_inHumidity 46.0
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_inTemp 26.200000000000003
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_outHumidity 71.0
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_outTemp 20.200000000000003
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_pressure 1010.8000000000001
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_windSpeed 7.2
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_windGust 9.72
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_windDir 225.0
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_rain None
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_radiation 228.18595
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_UV 2.0
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_status 0
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_ptr 42176
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_delay 18
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_rxCheckPercent 100
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_outTempBatteryStatus 0
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_rainTotal 7.739999999999999
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_altimeter 1010.8909740144559
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_appTemp 20.332427851579602
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_barometer 1010.8000000000001
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_beaufort 1
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_cloudbase 662.3046501766602
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_dewpoint 14.767697700714633
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_heatindex 20.129444444444452
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_humidex 24.02561521575064
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_inDewpoint 13.652460445809679
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_maxSolarRad 942.3936622272251
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_rainRate 0.0
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_windchill 20.200000000000006
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: pi2weewx weewx_windGustDir None
Dec 15 10:40:16 pi2weewx /weewxd[16646]: zabbix: command line : ['/usr/bin/zabbix_sender', '-z', 'XXX.XXX.XXX.XXX', '-i', '-']
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] INFO weewx.engine: Main loop exiting. Shutting engine down.
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] DEBUG weewx.restx: Shut down WeatherCloud thread.
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] DEBUG weewx.restx: Shut down Windy thread.
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] DEBUG weewx.restx: Shut down PWSWeather thread.
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] DEBUG weewx.restx: Shut down Wunderground-RF thread.
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__: Caught unrecoverable exception:
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****  memoryview: a bytes-like object is required, not 'str'
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****  Traceback (most recent call last):
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****    File "/usr/share/weewx/weewxd", line 154, in main
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****      engine.run()
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 206, in run
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****      self.dispatchEvent(weewx.Event(weewx.NEW_LOOP_PACKET, packet=packet))
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 241, in dispatchEvent
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****      callback(event)
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****    File "/usr/share/weewx/user/zabbix.py", line 90, in loop
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****      sender_stdout = p.communicate(input=s)[0]
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****    File "/usr/lib/python3.7/subprocess.py", line 939, in communicate
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****      stdout, stderr = self._communicate(input, endtime, timeout)
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****    File "/usr/lib/python3.7/subprocess.py", line 1666, in _communicate
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****      input_view = memoryview(self._input)
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****  TypeError: memoryview: a bytes-like object is required, not 'str'
Dec 15 10:40:16 pi2weewx python3[16646]: weewx[16646] CRITICAL __main__:     ****  Exiting.

Thanks

Reformat zabbix sender stdout - Enhancement

Hello.
Would you consider to replace this line 91. I didn't learn how to make a pr yet.
loginf(self.zabbix_sender + " result: " +sender_stdout.decode())
with
loginf(' '.join(sender_stdout.decode().split()))
to get a better output format. you will get something like this
Response from "XXX.XXX.XXX.XXX:10051": "processed: 32; failed: 0; total: 32; seconds spent: 0.000852" sent: 32; skipped: 0; total: 32

Thanks

Inconsistent use of tabs and spaces in indentation

Hello.
I installed the extension today and weewx service fails to run due to this error. I found it in many lines in the code. I finally fixed. I don't know if it is related to python3.

Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__: Caught unrecoverable exception:
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****  inconsistent use of tabs and spaces in indentation (zabbix.py, line 89)
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****  Traceback (most recent call last):
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****    File "/usr/share/weewx/weewxd", line 148, in main
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****      engine = weewx.engine.StdEngine(config_dict)
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 81, in __init__
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****      self.loadServices(config_dict)
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 153, in loadServices
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****      obj = weeutil.weeutil.get_object(svc)(self, config_dict)
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****    File "/usr/share/weewx/weeutil/weeutil.py", line 1093, in get_object
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****      mod = __import__(module)
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****    File "/usr/share/weewx/user/zabbix.py", line 89
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****      sender_stdout = p.communicate(input=s)[0]
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****                                              ^
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****  TabError: inconsistent use of tabs and spaces in indentation
Dec 15 10:05:14 pi2weewx python3[9962]: weewx[9962] CRITICAL __main__:     ****  Exiting.

Thanks in advanced

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.