【问题标题】:Monitor jenkins jobs health using nagios GUI使用 nagios GUI 监控 jenkins 作业运行状况
【发布时间】:2012-12-26 06:26:35
【问题描述】:

我正在使用 check_http 插件来发现 jenkins 服务(Winstone 托管和 Apache 托管)是否在安装了 check_mk_agent 的主机上运行。并且使用以下命令在 nagios GUI 的单个 ui 上对其进行监控。

./check_http -H Host_Name -u /api/xml?depth=0 -p 8080

下一步是使用 jenkins REST api 解析特定 jenkins 主服务器上的作业,并在 nagios GUI 中监控每个作业的运行状况。

有人可以给我任何想法,以便我可以在单个 GUI 上监控 jenkins 作业。非常感谢任何脚本或插件。

【问题讨论】:

    标签: jenkins hudson monitoring nagios


    【解决方案1】:
    #!/usr/bin/perl
    use strict;
    use warnings;
    use LWP::UserAgent;
    use XML::Twig;
    use HTTP::Request;
    use Getopt::Long;
    use Nagios::Plugin;
    #use File::stat;
    
    use File::Basename;
    my $PROGNAME = basename($0);
    
    my $p = Nagios::Plugin->new(
        usage => "Usage: %s [ -H|--host ] [ -p|--port ]",
        extra => "
        Examples:
        $PROGNAME --host myhost -port 8080
        Check Host name and port.
    ");
    
    $p->add_arg(
        spec => 'host|f=s',
        required => 1,
        help => "-H, --host=Hostname. REQUIRED.");
    
    $p->add_arg(
        spec => 'port|a=i',
        default => 8080,
        help => "-p, --port=Portnumber. Default 8080.");
    
    $p->getopts;
    
    my $o_host = $p->opts->host ;
    my $o_port = $p->opts->port;
    my $protocol = 'http';
    my $o_url = '/api/xml';
    my @jobs;
    
    my $url = $protocol . "://" . $o_host . ":" . $o_port . $o_url ;
    #print $url,"\n";
    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    $ua->env_proxy;
    my $response = $ua->get($url);
    if ($response->is_success) {
        my $content = $response->decoded_content;  # or whatever
        XML::Twig->new( twig_roots => { 'job/name' => sub { push @jobs, $_->text; } }) ->parseurl( $url);
    }
    else {
        $p->nagios_die( CRITICAL, "Bad page found" );
    }
    #print @jobs;
    foreach my $job_name (@jobs) {
            #print $job_name;
            my $job_url = $protocol . "://" . $o_host . ":" . $o_port . "/" . "job" . "/" . $job_name . $o_url ;
            #print $job_url;
            my $response2 = $ua->get($job_url);
            #print $job_url;
            if ($response2->is_success) {
                $p->nagios_die( OK, "Job link valid" );
            }
            else {
                $p->nagios_die( CRITICAL, "Bad page found" );
            }
    }
    

    【讨论】:

      猜你喜欢
      • 2012-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多