XenServer License Check — Nagios NRPE Plugin

If you hadn’t already guessed I am a big fan of the Xen hyper­vi­sor. Lately I have been using the Cit­rix XenServer release because it makes it quite palat­able for my co-workers. One annoy­ance that I do have about XenServer is the require­ment that you license it (with a free license) every year. If you fail to license it the GUI stops work­ing. Now I hate rely­ing on GUIs but the fact of the mat­ter is oth­ers in my team expect to have a work­ing GUI when they need to do some­thing. And I dont know about you but I don’t really log onto the man­age­ment con­sole very often. Really I only log on to it if I need to pro­vi­sion a new server so its entirely plau­si­ble that a license would expire and I wouldn’t know about it until I really needed to do something.

I ended up writ­ing a lit­tle Nagios plu­gin that checks the license expi­ra­tion date using XenAPI. I don’t know that it’s 100% com­pli­ant with the plu­gin spec­i­fi­ca­tion but it does work for me. I actu­ally don’t pre­fer to use the warn and crit­i­cal states with the Nagios (I use the per­for­mance data with Zenoss and apply thresh­olds there. I find that to be a bit more flex­i­ble.) but I did imple­ment them. The plu­gin can be exe­cuted on the XenServer (you may want to ref­er­ence how to install nrpe on XenServer) or on from your mon­i­tor­ing host as long as the host per­form­ing the check has the python XenAPI installed.

The plu­gin check_citrix_xenserver_license can be found on github.

I hope some­one can find it useful.

7 Comments

  • Mark Linux Google Chrome 11.0.696.57 wrote:

    Hey Nick,
    FYI the link to github is giv­ing a 404.
    I don’t sup­pose you still have this plu­gin avail­able do you?

    Cheers,
    Mark

  • Thanks for the heads up, i fixed the link.

  • Hi.
    Your script is excel­lent, except that there is a tiny bug with cast­ing. Com­par­i­son of expire_days and options.warning_days (and options.critical_days)actually pro­duces incor­rect results, due to one of them not being an inte­ger. I have enclosed them all (only for the com­par­i­son part) in int(), and the results are cor­rect now.

    Thanks for your script!
    Ez

  • If you send a patch or make a pull request on github I’ll make sure its updated for everyone.

    Thanks for the heads up on the bug and glad you found it useful.

  • Below is the con­tents of my diff. I have fixed both the cast prob­lem, and also the prob­lem with query­ing a slave. Your orig­i­nal script (after the cast change) would have just failed, as the slave does not respond cor­rectly. I am only par­tially happy with the cur­rent sta­tus of the script, as it does not answer a case where a sin­gle node loses its license (it has hap­pened to me) and reacts in a weird way, as long as the pool mas­ter is OK. For now, I will leave it. So, the patch:
    54c54
    options.warning_days:

    > if int(expire_days) > int(options.warning_days):
    59c59
    < elif expire_days elif int(expire_days) <= int(options.warning_days):
    61c61
    < if expire_days if int(expire_days) <= int(options.critical_days):
    111c111
    ses­sion = XenAPI.Session(“https://”+options.server)
    113a114,117
    > except XenAPI.Failure, e:
    > if e.details[0]==‘HOST_IS_SLAVE’:
    > session=XenAPI.Session(‘https://’+e.details[1])
    > session.login_with_password(options.username, options.password)

    I hope it helps, and I would be more than happy to test any fur­ther. I wish I was a bet­ter python coder (or, given my level — python coder at all…)

    Thanks!
    Ez

  • As sus­pected. Lines indent was lost. Mail me, and I will send you the patch file directly.

    Ez

  • I rewrote the check so it works with xen 5.8
    In a few weeks we will migrate to 6.2 and i’ll give you an update :)

    http://pastebin.com/1yR9pWEN

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha