HAProxy provides a socket file which can be used to do maintenance (enable/ disable backends, retrieve information and statistics, …). The statistics part contains quite some interesting information for monitoring and alerting. The below Perl code snippit will loop over a glob of socket files (for instance when you have multiple HAProxy configurations running as…
Category: Perl
Managing LDAP passwords with Perl
OpenLDAP Software is an open source implementation of the Lightweight Directory Access Protocol. Many graphical interfaces are available for managing user accounts in OpenLDAP like PHPLDAPAdmin (http://phpldapadmin.sourceforge.net/wiki/index.php/Main_Page) or LAM (https://www.ldap-account-manager.org/lamcms/). When generating a bulk amount of accounts with automation or just managing user details with a simple script, allows much more flexibility and can be…
Perl script to monitor the rate of logs
In a previous article (IPTables Logging in JSON with NFLOG and ulogd2) we learned how to log certain IPTables rules to JSON log files. Monitoring the logs in real-time on the command line, can also be very useful when debugging either the rules themselves or when analyzing certain issues. Rather than just looking at the…
Perl: Archive E-Mails in an IMAP Folder
IMAP folders are really because you can have your e-mails synchronized on multiple devices, without losing e-mails across your devices when retrieving your new e-mails. IMAP folders actually also aren’t that cool because e-mails are usually never deleted or even archived. Having millions of e-mails can make some e-mail readers on certain devices really slow….
Perl: SSL Communication in web applications
The following demonstrates how to create a strict SSL communication between client and server, using HTTP.This setup could used when creating a web API which requires strong encryption and only allows clients which have a properly signed certificate. The Apache configuration in the below example will actually require 2 web servers: one proxy host, which…
Perl: Create schema backups in PostgreSQL
At my recent job, I was asked to create a backup procedure, which would dump a PostgreSQL schema to a compressed file and which was able to create weekly and daily backups.The backups had to be full backups each time a backup was made and the amount of daily and weekly backups should be defined…
Monitor running processes with Perl
Update: This article is updated thanks to Colin Keith his excellent comment. I was extremely inspired by it Maintaining a large number of servers cannot be done without proper programming skills. Each good system administrator must therefor make sure he knows how to automate his daily works. Although many many programming languages exist, most persons…
Postgresql: Monitor sequence scans with Perl
Not using indexes or huge tables without indexes, can have a very negative impact on the duration of a SQL query. The query planner will decide to make a sequence scan, which means that the query will go through the table sequentially to search for the required data. When this table is only 100 rows…
Postgresql: Monitor unused indexes
Working on large database systems, with many tables and many indexes, it is easy to loose the overview on what is actually being used and what is just consuming unwanted disk space.If indexes are not closely monitored, they could end up using undesired space and moreover, they will consume unnecessary CPU cycles. Statistics about indexes…
Postgresql 9.3: Creating an index on a JSON attribute
Recently I’ve discovered some very interesting new features in the PostgreSQL 9.3 database.First of all, a new data type has been introduced: JSON. Together with this new data type, new functions were also introduced. These new features now simply for instance saving web forms in your Postgresql database. Or actually any kind of dynamic data,…