Facebook

Facebook_Daniele

Facebook_Daniele, uploaded by Daniele Muscetta on Flickr.

Yet another social networking. I am on there too, now.
http://www.facebook.com/p/Daniele_Muscetta/742258687

Ah, and by the way, I really find it incredible that every time I invite some people to a new social networking site (it has happened for all of them), it happens that some (many) of the persons I have invited reply to me or call me asking me “is this really sent by you ?” “it looked like spam” “what is this thing” and the like.

Come on, guys, we are in year 2007, you still don’t know what social networking is… especially if you work in IT you are sort of a dinosaur, you know?

This blog in C#

I have been busy trying to write a new frontend for this blog that uses .Net. I already blogged about it here. In the last couple of weeks I have been adding stuff – permalinks using mod_rewrite, I finally show the comments properly, I have added categories and category archives (as in http://www.muscetta.net/dotnet/tag/coding). There is even an RSS Feed.

The layout is still crap, but I sort of like it being so light weight, so that is not on my priority list so far. Moreover, I am a crap designer.

Before that, tough, I still have to add important functionalities like the possibility to POST comments (which needs a new CAPTCHA, etc, so it will take me a while), and I am having issues with text encoding (it does not show the accented characters properly, yet).

But I am having fun doing it.

[Edit of December 2009 – I killed the above experiment. I had fun doing it, but there is not time for all, it needs a lot of work to keep it running/update it with every wordpress update, and mod_mono is wasting too many resources on the server.]

WordPress.Net

WordPress.Net

WordPress.Net, uploaded by Daniele Muscetta on Flickr.

It has been quite a while that I wanted to experiment a bit more with ASP.Net but I don’t have a windows machine on the internet. Not one that performs enough anyway. My server runs linux. I have had mono running on it for a while, but its support was not complete with the old release of Debian, so part of my mono and mod_mono installation were a custom compile and they were breaking from time to time, each time some library got updated. So I did run a “Hello World” page with it, but nothing more, because it was a bit of a mess to mantain and, moreover, because I had not yet figured out how to have it connect with mysql instead than with MS SQL Server.
Also, I did not have any real project or idea to implement in my mind.

Now that I have upgraded to Debian Etch, mono support seems to be much more out-of-the-box and stable on this release. I also got an idea of what to do with it, so I finally gave it a try.

As a starter, I am trying to re-publish my blog, historically running at www.muscetta.com, on my other muscetta.NET domain (it makes sense to use a .NET domain, right?). But this is not a new site, it is a republish of the same content, but done using C# – just pointing at the same wordpress’ mysql database. Connection to MySQL is done with MySql.Data (the ADO.Net driver for MySQL).

I still need to implement a lot of things/features, such as comment posting (you can only read them now), some layout/styling/framing to make it look nicer, some sidebar/blogroll, feeds, and a many other things. I am not aiming at a complete rewrite (for example I won’t do an administrative interface or a webservice so far), but just a republish/frontend to the visitors.
I don’t know when I will have time to continue writing it, but all in all I am glad it works so far, and I had fun doing it.

Writing ASP.Net for mono on linux in the absence of Frontpage server extentions and WebDAV and the remote debugger is proving slightly more challenging than just dragging and dropping controls in Visual Studio and let it do a lot of work with you. You have to write the code, upload it, and see if it works. No debugging, no intellisense. Just the hard old way of trial and error, which makes development slower, but you learn a hell of a lot more that way. Of course you need to keep the MSDN library handly 🙂

[Edit of December 2009 – I killed the above experiment. I had fun doing it, but there is not time for all, it needs a lot of work to keep it running/update it with every wordpress update, and mod_mono is wasting too many resources on the server.]

Everybody loves T-Shirts, Etch.

An old photo of Joshua in his Debian T-Shirt has been used (with permission) by Holger Levsen in his presentation of http://www.debian-community.org/ given at FOSDEM 2007.
You can check out the slides here: http://layer-acht.org/slides/20070225-debian-community.org-prelaunch.pdf
and download a video here: http://meetings-archive.debian.net/pub/debian-meetings/2007/fosdem/

And yes, I feel very “debiany” today. In fact I just finished upgrading my server from Sarge to Etch and it went very smoothly, even if I had to reconfigure / migrate some settings – for example moving all the virtual server configuration from Apache 1.3 to 2.x … but it was about time for me to move my ass off 1.3! Among other things I am quite glad now I can use mod_mono and have it update with apt-get, instead than having my own compiled version with all sort of broken dependencies… also, it performs better – faster, and takes up the same amount of resources, which I would not have believed and I was in fact slightly concerned about. Nothing to be worried about, it turns out.

Some other guy was pointing me out today all the other improvements in the desktop-feature-space. I would not know, I am a runlevel-2 guy when it comes to linux.

MOM 2005 Alerts to RSS feed

I am an RSS Addict, you know that.So I wanted an RSS Feed to show MOM Alerts. I have been thinking of it for a while, last year (or was it the year before?).
It seemed like a logical thing to me: alerts are created (and can be resolved – that is, expire), generally get sorted by the date and the time when they have been created, the look pretty much like a list. Also, many people like to receive mail notification when new alerts are generated.
So, if the alert can be sent to you (push), you could also get to it(pull).
Pretty much the same deal with receiving a mail or reading a newsgroup, or syndicating a feed.

At the time I looked around but it seemed like no one had something like this already done.
So I wrote a very simple RSS feed generator for MOM Alerts.
I did it quite an amount of time ago, just as an exercise.
Then, after a while, I figured out that the MOM 2005 Resource Kit had been updated to include such a utility!

Wow, I thought, they finally added what I have been thinking for a while. Might it be because I mentioned it on an private Mailing list ? Maybe. Maybe not. Who cares. Of course, if it is included in the resource kit it must be way cooler than the one I made, I though.
I really thought something along these lines, but never actually had the time to try it out.
I think I just sort of assumed it must have been cooler than the one I made, since it was part of an official package, while I am not a developer. So I basically forgot about the one I wrote, dismissing it as being crap without looking too much into it anymore.
Until today.
Today I actually tried to use the alert to RSS tool included in the resource kit, because a customer asked if there was any other way to get notified, other than receiving notification or using the console (or the console notifier).
So I looked at the resource kit’s Alert-to-RSS Utility.
My experience with it:
1) it is provided in source code form – which is ok if it was ALSO provided as source. Instead it is ONLY provided as source, and most admins don’t have Visual Studio installed or don’t know how to compile from the command line;
2) Even when they wanted to compile it, it includes a bug which makes it impossible to compile – solution in this newsgroup discussion;
3) if you don’t want to mess about with code since you are using a resource Kit tool (as opposed to something present in the SDK) you can even get it already compiled by someone from somewhere on the net, but that choice is about trust.

Anyway, one way or another, after it is finally set up…. surprise surprise!!!
It does NOT show a LIST of alerts (as I was expecting).
It shows a summary of how many alerts you have. basically it is an RSS feed made of a single item, and this single item tells you how many alerts you have. What is one supposed to do with such a SUMMARY? IMHO, it is useless the way it is. It is even worse than one of those feed that only contains the excerpt of the article, rather than the full article.
Knowing that I have 7 critical errors and 5 warning without actually knowing ANYTHING of them is pointless.
It might be useful for a manager, but not for a sysadmin, at least.

So I thought my version, even if coded crap, might be useful to someone because it gives you a list of alerts (those that are not resolved) and each one of them tells you the description of the alert, the machine tat generated it, and includes links to the actual alert in the web console, so you can click, go there, and start troubleshooting from within your aggregator!
My code does this. Anyway, since I am a crap coder, since I wrote it in only fifteen minutes more than a year ago, and since I don’t have time to fix it and make it nicer… it has several issues, and could be improved in a million ways, in particular for the following aspects:

  1. is currently depends on the SDK Database views – it could use the MOM Server API’s or the webservice instead;
  2. it uses SQL Security to connect to the DB – by default MOM does not allow this – it is suggested for the SQL instance hosting “OnePoint” to only use Windows Integrated Authentication.. so to make my code work you have to switch back to Mixed mode, and create a login in SQL that has permission to read the database. This is due to the fact that I’ve coded this in five minutes and I don’t know how to use delegation – if I was able to use delegation, I would… so that the end user accessing IIS would be the one connecting to the DB. If anybody wants to teach me how to do this, I will be most grateful.
  3. it could accept parameters as URL variables, so to filter out only events for a specific machine, or a specific resolution state, etc etc
  4. At present it uses RSS.Net to generate the feed. It could made independent from it, but I don’t really see why, and I quite like that library.

