Coder Social home page Coder Social logo

generaliinformatik / build-monitor-traffic-lights Goto Github PK

View Code? Open in Web Editor NEW
4.0 9.0 0.0 53 KB

Build Monitor with traffic lights integration via Bluetooth

Shell 1.67% Python 98.33%
jenkins build monitor bluetooth rasperry python traffic lights trafficlights pipeline

build-monitor-traffic-lights's Introduction

Raspberry Lampe

Beschreibung

  • Das Skipt läuft täglich Mo-Fr, 7-19h (crontab) und prüft eine Liste von Jenkins Jobs auf deren Status
  • Ist ein roter Job dabei, wird die Ampel rot
  • Sind alle Jobs gefixed worden, wird die Ampel wieder grün
  • Bei Fehlern im Skript blinkt die orangene Lampe

Archite0cture

architecture

Jobs

siehe config.yml

Setup

Hardware

  • Lampe ELGATO AVEA
  • Raspberry Pi 4

Software

  • Python 3.x
  • Python Module
    • avea
    • requests
    • pyyaml
    • pygame
  • Git
  • BluPy (Bluetooth)

Skripte

lampe/lampe.py

  • Scannt die Status der konfigurierten Jenkins Pipelines und schaltet abhängig vom Ergebnis die entsprechende lampe ein / aus

ip/ethernet_up.sh

  • wird ausgeführt, nachdem eine Verbindung zu eth0 hergestellt worden ist und loggt die IP nach Mattermost

ip/parse_ip_addr.sh

  • parst IP adresse von eth0 und schreibt sie zur weiteren Verarbeitung auf die Konsole

Systemanpassungen

  • Konfiguration anpassen

Die beiliegende config.yml.sample beinhaltet die erforderliche Struktur mit Beispielangaben. Die Datei ist vor Inbetriebnahme als config.yml umzubenennen und die Inhalte auf das jeweilige EInsatzszenario anzupassen.

  • Timeserver setzten In die Datei '/etc/systemd/timesyncd.conf' folegende Werte einfügen: [Time] NTP=ntp1.de.top.com FallbackNTP=ntp2.de.top.com

im Anschluss sudo timedatectl set-ntp true ausführen

  • neue ssh keys generiert und ssh aktiviert sudo rm /etc/ssh/ssh_host_* sudo dpkg-reconfigure openssh-server sudo systemctl enable ssh sudo systemctl start ssh ssh-keygen an die default Stelle /home/pi/.ssh

  • Proxy setzen in /etc/apt/apt.conf.d/80proxy Acquire::http::proxy "http://<user>:<pw>@<proxy address>:<proxy port>/"; Acquire::https::proxy "https://<user>:<pw>@<proxy address>:<proxy port>/";

  • Initiale Installationen Auf dieser Seite ist die Einrichtung nochmal beschrieben: https://pypi.org/project/avea/

    • Dependencies sudo apt install libglib2.0-dev sudo apt-get install libsdl-image1.2
    • pip3 sudo apt install python3-pip
    • pip3 sudo pip3 install --upgrade avea
  • Zusatzlibs für python installieren

    • Pygame sudo pip3 install --proxy http://<user>:<pw>@<proxy address>:<proxy port> --upgrade pygame
    • Avea sudo pip3 install --proxy http://<user>:<pw>@<proxy address>:<proxy port> --upgrade avea
    • Pyyaml sudo pip3 install --proxy http://<user>:<pw>@<proxy address>:<proxy port> --upgrade pyyaml

Alternativ können die benötigten Module über folgenden Befehl installiert werden:

pip3 install -r requirements.txt
  • GIT Integration ...installieren sudo apt-get install git

... Zugriff hinterlegen Der public SSH Key vom Pi muss in einem Bitbucket Profil hinterlegt werden (aktuell ist er bei ACK hinterlegt), damit der Zugriff auf Bitbucket erfolgen kann. Dies kann gerne in Zukunft anders gelöst werden?

