Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / power5 / consumed_cpu_cycles @ 4b2fcbf8

Historique | Voir | Annoter | Télécharger (1,98 ko)

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=$MUNIN_PLUGSTATE/power5-consumed_cpu_cycles.state
33
# check input parameters
34
if [ "$1" = "autoconf" ]; then
35
	echo yes
36
	exit 0
37
fi
38

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

    
51
# let's do the main job
52

    
53
# get cpus in partition
54
unset LANG
55

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

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

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

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

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

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

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

    
88
echo "cpuCycles.value $CPUCYCLES"