From: hadaq Date: Fri, 17 Feb 2012 13:31:17 +0000 (+0000) Subject: JAM: added evaluation of epics etrax nodes to daq2icinga.pl X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=7ddd89bbf78d0b1d97b31e6f9c68a2384dedeecc;p=hadesicinga.git JAM: added evaluation of epics etrax nodes to daq2icinga.pl icinga configuration for hades hosts --- diff --git a/icinga/objects/commands.cfg b/icinga/objects/commands.cfg index 5b795ff..ed9b4da 100644 --- a/icinga/objects/commands.cfg +++ b/icinga/objects/commands.cfg @@ -335,5 +335,23 @@ define command { +#my_check_disk_smartctl.pl +define command { + command_name check_disk_smartctl + command_line $USER1$/my_check_disk_smartctl.pl -d $ARG1$ -d $ARG2$ +} + +#my_check_disk_smartctl.pl +define command { + command_name check_disk_smartctl_by_ssh + command_line $USER1$/check_by_ssh -l $ARG1$ -H $HOSTADDRESS$ -C "/usr/lib/nagios/plugins/my_check_disk_smartctl.pl $ARG2$ $ARG3$" +} + +#check_by_ssh my_check_raid.pl +define command { + command_name check_raid_by_ssh + command_line $USER1$/check_by_ssh -l $ARG1$ -H $HOSTADDRESS$ -C "/usr/lib/nagios/plugins/check_linux_raid.pl" +} + diff --git a/icinga/objects/daq2icinga.pl b/icinga/objects/daq2icinga.pl index 1f18baf..cff6f9d 100755 --- a/icinga/objects/daq2icinga.pl +++ b/icinga/objects/daq2icinga.pl @@ -18,6 +18,8 @@ my $icinga_config_file = "./hosts_etrax.cfg"; my $daqpath = "/home/hadaq/trbsoft/daq/"; my $dbfile = "trb.db"; my @subsystems = ("cts","mdc","start","tof","rpc","shower"); +# on hadesdaq02 we also have access to epics: +my $epicsconfig = "/home/scs/apps/hades/db/desc_ioc.db"; my @totalsystems; my @totalnodes; open( OUTFILE, '>', $icinga_config_file ) or die "Could not open $icinga_config_file: $! \n"; @@ -116,32 +118,75 @@ foreach my $component(@subsystems) } # add the slow control etrax nodes (fixed) +my @scsnodes; +my $rev=open( EIFILE, '<', $epicsconfig); + if(!$rev) + { + # we do not have file, just set empty number with template: + print "Could not open $epicsconfig. use all etraxp2**\n"; + my $i; + for ($i=1;$i<=50;$i++) + { + my $index= 200+$i; + my $scnode=sprintf("etraxp%d",$index); + push(@scsnodes, $scnode); + push(@totalnodes, $scnode); + + } + + + } + else + { + + my @elines= ; + foreach my $line (@elines) { + #ignore comments: + # Filter out headers which indicate used nodenames: + if ($line =~ /.*HADCON:.*/) + { + + my @larray=split(/\s+/,$line); + my $nodename="$larray[2]"; + $nodename=~ s/etrax/etraxp/; + print "Found line $line , nodename=$nodename\n"; + if (grep {$_ eq $nodename} @totalnodes) + { + print "!!!! WARNING: found duplicate node $nodename in $epicsconfig! Skipped.\n"; + next; + } + push(@scsnodes, $nodename); + push(@totalnodes, $nodename); + } + + } + close(EIFILE) || die "Couldn't close file $epicsconfig properly"; + } + + + print OUTFILE "\n###############################################################################\n"; print OUTFILE "# Hosts for slow control:\n"; print OUTFILE "###############################################################################\n"; -my @scsnodes; -my $i; -for ($i=1;$i<=50;$i++) -{ - my $index= 200+$i; - my $scnode=sprintf("etraxp%d",$index); - push(@scsnodes, $scnode); - push(@totalnodes, $scnode); - print OUTFILE "\n\# HOST DEFINITION $scnode \n"; - print OUTFILE "define host{\n"; - print OUTFILE " use etrax\n"; - my $hdef = sprintf(" host_name %s \; assigned to slow control system\n",$scnode); - print OUTFILE $hdef; - my $adef = sprintf(" alias %s_scs \n",$scnode); - print OUTFILE $adef; - print OUTFILE "}\n"; +foreach my $scnode (@scsnodes) { + print OUTFILE "\n\# HOST DEFINITION $scnode \n"; + print OUTFILE "define host{\n"; + print OUTFILE " use etrax\n"; + my $hdef = sprintf(" host_name %s \; assigned to slow control system\n",$scnode); + print OUTFILE $hdef; + my $adef = sprintf(" alias %s_scs \n",$scnode); + print OUTFILE $adef; + print OUTFILE "}\n"; + } + + # define hostgroup of scs nodes: print OUTFILE "\n\n###############################################################################\n"; -print OUTFILE "# Hostgroup definition for all nodes\n"; +print OUTFILE "# Hostgroup definition for scs nodes\n"; print OUTFILE "###############################################################################\n"; print OUTFILE "define hostgroup{\n"; print OUTFILE " hostgroup_name scs \n"; diff --git a/icinga/objects/hosts_etrax.cfg b/icinga/objects/hosts_etrax.cfg index 624e78f..b0595b0 100644 --- a/icinga/objects/hosts_etrax.cfg +++ b/icinga/objects/hosts_etrax.cfg @@ -1,7 +1,7 @@ ############################################################################### # Config File for Monitoring etrax nodes # This file was automatically generated from trb.db files by daq2icinga.pl -# Creation time: 16.02.2012 at 10:22:21 +# Creation time: 17.02.2012 at 14:29:30 # # HOST DEFINITIONS ############################################################################### @@ -302,6 +302,118 @@ define hostgroup{ # Hosts from subcomponent shower ############################################################################### +############################################################################### +# Hosts for slow control: +############################################################################### + +# HOST DEFINITION etraxp231 +define host{ + use etrax + host_name etraxp231 ; assigned to slow control system + alias etraxp231_scs +} + +# HOST DEFINITION etraxp239 +define host{ + use etrax + host_name etraxp239 ; assigned to slow control system + alias etraxp239_scs +} + +# HOST DEFINITION etraxp207 +define host{ + use etrax + host_name etraxp207 ; assigned to slow control system + alias etraxp207_scs +} + +# HOST DEFINITION etraxp210 +define host{ + use etrax + host_name etraxp210 ; assigned to slow control system + alias etraxp210_scs +} + +# HOST DEFINITION etraxp232 +define host{ + use etrax + host_name etraxp232 ; assigned to slow control system + alias etraxp232_scs +} + +# HOST DEFINITION etraxp234 +define host{ + use etrax + host_name etraxp234 ; assigned to slow control system + alias etraxp234_scs +} + +# HOST DEFINITION etraxp203 +define host{ + use etrax + host_name etraxp203 ; assigned to slow control system + alias etraxp203_scs +} + +# HOST DEFINITION etraxp202 +define host{ + use etrax + host_name etraxp202 ; assigned to slow control system + alias etraxp202_scs +} + +# HOST DEFINITION etraxp208 +define host{ + use etrax + host_name etraxp208 ; assigned to slow control system + alias etraxp208_scs +} + +# HOST DEFINITION etraxp236 +define host{ + use etrax + host_name etraxp236 ; assigned to slow control system + alias etraxp236_scs +} + +# HOST DEFINITION etraxp201 +define host{ + use etrax + host_name etraxp201 ; assigned to slow control system + alias etraxp201_scs +} + +# HOST DEFINITION etraxp225 +define host{ + use etrax + host_name etraxp225 ; assigned to slow control system + alias etraxp225_scs +} + +# HOST DEFINITION etraxp221 +define host{ + use etrax + host_name etraxp221 ; assigned to slow control system + alias etraxp221_scs +} + +# HOST DEFINITION etraxp237 +define host{ + use etrax + host_name etraxp237 ; assigned to slow control system + alias etraxp237_scs +} + + +############################################################################### +# Hostgroup definition for scs nodes +############################################################################### +define hostgroup{ + hostgroup_name scs + alias etrax_scs + members etraxp231,etraxp239,etraxp207,etraxp210,etraxp232,etraxp234,etraxp203,etraxp202,etraxp208,etraxp236,etraxp201,etraxp225,etraxp221,etraxp237 +} + ############################################################################### # Hostgroup definition for all nodes @@ -309,7 +421,7 @@ define hostgroup{ define hostgroup{ hostgroup_name etrax alias all etrax nodes - hostgroup_members cts,start,tof,rpc + hostgroup_members cts,start,tof,rpc,scs } diff --git a/icinga/objects/templates.cfg b/icinga/objects/templates.cfg index 9123128..ad25530 100644 --- a/icinga/objects/templates.cfg +++ b/icinga/objects/templates.cfg @@ -143,6 +143,14 @@ define host{ notification_period 24x7 } +define host{ + name hades-host ; The name of this host template + use linux-server + check_interval 3 + notification_period 24x7 +} + + define host{ name etrax ; The name of this host template use linux-server