~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/ganglia/objects/gmondLib.sh

  • 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
 
#!/bin/sh
2
 
 
3
 
#/*
4
 
# * Licensed to the Apache Software Foundation (ASF) under one
5
 
# * or more contributor license agreements.  See the NOTICE file
6
 
# * distributed with this work for additional information
7
 
# * regarding copyright ownership.  The ASF licenses this file
8
 
# * to you under the Apache License, Version 2.0 (the
9
 
# * "License"); you may not use this file except in compliance
10
 
# * with the License.  You may obtain a copy of the License at
11
 
# *
12
 
# *     http://www.apache.org/licenses/LICENSE-2.0
13
 
# *
14
 
# * Unless required by applicable law or agreed to in writing, software
15
 
# * distributed under the License is distributed on an "AS IS" BASIS,
16
 
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 
# * See the License for the specific language governing permissions and
18
 
# * limitations under the License.
19
 
# */
20
 
 
21
 
cd `dirname ${0}`;
22
 
 
23
 
# Slurp in all our user-customizable settings.
24
 
source ./gangliaEnv.sh;
25
 
 
26
 
# Get access to Ganglia-wide constants etc.
27
 
source ./gangliaLib.sh;
28
 
 
29
 
GMOND_BIN=/usr/sbin/gmond;
30
 
GMOND_CORE_CONF_FILE=gmond.core.conf;
31
 
GMOND_MASTER_CONF_FILE=gmond.master.conf;
32
 
GMOND_SLAVE_CONF_FILE=gmond.slave.conf;
33
 
GMOND_PID_FILE=gmond.pid;
34
 
 
35
 
# Functions.
36
 
function getGmondCoreConfFileName()
37
 
{
38
 
    clusterName=${1};
39
 
 
40
 
    if [ "x" != "x${clusterName}" ]
41
 
    then
42
 
        # ${clusterName} is not empty. 
43
 
        echo "${GANGLIA_CONF_DIR}/${clusterName}/${GMOND_CORE_CONF_FILE}";
44
 
    else
45
 
        echo "${GANGLIA_CONF_DIR}/${GMOND_CORE_CONF_FILE}";
46
 
    fi
47
 
}
48
 
 
49
 
function getGmondMasterConfFileName()
50
 
{
51
 
    clusterName=${1};
52
 
 
53
 
    if [ "x" != "x${clusterName}" ]
54
 
    then
55
 
        # ${clusterName} is not empty. 
56
 
        echo "${GANGLIA_CONF_DIR}/${clusterName}/conf.d/${GMOND_MASTER_CONF_FILE}";
57
 
    else
58
 
        echo "${GANGLIA_CONF_DIR}/conf.d/${GMOND_MASTER_CONF_FILE}";
59
 
    fi
60
 
}
61
 
 
62
 
function getGmondSlaveConfFileName()
63
 
{
64
 
    clusterName=${1};
65
 
 
66
 
    if [ "x" != "x${clusterName}" ]
67
 
    then
68
 
        # ${clusterName} is not empty. 
69
 
        echo "${GANGLIA_CONF_DIR}/${clusterName}/conf.d/${GMOND_SLAVE_CONF_FILE}";
70
 
    else
71
 
        echo "${GANGLIA_CONF_DIR}/conf.d/${GMOND_SLAVE_CONF_FILE}";
72
 
    fi
73
 
}
74
 
 
75
 
function getGmondPidFileName()
76
 
{
77
 
    clusterName=${1};
78
 
 
79
 
    if [ "x" != "x${clusterName}" ]
80
 
    then
81
 
        # ${clusterName} is not empty. 
82
 
        echo "${GANGLIA_RUNTIME_DIR}/${clusterName}/${GMOND_PID_FILE}";
83
 
    else
84
 
        echo "${GANGLIA_RUNTIME_DIR}/${GMOND_PID_FILE}";
85
 
    fi
86
 
}
87
 
 
88
 
function getGmondLoggedPid()
89
 
