Monthly Archives: September 2011 - Page 2

G-

Is it just me or does Google+ seem very quiet lately? At one point people were raving and bragging about how much better it is than that ‘other’ social site. Seems the ‘show’ is over and the people got bored with it being just ‘another’ social web site ‘out there’. I guess you sometimes win and sometimes loose… right google?

Thankfully Microsoft didn’t get crazy and created their own version… oh wait, they had one for years but no one is paying attention to it anymore anyway… Windows Live which should rather be called Windows dying.. (just joking).

At least Microsoft don’t push it in your face anymore so it is not that bad. I still use my Hotmail account – which I incidentally had since ‘BEFORE’ Microsoft bought Hotmail all those many moons ago.

Anyway, was fun while it lasted. Cheers G-.. I mean +, whatevar

QuickMon on CodePlex

I’ve finally decided to place the whole project on CodePlex (quickmon.codeplex.com)

Go and see it for yourself 🙂

 

TreeViewEx – a few enhancements

Sometimes I wonder why some functionality that should be common is simply left out of general controls.. like the WinForms TreeView (and ListView) controls that don’t have specific events for the enter key pressed. I’ve been taught long ago to always provide functionality so keyboard events also can be used to navigate around applications – like when the mouse is unavailable, broken or not your first choice (like for disabled people). Yes, I know the controls have general events for key pressing but it requires some hectic coding each time to do something that should be simple.

Anyway, adding it isn’t too difficult (but I still wished I didn’t have to do it each time I need to use it).

public class TreeViewEx : TreeView
{

public TreeViewEx() : base()
{

DoubleBuffered = true;

}
public event MethodInvoker EnterKeyPressed;
public event MethodInvoker DeleteKeyPressed;
protected override void OnKeyPress(KeyPressEventArgs e)
{

if (e.KeyChar == ‘\r’)

if (EnterKeyPressed != null)
{

EnterKeyPressed();
e.Handled = true;

}

base.OnKeyPress(e);

}

protected override void OnKeyDown(KeyEventArgs e)
{

if (e.KeyCode == Keys.Delete)

if (DeleteKeyPressed != null)
{

DeleteKeyPressed();
e.Handled = true;

}

base.OnKeyDown(e);

}

}

The code for the ListView control is basically (exactly) the same.

QuickMon update

In the past couple of weeks I’ve been busy part time working on this little project to build a simple monitoring system for myself. At the moment the basic ‘bits’ are all there working reasonably well I might add. On the one side I’ve been contemplating putting the project up on CodePlex like many of my other pet projects but this one has some potential to ‘grow’ into something that could generate some thing more (like income or so…) The trouble with that idea is it may be even more powerful if ‘others’ can extend it but then the main source is available to all. Also, this little tool is not in the same league as proper enterprise monitoring tools like Microsoft SCOM and so on.

Anyway, as far as progress goes, the ‘tool’ or set of tools now can do the following (all tested and working)

  • Main shared components for editing, management and configuration of agents plus both a Windows UI and Windows service for hosting the agents (monitor pack).
  • Collector agents for
    (General)
    Disk space – local drive space available
    File count and size – file/directory size
    Performance counters – monitor performance counters
    Ping – ping machines
    Windows service state – are specified services running or not
    WMI query – specify some WMI query and compare the return value
    (Specialized)
    BizTalk ports and orchestrations – check if ports/orchestrations are running
    BizTalk suspended count – check the suspended instance count
    SQL server database size – check database size
    SQL server table size – check row count
    Httpping – like ping but for http
  • Notifier agents for:
    Log file – a simple text log file
    RSS feed – actually really just an xml file that you can host on a web server that is exposed as an RSS feed
    SMTP – Sending out alerts as emails
    SQL database – storing alert details in a sql server
  • A special type of ‘Collector’ that is just a folder to contain others (so you can enable/disable all or set a service window for that branch)
  • Collector agents support the following general properties and methods:
    Enabled
    Check dependent collectors even after warning
    Repeat alert after x minutes
    Only alert once in x minutes
    Service windows (yes, even multiple service windows e.g. 5:00 to 12:00 and 13:00 to 17:00 etc.)
    Launch a detail view window
  • Notifier agents support the following properties:
    Enabled
    Alert level (Info, Warning, Error)
    Detail level (Detail, Summary or both)
    List of collectors to ‘service’ (default = all)
    If implemented – launch a viewer for the notifier

Development

I’m using the .Net 4 client profile framework so download footprint should be fairly small – and I’d like to keep it that way. It is developed using C# and is extendable because of the add-in type of architecture. To add an agent is as simple as implementing a provided interface.

Download example

Soon I’ll add a download link for (the current) test version. It is already fully working as is but I’m continuing to enhance and add things.

Download a first test version here.

Extension method to create CSV from List collection

A quick one to share:

I needed to a method to quickly convert a List<string> to a plain comma delimited string. So I created this little Extension class:

public static class ListEx
{

public static string ToCSVString(this List<string> l)
{

StringBuilder sb = new StringBuilder();
if (l != null)
{

l.ForEach(li => sb.Append(li + “, “));

}
return sb.ToString().Trim(‘ ‘, ‘,’);

}

}

Of course this is still very specific to string collections only. I could have created something that does the same to say a List<T> list that is more generic but that I’ll leave for another day.

[Update]

While I’m at it – here is the opposite method:

public static List<string> ToListFromCSVString(this string s, bool ordered = false)
{

List<string> list = new List<string>();
if (s != null && s.Trim().Length > 0)
{

if (ordered)

list.AddRange((from sitem in s.Split(new char[] { ‘,’ }, StringSplitOptions.RemoveEmptyEntries)
orderby sitem
select sitem.Trim()).ToArray());

else

list.AddRange((from sitem in s.Split(new char[] { ‘,’ }, StringSplitOptions.RemoveEmptyEntries)
select sitem.Trim()).ToArray());

}

return list;

}