IT

MRTG Today Screen Plugin for WM 6.1

Introduction

This little tool will help you keep an eye on some statistics of your own web server, because it is able to display two periodically downloaded images on the home screen (standard WM6.1 today screen).

Download: MRTGPlugin_1.1.zip (change log)

Requirements:

  • Windows Mobile 6.1 Pocket PC with Internet connection.
  • Minimum 800×480 or 640×480 pixels resolution. On smaller screens it will not render the second image.
  • It is not signed, so you need to have a custom ROM that allows these type of applications.
  • A web server that you can configure to serve .png images.

Limitations:

  • Does not have a configuration screen. You will have to use a registry editor to modify the URLs of the two images as well as the refresh interval in minutes.
  • Supports HTTP only (no HTTPS support yet) and no authentication. You might want to select a random folder name on the HTTP server to “hide” the images.
  • Uninstall needs 3 additional steps, besides the standard Windows Mobile uninstall.
  • Since the images are generated on the server side (more about them below), you will probably see the server time (and not phone timezone).

Other than that, I’m using it for about two weeks now and no problems yet 🙂

Configuration:

The configuration consists in two steps: server side and phone registry updates.

Server side:

You need to generate two images (the application can only display two “live” images) each of the exact size of 225×93 pixels.

Every 5 minutes, a cron job invokes mrtg which, based on configuration file, updates the history database and then generates the images. mrtg invokes qmailmrtg7 to collect live stats.

Here’s my cronjob:

*/5 * * * * /usr/bin/mrtg /path/to/mrtg.cfg 2>&1 > /dev/null

Here’s my configuration file:

#-------------------------------------------------------------------
Title[venet0]: venet0 bits - FQDN
Options[venet0]: bits
Target[venet0]: `grep venet0 /proc/net/dev | sed 's/venet0://' | awk '{print $1; print $9; print ""; print ""}'`
PageTop[venet0]: venet0 bits - FQDN

MaxBytes[venet0]: 100000000
Ylegend[venet0]: bits
ShortLegend[venet0]: bits
XSize[venet0]: 125
YSize[venet0]: 58
Legend1[venet0]: bits
LegendI[venet0]: input
LegendO[venet0]: output
WithPeak[venet0]: ymwd

#-------------------------------------------------------------------
Title[smtp]: SMTP Concurrency - FQDN
MaxBytes[smtp]: 100
AbsMax[smtp]: 500
Options[smtp]: gauge
Target[smtp]: `/usr/local/bin/qmailmrtg7 t /var/qmail/supervise/qmail-smtpd/log/main`
PageTop[smtp]: FQDN - SMTP Concurrency

ShortLegend[smtp]: SMTP
YLegend[smtp]: max SMTP
Legend1[smtp]: SMTP
LegendI[smtp]: SMTP
LegendO[smtp]: SMTP
WithPeak[smtp]: ymwd
XSize[smtp]: 125
YSize[smtp]: 58

Observations:

  1. History files, images, and so on will be generated in the same folder where the configuration file is. You might want to run the cronjob few times since there will be warnings if history files are not found, not complete, etc. But it will create them, keep adding values and eventually, after few runs, there will be no further errors.
  2. Make sure the XSize / YSize values above are the same. After some trial and errors, I found those values are actually generating the 225×93 images that the application displays.
  3. Also, check the images, as it might very well be that in your setup the paths to the network interface (venet0) / qmailmrtg7 / etc locations etc might be different.

Since the application doesn’t support any security, you might choose a random folder name in the DOCROOT of your HTTP server, to “hide” the images (and don’t link it anywhere on the web pages so that the crawlers won’t find it). But this is not security, so please proceed only if you understand and you assume the risks.

The last step is to check that you can actually access the two images from the internet. mrtg generates a couple of images for each parameter you trace, I have chosen the *-day.png as I believe it gives me a good overview of the server status. Thus, images names will be something like http://yourserver.com/random_folder_name/smtp-day.png and http://yourserver.com/random_folder_name/venet0-day.png

Phone Registry configuration

After the application is installed, there are two steps:

  1. Activate the plugin by going into Start -> Settings -> Today -> Items tab -> MRTG Plugin (has to be checked) -> OK
  2. Edit the following registry keys: HKLM\Software\Microsoft\Today\Items\MRTGPlugin\0 and HKLM\Software\Microsoft\Today\Items\MRTGPlugin\1 to point to the URLs of your images:

The minutes refresh interval is configured by the key HKLM\Software\Microsoft\Today\Items\MRTGPlugin\Refresh key.

I’m using Total Commander to edit the registry, but you may use any other tool.

For any changes in the registry, you need to manually issue “Update” ( by clicking on the images displayed on the Today Screen and selecting it from the popup menu) for the new values to be taken into account.

Other observations:

  • Logging is ON, and two log files will be created on the root of your phone: MRTGPlugin.log.txt and Downloader.log.txt. The latter one will get bigger in time, you can remove it when the application is not updating itself.
  • If you want to uninstall the application, please do so using standard procedure. Then, you need to delete the two log files, plus, using the Check Notifications program, remove the Downloader.exe notification.
  • If the phone doesn’t have signal and downloading fails, you will see two ‘broken’ images as placeholders. This is by design, so that it won’t create confusion showing old snapshots.
  • Traffic is low, in my case the .png files are ~1Kb size. It means that each day, if the refresh period is 30 minutes, you get 4kb of download every hour, so 24h * 4kb = ~100kb/day.

Change log:

Version 1.1 (8 Apr 2011)

  • Fix refresh bug of images once Downloader completes saving the images. (Due to a missing /n on the resource compiler command line).

Version 1.0 – Initial Release

License:

Copyright Iulian Virtejanu, 2011.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You are free to use the application for your personal use. You are still free to use it for commercial purposes, but please contact me if you need security updates or other settings being added.

Please do not redistribute the application, and if you like to mention it, please link back to this page (I’d like to keep track of the number of downloads).

Leave a Reply