{
90
 
    gmondPidFile=`getGmondPidFileName ${1}`;
91
 
 
92
 
    if [ -e "${gmondPidFile}" ]
93
 
    then
94
 
        echo `cat ${gmondPidFile}`;
95
 
    fi
96
 
}
97
 
 
98
 
function getGmondRunningPid()
99
 
{
100
 
    gmondLoggedPid=`getGmondLoggedPid ${1}`;
101
 
 
102
 
    if [ -n "${gmondLoggedPid}" ]
103
 
    then
104
 
        echo `ps -o pid=MYPID -p ${gmondLoggedPid} | tail -1 | awk '{print $1}' | grep -v MYPID`;
105
 
    fi
106
 
}
107
 
 
108
 
function generateGmondCoreConf()
109
 
{
110
 
    clusterName=${1};
111
 
 
112
 
    if [ "x" != "x${clusterName}" ]
113
 
    then
114
 
        read gmondClusterName gmondMasterIP gmondPort <<<`getGangliaClusterInfo ${clusterName}`;
115
 
 
116
 
        # Check that all of ${gmondClusterName} and ${gmondMasterIP} and ${gmondPort} are populated.
117
 
        if [ "x" != "x${gmondClusterName}" -a "x" != "x${gmondMasterIP}" -a "x" != "x${gmondPort}" ]
118
 
        then
119
 
            now=`date`;
120
 
 
121
 
            cat << END_OF_GMOND_CORE_CONF
122
 
#################### Generated by ${0} on ${now} ####################
123
 
#
124
 
/* This configuration is as close to 2.5.x default behavior as possible
125
 
   The values closely match ./gmond/metric.h definitions in 2.5.x */
126
 
globals {
127
 
  daemonize = yes
128
 
  setuid = yes
129
 
  user = ${GMOND_USER}
130
 
  debug_level = 0
131
 
  max_udp_msg_len = 1472
132
 
  mute = no
133
 
  deaf = no 
134
 
  allow_extra_data = yes
135
 
  host_dmax = 0 /*secs */
136
 
  host_tmax = 20 /*secs */
137
 
  cleanup_threshold = 300 /*secs */
138
 
  gexec = no
139
 
  send_metadata_interval = 30 /*secs */
140
 
}
141
 
 
142
 
/*
143
 
 * The cluster attributes specified will be used as part of the <CLUSTER>
144
 
 * tag that will wrap all hosts collected by this instance.
145
 
 */
146
 
cluster {
147
 
  name = "${gmondClusterName}"
148
 
  owner = "unspecified"
149
 
  latlong = "unspecified"
150
 
  url = "unspecified"
151
 
}
152
 
 
153
 
/* The host section describes attributes of the host, like the location */
154
 
host {
155
 
  location = "unspecified"
156
 
}
157
 
 
158
 
/* You can specify as many tcp_accept_channels as you like to share
159
 
 * an XML description of the state of the cluster.
160
 
 *
161
 
 * At the very least, every gmond must expose its XML state to 
162
 
 * queriers from localhost.
163
 
 */
164
 
tcp_accept_channel {
165
 
  bind = localhost
166
 
  port = ${gmondPort}
167
 
}
168
 
 
169
 
/* Each metrics module that is referenced by gmond must be specified and
170
 
   loaded. If the module has been statically linked with gmond, it does
171
 
   not require a load path. However all dynamically loadable modules must
172
 
   include a load path. */
173
 
modules {
174
 
  module {
175
 
    name = "core_metrics"
176
 
  }
177
 
  module {
178
 
    name = "cpu_module"
179
 
    path = "modcpu.so"
180
 
  }
181
 
  module {
182
 
    name = "disk_module"
183
 
    path = "moddisk.so"
184
 
  }
185
 
  module {
186
 
    name = "load_module"
187
 
    path = "modload.so"
188
 
  }
189
 
  module {
190
 
    name = "mem_module"
191
 
    path = "modmem.so"
192
 
  }
193
 
  module {
194
 
    name = "net_module"
195
 
    path = "modnet.so"
196
 
  }
197
 
  module {
198
 
    name = "proc_module"
199
 
    path = "modproc.so"
200
 
  }
201
 
  module {
202
 
    name = "sys_module"
203
 
    path = "modsys.so"
204
 
  }
205
 
}
206
 
 
207
 
/* The old internal 2.5.x metric array has been replaced by the following
208
 
   collection_group directives.  What follows is the default behavior for
209
 
   collecting and sending metrics that is as close to 2.5.x behavior as
210
 
   possible. */
211
 
 
212
 
/* This collection group will cause a heartbeat (or beacon) to be sent every
213
 
   20 seconds.  In the heartbeat is the GMOND_STARTED data which expresses
214
 
   the age of the running gmond. */
215
 
collection_group {
216
 
  collect_once = yes
217
 
  time_threshold = 20
218
 
  metric {
219
 
    name = "heartbeat"
220
 
  }
221
 
}
222
 
 
223
 
/* This collection group will send general info about this host total memory every
224
 
   180 secs.
225
 
   This information doesn't change between reboots and is only collected
226
 
   once. This information needed for heatmap showing */
227
 
 collection_group {
228
 
   collect_once = yes
229
 
   time_threshold = 180
230
 
   metric {
231
 
    name = "mem_total"
232
 
    title = "Memory Total"
233
 
   }
234
 
 }
235
 
 
236
 
/* This collection group will send general info about this host every
237
 
   1200 secs.
238
 
   This information doesn't change between reboots and is only collected
239
 
   once. */
240
 
collection_group {
241
 
  collect_once = yes
242
 
  time_threshold = 1200
243
 
  metric {
244
 
    name = "cpu_num"
245
 
    title = "CPU Count"
246
 
  }
247
 
  metric {
248
 
    name = "cpu_speed"
249
 
    title = "CPU Speed"
250
 
  }
251
 
  /* Should this be here? Swap can be added/removed between reboots. */
252
 
  metric {
253
 
    name = "swap_total"
254
 
    title = "Swap Space Total"
255
 
  }
256
 
  metric {
257
 
    name = "boottime"
258
 
    title = "Last Boot Time"
259
 
  }
260
 
  metric {
261
 
    name = "machine_type"
262
 
    title = "Machine Type"
263
 
  }
264
 
  metric {
265
 
    name = "os_name"
266
 
    title = "Operating System"
267
 
  }
268
 
  metric {
269
 
    name = "os_release"
270
 
    title = "Operating System Release"
271
 
  }
272
 
  metric {
273
 
    name = "location"
274
 
    title = "Location"
275
 
  }
276
 
}
277
 
 
278
 
/* This collection group will send the status of gexecd for this host
279
 
   every 300 secs.*/
280
 
/* Unlike 2.5.x the default behavior is to report gexecd OFF. */
281
 
collection_group {
282
 
  collect_once = yes
283
 
  time_threshold = 300
284
 
  metric {
285
 
    name = "gexec"
286
 
    title = "Gexec Status"
287
 
  }
288
 
}
289
 
 
290
 
/* This collection group will collect the CPU status info every 20 secs.
291
 
   The time threshold is set to 90 seconds.  In honesty, this
292
 
   time_threshold could be set significantly higher to reduce
293
 
   unneccessary  network chatter. */
294
 
collection_group {
295
 
  collect_every = 20
296
 
  time_threshold = 90
297
 
  /* CPU status */
298
 
  metric {
299
 
    name = "cpu_user"
300
 
    value_threshold = "1.0"
301
 
    title = "CPU User"
302
 
  }
303
 
  metric {
304
 
    name = "cpu_system"
305
 
    value_threshold = "1.0"
306
 
    title = "CPU System"
307
 
  }
308
 
  metric {
309
 
    name = "cpu_idle"
310
 
    value_threshold = "5.0"
311
 
    title = "CPU Idle"
312
 
  }
313
 
  metric {
314
 
    name = "cpu_nice"
315
 
    value_threshold = "1.0"
316
 
    title = "CPU Nice"
317
 
  }
318
 
  metric {
319
 
    name = "cpu_aidle"
320
 
    value_threshold = "5.0"
321
 
    title = "CPU aidle"
322
 
  }
323
 
  metric {
324
 
    name = "cpu_wio"
325
 
    value_threshold = "1.0"
326
 
    title = "CPU wio"
327
 
  }
328
 
  /* The next two metrics are optional if you want more detail...
329
 
     ... since they are accounted for in cpu_system.
330
 
  metric {
331
 
    name = "cpu_intr"
332
 
    value_threshold = "1.0"
333
 
    title = "CPU intr"
334
 
  }
335
 
  metric {
336
 
    name = "cpu_sintr"
337
 
    value_threshold = "1.0"
338
 
    title = "CPU sintr"
339
 
  }
340
 
  */
341
 
}
342
 
 
343
 
collection_group {
344
 
  collect_every = 20
345
 
  time_threshold = 90
346
 
  /* Load Averages */
347
 
  metric {
348
 
    name = "load_one"
349
 
    value_threshold = "1.0"
350
 
    title = "One Minute Load Average"
351
 
  }
352
 
  metric {
353
 
    name = "load_five"
354
 
    value_threshold = "1.0"
355
 
    title = "Five Minute Load Average"
356
 
  }
357
 
  metric {
358
 
    name = "load_fifteen"
359
 
    value_threshold = "1.0"
360
 
    title = "Fifteen Minute Load Average"
361
 
  }
362
 
}
363
 
 
364
 
/* This group collects the number of running and total processes */
365
 
collection_group {
366
 
  collect_every = 80
367
 
  time_threshold = 950
368
 
  metric {
369
 
    name = "proc_run"
370
 
    value_threshold = "1.0"
371
 
    title = "Total Running Processes"
372
 
  }
373
 
  metric {
374
 
    name = "proc_total"
375
 
    value_threshold = "1.0"
376
 
    title = "Total Processes"
377
 
  }
378
 
}
379
 
 
380
 
/* This collection group grabs the volatile memory metrics every 40 secs and
381
 
   sends them at least every 180 secs.  This time_threshold can be increased
382
 
   significantly to reduce unneeded network traffic. */
383
 
collection_group {
384
 
  collect_every = 40
385
 
  time_threshold = 180
386
 
  metric {
387
 
    name = "mem_free"
388
 
    value_threshold = "1024.0"
389
 
    title = "Free Memory"
390
 
  }
391
 
  metric {
392
 
    name = "mem_shared"
393
 
    value_threshold = "1024.0"
394
 
    title = "Shared Memory"
395
 
  }
396
 
  metric {
397
 
    name = "mem_buffers"
398
 
    value_threshold = "1024.0"
399
 
    title = "Memory Buffers"
400
 
  }
401
 
  metric {
402
 
    name = "mem_cached"
403
 
    value_threshold = "1024.0"
404
 
    title = "Cached Memory"
405
 
  }
406
 
  metric {
407
 
    name = "swap_free"
408
 
    value_threshold = "1024.0"
409
 
    title = "Free Swap Space"
410
 
  }
411
 
}
412
 
 
413
 
collection_group {
414
 
  collect_every = 40
415
 
  time_threshold = 300
416
 
  metric {
417
 
    name = "bytes_out"
418
 
    value_threshold = 4096
419
 
    title = "Bytes Sent"
420
 
  }
421
 
  metric {
422
 
    name = "bytes_in"
423
 
    value_threshold = 4096
424
 
    title = "Bytes Received"
425
 
  }
426
 
  metric {
427
 
    name = "pkts_in"
428
 
    value_threshold = 256
429
 
    title = "Packets Received"
430
 
  }
431
 
  metric {
432
 
    name = "pkts_out"
433
 
    value_threshold = 256
434
 
    title = "Packets Sent"
435
 
  }
436
 
}
437
 
 
438
 
 
439
 
collection_group {
440
 
  collect_every = 40
441
 
  time_threshold = 180
442
 
  metric {
443
 
    name = "disk_free"
444
 
    value_threshold = 1.0
445
 
    title = "Disk Space Available"
446
 
  }
447
 
  metric {
448
 
    name = "part_max_used"
449
 
    value_threshold = 1.0
450
 
    title = "Maximum Disk Space Used"
451
 
  }
452
 
  metric {
453
 
    name = "disk_total"
454
 
    value_threshold = 1.0
455
 
    title = "Total Disk Space"
456
 
  }
457
 
}
458
 
 
459
 
udp_recv_channel {
460
 
    port = 0
461
 
}
462
 
 
463
 
 
464
 
include ("${GANGLIA_CONF_DIR}/${gmondClusterName}/conf.d/*.conf")
465
 
END_OF_GMOND_CORE_CONF
466
 
        else
467
 
            return 2;
468
 
        fi
469
 
    else
470
 
        return 1;
471
 
    fi
472
 
}
473
 
 
474
 
