Skip to content

Instantly share code, notes, and snippets.

@mattdees
Created August 22, 2013 02:21
Show Gist options
  • Save mattdees/6302506 to your computer and use it in GitHub Desktop.
Save mattdees/6302506 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Smokeping;
#
# CONFIG VARS, CHANGE THESE TO YOUR SETUP.
#
my $config_file = '/etc/smokeping/config';
# load the smokeping_config to $Smokeping::cfg
Smokeping::load_cfg($config_file, 1);
# build worker hash
foreach my $group ( keys %{ $Smokeping::cfg->{'Targets'} } ) {
unless ( ref $Smokeping::cfg->{'Targets'}->{$group} ) {
# Unless the entry in the smokeping hash is a reference to another datastructure
next;
}
my $group_hr = $Smokeping::cfg->{'Targets'}->{$group};
foreach my $server ( keys %{ $group_hr } ) {
unless ( ref $group_hr->{$server} && ref $group_hr->{$server} eq 'HASH' ) {
# Unless the entry in the smokeping hash is a reference to another datastructure
next;
}
# set fully_qualified_name to Group.Name, like in the UI
my $fully_qualified_name = "${group}.${server}";
my $host = $group_hr->{$server}->{host};
print "${fully_qualified_name}: ${host}\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment