search cancel

Report for alerts

book

Article ID: 201858

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM)

Issue/Introduction

Where can we see a report on the total robots installed in the company? Is there any report/statistic on how many alert receive per day/months?

Environment

Release : 8.51

Component : UIM - ROBOT

Resolution

Here is a script to count the number of robots and probes.

This is a simple LUA script that can be ran from the NAS that will poll each hub and pull the total number of Robots and probes deployed. This will also create a file called nimsoft_count.txt in the Nimsoft\probes\nas directory.
================================================

file = io.open("nimsoft_count.txt", "w")

robots = 0
probeTotal = 0

resp,rc = nimbus.request("hub", "gethubs")
for h,hinfo in pairs(resp.hublist) do
   local args = pds.create()
   pds.putInt(args, "detail", 1)
   sessionhandle = nimbus.session_open(hinfo.addr)
   if sessionhandle ~= nil then
      local r_resp,rc = nimbus.session_request(sessionhandle, "getrobots", args, 300)
      if rc == 0 then
         for r,rinfo in pairs(r_resp.robotlist) do
            if rinfo.probelist ~= nil then
               probes = 0
               for p,pinfo in pairs (rinfo.probelist) do
                  probes = probes + 1
                  probeTotal = probeTotal + 1
               end
              -- print("Number of probes on " .. rinfo.name .. " is: " .. probes)
            end
            robots = robots + 1
         end

      end
   end
   nimbus.session_close(sessionhandle)
end

file:write ("Total robots: " .. robots .. "\n")
print ("Total robots: " .. robots .. "\n")
print ("Total probes: " .. probeTotal .. "\n")
file:write ("Total probes: " .. probeTotal .. "\n")
====================================================

====================================================

NAS script to generate a report of alarms that occured last night

require ("library/html-alarms-lib") 

recipient   = "[email protected]"

title       = "Nimsoft - 24 Hour Alert Report" 

buf = ""

buf = buf .. html_start (title)

buf = buf .. html_alarms (transactions)

buf = buf .. html_end () 

day = 60*60*24

past_day = timestamp.now() - day

past_week = timestamp.now() - 7*day

past_month = timestamp.now() - 30*day
 

database.open("transactionlog.db")

query = "select * from NAS_TRANSACTION_SUMMARY where created > \"" .. timestamp.format(past_day, "%Y-%m-%d %H:%M:%S") .. "\";"

data, rc = database.query(query);
 

email_msg = "\n"

email_msg = email_msg .. sprintf("%-25s%-25s%-20s%-40s%s\n", "created", "visibility", "origin", "host", "message") 

for _, x in pairs(data) do

   closed = "open" 

   if x.closed then

      closed = x.closed

   end 

   email_msg = email_msg .. sprintf("%-25s%-25s%-20s%-40s%s\n",x.created, x.visible, x.origin, x.hostname, x.message) 

end 

database.close() 

action.email(recipient,title,buf) 

--print (email_msg)


Here is an example report from the nas Scripts folder that can be run via he NAS, and you'll find other script examples there:

Current alarm report
======================
-- This script gives an example on using external libraries
-- and sends an email to recipient containing a list of the current open alarms

require ("library/html-alarms-lib")

recipient    = "[email protected]"
title        = "Current Alarm Report"
transactions = 3

buf = ""
buf = buf .. html_start (title)
buf = buf .. html_alarms (transactions)
buf = buf .. html_end ()

action.email(recipient,title,buf)
===================================

===================================

Query approach

UIM alarms - last 24 hours

You can create a table and use a query like this to display the last 24 hours of data from the nas_transaction_log. You can limit the data using the columns and order by/sort it as you like. You can either present this on a dashboard or nested in a dashboard page. 

SELECT * from nas_transaction_log WHERE nimts >= DATEADD(hh,-24,GETDATE())

You can adjust the date value and you can see the row count for all of the alams.

Other example queries using different time ranges:

select severity,Count(nimid) as alarmcount from NAS_TRANSACTION_LOG WHERE nimts >= DATEADD(hh,-24,GETDATE()) group by severity

select severity,Count(nimid) as alarmcount from NAS_TRANSACTION_LOG WHERE nimts >= DATEADD(mm,-6,GETDATE()) group by severity

select severity,Count(nimid) as alarmcount from NAS_TRANSACTION_LOG WHERE nimts >= DATEADD(yy,-1,GETDATE()) group by severity