Hobbit(3pm)
π Hobbit(3pm) β the Perl module that writes Hobbit/Xymon tests for you π
okay bestie, buckle up, we're doing Hobbit.pm and it's genuinely so useful. it lives in the User Contributed Perl Documentation corner of your system and it's here to make writing monitoring tests not a whole ordeal. π¦
β¨ NAME β¨
Hobbit.pm β a Perl module to easily write Hobbit/Xymon tests. that's it, that's the vibe. π
πΈ SYNOPSIS πΈ
look at how little you have to write, it's giving main character energy:
use Hobbit;
my $bb = new Hobbit('testname');
if (somethings_is_not_so_good) {
$bb->color_line('yellow', 'Something is not so good');
}
if (somethings_is_really_bad) {
$bb->color_line('red', 'Something is really bad');
}
$bb->send();
π DESCRIPTION π
Hobbit.pm is part of the Debian package hobbit-plugins, and it was written to gather up all the common tasks you keep needing when you write tests for the Xymon monitoring system (which used to be called Hobbit, hence the name, iykyk). it's the little helper that handles the boring bits so you can just write your check. π«Ά
π§ EXPORTABLE HELPER FUNCTIONS π§
@regexps = file_to_list_of_regexps($file)β hands you back a list of regexps from a file β¨@globs = file_to_list_of_globs($file)β hands you back a list of globs from a file β¨
π INTERNAL FUNCTIONS π
$max_color = max_color($color1, $color)β out of two colors, this returns the color with the highest severity. like a vibe check but for alerts. π
π METHODS π
π£ Constructor: new Hobbit('testname');
π£ Constructor: new Hobbit({ test => 'testname', ttl => 60, ...});
Creates a new Hobbit object. periodt. β¨
π Common use cases
my $bb = new Hobbit('sometest');
my $bb = new Hobbit({ test => 'testname',
color => 'green',
hostname => 'host.example.com',
text => 'Test successful',
title => 'Some Test',
ttl => 60,
type => 'status',
dont_moan => 1 });
π Available parameters
colorβ the initial color of the test. (Default:"clear") π¨dont_moanβ disablesmoan()andcroak()(they're down below, keep scrolling). you need this if, like, another Perl module you're using throws a whole bunch of warnings but works fine otherwise, etc. let it live. πhostnameβ the hostname for which the test should report. (Default:$ENV{CLIENTHOSTNAME} || $ENV{MACHINEDOTS} || $ENV{MACHINE} || 'unknown')testβ the name of the test, i.e. the name of the column on the hobbit status web pages. (Mandatory, bestie, you can't skip it) πtextβ text which is prepended to generated report. (Default: the empty string)titleβ the summary of the test. (Default:"$test OK"respectively"$test NOT ok") π·οΈttlβ how long the test result is valid before the test state is changed to purple by the xymon daemon if no newer test results have been received.
The default value is set on the xymon server and is 300 seconds by default.
Values without unit are interpreted as minutes. Valid units are h for hours, d for days, and w for weeks. No space between value and unit allowed. β°
typeβ allows one to send messages of other types than"status", e.g.data,notify,disable,enable, etc.
β οΈ May not yet work with all of these types properly. Please report bugs via the Debian Bug Tracking system.
π¦ Constructor: Hobbit::trends;
π¦ Constructor: Hobbit::trends ('hostname');
Creates a new Hobbit trends object. this is a shorthand for:
new Hobbit({ type = 'data', test = 'trends', hostname = $hostname, dont_moan => 1 });
π Common use case
my $trends = Hobbit::trends;
$trends->print ("[$bb->{test},extralabel.rrd]\n");
$trends->print ("DS:lambda:GAUGE:600:U:U $value\n");
$trends->send;
π add_color('somecolor')
Minutes that a sub test caused the given color state. Adjusts the overall resulting color accordingly. π¨
π print('some text')
Adds the given text to the end of the current report without changing the current color. chill, no drama. π
π sprintf('format', args ...)
Like the print() method, but using sprintf() with format string and arguments. fancy formatting, slay. β¨
π color_print('somecolor', 'some text')
Adds the given text to the end of the current report and minutes that a sub test caused the given color state. Adjusts the overall resulting color accordingly. π¨
π color_line('somecolor', 'some text')
Adds the given text to the end of the current report and minutes that a sub test caused the given color state. Prepends that text with an accordingly colored Xymon icon and adjusts the overall resulting color accordingly. so cute, so useful. π
π graph('graphname')
Adds HTML for showing a graph. Xymon itself can only show a single graph per test (others can be added to the "trends" column). This method works around that limitation by manually linking to the graph CGI. not me working around the system, iconic. π
π send()
Sends the report to the xymon server. the moment of truth. π
π FUNCTIONS π
π― grep(tag)
Run a xymongrep (bbhostgrep) query and return an array reference of hashes with keys ip (string), hostname (string), and tags (array reference).
my $list = Hobbit::grep('foobar');
foreach my $host (@$list) {
print "$host->{ip} $host->{hostname}\n";
}
π INTERNAL METHODS π
π moan()
If the check issues a Perl warning, this warning is added to the report with color state "yellow".
Set dont_moan to 1 to disable this feature. π
π croak()
If the check issues a Perl error, this error is added to the report with color state "red".
Set dont_moan to 1 to disable this feature. π
π AUTHORS AND COPYRIGHT π
Copyright (C) 2008-2011 Christoph Berg <myon@debian.org>
Copyright (C) 2011 Axel Beckert <abe@debian.org>
π«Ά SEE ALSO π«Ά
<http://www.xymon.org/> bb(5), xymon(1)
and that's the whole page bestie!! this one shipped as perl v5.40.1, dated 2025-12-11, in the classic Hobbit(3pm) fit. go write some tests, you're gonna eat. πβ¨π
π¦ where this page comes from
- ubuntu resolute: hobbit-plugins 20230301build1 Β· MIT
- ubuntu stonking: hobbit-plugins 20230301build1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms