[IPython-dev] utility to monitor CPU utilization

Glen W. Mabey Glen.Mabey at swri.org
Fri Aug 31 14:25:31 EDT 2007


Hello,

If you happen to have PyQt3 installed on your system, and you happen to
have gkrellmd running on a whole bunch of nodes whose CPU utilization
you want to monitor, and you happen to have gkrellm installed, then you
might find the attached source code files really useful.   Oh yeah, you
also have to matplotlib installed.

Basically, I hacked a C source file that was posted to the gkrellm
mailing list:

http://lists.jutley.org/pipermail/gkrellm/2006-November/000209.html

see also:

http://lists.jutley.org/pipermail/gkrellm/2007-August/000350.html

Anyway, the attached files are a terrible hack and are strictly only
provided as an example of what could be done.

Really, all of the network operations done in gkrellmd_to_text.c should
be done in python.  And if a network connection fails on the first time
things run, a gkrellmd instance could be spawned via `ssh -f hostname
gkrellmd ---options...`

Those that don't want to use PyQt3 could probably implement something
similar with their toolkit of choice very easily -- it's very simple,
but can be extremely useful for dealing with IPython1 setups.

Best Regards,
Glen Mabey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gkrellmd_to_text.c
Type: text/x-csrc
Size: 6528 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20070831/9fa49e65/attachment.c>
-------------- next part --------------
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>Form1</class>
<comment>Python:from mplwidget import *</comment>
<widget class="QMainWindow">
    <property name="name">
        <cstring>Form1</cstring>
    </property>
    <property name="geometry">
        <rect>
            <x>0</x>
            <y>0</y>
            <width>600</width>
            <height>480</height>
        </rect>
    </property>
    <property name="caption">
        <string>Form1</string>
    </property>
    <hbox>
        <property name="name">
            <cstring>unnamed</cstring>
        </property>
        <widget class="MatplotlibWidget">
            <property name="name">
                <cstring>cpu_matplotlibWidget</cstring>
            </property>
        </widget>
        <widget class="QLayoutWidget">
            <property name="name">
                <cstring>layout2</cstring>
            </property>
            <vbox>
                <property name="name">
                    <cstring>unnamed</cstring>
                </property>
                <spacer>
                    <property name="name">
                        <cstring>spacer1_2</cstring>
                    </property>
                    <property name="orientation">
                        <enum>Vertical</enum>
                    </property>
                    <property name="sizeType">
                        <enum>Expanding</enum>
                    </property>
                    <property name="sizeHint">
                        <size>
                            <width>21</width>
                            <height>16</height>
                        </size>
                    </property>
                </spacer>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_tp</cstring>
                    </property>
                    <property name="text">
                        <string>tp</string>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_1</cstring>
                    </property>
                    <property name="text">
                        <string>mp1</string>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_2</cstring>
                    </property>
                    <property name="text">
                        <string>mp2</string>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_3</cstring>
                    </property>
                    <property name="text">
                        <string>mp3</string>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_4</cstring>
                    </property>
                    <property name="text">
                        <string>mp4</string>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_5</cstring>
                    </property>
                    <property name="text">
                        <string>mp5</string>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_6</cstring>
                    </property>
                    <property name="text">
                        <string>mp6</string>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_7</cstring>
                    </property>
                    <property name="text">
                        <string>mp7</string>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_8</cstring>
                    </property>
                    <property name="text">
                        <string>mp8</string>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_9</cstring>
                    </property>
                    <property name="text">
                        <string>mp9</string>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>host_pushButton_10</cstring>
                    </property>
                    <property name="text">
                        <string>mp10</string>
                    </property>
                </widget>
                <spacer>
                    <property name="name">
                        <cstring>spacer1</cstring>
                    </property>
                    <property name="orientation">
                        <enum>Vertical</enum>
                    </property>
                    <property name="sizeType">
                        <enum>Expanding</enum>
                    </property>
                    <property name="sizeHint">
                        <size>
                            <width>21</width>
                            <height>20</height>
                        </size>
                    </property>
                </spacer>
            </vbox>
        </widget>
    </hbox>
</widget>
<toolbars>
    <toolbar dock="2">
        <property name="name">
            <cstring>toolBar</cstring>
        </property>
        <property name="label">
            <string>Tools</string>
        </property>
        <action name="editUndoAction"/>
    </toolbar>
</toolbars>
<customwidgets>
    <customwidget>
        <class>MatplotlibWidget</class>
        <header location="global">mplwidget</header>
        <sizehint>
            <width>200</width>
            <height>120</height>
        </sizehint>
        <container>0</container>
        <sizepolicy>
            <hordata>7</hordata>
            <verdata>7</verdata>
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
        </sizepolicy>
        <pixmap>image0</pixmap>
        <property type="String">margins</property>
    </customwidget>
</customwidgets>
<actions>
    <action>
        <property name="name">
            <cstring>editUndoAction</cstring>
        </property>
        <property name="iconSet">
            <iconset>image1</iconset>
        </property>
        <property name="text">
            <string>Undo</string>
        </property>
        <property name="menuText">
            <string>&Undo</string>
        </property>
        <property name="accel">
            <string>Ctrl+Z</string>
        </property>
    </action>
</actions>
<images>
    <image name="image0">
        <data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154789cad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a19017a725d8c60000000049454e44ae426082</data>
    </image>
    <image name="image1">
        <data format="PNG" length="172">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000007349444154789ced92c10e80200840b1ef661d1cff4d876aa888a17669f9360f283ed80060f159425f3a71f53602e08e992b098801d02854176ae47f21ce1fb5b05d38eddc9060d0f11379635b3bc92bd518e239a943ec1d5ab7785cee107be4b215af4091f894de47181ecea59ede9ec59f380062ac28b10fe74fef0000000049454e44ae426082</data>
    </image>
</images>
<layoutdefaults spacing="6" margin="11"/>
<includehints>
    <includehint>mplwidget</includehint>
</includehints>
</UI>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: blademon.py
Type: text/x-python
Size: 6560 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20070831/9fa49e65/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mplwidget.py
Type: text/x-python
Size: 1789 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20070831/9fa49e65/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: blademon_designer.py
Type: text/x-python
Size: 4962 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20070831/9fa49e65/attachment-0002.py>


More information about the IPython-dev mailing list