function generateGmondMasterConf
475
 
{
476
 
    clusterName=${1};
477
 
 
478
 
    if [ "x" != "x${clusterName}" ]
479
 
    then
480
 
        read gmondClusterName gmondMasterIP gmondPort <<<`getGangliaClusterInfo ${clusterName}`;
481
 
 
482
 
        # Check that all of ${gmondClusterName} and ${gmondMasterIP} and ${gmondPort} are populated.
483
 
        if [ "x" != "x${gmondClusterName}" -a "x" != "x${gmondMasterIP}" -a "x" != "x${gmondPort}" ]
484
 
        then
485
 
            now=`date`;
486
 
 
487
 
            cat << END_OF_GMOND_MASTER_CONF
488
 
#################### Generated by ${0} on ${now} ####################
489
 
/* Masters only receive; they never send. */
490
 
udp_recv_channel {
491
 
  bind = ${gmondMasterIP}
492
 
  port = ${gmondPort}
493
 
}
494
 
 
495
 
/* The gmond cluster master must additionally provide an XML 
496
 
 * description of the cluster to the gmetad that will query it.
497
 
 */
498
 
tcp_accept_channel {
499
 
  bind = ${gmondMasterIP}
500
 
  port = ${gmondPort}
501
 
}
502
 
END_OF_GMOND_MASTER_CONF
503
 
        else
504
 
            return 2;
505
 
        fi
506
 
    else
507
 
        return 1;
508
 
    fi
509
 
}
510
 
 
511
 
