Changeset 1680

Show
Ignore:
Timestamp:
11/13/08 17:48:21 (2 months ago)
Author:
ton
Message:

Use the $servicecheck->command routine in nagconfgen, as web ui uses this

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/DEV-opsview3/opsview-core/bin/nagconfgen.pl

    r1679 r1680  
    429429} 
    430430 
     431# Special commands 
     432define command{ 
     433        command_name    negate 
     434        command_line    $libexecpath/negate $libexecpath/\$ARG1\$ 
     435} 
    431436define command{ 
    432437        command_name    my_check_snmp_linkstatus 
    433438        command_line    $libexecpath/check_snmp_linkstatus -H \$HOSTADDRESS\$ \$ARG1\$ -i -o -I \$ARG2\$ \$ARG3\$ 
    434439        } 
    435  
    436440define command{ 
    437441        command_name    set_to_stale 
    438442        command_line    /usr/local/nagios/bin/set_to_stale 
    439443        } 
    440  
    441444define command{ 
    442445        command_name    set_to_stale_timedoverride 
    443446        command_line    /usr/local/nagios/bin/set_to_stale 
    444447        } 
    445  
    446448define command{ 
    447449        command_name    refresh_state 
    448450        command_line    /usr/local/nagios/bin/refresh_state 
    449451        } 
    450  
    451452define command{ 
    452453        command_name    my_check_snmp 
    453454        command_line    $libexecpath/check_snmp -H \$HOSTADDRESS\$ -C \$ARG1\$ -P 2c -o \$ARG2\$ \$ARG3\$ 
    454455        } 
    455  
    456456define command{ 
    457457        command_name    check_ocsp_status 
    458458        command_line    /usr/local/nagios/bin/check_file_state /usr/local/nagios/var/ocsp.status 
    459459} 
    460  
    461460define command{ 
    462461        command_name    takeover_hosts 
     
    518517 
    519518                        my $commandalias; 
    520                         my $commandargs; 
    521519                        my %notification_options; 
    522520                        map { $notification_options{$_}++ } split(",", $s->notification_options); 
     
    524522                                $commandalias = "set_to_stale"; 
    525523                        } elsif ($s->checktype->id == 1) { 
    526                                 $commandalias = $s->plugin; 
    527                                 $commandargs = "!".$h->expand_host_macros($sc->{args}); 
     524                                $commandalias = $h->expand_host_macros($s->command(args => $sc->{args}, sep => "!")); 
    528525                        } elsif ($s->checktype->id == 4 || $s->checktype->id == 2) { 
    529526                                $commandalias = "refresh_state"; 
     
    537534                                        $oid = &SNMP::translateObj($oid); 
    538535                                } 
    539                                 $commandargs = "!".(Opsview::Utils->make_shell_friendly(Opsview::Utils->cleanup_args_for_nagios($h->snmp_community)))."!".$oid."!".$s->check_snmp_threshold_args; 
     536                                $commandalias .= "!".(Opsview::Utils->make_shell_friendly(Opsview::Utils->cleanup_args_for_nagios($h->snmp_community)))."!".$oid."!".$s->check_snmp_threshold_args; 
    540537                        } else { 
    541538                                $commandalias = "set_to_stale"; 
     
    547544        host_name ".$h->name." 
    548545        service_description     ".$s->name." 
    549         check_command           $commandalias$commandargs 
     546        check_command           $commandalias 
    550547        normal_check_interval   ".($s->check_interval || 5)." 
    551548        retry_check_interval    ".($s->retry_check_interval || 1)." 
     
    572569 
    573570                        if($sc->{timedoverride} && ${commandalias} ne "set_to_stale") { 
    574                                 my $args = $h->expand_host_macros($sc->{timedoverride_args}); 
    575                                 print OUTFILE " check_timeperiod_command    ".$sc->{timedoverride_timeperiod}.",".$commandalias."!".$args."\n"; 
     571                                my $args = $h->expand_host_macros($s->command(args => $sc->{timedoverride_args}, sep => "!")); 
     572                                print OUTFILE " check_timeperiod_command    ".$sc->{timedoverride_timeperiod}.",$args\n"; 
    576573                        }  
    577574 
  • branches/DEV-opsview3/opsview-core/lib/Opsview/Servicecheck.pm

    r1679 r1680  
    227227sub command { 
    228228        my $self = shift; 
    229         my %args = @_
     229        my %args = ( sep => " ", @_ )
    230230        my $command; 
    231         my $path = $args{fullpath} || ""; 
    232         if ($path && $path !~ /\/$/) { 
    233                 $path .= "/"; 
    234         } 
    235231        if ($self->invertresults) { 
    236                 $command = $path."negate "; 
     232                $command = "negate$args{sep}"; 
     233                $args{sep}=" "; 
    237234        } 
    238235        my $plugin_args; 
     
    248245                my $a = $self->args; 
    249246                $template =~ s/\$ARGS\$/$a/; 
    250                 $command .= $path.$template; 
     247                $command .= $template; 
    251248        } else { 
    252                 $command .= $path.$self->plugin." $plugin_args"; 
     249                $command .= $self->plugin; 
     250                $command .= $args{sep}.$plugin_args if $plugin_args; 
    253251        } 
    254252        return $command; 
  • branches/DEV-opsview3/opsview-core/t/var/configs/ClusterA/objects.cache

    r1679 r1680  
    244244        command_name    my_check_snmp_linkstatus 
    245245        command_line    /usr/local/nagios/libexec/check_snmp_linkstatus -H $HOSTADDRESS$ $ARG1$ -i -o -I $ARG2$ $ARG3$ 
     246        } 
     247 
     248define command { 
     249        command_name    negate 
     250        command_line    /usr/local/nagios/libexec/negate /usr/local/nagios/libexec/$ARG1$ 
    246251        } 
    247252 
  • branches/DEV-opsview3/opsview-core/t/var/configs/ClusterA/services.cfg

    r1679 r1680  
    2222} 
    2323 
     24# Special commands 
     25define command{ 
     26        command_name    negate 
     27        command_line    /usr/local/nagios/libexec/negate /usr/local/nagios/libexec/$ARG1$ 
     28} 
    2429define command{ 
    2530        command_name    my_check_snmp_linkstatus 
    2631        command_line    /usr/local/nagios/libexec/check_snmp_linkstatus -H $HOSTADDRESS$ $ARG1$ -i -o -I $ARG2$ $ARG3$ 
    2732        } 
    28  
    2933define command{ 
    3034        command_name    set_to_stale 
    3135        command_line    /usr/local/nagios/bin/set_to_stale 
    3236        } 
    33  
    3437define command{ 
    3538        command_name    set_to_stale_timedoverride 
    3639        command_line    /usr/local/nagios/bin/set_to_stale 
    3740        } 
    38  
    3941define command{ 
    4042        command_name    refresh_state 
    4143        command_line    /usr/local/nagios/bin/refresh_state 
    4244        } 
    43  
    4445define command{ 
    4546        command_name    my_check_snmp 
    4647        command_line    /usr/local/nagios/libexec/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -P 2c -o $ARG2$ $ARG3$ 
    4748        } 
    48  
    4949define command{ 
    5050        command_name    check_ocsp_status 
    5151        command_line    /usr/local/nagios/bin/check_file_state /usr/local/nagios/var/ocsp.status 
    5252} 
    53  
    5453define command{ 
    5554        command_name    takeover_hosts 
  • branches/DEV-opsview3/opsview-core/t/var/configs/Master Monitoring Server/objects.cache

    r1679 r1680  
    249249        command_name    my_check_snmp_linkstatus 
    250250        command_line    /usr/local/nagios/libexec/check_snmp_linkstatus -H $HOSTADDRESS$ $ARG1$ -i -o -I $ARG2$ $ARG3$ 
     251        } 
     252 
     253define command { 
     254        command_name    negate 
     255        command_line    /usr/local/nagios/libexec/negate /usr/local/nagios/libexec/$ARG1$ 
    251256        } 
    252257 
     
    28302835        service_description     AFS 
    28312836        check_period    24x7 
    2832         check_command   check_tcp!-H $HOSTADDRESS$ -p 548 
     2837        check_command   negate!check_tcp -H $HOSTADDRESS$ -p 548 
    28332838        event_handler   host6_service1_eh-done-for-afs 
    28342839        contact_groups  hostgroup5_servicegroup1/masterprofile 
  • branches/DEV-opsview3/opsview-core/t/var/configs/Master Monitoring Server/services.cfg

    r1679 r1680  
    2222} 
    2323 
     24# Special commands 
     25define command{ 
     26        command_name    negate 
     27        command_line    /usr/local/nagios/libexec/negate /usr/local/nagios/libexec/$ARG1$ 
     28} 
    2429define command{ 
    2530        command_name    my_check_snmp_linkstatus 
    2631        command_line    /usr/local/nagios/libexec/check_snmp_linkstatus -H $HOSTADDRESS$ $ARG1$ -i -o -I $ARG2$ $ARG3$ 
    2732        } 
    28  
    2933define command{ 
    3034        command_name    set_to_stale 
    3135        command_line    /usr/local/nagios/bin/set_to_stale 
    3236        } 
    33  
    3437define command{ 
    3538        command_name    set_to_stale_timedoverride 
    3639        command_line    /usr/local/nagios/bin/set_to_stale 
    3740        } 
    38  
    3941define command{ 
    4042        command_name    refresh_state 
    4143        command_line    /usr/local/nagios/bin/refresh_state 
    4244        } 
    43  
    4445define command{ 
    4546        command_name    my_check_snmp 
    4647        command_line    /usr/local/nagios/libexec/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -P 2c -o $ARG2$ $ARG3$ 
    4748        } 
    48  
    4949define command{ 
    5050        command_name    check_ocsp_status 
    5151        command_line    /usr/local/nagios/bin/check_file_state /usr/local/nagios/var/ocsp.status 
    5252} 
    53  
    5453define command{ 
    5554        command_name    takeover_hosts 
     
    10151014        host_name resolved_services 
    10161015        service_description     AFS 
    1017         check_command           check_tcp!-H $HOSTADDRESS$ -p 548 
     1016        check_command           negate!check_tcp -H $HOSTADDRESS$ -p 548 
    10181017        normal_check_interval   5 
    10191018        retry_check_interval    1 
  • branches/DEV-opsview3/opsview-core/t/var/opsview.test.db

    r1665 r1680  
    13271327LOCK TABLES `servicechecks` WRITE; 
    13281328/*!40000 ALTER TABLE `servicechecks` DISABLE KEYS */; 
    1329 INSERT INTO `servicechecks` VALUES (1,'AFS',1,'check_tcp','-H $HOSTADDRESS$ -p 548','Network Services',1,'AFS over TCP',0,'w,c,r',NULL,NULL,'5','1','3',0,NULL,0,1,NULL,1,0); 
     1329INSERT INTO `servicechecks` VALUES (1,'AFS',1,'check_tcp','-H $HOSTADDRESS$ -p 548','Network Services',1,'AFS over TCP',1,'w,c,r',NULL,NULL,'5','1','3',0,NULL,0,1,NULL,1,0); 
    13301330INSERT INTO `servicechecks` VALUES (2,'PowerChute',1,'check_tcp','-H $HOSTADDRESS$ -p 3052','Network Services',1,'Checks APC PoweChute on TCP port 3052',0,'w,c,r',NULL,NULL,'5','1','3',0,NULL,0,1,NULL,1,0); 
    13311331INSERT INTO `servicechecks` VALUES (3,'DHCP',1,'check_dhcp','','Network Services',1,'Checks DHCP on local network',0,'w,c,r',NULL,NULL,'5','1','3',0,NULL,0,1,NULL,1,0);