cfg_file=//etc/icinga/objects/hosts_power.cfg
+cfg_file=//etc/icinga/objects/hosts_trb3.cfg
+
cfg_file=//etc/icinga/objects/hosts_hades.cfg
###############################################################################
# Config File for Monitoring etrax nodes
# This file was automatically generated from trb.db files by daq2icinga.pl
-# Creation time: 18.02.2014 at 11:08:53
+# Creation time: 16.03.2018 at 09:42:59
#
# HOST DEFINITIONS
###############################################################################
members etraxp107,etraxp119,hadesp31
}
-###############################################################################
-# Hosts from subcomponent start
-###############################################################################
-
-# HOST DEFINITION etraxp076
-define host{
- use etrax
- host_name etraxp076 ; assigned to start
- alias etraxp076_start
-}
-
-# HOST DEFINITION etraxp082
-define host{
- use etrax
- host_name etraxp082 ; assigned to start
- alias etraxp082_start
-}
-define hostgroup{
- hostgroup_name start
- alias etrax_start
- members etraxp076,etraxp082,etraxp107
-}
-
###############################################################################
# Hosts from subcomponent tof
###############################################################################
members etraxp031,etraxp040,etraxp051,etraxp052,etraxp053,etraxp054,etraxp056,etraxp059,etraxp061,etraxp063,etraxp065,etraxp067,etraxp074,etraxp075,etraxp078,etraxp080,etraxp083,etraxp085,etraxp089,etraxp091,etraxp092,etraxp094,etraxp110,etraxp122,etraxp054,etraxp059,etraxp089,etraxp091,etraxp092,etraxp094
}
-###############################################################################
-# Hosts from subcomponent shower
-###############################################################################
-define hostgroup{
- hostgroup_name shower
- alias etrax_shower
- members etraxp031,etraxp053,etraxp067,etraxp080,etraxp083,etraxp085
-}
-
###############################################################################
# Hosts from subcomponent wall
###############################################################################
alias etraxp096_hub
}
-# HOST DEFINITION etraxp097
-define host{
- use etrax
- host_name etraxp097 ; assigned to hub
- alias etraxp097_hub
-}
-
-# HOST DEFINITION etraxp098
-define host{
- use etrax
- host_name etraxp098 ; assigned to hub
- alias etraxp098_hub
-}
-
-# HOST DEFINITION etraxp099
-define host{
- use etrax
- host_name etraxp099 ; assigned to hub
- alias etraxp099_hub
-}
-
-# HOST DEFINITION etraxp100
-define host{
- use etrax
- host_name etraxp100 ; assigned to hub
- alias etraxp100_hub
-}
-
# HOST DEFINITION etraxp101
define host{
use etrax
alias etraxp102_hub
}
-# HOST DEFINITION etraxp103
-define host{
- use etrax
- host_name etraxp103 ; assigned to hub
- alias etraxp103_hub
-}
-
-# HOST DEFINITION etraxp104
-define host{
- use etrax
- host_name etraxp104 ; assigned to hub
- alias etraxp104_hub
-}
-
# HOST DEFINITION etraxp121
define host{
use etrax
define hostgroup{
hostgroup_name hub
alias etrax_hub
- members etraxp096,etraxp097,etraxp098,etraxp099,etraxp100,etraxp101,etraxp102,etraxp103,etraxp104,etraxp121,etraxp107
+ members etraxp096,etraxp101,etraxp102,etraxp121
}
###############################################################################
alias etraxp237_scs
}
+# HOST DEFINITION dreamp04
+define host{
+ use etrax
+ host_name dreamp04 ; assigned to slow control system
+ alias dreamp04_scs
+}
+
# HOST DEFINITION dreamp05
define host{
use etrax
define hostgroup{
hostgroup_name scs
alias etrax_scs
- members etraxp231,etraxp239,etraxp207,etraxp230,etraxp232,etraxp233,etraxp222,etraxp202,etraxp238,etraxp236,etraxp201,etraxp225,etraxp221,etraxp204,etraxp237,dreamp05,dreamp06,dreamp09
+ members etraxp231,etraxp239,etraxp207,etraxp230,etraxp232,etraxp233,etraxp222,etraxp202,etraxp238,etraxp236,etraxp201,etraxp225,etraxp221,etraxp204,etraxp237,dreamp04,dreamp05,dreamp06,dreamp09
}
define hostgroup{
hostgroup_name etrax
alias all etrax nodes
- hostgroup_members cts,start,tof,rpc,shower,wall,hub,scs
+ hostgroup_members cts,tof,rpc,wall,hub,scs
}
--- /dev/null
+###############################################################################
+# Config File for Monitoring trb3 ethernet nodes
+# This file was automatically generated from trb.db files by trb3sc2icinga.pl
+# Creation time: 16.03.2018 at 14:42:17
+#
+# HOST DEFINITIONS
+###############################################################################
+
+###############################################################################
+# Hosts from subcomponent ecal
+###############################################################################
+
+# HOST DEFINITION trb3sc009
+define host{
+ use trb3
+ host_name trb3sc009 ; assigned to ecal
+ alias trb3sc009_ecal
+}
+
+# HOST DEFINITION trb3sc128
+define host{
+ use trb3
+ host_name trb3sc128 ; assigned to ecal
+ alias trb3sc128_ecal
+}
+
+# HOST DEFINITION trb3sc129
+define host{
+ use trb3
+ host_name trb3sc129 ; assigned to ecal
+ alias trb3sc129_ecal
+}
+
+# HOST DEFINITION trb3sc130
+define host{
+ use trb3
+ host_name trb3sc130 ; assigned to ecal
+ alias trb3sc130_ecal
+}
+
+# HOST DEFINITION trb3sc131
+define host{
+ use trb3
+ host_name trb3sc131 ; assigned to ecal
+ alias trb3sc131_ecal
+}
+
+# HOST DEFINITION trb3sc134
+define host{
+ use trb3
+ host_name trb3sc134 ; assigned to ecal
+ alias trb3sc134_ecal
+}
+define hostgroup{
+ hostgroup_name ecal_trb3
+ alias trb3_ecal
+ members trb3sc009,trb3sc128,trb3sc129,trb3sc130,trb3sc131,trb3sc134
+}
+
+###############################################################################
+# Hosts from subcomponent rich
+###############################################################################
+
+# HOST DEFINITION trb3sc136
+define host{
+ use trb3
+ host_name trb3sc136 ; assigned to rich
+ alias trb3sc136_rich
+}
+
+# HOST DEFINITION trb3sc137
+define host{
+ use trb3
+ host_name trb3sc137 ; assigned to rich
+ alias trb3sc137_rich
+}
+
+# HOST DEFINITION trb3sc138
+define host{
+ use trb3
+ host_name trb3sc138 ; assigned to rich
+ alias trb3sc138_rich
+}
+
+# HOST DEFINITION trb3sc139
+define host{
+ use trb3
+ host_name trb3sc139 ; assigned to rich
+ alias trb3sc139_rich
+}
+
+# HOST DEFINITION trb3sc144
+define host{
+ use trb3
+ host_name trb3sc144 ; assigned to rich
+ alias trb3sc144_rich
+}
+
+# HOST DEFINITION trb3sc153
+define host{
+ use trb3
+ host_name trb3sc153 ; assigned to rich
+ alias trb3sc153_rich
+}
+
+# HOST DEFINITION trb3sc158
+define host{
+ use trb3
+ host_name trb3sc158 ; assigned to rich
+ alias trb3sc158_rich
+}
+
+# HOST DEFINITION trb3sc162
+define host{
+ use trb3
+ host_name trb3sc162 ; assigned to rich
+ alias trb3sc162_rich
+}
+
+# HOST DEFINITION trb3sc163
+define host{
+ use trb3
+ host_name trb3sc163 ; assigned to rich
+ alias trb3sc163_rich
+}
+
+# HOST DEFINITION trb3sc164
+define host{
+ use trb3
+ host_name trb3sc164 ; assigned to rich
+ alias trb3sc164_rich
+}
+
+# HOST DEFINITION trb3sc166
+define host{
+ use trb3
+ host_name trb3sc166 ; assigned to rich
+ alias trb3sc166_rich
+}
+define hostgroup{
+ hostgroup_name rich_trb3
+ alias trb3_rich
+ members trb3sc136,trb3sc137,trb3sc138,trb3sc139,trb3sc144,trb3sc153,trb3sc158,trb3sc162,trb3sc163,trb3sc164,trb3sc166
+}
+
+###############################################################################
+# Hosts from subcomponent start
+###############################################################################
+
+# HOST DEFINITION trbp006
+define host{
+ use trb3
+ host_name trbp006 ; assigned to start
+ alias trbp006_start
+}
+
+# HOST DEFINITION trbp074
+define host{
+ use trb3
+ host_name trbp074 ; assigned to start
+ alias trbp074_start
+}
+
+# HOST DEFINITION trbp106
+define host{
+ use trb3
+ host_name trbp106 ; assigned to start
+ alias trbp106_start
+}
+define hostgroup{
+ hostgroup_name start_trb3
+ alias trb3_start
+ members trbp006,trbp074,trbp106
+}
+
+###############################################################################
+# Hosts from subcomponent hub
+###############################################################################
+
+# HOST DEFINITION trb3sc142
+define host{
+ use trb3
+ host_name trb3sc142 ; assigned to cts
+ alias trb3sc142_cts
+}
+define hostgroup{
+ hostgroup_name hub_trb3
+ alias trb3_hub
+ members trb3sc142,trb3sc009,trb3sc128,trb3sc129,trb3sc130,trb3sc131,trb3sc134,trb3sc136,trb3sc137,trb3sc138,trb3sc139,trb3sc144,trb3sc153,trb3sc158,trb3sc162,trb3sc163,trb3sc164,trb3sc166
+}
+
+###############################################################################
+# Hosts from subcomponent cts
+###############################################################################
+define hostgroup{
+ hostgroup_name cts_trb3
+ alias trb3_cts
+ members trb3sc142
+}
+
+
+###############################################################################
+# Hostgroup definition for all nodes
+###############################################################################
+define hostgroup{
+ hostgroup_name trb3
+ alias all trb3 nodes
+ hostgroup_members ecal_trb3,rich_trb3,start_trb3,hub_trb3,cts_trb3
+}
+
+
+###############################################################################
+# Ping service for all nodes
+###############################################################################
+define service{
+ use remote-service
+ hostgroup_name trb3
+ service_description PING
+ check_command check-host-alive
+}
notification_period 24x7
}
+define host{
+ name trb3 ; The name of this host template
+ use linux-server
+ check_interval 5
+ notification_period 24x7
+}
+
+
+
define host{
name power ; The name of this host template
use linux-server
--- /dev/null
+#!/usr/bin/perl -w
+
+# trb3sc2icinga V0.1
+# convert trb3sc nodes from daq config to icinga hosts config file
+# v0.1: 15-Feb-2012 daq2icinga.pl Joern Adamczewski-Musch, gsi
+# v0.2: 18-Mar-2018 adjusted for trb3sc Joern Adamczewski-Musch, gsi
+#
+
+use English;
+use strict;
+use Getopt::Long;
+use FileHandle;
+use File::Path;
+use File::Basename;
+#use String::Scanf;
+
+
+my $icinga_config_file = "./hosts_trb3.cfg";
+my $daqpath = "/home/hadaq/trbsoft/daq/";
+my $dbfile = "trb3sc.db";
+my @subsystems = ("ecal","rich","start","tof","rpc","wall", "hub","cts"); # not for 2018,"pion"
+my @totalsystems;
+my @totalnodes;
+
+
+
+open( OUTFILE, '>', $icinga_config_file ) or die "Could not open $icinga_config_file: $! \n";
+
+print "Generating icinga config file $icinga_config_file ...\n";
+
+
+
+# first provide output file with standard header:
+ my ($sec, $min, $hr, $day, $mon, $year) = localtime;
+my $timestamp= sprintf("%02d.%02d.%04d at %02d:%02d:%02d",$day, $mon + 1, 1900 + $year, $hr, $min, $sec);
+
+
+print OUTFILE "###############################################################################\n";
+print OUTFILE "# Config File for Monitoring trb3 ethernet nodes\n";
+print OUTFILE "# This file was automatically generated from trb.db files by trb3sc2icinga.pl\n";
+print OUTFILE "# Creation time: $timestamp\n";
+print OUTFILE "#\n";
+print OUTFILE "# HOST DEFINITIONS\n";
+print OUTFILE "###############################################################################\n";
+
+
+foreach my $component(@subsystems)
+{
+ my $inputfile="$daqpath$component/$dbfile";
+ print " processing $inputfile ... \n";
+ my @validnodes;
+ my $rev=open( IFILE, '<', $inputfile);
+ if(!$rev)
+ {
+ # we do not have file, just set empty number with template:
+ print "Could not open $inputfile .\n";
+ }
+ else
+ {
+
+ my @hosts= <IFILE>;
+# my $numlongs = $#hosts + 1;
+# print "Using $numlongs entries from file $inputfile\n";
+ print OUTFILE "\n###############################################################################\n";
+ print OUTFILE "# Hosts from subcomponent $component\n";
+ print OUTFILE "###############################################################################\n";
+ @hosts = sort @hosts;
+ foreach my $line (@hosts) {
+ #ignore comments:
+ #- Remove all comments and whitespace:
+ next if ($line =~ /^\s*($|#)/);
+
+ # first define the host
+
+ my @larray=split(/\s+/,$line);
+ my $nodename=$larray[1];
+ my $cid=$larray[0];
+ print "Found node $nodename of component $cid\n";
+ if (grep {$_ eq $nodename} @totalnodes)
+ {
+ print "!!!! WARNING: found duplicate node $nodename in $inputfile!\n";
+ push(@validnodes, $nodename);
+ # we still assign the duplicate host to our group...
+ next;
+ }
+ push(@validnodes, $nodename);
+ push(@totalnodes, $nodename);
+ print OUTFILE "\n\# HOST DEFINITION $nodename \n";
+ print OUTFILE "define host{\n";
+ print OUTFILE " use trb3\n";
+ my $hdef = sprintf(" host_name %s \; assigned to %s \n",$nodename,$cid);
+ print OUTFILE $hdef;
+ my $adef = sprintf(" alias %s_%s \n",$nodename,$cid);
+ print OUTFILE $adef;
+ # to do: figure out ip from hostname
+# $ip= sscanf("trb3p%d", $nodename);
+# print "Found ip adress $ip \n";
+# my fullip=sprintf("address 192.168.101.%d\n",$ip);
+# print OUTFILE $fullip;
+ print OUTFILE "}\n";
+ }
+
+
+
+
+
+
+ # define hostgroup for this file
+ if($#validnodes>=0)
+ {
+ my $groupname = "$component\_trb3";
+ push(@totalsystems, $groupname);
+ print OUTFILE "define hostgroup{\n";
+ print OUTFILE " hostgroup_name $groupname \n";
+ print OUTFILE " alias trb3_$component\n";
+ my $members = join(",", @validnodes);
+ print OUTFILE " members $members \n";
+ print OUTFILE "}\n";
+ }
+ close(IFILE) || die "Couldn't close file $inputfile properly";
+
+ }
+
+}
+
+
+
+
+
+
+
+
+
+##################################################################################################################
+
+# define hostgroup of all components:
+print OUTFILE "\n\n###############################################################################\n";
+print OUTFILE "# Hostgroup definition for all nodes\n";
+print OUTFILE "###############################################################################\n";
+print OUTFILE "define hostgroup{\n";
+print OUTFILE " hostgroup_name trb3 \n";
+print OUTFILE " alias all trb3 nodes\n";
+my $groupmembers = join(",", @totalsystems);
+print OUTFILE " hostgroup_members $groupmembers \n";
+print OUTFILE "}\n";
+
+# define ping service for all nodes:
+print OUTFILE "\n\n###############################################################################\n";
+print OUTFILE "# Ping service for all nodes\n";
+print OUTFILE "###############################################################################\n";
+print OUTFILE "define service{\n";
+print OUTFILE " use remote-service\n";
+print OUTFILE " hostgroup_name trb3\n";
+print OUTFILE " service_description PING\n";
+print OUTFILE " check_command check-host-alive\n";
+print OUTFILE "}\n";
+
+
+
+close(OUTFILE) || die "Couldn't close file $icinga_config_file properly";
+
+print "\tdone.\n";