Nagios status report in Ion3 statusbar

Here is a little script that permits to report one or more nagios servers status in the ion3 status bar:

statusd_nginfo.lua (Download)

--
-- statusd_nginfo.lua
-- 
-- Made by Raffaello Pelagalli
-- 
-- Started on  Sun Mar  9 00:22:31 2008 Raffaello Pelagalli
-- Last update Thu May  8 23:29:32 2008 Raffaello Pelagalli
-- 
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
-- 
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-- Lesser General Public License for more details.
-- 
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-- 02111-1307  USA
--
 
-- Nagios checking script
-- Reports nagios status in ion status bar
-- Sample configuration:
-- mod_statusbar.launch_statusd{
--    ...
--    nginfo = {
--       urls = {
--          "http://user1:password1@server1.domain1.tld/cgi-bin/nagios2/nginfo.pl",
--          "http://user2:password2@server2.domain2.tld/nagios/cgi-bin/nginfo.pl",
--       },
--    }
--    ...
-- }
--
-- Need to be used with nginfo.pl script from
-- http://redstack.net/blog/index.php/2008/05/08/nagios-status-report-in-ion3-statusbar.html
 
require "lxp"
local ng_timer
local error = false
 
local status = {0, 0, 0, 0}
 
local defaults = { 
   update_interval=30*1000, 
   urls = { },
}
 
local settings = table.join(statusd.get_config("nginfo"), defaults)
 
nginfo_callbacks = {
   StartElement = function (parser, name)
                     if (name == "current_state") then
                        nginfo_callbacks.CharacterData = function (parser, val)
                                                            status[tonumber(val) + 1] = 
                                                               status[tonumber(val) + 1] + 1
                                                         end
                     end
                  end,
   EndElement = function (parser, name)
                   if (name == "current_state") then
                      nginfo_callbacks.CharacterData = false
                   end
                end,
   CharacterData = false,
}
 
function parse (data)
   p = lxp.new(nginfo_callbacks)
   p:parse(b)
   p:close()
end
 
function get_nginfo ()
   status = {0, 0, 0, 0}
   error = false
   local http = require("socket.http")
   socket.http.TIMEOUT=10
   local errstr = " ERROR while reading data"
   for n, url in pairs(settings.urls) do
      b, c, h = http.request(url)
      if not (c == 200) then 
         error = true 
         errstr = errstr .. " (NET " .. tostring(c) .. ")"
      else
         local st, err = pcall(parse, b)
         if not st then 
            error = true 
            errstr = errstr .. " (XML" .. err .. ")"
         end
      end
   end
 
   if not error then
      errstr = ""
   end
   return "OK: " .. tostring(status[1])
      .. ", WARN: " .. tostring(status[2])
      .. ", ERROR: " .. tostring(status[3])
      .. ", UNKN: " .. tostring(status[4])
      .. errstr
end
 
local function update_nginfo()
   statusd.inform("nginfo", get_nginfo())
   if (status[3] > 0 or status[4] > 0) then
      statusd.inform("nginfo_hint", "critical")
   elseif (status[2] > 0) then
      statusd.inform("nginfo_hint", "important")
   else 
      statusd.inform("nginfo_hint", "normal")
   end
   ng_timer:set(settings.update_interval, update_nginfo)
end
 
-- Init
ng_timer=statusd.create_timer()
update_nginfo()

This nginfo.pl script needs to be installed on nagios servers :

nginfo.pl (Download)

#!/usr/bin/perl
 
use Nagios::StatusLog;
 
my $log = Nagios::StatusLog->new(
Filename => "/var/cache/nagios2/status.dat",
Version => 2.0 
);
print("Content-type: text/xml\n\n");
print("<?xml version='1.0'?>");
print("<status>\n");
foreach my $host ($log->list_hosts()) {
        print("<host>\n<name>$host</name>\n<services>");
 
        foreach my $serv ($log->list_services_on_host($host)) {
                print ("<service>\n");
                print (ref $serv);
                my $st  = $log->service($host, $serv); 
                foreach $tag ($st->list_tags()) {
                        print("<$tag>$$st{$tag}</$tag>\n");
                }
                print ("</service>\n");
        }
        print("</services>\n</host>\n")
}
print("</status>");

Information on installing lua scipts for ion3 can be found here

