Help - Search - Members - Calendar
Full Version: Script - SNMPWalkMajority
Intellipool Network Monitor - Forum > Intellipool Network Monitor > Lua scripts
Jazz
This is a script we use to monitor various systems. It Simply preforms a SNMP Walk over an OID range and returns False if the majority of OIDS are above a given threshold.

Useful for Blackberry Queues, etc, where an individual User may have many messages Queued (as they are out of service range or device is turned off). In this case an individual data will not set off the alarm. The monitor will alarm when the majority of individuals are seeing an increase in Queued messages.

Arguments:
-OID to be walked
-SNMP Community < will not poll form Object/ monitor properties
-Threshold - Maximum Accepted value for OID's

Comments Welcome.

CODE
--name= "SNMPWalkMajority"
--date= "April 19, 2008"
Author = "Jazz Alyxzander Turner-Baggs"
VersionMaj = 1
VersionMin = 3
Description = "Returns False When The Majority of OID Instances are above a given Threshold"

----------------------------------------------------------------------------------------------------------

function OnConfigure()

    Config = LuaScriptConfigurator()
    Config:SetAuthor(Author)
    Config:SetDescription(Description)
    Config:SetMinBuildVersion(0)
    Config:SetScriptVersion(VersionMaj, VersionMin )

    Config:AddArgument("OID","OID to be walked. <do not include the instance identifier>",LuaScriptConfigurator.CHECK_NOT_EMPTY)
    Config:AddArgument("Community String","",LuaScriptConfigurator.CHECK_NOT_EMPTY)
    Config:AddArgument("Threshold","Minimum Accepted Value",LuaScriptConfigurator.CHECK_NOT_EMPTY)
    
    Config:SetEntryPoint("main")
    return Config
end

function main()



--// ===========================================================================
--// Functions
--// ===========================================================================
    
    

--// ===========================================================================
--// Variables
--// ===========================================================================

    --// Script Vars
    debugOn = 0
    iArgumentsRequired = 3    

    ERROR_STRING = "Possible Errors Detected"
    SUCCESS_STRING = "OK"

    --// Compare Vars
    
    iProblemCount = 0
    iTotalCount = 0
    
    --// SNMP vars
    
    SNMP = TLuaSNMP()
    sOID = ".iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifIndex"
    sCommunity = "public"

    


--// ===========================================================================
--// Initialize Script
--// ===========================================================================
    
    --// Ensure Arguments are entered Correctly
    if GetArgumentCount() ~= iArgumentsRequired then
            SetExitStatus("Incorrect Number of Paramaters", false);
            return
    else
        print("Load Var")
        sOID = GetArgument(0)
        sCommunity = GetArgument(1)
        iMinVal = tonumber(GetArgument(2))
    end
    
--// ===========================================================================
--// SNMP Query
--// ===========================================================================
    
    SNMP:Open(sCommunity);
    snmpResult = TLuaSNMPResult();

-- Loop Through OIDS and record the number that are above iMinVal

    SNMP:BeginWalk(sOID);
    repeat
        snmpResult = SNMP:Walk(sOID);
        sOID = snmpResult.m_sOID;

        if debugOn == 1 then
            print("Total: " .. iTotalCount .. " Problems: " .. iProblemCount )
            print("OID: " ..snmpResult.m_sOID)
            print("Data: " ..snmpResult.m_sData)
        end    
        

        if snmpResult.m_sData ~= "" then
            if tonumber(snmpResult.m_sData) > iMinVal then
                iProblemCount = iProblemCount + 1
            end
            iTotalCount = iTotalCount + 1
        end

    until snmpResult.m_sOID == "";

    

    
--// ===========================================================================
--// Compare
--// ===========================================================================

-- If there are more than 50% errors Alarm.

    if iTotalCount == 0 then
        SetExitStatus("Error", false)
    elseif iProblemCount > (iTotalCount / 2) then
        SetExitStatus(ERROR_STRING, false)
    else
        SetExitStatus(SUCCESS_STRING, true)
    end

--// ===========================================================================
--// ~~
--// ===========================================================================


end


/jAzz

sylvain
thank you very much !
i use your script in order to monitor multiple RAID controlers http://www.intellipool.se/forum/index.php?showtopic=1468
Jazz
Thats a good idea i never thought of using it for Monitoring Our Raid Controllers , i'll have to look in to implementing that.

Thanks Sylvain,

/jAzz
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.