Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
monitors:db_cpu.ksh [2014/02/27 04:22] – [db_cpu.ksh] vernon | monitors:db_cpu.ksh [2014/02/27 04:37] (current) – [Changelog] vernon | ||
---|---|---|---|
Line 5: | Line 5: | ||
^ Requirements | Perl, Oracle Database, Solaris | | ^ Requirements | Perl, Oracle Database, Solaris | | ||
^ Download | None | | ^ Download | None | | ||
- | ^ Last Update | 2013-04-23 | | + | ^ Last Update | <del>2013-04-23</ |
===== Description ===== | ===== Description ===== | ||
Line 882: | Line 882: | ||
# | # | ||
COLOUR=green | COLOUR=green | ||
- | TOP=/ | + | type top >> /dev/null |
+ | ERR=$? | ||
+ | if [ $ERR -eq 0 ] | ||
+ | then | ||
+ | | ||
+ | else | ||
+ | [ -x / | ||
+ | fi | ||
CPU_tmp=$XYMONTMP/ | CPU_tmp=$XYMONTMP/ | ||
TEMPFILE=$XYMONTMP/ | TEMPFILE=$XYMONTMP/ | ||
Line 911: | Line 919: | ||
# Get the idle figure. Run top -d4, and take the last value to prevent | # Get the idle figure. Run top -d4, and take the last value to prevent | ||
# a possible skewed result from the other xymon tasks that have just kicked off. | # a possible skewed result from the other xymon tasks that have just kicked off. | ||
- | IDLE=$($TOP -n -d4 | grep "^CPU states" | + | if [ -x $TOP ] |
- | IDLE=" | + | then |
+ | # We have a working version of top | ||
+ | IDLE=$($TOP -n -d4 | grep "^CPU states" | ||
+ | | ||
+ | else | ||
+ | # No working top. We will have to resort to iostat. | ||
+ | # Pity. Top is at least accurate to 1 decimal place. | ||
+ | IDLE=$(iostat -p 2 5 | awk '{ print $NF }' | tail -1) | ||
+ | IDLE=" | ||
+ | fi | ||
# Set DBID to your oracle identifier. You can use the userID or the username | # Set DBID to your oracle identifier. You can use the userID or the username | ||
# or any value that will identify your oracle processes in a ps | grep | # or any value that will identify your oracle processes in a ps | grep | ||
- | DBID="oracle" | + | DBID="^ 0000100" |
# Get a list of all Databases running on the system | # Get a list of all Databases running on the system | ||
- | DBLIST=$(ps -efa | grep $DBID | grep pmon | cut -d" | + | DBLIST=$(ps -efa | grep "$DBID" |
if [ -z " | if [ -z " | ||
then | then | ||
echo "No databases found!" | echo "No databases found!" | ||
[ " | [ " | ||
- | DB_USED=" | + | DB_USED=" |
else | else | ||
# Get a list of all the processes and their CPU utilisation. | # Get a list of all the processes and their CPU utilisation. | ||
Line 956: | Line 973: | ||
fi | fi | ||
DB_USED=$(echo " | DB_USED=$(echo " | ||
+ | USAGE=$(echo $USAGE | sed 's/ \./ | ||
echo "$DB $USAGE" | echo "$DB $USAGE" | ||
done | done | ||
fi | fi | ||
- | |||
if [ $SHOW_IDLE -eq 1 ] | if [ $SHOW_IDLE -eq 1 ] | ||
then | then | ||
Line 968: | Line 985: | ||
# We only change the IDLE and OTHER values though, not the database values. | # We only change the IDLE and OTHER values though, not the database values. | ||
# Those are real data. | # Those are real data. | ||
- | if [ $OTHER -le 0 ] | + | if [ $OTHER -lt 0 ] |
then | then | ||
IDLE=$(echo ${IDLE}+${OTHER} | bc) | IDLE=$(echo ${IDLE}+${OTHER} | bc) | ||
Line 977: | Line 994: | ||
| | ||
| | ||
+ | | ||
echo "$DB $USAGE" | echo "$DB $USAGE" | ||
| | ||
| | ||
+ | | ||
echo "$DB $USAGE" | echo "$DB $USAGE" | ||
fi | fi | ||
Line 996: | Line 1015: | ||
rm $CPU_tmp | rm $CPU_tmp | ||
rm $TEMPFILE $TEMPFILE.2 | rm $TEMPFILE $TEMPFILE.2 | ||
- | |||
</ | </ | ||
Line 1055: | Line 1073: | ||
* **2013-04-23** | * **2013-04-23** | ||
* Updated to handle the case of no databases running. Previously, it just didn't bother doing anything, but now it will report there are no databases, and can trigger a colour change if there are no databases found. | * Updated to handle the case of no databases running. Previously, it just didn't bother doing anything, but now it will report there are no databases, and can trigger a colour change if there are no databases found. | ||
+ | * **2014-02-27** | ||
+ | * Updated to run with Solaris 11. | ||
+ | * If top isn't available, (Solaris 10 and earlier) will use iostat to get idle stats. | ||
+ | * Fixed a few display bugs. |