Projet

Général

Profil

Révision b096ad6d

IDb096ad6d86a7aa388266deeeb436e1c130a5b4e2
Parent 6355d3d2
Enfant 6d1acea4

Ajouté par Jens Schanz il y a presque 14 ans

Initial version

Voir les différences:

plugins/other/consumed_cpu_cycles
1
#!/bin/sh
2
#
3
# Copyright (C) 2006 Jens Schanz
4
#
5
# Plugin to monitor the consumed CPU cycles of an uncapped LPAR
6
# on a power5 system for linux
7
#
8
# Parameters:
9
#
10
#       config   (required)
11
#       autoconf (optional - used by munin-config)
12
#
13
# $Log: lop5-consumed_cpu_cycles.sh,v $
14
# Revision 1.1  2006/12/08 10:08:33  schanz
15
# *** empty log message ***
16
#
17
#
18
# Revision 1.0  20.11.2006 - first build
19
#
20
# If you have any suggestions, questions, or enhancements, feel free to email
21
# me at mail@jensschanz.de
22
#
23
# Let's go ...
24
#
25
# Magick markers (optional - used by munin-config and some installation
26
# scripts):
27
#%# family=auto
28
#%# capabilities=autoconf
29

  
30
LPARCFG=/proc/ppc64/lparcfg
31

  
32
# STATEFILE=/var/lib/munin/plugin-state/power5-consumed_cpu_cycles.state
33
STATEFILE=/tmp/power5-consumed_cpu_cycles.state
34
# check input parameters
35
if [ "$1" = "autoconf" ]; then
36
	echo yes
37
	exit 0
38
fi
39

  
40
if [ "$1" = "config" ]; then
41
	echo 'graph_title Consumed CPU cycles'
42
	echo 'graph_args -l 0'
43
	echo 'graph_category Power5'
44
	echo 'graph_vlabel CPU cycles'
45
	echo 'graph_info This graph shows the CPU cycles on an uncapped LPAR'
46
	
47
	echo 'cpuCycles.label used CPU cycles'
48
	
49
	exit 0
50
fi
51

  
52
# let's do the main job
53

  
54
# get cpus in partition
55
unset LANG
56

  
57
# get actual time
58
ACTUALTIME=`date +%s`;
59

  
60
# get old time
61
if [ -f $STATEFILE ]; then
62
	OLDTIME=`cat $STATEFILE | grep OLDTIME | awk -F = '{print $2}'`;
63
else
64
	echo "OLDTIME = $ACTUALTIME" > $STATEFILE;
65
	OLDTIME=$ACTUALTIME;
66
fi
67

  
68
# get timebase
69
TIMEBASE=`cat /proc/cpuinfo | grep timebase | awk -F : '{print $2}'`;
70

  
71
# get actual purr
72
ACTUALPURR=`cat $LPARCFG| grep purr | awk -F = '{print $2}'`;
73

  
74
# get old purr
75
if [ -f $STATEFILE ]; then
76
	OLDPURR=`cat $STATEFILE | grep OLDPURR | awk -F = '{print $2}'`;
77
else
78
	echo "OLDPURR = $ACTUALPURR" >> $STATEFILE;
79
	OLDPURR=$ACTUALPURR;
80
fi
81

  
82
# calcualte CPU cycles
83
CPUCYCLES=$(echo $OLDPURR $ACTUALPURR $TIMEBASE $OLDTIME $ACTUALTIME | awk '{printf ("%.1f", (($1-$2)/$3)/($4-$5));}');
84

  
85
# write data to state file
86
echo "OLDTIME = $ACTUALTIME" > $STATEFILE;
87
echo "OLDPURR = $ACTUALPURR" >> $STATEFILE;
88

  
89
echo "cpuCycles.value $CPUCYCLES"

Formats disponibles : Unified diff