By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SmartData CollectiveSmartData Collective
  • Analytics
    AnalyticsShow More
    AI analytics
    AI-Based Analytics Are Changing the Future of Credit Cards
    6 Min Read
    data overload showing data analytics
    How Does Next-Gen SIEM Prevent Data Overload For Security Analysts?
    8 Min Read
    hire a marketing agency with a background in data analytics
    5 Reasons to Hire a Marketing Agency that Knows Data Analytics
    7 Min Read
    predictive analytics for amazon pricing
    Using Predictive Analytics to Get the Best Deals on Amazon
    8 Min Read
    data science anayst
    Growing Demand for Data Science & Data Analyst Roles
    6 Min Read
  • Big Data
  • BI
  • Exclusive
  • IT
  • Marketing
  • Software
Search
© 2008-23 SmartData Collective. All Rights Reserved.
Reading: Monitoring a System
Share
Notification Show More
Aa
SmartData CollectiveSmartData Collective
Aa
Search
  • About
  • Help
  • Privacy
Follow US
© 2008-23 SmartData Collective. All Rights Reserved.
SmartData Collective > Uncategorized > Monitoring a System
Uncategorized

Monitoring a System

Editor SDC
Last updated: 2010/01/24 at 8:26 PM
Editor SDC
5 Min Read
SHARE
I’ve been using Python with IbPy, rather than Matlab. The code I post will most likely be in Python going forward. I like it because it’s more natural, ex. default and variable arguments are concise, no semicolons, dictionaries; it’s open source so there are more libraries and it’s free (Matlab requires a “license server” for instances running in parallel, for example); and it’s easier to organize code with better package management, simple classes, and files are more flexible.

Anyway, I like to know what’s going on with my system when I’m away. The system writes out a log of errors, trades, finished processes, etc, and also emails me important events like Trader Workstation shutting down, and executed trades. These go to my Blackberry wherever I am. To send emails from/to a Gmail account…

I’ve been using Python with IbPy, rather than Matlab. The code I post will most likely be in Python going forward. I like it because it’s more natural, ex. default and variable arguments are concise, no semicolons, dictionaries; it’s open source so there are more libraries and it’s free (Matlab requires a “license server” for instances running in parallel, for example); and it’s easier to organize code with better package management, simple classes, and files are more flexible.

Anyway, I like to know what’s going on with my system when I’m away. The system writes out a log of errors, trades, finished processes, etc, and also emails me important events like Trader Workstation shutting down, and executed trades. These go to my Blackberry wherever I am. To send emails from/to a Gmail account, which I like to use because it has a lot of storage and can be searched easily, I had to write a little script (code at the bottom) to add to the Python logging library since Gmail uses a special kind of authentication not supported by the standard library.

Here’s how I use it:
import logging
logging.config.fileConfig(“/yourdirectorystructure/logging.conf“)
logging.debug(‘Live trading online’)
logging.critical(strategy_name+’ ‘+signal+’ ‘+position_size+’ ‘+etf)
What that says is: load Python’s logging library (which does most of the work for me); then configure it according to my preferences in the file logging.conf; then as an example send a debug-level message ‘Live trading loop starting’; and then a critical-level message with the strategy name, buy/sell signal, position size, and ETF name. These two messages are taken out of context from one of my strategies, so the variables don’t reference anything here. The first is called when I turn on the system, the second is called whenever a trade is executed.
It looks like this in the inbox:
logging.debug(msg) sends a debug(low)-level message to be logged, in my case it prints to a console window and writes to a file. logging.critical(msg) sends a critical(high)-level message, which goes to the console and file, and also gets sent to my email address.
It used to be frustrating to wake up in the morning and see that my system had crashed at some unknown point in the night for some unknown reason, but now I know what’s going on, when it’s happening, and why.
Python’s logging library isn’t documented very well, especially the email handler and file configuration, so I thought sharing these two parts would be useful. Here’s my configuration file, from above (modify it to set the directory where you want to store logs), and the custom Gmail email handler (modify it for your own username/password). The overall logging system works well and adds the minimum amount of superfluous code.
I’m interested in knowing how others have approached the problem of monitoring and logging.

More Read

hire the right python developers for your data science team

Roles of Python Developer in Data Science Teams

Python for Business: Optimize Pre-Processing Data for Decision-Making
An Introduction To Hands-On Text Analytics In Python
7 Lessons That Will Teach You All You Need To Know About Machine Learning
Why Choosing Python For Data Science Is An Important Move

TAGGED: python, system architecture
Editor SDC January 24, 2010
Share This Article
Facebook Twitter Pinterest LinkedIn
Share

Follow us on Facebook

Latest News

Data Ethics: Safeguarding Privacy and Ensuring Responsible Data Practices
Data Ethics: Safeguarding Privacy and Ensuring Responsible Data Practices
Best Practices Big Data Data Collection Data Management Privacy
data protection for SMEs
8 Crucial Tips to Help SMEs Guard Against Data Breaches
Data Management
How AI is Boosting the Customer Support Game
How AI is Boosting the Customer Support Game
Artificial Intelligence
AI analytics
AI-Based Analytics Are Changing the Future of Credit Cards
Analytics Artificial Intelligence Exclusive

Stay Connected

1.2k Followers Like
33.7k Followers Follow
222 Followers Pin

You Might also Like

hire the right python developers for your data science team
Python

Roles of Python Developer in Data Science Teams

5 Min Read
using python for data preprocessing
Programming

Python for Business: Optimize Pre-Processing Data for Decision-Making

9 Min Read
hands on text analytics tutorial
AnalyticsExclusiveText Analytics

An Introduction To Hands-On Text Analytics In Python

7 Min Read
machine learning with spark-language
ExclusiveMachine Learning

7 Lessons That Will Teach You All You Need To Know About Machine Learning

6 Min Read

SmartData Collective is one of the largest & trusted community covering technical content about Big Data, BI, Cloud, Analytics, Artificial Intelligence, IoT & more.

ai is improving the safety of cars
From Bolts to Bots: How AI Is Fortifying the Automotive Industry
Artificial Intelligence
giveaway chatbots
How To Get An Award Winning Giveaway Bot
Big Data Chatbots Exclusive

Quick Link

  • About
  • Contact
  • Privacy
Follow US
© 2008-23 SmartData Collective. All Rights Reserved.
Go to mobile version
Welcome Back!

Sign in to your account

Lost your password?