50 Responses to “Nagios status report in Ion3 statusbar”

  1. nupMostepePup Says:

    buy propecia online Colorado Nebraska buy propecia online http://buy-propeciaonline.webnode.com buy propecia online buy propecia online india buy propecia online Michigan

  2. nudeu Says:

    varcevalni racun investicija

  3. fkkxqzdbun Says:

    efbdysfetubdl, bbxvtrcakv

  4. Clonazepam tablet Says:

    lxcuisfetubdl, Clonazepam, IfiBryk.

  5. Tadalafil dosage Says:

    ocudgsfetubdl, Tadalafil 2.5mg, jbewNGv.

  6. Purchase xanax no prescription Says:

    swvlwsfetubdl, Purchase xanax overnight, MolPREM.

  7. Adderall Says:

    amfttsfetubdl, Adderall alternative, AlbjgSj.

  8. Meridia Says:

    vznussfetubdl, Meridia, Jueoryt.

  9. spy sniper Says:

    kbcspsfetubdl, sniper spy, OzbfZUQ.

  10. Infants motrin Says:

    xzrcbsfetubdl, Better for infant teething pain tylenol or motrin, FlHCjgH.

  11. International travel maps Says:

    pvcpksfetubdl, Travel tracker create maps, IpRNZOw.

  12. Sildenafil + duchenne muscular dystrophy + phase ii Says:

    bbbhjsfetubdl, Kegunaan obat lyrica sildenafil rx drugstore online, RoCSflz.

  13. HCG Says:

    dsbwpsfetubdl, Dr oz and hcg diet, kSMBbCw.

  14. Xanax Says:

    vuattsfetubdl, Xanax, cWbCIws.

  15. Maxburn Says:

    vchvcsfetubdl, Max burn, UOefLVN.

  16. Learn forex trade Says:

    aygiusfetubdl, Trend trade forex chaos timeframe, HzfbGpl.

  17. How to make a computer faster 6 ways to speed up your pc Says:

    tqtxcsfetubdl, Speed up your computer the need for speed how to speed up, JRuDChN.

  18. Admirable kamagra gastenboek bericht naam e-mail Says:

    kxkdmsfetubdl, Camaraderie kamagra gastenboek bericht naam e-mail, mkgsLgF.

  19. How to get 8 pac abs Says:

    zmjdcsfetubdl, How to get abs filipino girl, NSNYcBT.

  20. Buying ativan online Says:

    hlbxwsfetubdl, Lorazepam ativan, llyQfZT.

  21. Brand levitra Says:

    nebtesfetubdl, Bph and taking levitra, xBlneqF.

  22. Side effectsand lunesta Says:

    selltsfetubdl, Lunesta for sale, PoDNWQt.

  23. Klonopin drug interaction Says:

    zgsxisfetubdl, Klonopin vs valium, JGfuJiW.

  24. Besides valium comments add comment name e-mail website country powered by blogen Says:

    rsipdsfetubdl, Is valium a depressant, rxNrcEU.

  25. Buy 25mg klonopin Says:

    dlerssfetubdl, Buy .5 mg klonopin, XZYzUNZ.

  26. Generic valium 10mg Says:

    jvrqesfetubdl, Valium over the counter, AxEjheT.

  27. Cheap xanax bars Says:

    dxzefsfetubdl, Purchase xanax overnight, bofhoWf.

  28. Lunesta Says:

    kojiwsfetubdl, Lunesta, pfldAgo.

  29. ulfehqrtiq Says:

    anywosfetubdl, floheehqhi

  30. Cialis Says:

    wppdwsfetubdl, Cialis, dhWcwcY.

  31. Side effects while withdrawing from klonopin Says:

    wdsynsfetubdl, Effects of klonopin, VJCYKhf.

  32. Alprazolam 0.5 mg pictures Says:

    lyayhsfetubdl, 50 picture alprazolam, NryHcso.

  33. Hydrocodone and diazepam Says:

    otoiosfetubdl, Diazepam dosages, uTtZqxA.

  34. Alprazolam efficacy safety blood plasma levels Says:

    jippesfetubdl, Alprazolam, XoHdacA.

  35. Hydrocodine and diazepam Says:

    nfunnsfetubdl, Diazepam apaurin by krka, aYmrSjn.

  36. Clonazepam Says:

    iqtinsfetubdl, Cheap clonazepam online, frVaevF.

  37. Side effects of ambien 10 mg Says:

    yqqrysfetubdl, Taper from ambien with sublingual melatonin, xtpAJJq.

  38. Shop tramadol Says:

    jippesfetubdl, Ultram, oHdacAp.

  39. Miracet Says:

    mpldysfetubdl, Miracet, udqybEE.

  40. Caralluma Burn Says:

    ucwvvsfetubdl, Caralluma Burn, XbssMac.

  41. Melatrol Says:

    aexsdsfetubdl, Melatrol, MZHrvwR.

  42. Yeastrol review Says:

    vrqsysfetubdl, Yeastrol, oaFskVO.

  43. Hoodia Chaser Says:

    sretvsfetubdl, Hoodia Chaser, yyuvnoj.

  44. Prostate prostacet Says:

    jgqjcsfetubdl, Prostacet, UUczpkh.

  45. Deer Antler Says:

    lslwysfetubdl, Natural na pampalaki ng burat velvet deer antler plus, JHseHXL.

  46. Lemonade Diet Says:

    zzftksfetubdl, Lemonade Diet, GCjxDmZ.

  47. Dual action cleanse w/ digestion optimizer Says:

    iarzasfetubdl, Has anyone tried the dual action cleanse, NparjmG.

  48. Can you take electronic cigarettes through israeli customs? Says:

    kxeuxsfetubdl, Where can i buy electronic cigarettes, DOsxBlX.

  49. Binary options pdf Says:

    ovkqvsfetubdl, Binary options pdf, PnLgSsT.

  50. Binary options trading platform Says:

    kgwsasfetubdl, Day trading online binary options, ymagPdB.

Leave a Reply

Security Code: