This is an old revision of the document!
Author | Rich Jones |
Compatibility | Xymon 4.2 |
Requirements | Perl, GitLab |
Download | None |
Last Update | 2017-07-17 |
Client side
Change the appropriate vars in the script (see below) and place in /usr/lib/xymon/client/ext (or wherever you have the client extension dir).
Vars:
Add the following to clientlaunch.cfg
[gitlab]
ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
CMD $XYMONCLIENTHOME/ext/bb-gitlab.pl
LOGFILE $XYMONCLIENTHOME/logs/bb-gitlab.log
INTERVAL 5m
#!/usr/bin/perl -w
#
# bb-gitlab - Git lab checks
# R Jones 2016
#
#
use strict;
use LWP::Simple;
## BB Global variables
#############################################################################
my $BBHOME = "/usr/lib/xymon/client";
my $BB = "/usr/lib/xymon/client/bin/xymon";
my $BBDISP = "_SOME_IP_";
my $MACHINE = "_SOME_HOSTNAME_";
my $COLOR = "clear";
my $MSG = "";
my $HEAD = "";
my $DATA = "";
my $TESTNAME = "gitlab";
## Main Program
#############################################################################
{
my $CACHEURL = "_GITLAB_URL_/health_check/cache?token=_GITLAB_TOKEN_";
my $DATABASEURL = "_GITLAB_URL_/health_check/database?token=_GITLAB_TOKEN_";
my $MIGRATIONSURL = "_GITLAB_URL_/health_check/migrations?token=_GITLAB_TOKEN_";
my $GITURL = "_GITLAB_URL_/health_check?token=r-_GITLAB_TOKEN_";
my $GITSTATUS = get($GITURL);
if($GITSTATUS eq "success"){
$COLOR = "green";
$MSG = "GitLab good";
if(get($CACHEURL) ne "success") {
$COLOR = "yellow";
$MSG = "Cache errror";
}
if(get($DATABASEURL) ne "success") {
$COLOR = "yellow";
$MSG = "Database error";
}
if(get($MIGRATIONSURL) ne "success") {
$COLOR = "yellow";
$MSG = "Migration error";
}
}
else {
$COLOR = "red";
$MSG = "GitLab error";
}
$MACHINE =~ s/\./,/g;
my $date = localtime;
my $cmd = "$BB $BBDISP \"status $MACHINE.$TESTNAME $COLOR $date $HEAD\n$DATA\n$MSG\"";
print $cmd;
system($cmd);
}