The code is just an ASP.Net page and its codebehind, no need to compile, but of course you need to change a couple of lines to match your webconsole address.
Also, you need to get RSS.NET and copy its library (RSS.Net.dll) in the /bin subfolder of the website directory where you place the RSSFeed generator page. I see that I wrote this with version 0.86, but any version should do, really.

Here is what it will look like:

AlertToRSS

And here’s the code of the page (two files):

Default.aspx

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

Default.aspx.cs

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using Rss;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string webconsoleaddress = “http://192.168.0.222:1272/AlertDetail.aspx?v=a&sid=” // must change to match your address

// Inizializza il Feed
RssChannel rssChannel = new RssChannel();
rssChannel.Title = “MOM Alerts”
rssChannel.PubDate = DateTime.Now;
rssChannel.Link = new Uri(“http://192.168.0.222:1272/rss/”); // must change to match your address
rssChannel.LastBuildDate = DateTime.Now;
rssChannel.Description = “Contains the latest Alerts”

// query – you might want to change the severity
string mySelectQuery = “SELECT ComputerName, Name, Severity, TimeRaised, RepeatCount, GUID FROM dbo.SDKAlertView WHERE Severity > 10 AND ResolutionState < 255”

// SQL Connection – must change SQL server, user name and password
SqlConnection conn = new SqlConnection(“Data Source=192.168.0.222;Initial Catalog=OnePoint;User ID=rss;Password=rss”);
SqlDataReader rdr = null;

try
{
conn.Open();
SqlCommand cmd = new SqlCommand(mySelectQuery, conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
RssItem rssItem = new RssItem();
string titleField = rdr[1].ToString();
rssItem.Title = titleField;
string url = webconsoleaddress + rdr[5];
rssItem.Link = new Uri(url.ToString());
string description = “<![CDATA[ <p><a xhref=\”” + rssItem.Link + “\”>” + rdr[1] + ” </a></p><br>” + “<br>Computer: ” + rdr[0] + “<br>Repeat Count: ” + rdr[4] + “<BR>Original ALert Time: ” + rdr[3];
rssItem.Description = description;
rssChannel.Items.Add(rssItem);
}

// Finalizza il feed
RssFeed rssFeed = new RssFeed();
rssFeed.Channels.Add(rssChannel);
Response.ContentType = “text/xml”
Response.ExpiresAbsolute = DateTime.MinValue;
rssFeed.Write(Response.OutputStream);
}
finally
{
if (rdr != null)
{
rdr.Close();
}

if (conn != null)
{
conn.Close();
}
}
}
}

Out-Blog!

[Edited again 25th November – Jachym gave me some suggestions and insights on the use of parameters, and I slightly changed/fixed the original code I had posted yesterday. There are still some more things that could be improved, of course, but I’ll leave them to the future, next time I’ll have time fot it (who knows when that will be?)]

This one is a post regarding my first test writing a cmdlet for PowerShell. After a few days since having change my blog’s title to “$daniele.rant | Out-Blog” (where Out-Blog was a fantasy cmdlet name, and the title just meant to mimick PowerShell syntax in a funny way), I stumbled across this wonderful blog post: http://blog.boschin.it/archive/2006/09/21/4375.aspx that describes how to use the assemblies of “Windows Live Writer”. Then I saw the light: I could actually implement an “Out-Blog” cmdlet. I am not sure what this could be useful for… but I thought it was funny to experiment with. I followed the HOW TO information on this other blog post to guide me through the coding: http://www.proudlyserving.com/archives/2005/10/lets_all_write_1.html

The result is the code that follows. you see is pretty much Boschin’s code wrapped into a cmdlet class. Nothing fancy. Just a test. I thought someone might find it interesting. It is provided “AS IS”, mainly for educational purpose (MINE, only mine…. I’m the one whose education is being improved, not you :-))

