In the last post we prepared/configured Stats Store(sstore) with our own schema.below I am going to show you haw to capture and prepare the data to be able to populate in the Stats Store(sstore) format.

DB related scripts are below

chk_db-ses.sh – get db sessions

The below script will return the number of active system sessions in MySQL which will then be populate to the Stats store(sstore) with the results.
cat /opt/sys_monitor/conf/chk_db1_apps-ses.sh

1

2

3

4

5

6

7

#!/usr/bin/env bash

### Export environment variable settings

./opt/sys_monitor/conf/set_env

mysql-uroot-ppassword-t<<!END

show status where`variable_name`='Threads_connected'

!END

checks db query timing

The below script will run a particular query which takes some time to return (you can replace with your own query). We will then populate the Stats store with the time it took to complete the query.
cat /opt/sys_monitor/conf/test_db1_apps.sh

1

2

3

4

5

6

7

8

9

#!/usr/bin/env bash

#set -x

### Export environment variable settings

./opt/sys_monitor/conf/set_env

mysql-uroot-ppassword-t<<!END

usewordpress;

select count(*)from wp_posts;

!END

Python capture scripts.

Stats python capture script

The below Python capture script captures OS data as well as db data (like the two scripts above).
cat /opt/sys_monitor/bin/capture.py

"date":{

"date_time":1472679323

},

"disk":{

"dsk_0b_rmb":10,

"dsk_0b_rop":1327,

"dsk_0b_rtm":326,

"dsk_0b_wmb":0,

"dsk_0b_wop":134,

"dsk_0b_wtm":4,

"dsk_0c_rmb":11,

"dsk_0c_rop":1432,

"dsk_0c_rtm":334,

"dsk_0c_wmb":0,

"dsk_0c_wop":134,

"dsk_0c_wtm":4

},

"db1":{

"db1_qry":24,

"db1_ses":2107,

"lst_qry":1472679318

},

"memory":{

"mem_tot":261120,

"mem_usd":205772

},

"network":{

"net_rmb":2,

"net_smb":3

},

"swap":{

"swp_tot":92159,

"swp_usd":0

}

}

Note: in many cases you need to update the below seeings in the capture scripts – /opt/sys_monitor/bin/capture.py
Your device can be seen with iostat -xc
Your network device can be seen with ipadm or dladm