====== gitlab.pl ====== ^ Author | [[ http://www.nothingatall.net | Rich Jones]] | ^ Compatibility | Xymon 4.2 | ^ Requirements | Perl, GitLab | ^ Download | None | ^ Last Update | 2017-07-17 | ===== Description ===== A super simple script to monitor a self hosted GitLab (https://about.gitlab.com/) server. ===== Installation ===== === 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: * _SOME_IP_ - The Xymon server IP * _SOME_HOSTNAME_ - The Xymon server hostname/URL * _GITLAB_URL_ - Gitlab instance URL * _GITLAB_TOKEN_ - The Gitlab healthcheck token that you can get from _GITLAB_URL_/admin/health_check Add the following to clientlaunch.cfg [gitlab] ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg CMD $XYMONCLIENTHOME/ext/gitlab.pl LOGFILE $XYMONCLIENTHOME/logs/gitlab.log INTERVAL 5m ===== Source ===== ==== gitlab.pl ==== #!/usr/bin/perl -w # # gitlab.pl - 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); }