... Ampel Repo clonen git clone <repo-link> Nachdem hier der Zugriff erfolgreich ist, können die nächsten Änderungen vorgenommen werden

  • Symlink auf repo ln -fsn /home/pi/raspberry-ampel jenkins-monitor Dies sollte gemacht werden, damit bspw. der Eintrag im Crontab nicht immer wieder erneutert werden muss

  • Crontab erweitern damit minütlich Jenkins gecheckt wird sudo nano /etc/crontab */1 7-19 * * 1-5 pi sudo python3 /home/pi/jenkins-monitor/scripts/lampe/lampe.py >/home/pi/logs/cronlog 2>&1 Ordner und Datei (home/pi/logs/cronlog) vorher anlegen!

  • ViewStatus im Jenkins ändern Anonymus muss Zugriff auf den ViewStatus haben, damit er ihn auslesen kann. Dieser kann bspw. auf Ordnerebene vergeben werden.

  • scripts/lampe/lampe.py anpassen

Bitte die Platzhalter in der Datei anpassen, so dass <mattermost graphic url> für die im Chat anzuzeigende Grafik angegeben wird.

  • scripts/ip/log_ip_to_chat.py anpassen

Bitte die Platzhalter in der Datei anpassen, so dass der Mattermost URL für den Platzhalter <mattermost channel url> und <mattermost graphic url> für die im Chat anzuzeigende Grafik angegeben wird.

build-monitor-traffic-lights's People

Contributors

rfuehrer avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

build-monitor-traffic-lights's Issues

File completion

Before a publication the required files are

CODE_OF_CONDUCT
CONTRIBUTION
SECURITY

to the project. This helps the users of the repo, the cooperation with third parties becomes a bit clearer.

Proposal:
The files will be contributed to the project by the OST as PR.

Single configuration option

In a forthcoming feature, it is necessary to provide the flexibility to display fields using a single configuration. Otherwise, PHP and Angular will still have to use different locations for configuration, which adds complexity.

In this case, it would make sense to use the config.php file and control the display via a PHP file with a query whether the variable is set. But currently the file is a HTML with JS. If this HTML is changed to PHP, the display could be easily controlled by an IF query.

Affected files:

  • sample-config.php
  • (config.php)
  • templates/jira_source.html
  • js/jira-plugin.js

Architecture description

The architecture used by the solution shall be described in order to give users an idea of the scenario for which the solution is suitable. Ideally, the architecture should be documented graphically for better illustration.

Documentation of the requirements

The requirements for the use of the solution must be described in detail to enable users to get started quickly. This includes the extension of the README, but also the documentation of the required Python modules via a requirements.txt.

Add all variables to the configuration

In the source code, the scripts sometimes contain static information that can be transferred as variables into the configuration. Currently, adjustments to other usage scenarios are necessary both by adapting the config.yml and directly in the scripts. The adaptation provides for a standardization of the procedure.

Choose license and add license header to files

A license must be selected and added to the repository as a LICENSE. If no license is specified, the use for other uses is not obvious. Once a license has been selected, the files should - where possible - be supplemented with the license header.

If the development is original, Generali AG can be specified in the license. If not, a reference to the original repo must be included in the README and the upstream license must be considered.

Specification of the company-specific configurations

The company-specific configurations must be described in a separate file. Among other things, the proxy configuration and infrastructure-specific information must be documented here.

For security reasons, this file should have a file name as a markdown that is not transferred when specified in the .gitignore.

Rename files to english

The file names should be renamed to English terms for better comprehensibility by international users. The references to the files (e.g. README) should be adapted accordingly.

Implementation of the findings from pylint

The Python scripts are to be checked with pylint to see if the code corresponds to best practices. For better readability by third parties, the modules and functions are to be described by documentation headers (PEP 257) and the variables are to be described uniformly and internationally.

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.