~asanjar/charms/trusty/hdp-hadoop/test

« back to all changes in this revision

Viewing changes to hooks/test/hdp_scripts/hdp_manual_install_rpm_helper_files-2.1.1.385/configuration_files/nagios/plugins/check_rpcq_latency.php

  • Committer: amir sanjar
  • Date: 2014-07-21 19:53:44 UTC
  • Revision ID: amir.sanjar@canonical.com-20140721195344-a23z0lrebqzhl167
namenode & data node initialization

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
 * Licensed to the Apache Software Foundation (ASF) under one
4
 
 * or more contributor license agreements.  See the NOTICE file
5
 
 * distributed with this work for additional information
6
 
 * regarding copyright ownership.  The ASF licenses this file
7
 
 * to you under the Apache License, Version 2.0 (the
8
 
 * "License"); you may not use this file except in compliance
9
 
 * with the License.  You may obtain a copy of the License at
10
 
 *
11
 
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 
 *
13
 
 * Unless required by applicable law or agreed to in writing, software
14
 
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 
 * See the License for the specific language governing permissions and
17
 
 * limitations under the License.
18
 
 */
19
 
 
20
 
/* This plugin makes call to master node, get the jmx-json document
21
 
 * It checks the rpc wait time in the queue, RpcQueueTime_avg_time
22
 
 * check_rpcq_latency -h hostaddress -p port -t ServiceName -w 1 -c 1
23
 
 * Warning and Critical values are in seconds
24
 
 * Service Name = JobTracker, NameNode, JobHistoryServer
25
 
 */
26
 
 
27
 
  $options = getopt ("h:p:w:c:n:");
28
 
  if (!array_key_exists('h', $options) || !array_key_exists('p', $options) || !array_key_exists('w', $options)
29
 
      || !array_key_exists('c', $options) || !array_key_exists('n', $options)) {
30
 
    usage();
31
 
    exit(3);
32
 
  }
33
 
 
34
 
  $host=$options['h'];
35
 
  $port=$options['p'];
36
 
  $master=$options['n'];
37
 
  $warn=$options['w'];
38
 
  $crit=$options['c'];
39
 
 
40
 
  /* Get the json document */
41
 
  $json_string = file_get_contents("http://".$host.":".$port."/jmx?qry=Hadoop:service=".$master.",name=RpcActivityForPort*");
42
 
  $json_array = json_decode($json_string, true);
43
 
  $object = $json_array['beans'][0];
44
 
 
45
 
  $RpcQueueTime_avg_time = round($object['RpcQueueTime_avg_time'], 2); 
46
 
  $RpcProcessingTime_avg_time = round($object['RpcProcessingTime_avg_time'], 2);
47
 
 
48
 
  $out_msg = "RpcQueueTime_avg_time:<" . $RpcQueueTime_avg_time .
49
 
             "> Secs, RpcProcessingTime_avg_time:<" . $RpcProcessingTime_avg_time .
50
 
             "> Secs";
51
 
 
52
 
  if ($RpcQueueTime_avg_time >= $crit) {
53
 
    echo "CRITICAL: " . $out_msg . "\n";
54
 
    exit (2);
55
 
  }
56
 
  if ($RpcQueueTime_avg_time >= $warn) {
57
 
    echo "WARNING: " . $out_msg . "\n";
58
 
    exit (1);
59
 
  }
60
 
  echo "OK: " . $out_msg . "\n";
61
 
  exit(0);
62
 
 
63
 
  /* print usage */
64
 
  function usage () {
65
 
    echo "Usage: $0 -h <host> -p port -n <JobTracker/NameNode/JobHistoryServer> -w <warn_in_sec> -c <crit_in_sec>\n";
66
 
  }
67
 
?>