Select Page

NETWAYS Blog

Running RedHat SCL PostgreSQL with Puppet

On a test system for a customer I wanted to bring up a newer PostgreSQL version on CentOS 7 (same for RHEL 7). Software Collections (also for RedHat) gives you a neat distribution method that is not very invasive into your existing distribution. So you can install a PostgreSQL 9.4 under RHEL 7 without replacing any of the existing packages. This is a bit tricky in terms of paths, but just works.
I found a relatively simple way to install, configure and run such a SCL with Puppet, with just using the existing PostgreSQL module.
https://gist.github.com/lazyfrosch/1926b17d1d605bfb819e899ef6bd4b63
Have fun trying it out and let me know what you think.

May I introduce the Rubocop

When you are into developing Ruby code, or even Ruby near stuff like Puppet modules, or Chef cookbooks, there is a nice tool you should have a look at.
The RuboCop can help you writing better Ruby code, it certainly did it for me.
In short words, RubyCop is a code analyzer that checks Ruby code against common style guidelines and tries to detect a lot of mistakes and errors that you might write into your code.
There are a lot of configuration options, and even an auto-correct functionality, that updates your code.

Simple usage

Either install the gem, or add it to your Gemfile:

gem 'rubocop', require: false

You can just run it without configuration, and it will look for all Ruby files in your work directory.

$ rubocop
Inspecting 19 files
....C............CC
Offenses:
lib/test/cli.rb:3:3: C: Missing top-level class documentation comment.
 class CLI
 ^^^^^
lib/test/cli.rb:36:1: C: Extra empty line detected at method body beginning.
lib/test/cli.rb:41:1: C: Extra empty line detected at block body beginning.
lib/test/cli.rb:45:4: C: Final newline missing.
end
bin/test:12:1: C: Missing space after #.
#api.login('username', 'Passw0rd') unless api.logged_in?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bin/test:15:3: C: Missing space after #.
 #puts response.code
 ^^^^^^^^^^^^^^^^^^^
bin/test:19:1: C: Missing space after #.
#session.save(file)
^^^^^^^^^^^^^^^^^^^
18 files inspected, 7 offenses detected

You can add it as a rake job to your Rakefile:

require 'rubocop/rake_task'
RuboCop::RakeTask.new
task default: [:spec, :rubocop]

And run the test via your rake tests:

$ rake
$ rake rubocop

Configuration galore

There are a lot of options to modify the behavior and expectations of RuboCop.
Here is a short example I used with recent Puppet module.

require: rubocop-rspec
AllCops:
  TargetRubyVersion: 1.9
  Include:
    - ./**/*.rb
  Exclude:
    - vendor/**/*
    - .vendor/**/*
    - pkg/**/*
    - spec/fixtures/**/*
# We don't use rspec in this way
RSpec/DescribeClass:
  Enabled: False
RSpec/ImplicitExpect:
  Enabled: False
# Example length is not necessarily an indicator of code quality
RSpec/ExampleLength:
  Enabled: False
RSpec/NamedSubject:
  Enabled: False

Where to go next

Telegram Notifications von Icinga 2

Ich nutze nun Telegram privat schon seit einiger Zeit, mir gefällt der Messenger und man kann dort auch sehr schön Bots einbinden.
Für meine privaten Systeme hat mich E-Mail für Notifications immer ein bisschen gestresst. Man möchte doch eigentlich nur kurz die Info sehen, was zählt ist doch eh der aktuelle Status im Dashboard. Mails muss man immer wegräumen/löschen.
Warum also nicht die Notifications via Bot an mich in Telegram schicken? Nichts einfacher als das.
In einem GitHub Repository habe ich alles nötige (auf Englisch) zusammengefasst. Doch hier gerne noch ein wenig auf Deutsch erklärt.
read more…

SNMPv3 INFORM in a high available setup

SNMP is, and will be for a long time, one of the key protocols in monitoring. Widely used in hardware and appliance monitoring, and for sending events and alerts via TRAP or INFORM.
Now the problem of SNMPv1 or v2 is, that it has no real security. SNMPv3 offers that, but might cause you headaches, trying to understand, how it works.
With this post I want to explain, how snmptrapd can be used in a high availability setup, with the security of SNMPv3. I hope this gives you an inside and a quick start guide to try it out.

Security model

If you never worked with SNMPv3, just a quick introduction to authentication and security. There are no communities anymore, but a few other parameters are required:

  • securityName (username)
  • authProtocol (MD5 or SHA hashing algorithm)
  • authKey (secret to authenticate the peer)
  • privProtocol (AES or DES to encrypt the data)
  • privKey (secret to encrypt data)

Note: All keys are symmetric, which means both ends of the communication need to use the same keys (and protocol settings).
You can also disable authKey and/or privKey, but than why use SNMPv3? Check the manpage of snmptrapd for how to configure it in detail.

TRAP or INFORM?

With SNMPv3 a new notification type got introduced, called “INFORM”. The main differences between both types are:

  • INFORM is using a protocol to ensure delivery (Receiver sends an ack)
  • TRAP is working similar to v1/2, but its tricky with SNMPv3 security
  • INFORM has protection against message replay

read more…

Tips für Bahnreisende – Heute: Bahn Wagenreihungsplan

Für Menschen, die viel mit der Deutschen Bahn durch Deutschland gondeln, ist eine Sitzplatzreservierung oft unverzichtbar.
Wenn man nun, wie z.B. in Frankfurt oder München, in einem Kopfbahnhof ein- oder aussteigen will, stellt sich oft die Frage, welcher Wagen steht denn da wo.
Bisher ist diese Info, außer am Bahnsteig, schwer zu bekommen. Man konnte nur versuchen in der Datensammlung auf grahnert.de etwas brauchbares zu finden. Leider sind die Daten oft nicht aktuell.
Durch einen Tipp auf Twitter wurde ich auf die App Bahnhof Live aufmerksam (Android) (iOS), und das hilft – zumindest mir – schon mal sehr.

@DB_Bahn @lazyfrosch Mir wurde hier die "Bahnhof Live"-App empfohlen. Nicht komfortabel, um gleichzeitig auf dem Handy zu buchen, aber nett.

— Dominik (@astrolenni) May 17, 2016


Und tatsächlich, dort kann man für den aktuell Tag bei jedem Bahnhof den Wagenreihungsplan finden. Das ist doch schon mal eine tolle Quelle.
Zumindest sagt die Bahn dass voraussichtlich dieses Jahr noch mehr kommen soll. (Hoffentlich direkt bei der Sitzplatzwahl)
Bahnhof-Live-2