Dimstat and add on stats

In my working life I regularly use a tool called Dimstat, a unix performance monitoring tool which stores the statistics into a MySQL database. The tool is written by a former colleague and is available from http://dimitrik.free.fr/

It comes with ‘built in’ support to gather standard unix statistics such as vmstat, mpstat but one of the great features is the ability to add new statistics collection methods. It can handle single line output (e.g. vmstat) or multi line output like mpstat. Let’s say we want to gather filesystem utilisation information based on the output of df -k. This will be a multi-line STAT as we will have more than one filesystem reported.

Creating your script

First you create your script that gathers the information you want. You must remember to include a line separator field in your output (default newline) so dimstat knows that the record is complete and also a field to accept the interval.

So here’s my basic script, you may want to adjust the filesystems I am excluding from the list (or make the egrep more elegant!)

# cat mel_df.sh
#!/bin/bash
while true
do
df -k |egrep -v 'fd|mnttab|objfs|sharetab|Filesystem|volatile|proc|devices|contract|dev' | sort | awk  '{ print $6 " " $2 " " $3 " " $4}'
echo ""
sleep $1
done

Test your script interactively

# ./mel_df.sh 5
/logpool 1717567488 31 1262824069
/var/fmw/app 1717567488 454729292 1262824069
/rpool 429391872 73 164531945
/ 429391872 14039895 164531945
/var 429391872 125827192 164531945
/var/share 429391872 195 164531945
/export 429391872 32 164531945
/export/home 429391872 35 164531945
/export/home/oracle 429391872 1415887 164531945
/export/home/otd_user 429391872 35 164531945
/export/home/weblogic 429391872 36 164531945
/zones 429391872 32 164531945
/zones/otd-zone 429391872 35 164531945
/tmp 235826528 48 235826480

/logpool 1717567488 31 1262824069
/var/fmw/app 1717567488 454729292 1262824069
/rpool 429391872 73 164531769
/ 429391872 14039895 164531769
/var 429391872 125827196 164531769
/var/share 429391872 195 164531769
/export 429391872 32 164531769
/export/home 429391872 35 164531769
/export/home/oracle 429391872 1415887 164531769
/export/home/otd_user 429391872 35 164531769
/export/home/weblogic 429391872 36 164531769
/zones 429391872 32 164531769
/zones/otd-zone 429391872 35 164531769
/tmp 235826528 48 235826480

Now you copy the script into /etc/STATsrv/bin on the hosts you want to capture the statistics from.

Then you edit the /etc/STATsrv/access file and add a line pointing to your script, and giving it the name ‘DF_CHECK’

command  DF_check       /etc/STATsrv/bin/mel_df.sh

On the host with the STATsrv demon we can check if this stat is advertised and available..

 ./STATcmd -h localhost -c STAT_LIST
STAT *** OK CONNECTION 0 sec.
STAT *** LIST COMMAND (STAT_LIST)
STAT: vmstat
STAT: mpstat
STAT: netstat
STAT: ForkExec
STAT: MEMSTAT
STAT: tailX
STAT: ioSTAT.sh
STAT: netLOAD.sh
STAT: netLOAD
STAT: psSTAT
STAT: UserLOAD
STAT: ProcLOAD
STAT: bsdlink
STAT: bsdlink.sh
STAT: sysinfo
STAT: SysINFO
STAT: Siostat
STAT: ProjLOAD
STAT: PoolLOAD
STAT: TaskLOAD
STAT: ZoneLOAD
STAT: IOpatt
STAT: CPUSet
STAT: UDPstat
STAT: DF_check
STAT *** LIST END (STAT_LIST)

We can test if the STATsrv demon can run the script

 ./STATcmd -h localhost -c "DF_check 1"
STAT *** OK CONNECTION 0 sec.
STAT *** OK COMMAND (cmd: DF_check)
/logpool 1717567488 31 891420077
/var/fmw/app 1717567488 826058863 891420077
/rpool 429391872 73 55609192
/ 429391872 10794969 55609192
/var 429391872 237518790 55609192
/var/share 429391872 169 55609192
/export 429391872 32 55609192
/export/home 429391872 35 55609192
/export/home/mel 429391872 2871626 55609192
/export/home/oracle 429391872 136058 55609192
/export/home/weblogic 429391872 36 55609192
/tmp 194877488 296 194877192

/logpool 1717567488 31 891420077
/var/fmw/app 1717567488 826058863 891420077
/rpool 429391872 73 55609192
/ 429391872 10794969 55609192
/var 429391872 237518790 55609192
/var/share 429391872 169 55609192
/export 429391872 32 55609192
/export/home 429391872 35 55609192
/export/home/mel 429391872 2871626 55609192
/export/home/oracle 429391872 136058 55609192
/export/home/weblogic 429391872 36 55609192
/tmp 194877488 296 194877192

Declaring your script to the Dimstat server

You have 2 methods to declare your script to the server, either via the GUI or by importing a stat definition file (the format for these files make this option for experienced users only)

Via the GUI you select ADD-on STATS -> Integrate new ADD-on STAT

Enter the name of your STAT: DF_check and complete the information about the column names and data types

dimstat

Once you have declared your add on stat you should now be able to start a new collect on the host using your new statistic. Once it has collected some data, the button for your statistic will become visible in the Analyze page.

Sample stat description file

# =======================================================================
# DF_check: dim_STAT New STAT Description
# =======================================================================
DF_check
4
1
DF_check Statistic(s)
DF_check %i


# =======================================================================
# Column: v_df_check_att (mountpoint)
# =======================================================================
v_df_check_att
64
1
mountpoint
mountpoint
0
# =======================================================================
# Column: v_column4 (size_kb)
# =======================================================================
v_column4
1
2
size_kb
size_kb
0
# =======================================================================
# Column: v_column5 (used_kb)
# =======================================================================
v_column5
1
3
used_kb
used_kb
0
# =======================================================================
# Column: v_column6 (free_kb)
# =======================================================================
v_column6
1
4
free_kb
free_kb
0

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s