Giter VIP home page Giter VIP logo

py-logger's Introduction

py-logger

Overview

This solution contains the following Python 3 application:

  • py-logger (python logger).

Python Files

py-logger contains the following python files:

  • logger.py
  • abstract_logger.py
  • sql_logger.py
  • nrdp_logger.py
  • send_nrdp.py

Required Python libraries

  • pyodbc,
  • gpiozero.

Configuration Files

  • config.dat,
  • config.json.

Configurable Log Outputs

  • Console,
  • File (daily),
  • Database.

and the above can add logging to:

  • Nagios.

Logging Attributes (config.dat)

  • Id (needs to be unique across all sources)
  • Type (type of sensor)
  • Room (location)
  • GP I/O (Raspberry-PI General Purpose I/O port #)
  • Value type (R=range/A=always/N=never)
  • Valid value (either 0 or 1)
  • Start Time (range valid start time)
  • End Time (range valid end time)
  • Settings (2 string values seperated by |, example "ok|alarm", the first value is if 0 and second value if 1)
  • Notification (nagios if responsible person should be notified)

Example:

id,type,room,gpio,valtyp,vadval,start,end,settings,notification
door-115,Door,115,4,R,0,08:00:00,17:00:00,closed|open,0
light-115,Light,115,18,R,0,08:00:00,17:00:00,off|on,0
door-116,Door,116,17,A,0,00:00:00,23:59:59,closed|open,0
refrig-116,Refrig,116,22,N,0,00:00:00,23:59:59,ok|alarm,1

Logging Configuration (config.json)

{
  "SensorConfigFile": "config.dat",
  "OutputLogger": "Console",
  "Nrdp": "true",
  "Console": {},
  "File": {
    "Folder": ""
  },
  "Sql": {
    "OdbcDriver": "SQL Server",
    "ServerName": "192.168.0.21\\SQLExpress",
    "Port": "55109",
    "DbName": "Logging",
    "User": "RaspPI",
    "Password": "Colony-0RaspPI-0"
  },
  "Nagios": {
    "Url": "http://localhost/nrdp/",
    "Token": "u%test-token",
    "Host": "raspberrypi",
    "Service": "sensor-logger",
    "State": "0",
    "CheckType": "1"
  }
}

Installation Instructions

sudo mkdir /usr/local/src
cd /usr/local/src
sudo wget https://codeload.github.com/PHuhn/py-logger/zip/master -Opy-logger.zip
sudo unzip py-logger.zip
sudo rm py-logger.zip
cd ./py-logger-master/py-logger/.
  <configure the config.dat and test the configuration with the following:
   sudo python3 py-logger.py
  >
  <configure the config.json, I suggest leaving it in console output, so you can return here and change and retest the configuration>
cd etc
sudo chmod 755 *.sh
sudo ./py-logger-install.sh
  <configure the config.json in /usr/local/py-logger directory>

Other Documents

Also see:

Good luck, Phil

py-logger's People

Contributors

phuhn avatar

Watchers

 avatar

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.