Continuous Integration Server LED Status Monitor
The active implementation of Jenkins-based servers (fork Hudson) at Continuous Integraion led to a lot of talk about the “red lamp” - an ordinary lamp that would stand by the development manager and signal in case of an unsuccessful build. Interest picked up, and on the weekend moved from words to deeds. As a result, we got such a device:
What it can do:
It was built on the basis of the popular Arduino platform (more precisely, its no less popular clone - Seeeduino).
The basic concept of the device is simple:
Arduino on board has built-in SerialPort support, so there are no problems connecting to a PC. The team
listening on the port at a given frequency is initialized (it is important here that the program running on the computer runs at the same frequency in the same mode), and then the command
in an infinite loop, the signal from the port is read. Depending on what has arrived, one of five modes is selected for one of the six LEDs:
You can make another mode - blinking green-red in turn, if to someone this set of statuses seems insufficient.
To save the conclusions of Arduino, two-pin red-green LEDs were chosen. When the current flows in one direction, such a diode lights up in green, in the opposite - red:
Connect it to two Arduino pins (do not forget about the current-limiting resistor) and, setting these legs to low and high potential, set the required LED operation mode:
The flashing mode is obtained by alternating on and off the LED on the timer.
Conclusions 0 and 1 are busy for communication on UART, they can not be used. I limited myself to six indicators, hanging them, respectively, on conclusions 2-13.
If desired, you can use the remaining 6 Arduino pins, as well as expand the number of indicators using, for example, shift registers. True, an additional code will have to be conjoined over the firmware code.
The full sketch for arduino can be viewed in the archive with the source code .
I implemented the iron part of the interface in the form of an expansion card for Arduino - see photo. The pins are inserted into the connectors, it turns out a rigid, rugged design without wires and cables. Convenient and reliable.
The board is made by the LUT method, about which many times have already been written on Habré. A good description in the pictures is on the website easyelectronics.ru .
LEDs and current limiting resistors are used in chip format, but, of course, any will do. As a "chip" etched the name of the projects directly on the board. In the photo I had to “gloss over”, because These are the names of specific customers of our company. You could just write Server01, Server02, etc. But I wanted to do it Beautifully :)
The monitoring status of the server program is written in Perl. In principle, any language that can send signals to SerialPort will do. Which language to use is a matter of taste for everyone.
I note that for Perl I had to install the packages DeviceSerial (for Mac OS X), Win32-API (for Windows) and Win32-Serial (for Windows).
The main steps of the program:
The most difficult part in Perl for me was setting up a connection to the Jenkins server. We use authorization, and without entering the username / password Perl script did not get the desired result. The issue was resolved as follows:
We take the status of the current server status from the Jenkins API. If the project works at the address,
then
in plain text mode displays various information about the project. We are interested in, in particular, the fragment that begins with. '
Jenkins in this place displays the current status. Examples
Through
we get the content of the page. Next is a technical matter. We find the necessary fragment and compare it with the well-known variants of “color solutions”. If you did not find a known option or the page is not available, we extinguish the corresponding LED.
Full Perl code is also available in the source code archive .
Device in use: www.youtube.com/watch?feature=player_embedded&v=IsgqKsnJ8Uo
- connect via USB to a computer;
- track the status of six Jenkins projects;
- display information about the current state using 4 display options (two colors, two operating modes).
It was built on the basis of the popular Arduino platform (more precisely, its no less popular clone - Seeeduino).
The basic concept of the device is simple:
- A program is launched on the working machine that listens to the status of the given Jenkins projects;
- When the status changes, the program sends a certain signal to the Arduino via UART (via the Serial Port, aka COM port);
- Arduino receives the signal and turns on the corresponding LED in the desired mode.
Software part on Arduino
Arduino on board has built-in SerialPort support, so there are no problems connecting to a PC. The team
- Serial.begin(9600);
listening on the port at a given frequency is initialized (it is important here that the program running on the computer runs at the same frequency in the same mode), and then the command
- incomingByte = Serial.read();
in an infinite loop, the signal from the port is read. Depending on what has arrived, one of five modes is selected for one of the six LEDs:
- The last build was successful (green diode);
- Assembly in progress (flashing green diode);
- The last assembly was unsuccessful (red diode);
- The last assembly was manually interrupted (red diode);
- It is impossible to receive a response from the server, or the status is undefined (diode off).
You can make another mode - blinking green-red in turn, if to someone this set of statuses seems insufficient.
To save the conclusions of Arduino, two-pin red-green LEDs were chosen. When the current flows in one direction, such a diode lights up in green, in the opposite - red:
Connect it to two Arduino pins (do not forget about the current-limiting resistor) and, setting these legs to low and high potential, set the required LED operation mode:
- Green: high on one pin, low on the other;
- Red: the same, but in the opposite direction;
- LED off if a low signal is applied to both outputs.
The flashing mode is obtained by alternating on and off the LED on the timer.
Conclusions 0 and 1 are busy for communication on UART, they can not be used. I limited myself to six indicators, hanging them, respectively, on conclusions 2-13.
If desired, you can use the remaining 6 Arduino pins, as well as expand the number of indicators using, for example, shift registers. True, an additional code will have to be conjoined over the firmware code.
The full sketch for arduino can be viewed in the archive with the source code .
Iron part
I implemented the iron part of the interface in the form of an expansion card for Arduino - see photo. The pins are inserted into the connectors, it turns out a rigid, rugged design without wires and cables. Convenient and reliable.
The board is made by the LUT method, about which many times have already been written on Habré. A good description in the pictures is on the website easyelectronics.ru .
LEDs and current limiting resistors are used in chip format, but, of course, any will do. As a "chip" etched the name of the projects directly on the board. In the photo I had to “gloss over”, because These are the names of specific customers of our company. You could just write Server01, Server02, etc. But I wanted to do it Beautifully :)
Programmed part on PC
The monitoring status of the server program is written in Perl. In principle, any language that can send signals to SerialPort will do. Which language to use is a matter of taste for everyone.
I note that for Perl I had to install the packages DeviceSerial (for Mac OS X), Win32-API (for Windows) and Win32-Serial (for Windows).
The main steps of the program:
- Connect to SerialPort;
In Perl, this is done through- my $port = Win32::SerialPort->new("COM8"); # COM8 – название порта, в котором определилось устройство
- # Для Mac OS X будет так: my $port = Device::SerialPort->new("/dev/tty.usbserial-A100eEO6");
- $port->databits(8);
- $port->baudrate(9600);
- $port->parity("none");
- $port->stopbits(1);
- In an endless loop, watch the status of the specified service and send the appropriate code via UART.
Departure by team- $port->write(“Any string”);
The most difficult part in Perl for me was setting up a connection to the Jenkins server. We use authorization, and without entering the username / password Perl script did not get the desired result. The issue was resolved as follows:
- my $realm = 'Enter you domain credentials'; # Realm сервера
- my $user = 'pavel'; # Имя пользователя
- my $pass = 'sfD90_df13'; # Пароль пользователя. Разумеется, не настоящий :)
- my $browser;
- $browser = LWP::UserAgent->new;
- $browser->credentials('localhost:443', $realm, $user => $pass);
We take the status of the current server status from the Jenkins API. If the project works at the address,
https://localhost/job/Project
then
https://localhost/job/Project/api/json
in plain text mode displays various information about the project. We are interested in, in particular, the fragment that begins with. '
“color”:
' Jenkins in this place displays the current status. Examples
“color”:”blue”
- the last build was successful (interesting fact: instead of the “traditional” green, the color blue was chosen for the convenience of people with color blindness)“color”:”red”
- last build failed“color”:”aborted_anime”
- assembly is in progress; The last build was manually aborted.
Through
- $response = $browser->get($url); # где $url – прямая ссылка до API для json
- # Например, https://localhost/job/Project/api/json
we get the content of the page. Next is a technical matter. We find the necessary fragment and compare it with the well-known variants of “color solutions”. If you did not find a known option or the page is not available, we extinguish the corresponding LED.
Full Perl code is also available in the source code archive .
Device in use: www.youtube.com/watch?feature=player_embedded&v=IsgqKsnJ8Uo