Out-Blog! 1 

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Management.Automation;

using WindowsLive.Writer.BlogClient.Clients;

using WindowsLive.Writer.BlogClient;

using WindowsLive.Writer.CoreServices;

using WindowsLive.Writer.CoreServices.Settings;

using WindowsLive.Writer.Extensibility.BlogClient;

using Microsoft.Win32;

 

 

namespace LiveWriterCmdlet

{

[Cmdlet(“out”, “blog”, SupportsShouldProcess=true)]

 

public sealed class OutBlogCmdlet : Cmdlet

{

[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public string Title

{

get { return _title; }

set { _title = value; }

}

private string _title;

 

[Parameter(Position=1,Mandatory=true,ValueFromPipeline=true,ValueFromPipelineByPropertyName=true)]

[ValidateNotNullOrEmpty]

public string Text

{

get { return _text; }

set { _text = value; }

}

private string _text;

 

[Parameter(Position = 2, Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public string BlogApiEndPoint

{

get { return _blogapiendpoint; }

set { _blogapiendpoint = value; }

}

private string _blogapiendpoint;

 

[Parameter(Position = 3, Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public string UserName

{

get { return _username; }

set { _username = value; }

}

private string _username;

 

[Parameter(Position = 4, Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public string Password

{

get { return _password; }

set { _password = value; }

}

private string _password;

 

 

[Parameter(Position = 6, Mandatory = false, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public string ProxyAddress

{

get { return _proxyaddress; }

set { _proxyaddress = value; }

}

private string _proxyaddress;

 

[Parameter(Position = 7, Mandatory = false, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

[ValidateNotNullOrEmpty]

public int ProxyPort

{

get { return _proxyport; }

set { _proxyport = value; }

}

private int _proxyport;

 

[Parameter(Position = 8, Mandatory = false, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

public string ProxyUserName

{

get { return _proxyusername; }

set { _proxyusername = value; }

}

private string _proxyusername;

 

[Parameter(Position = 9, Mandatory = false, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

public string ProxyPassword

{

get { return _proxypassword; }

set { _proxypassword = value; }

}

private string _proxypassword;

 

[Parameter(Position = 10, Mandatory = false, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]

public SwitchParameter Published

{

get { return _published; }

set { _published = value; }

}

private bool _published;

 

 

 

 

protected override void BeginProcessing()

{

base.BeginProcessing();

 

 

ApplicationEnvironment.Initialize();

if ((ProxyAddress != null) | (ProxyAddress != “”))

{

WebProxySettings.ProxyEnabled = true;

WebProxySettings.Hostname = ProxyAddress;

WebProxySettings.Port = ProxyPort;

WebProxySettings.Username = ProxyUserName;

WebProxySettings.Password = ProxyPassword;

 

}

else

{

WebProxySettings.ProxyEnabled = false;

}

 

}

 

 

 

 

protected override void ProcessRecord()

{

if (ShouldProcess(Text))

{

ISettingsPersister persister = new RegistrySettingsPersister(Registry.CurrentUser, @”Software\Windows Live Writer”);

IBlogCredentials credentials = new BlogCredentials(new SettingsPersisterHelper(persister));

IBlogCredentialsAccessor credentialsAccessor = new BlogCredentialsAccessor(“dummy-value”, credentials);

 

credentials.Username = UserName;

credentials.Password = Password;

 

MovableTypeClient client = new MovableTypeClient(new Uri(BlogApiEndPoint), credentialsAccessor, PostFormatOptions.Unknown);

 

 

BlogPost MyPost = new BlogPost();

MyPost.Title = Title;

MyPost.Contents = Text;

client.NewPost(“dummy-value”, MyPost, Published);

 

WriteVerbose(“Posted Successfully.”);

 

}

 

}

 

}

}

On this website we use first or third-party tools that store small files (cookie) on your device. Cookies are normally used to allow the site to run properly (technical cookies), to generate navigation usage reports (statistics cookies) and to suitable advertise our services/products (profiling cookies). We can directly use technical cookies, but you have the right to choose whether or not to enable statistical and profiling cookies. Enabling these cookies, you help us to offer you a better experience. Cookie and Privacy policy