solaris-analytics-publisher
Solaris Analytics Capture And Publisher
This repository contains Solaris 11.4+(12) Analytics Capture and Publisher sample code. The sample code will help you getting quickly up and running, and possibly add your own statistics.
The sample application will extend the Solaris Stats Store Schema. The list of stats are below. Note: Two of the stats uses scripts to capture MySQL/DB related stats (below), feel free to add/remove your own stats.
"description": "date_time", "id": "//:class.app/company/servers//:stat.date_time", "description": "cpu usage sys", "id": "//:class.app/company/servers//:stat.cpu.usage-sys", "description": "cpu usage usr", "id": "//:class.app/company/servers//:stat.cpu.usage-usr", "description": "cpu total", "id": "//:class.app/company/servers//:stat.cpu.usage-total", "description": "memory total", "id": "//:class.app/company/servers//:stat.memory-total", "description": "memory used", "id": "//:class.app/company/servers//:stat.memory-used", "description": "swap total", "id": "//:class.app/company/servers//:stat.swap-total", "description": "swap used", "id": "//:class.app/company/servers//:stat.swap-used", "description": "net in megabytes", "id": "//:class.app/company/servers//:stat.net.in-megabytes", "description": "network out megabytes", "id": "//:class.app/company/servers//:stat.net.out-megabytes", "description": "disk read-megabytes (0B)", "id": "//:class.app/company/servers//:stat.disk.read-megabytes-0B", "description": "disk write-megabytes (0B)", "id": "//:class.app/company/servers//:stat.disk.write-megabytes-0B", "description": "disk read-ops (0B)", "id": "//:class.app/company/servers//:stat.disk.read-ops-0B", "description": "disk write-ops (0B)", "id": "//:class.app/company/servers//:stat.disk.write-ops-0B", "description": "disk read wait-time (0B)", "id": "//:class.app/company/servers//:stat.disk.read_wait-time-0B", "description": "disk write wait-time (0B)", "id": "//:class.app/company/servers//:stat.disk.write_wait-time-0B", "description": "disk read-megabytes (0C)", "id": "//:class.app/company/servers//:stat.disk.read-megabytes-0C", "description": "disk write-megabytes (0C)", "id": "//:class.app/company/servers//:stat.disk.write-megabytes-0C", "description": "disk read-ops (0C)", "id": "//:class.app/company/servers//:stat.disk.read-ops-0C", "description": "disk write-ops (0C)", "id": "//:class.app/company/servers//:stat.disk.write-ops-0C", "description": "disk read wait-time (0C)", "id": "//:class.app/company/servers//:stat.disk.read_wait-time-0C", "description": "disk write wait-time (0C)", "id": "//:class.app/company/servers//:stat.disk.write_wait-time-0C", "description": "db1 query-time", "id": "//:class.app/company/servers//:stat.db1.qry-time", "description": "db1 session-count", "id": "//:class.app/company/servers//:stat.db1.ses-count", "description": "db1 date generate", "id": "//:class.app/company/servers//:stat.db1.date_gen",
Versions
Version 0.2
Note: This update significantly enhances Analytics collection on Solaris 11.4+(12).
- Removed the need for an extra Python HTTP server to gather remote analytics (this is still needed for pre s11.4 clients).
- Removed the need for a local SQLite Database (this is still needed for pre s11.4 clients).
- Updated all REST API calls to use Solars Remote Administration Demon(RAD) Authentication.
The new version only needs one service/demon to run on the remote node.
All data captured is stored in the local Stats Store.
The remote Stats Store central server queries / pulls from all the remote client.
The install adds two new SMF services and two new Python applications.
To use the new version (preferred for Solaris 11.4+/12) follow the instructions below in the install section.
Version 0.1
Initial Release
Getting Started
Installation
The following Python libraries are required: Dependencies / Prerequisites
os, sys, time, socket, string, json, sqlite3, threading, subprocess, multiprocessing, psutil as ps, from functools import partial, from libsstore import SStore, from multiprocessing import Process, from pprint import pprint, from urllib2 import Request, urlopen, URLError, from urlparse import urlparse # Solaris 11.4+(12) import rad.auth as rada import rad.client as radcli import rad.connect as radcon import rad.bindings.com.oracle.solaris.rad.sstore_1 as sstoreNote: You can install libraries by running pip install [library]
The directory layout are explained below. Application Layout Details
- /opt/sys_monitor/conf: contains configuration scripts
- /opt/sys_monitor/bin: python code to capture and exposed stats
- /opt/sys_monitor/db: contains local sqlite db with latest stat record
- /opt/sys_monitor/services: contains Solaris xml service files
- /opt/sys_monitor/startup: smf startup helper scripts
- /opt/sys_monitor/modules: psutil module (only needed for install)
- /opt/sys_monitor/statsSrc: contains custom stats Src Json files
To use Analytics sample application, follow the steps below. Usage examples
Note: Additional details are avalble at Capturing Your Own Solaris 11.4 (12) Analytics / Sstore
Solaris 11.4+(12)
- Clone the git repository in to /opt/sys_monitor with git clone. for example, git clone https://github.com/elik1001/solaris-analytics-publisher
- Modify /opt/sys_monitor/bin/capture_from_local-s11_4.py, replace disks1/sd1 and disk2/sd4 with your sd device - you can find your device with iostat -xc (left col).
- Modify /opt/sys_monitor/bin/capture_from_local-s11_4.py, replace net1/interface1 and disk2/interface2 with your network device - you can find your device with ipadm.
- Modify /opt/sys_monitor/bin/pull_from_remote-s11_4.py, replace user and password with your remote host user and password
- Modify/add you host to /opt/sys_monitor/conf/s12-links.txt, this file contains a list of hosts to fetch data from, the data will then be published to the local central Analytics Stats Store.
- Add/replace /opt/sys_monitor/conf/chk_db1_apps-ses.sh and /opt/sys_monitor/conf/test_db1_apps.sh with your MySQL DB password (or if you allow localhost without a password, just remove -p option)
- Optional: Add any (MySQL) required variables to /opt/sys_monitor/conf/set_env
Pre Solaris 11.4+(12)
- Clone the git repository in to /opt/sys_monitor with git clone. for example, git clone https://github.com/elik1001/solaris-analytics-publisher
- On the target host, modify /opt/sys_monitor/bin/capture.py, replace db1_host if listening for remote traffic (default is localhost).
- Modify /opt/sys_monitor/bin/capture.py, replace disks1/sd1 and disk2/sd4 with your sd device - you can find your device with iostat -xc (left col).
- Modify /opt/sys_monitor/bin/capture.py, replace net1/interface1 and disk2/interface2 with your network device - you can find your device with ipadm.
- Optional: Modify /opt/sys_monitor/bin/get_results.py, replace host with your hostname (or localhost)
- Modiyf/add you host to /opt/sys_monitor/conf/links.txt, this file contains the list of hosts to fetch results which will then be published to Analytics(Sstore).
- Add/replace /opt/sys_monitor/conf/chk_db1_apps-ses.sh and /opt/sys_monitor/conf/test_db1_apps.sh with your MySQL DB password (or if you allow localhost, just remove it)
- Optional: Add any MySQL required variables to /opt/sys_monitor/conf/set_env
Solaris 11.4+(12)
First Copy the Stats Store (sstore) custom json files to the stats directory.
cp /opt/sys_monitor/statsSrc/*.json /usr/lib/sstore/metadata/json/site
Now, restart the Stats Store service for the new stats to be available.
svcadm restart svc:/system/sstore:default
Solaris 11.4+(12)
To use the application, you will need to import the SMF services, by running the below..
- Used for local capture:
svccfg import /opt/sys_monitor/services/s11_4-capture_service.xml - Used for pulling the remote host analytics:
svccfg import /opt/sys_monitor/services/s11_4-pull_from_remote.xml
Pre Solaris 11.4+(12)
To use the application, you will need to import the SMF services, by running the below..
- Used for local capture:
svccfg import /opt/sys_monitor/services/s11_4-capture_service.xml - Exposes the local analytics with the HTTP interface:
svccfg import /opt/sys_monitor/services/s11_4-pull_from_remote.xml - Used for pulling the remote host analytics:
svccfg import /opt/sys_monitor/services/populate_service.xml
Make sure the services are up and running, by running the below.
S11.4+ svcs svc:/application/monitor/s11_4-local_stats_capture:default svc:/application/monitor/s11_4-remote_stats_capture:default STATE STIME FMRI online 17:24:45 svc:/application/monitor/s11_4-local_stats_capture:default online 17:24:45 svc:/application/monitor/s11_4-remote_stats_capture:default Pre S11.4 svcs svc:/application/stats_capture:default svc:/application/stats_result:default svc:/application/monitor/update_stats:default STATE STIME FMRI online 12:58:35 svc:/application/stats_capture:default online 12:58:35 svc:/application/stats_result:default online 12:59:33 svc:/application/monitor/update_stats:default
You are now ready to setup stats on the Solaris BUI/GUI dashboard. Login to https://localhost:6787/
- In the Dashboard, click on the right side on Applications and select Solaris Analytics.
- Click Add sheet, then give it a name
- Click on Add a Visualization, then click on the left side gear and select add statistic
- Now select, I want to enter a new statistic
- Now you have plenty of options, but I will show one example below
In Class : app/company/servers
In Resource: server/your_server_name (or *)
In Statistic: db1.ses-count
In Operation: (optional) sum
A sample screen shut is below.