function generateGmondSlaveConf
512
 
{
513
 
    clusterName=${1};
514
 
 
515
 
    if [ "x" != "x${clusterName}" ]
516
 
    then
517
 
        read gmondClusterName gmondMasterIP gmondPort <<<`getGangliaClusterInfo ${clusterName}`;
518
 
 
519
 
        # Check that all of ${gmondClusterName} and ${gmondMasterIP} and ${gmondPort} are populated.
520
 
        if [ "x" != "x${gmondClusterName}" -a "x" != "x${gmondMasterIP}" -a "x" != "x${gmondPort}" ]
521
 
        then
522
 
            now=`date`;
523
 
 
524
 
            cat << END_OF_GMOND_SLAVE_CONF
525
 
#################### Generated by ${0} on ${now} ####################
526
 
/* Slaves only send; they never receive. */
527
 
udp_send_channel {
528
 
  #bind_hostname = yes # Highly recommended, soon to be default.
529
 
                       # This option tells gmond to use a source address
530
 
                       # that resolves to the machine's hostname.  Without
531
 
                       # this, the metrics may appear to come from any
532
 
                       # interface and the DNS names associated with
533
 
                       # those IPs will be used to create the RRDs.
534
 
  host = ${gmondMasterIP}
535
 
  port = ${gmondPort}
536
 
  ttl = 1
537
 
}
538
 
END_OF_GMOND_SLAVE_CONF
539
 
        else
540
 
            return 2;
541
 
        fi
542
 
    else
543
 
        return 1;
544
 
    fi
545
 
}