New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


[HP ProCurve Switch] Monitoring Version And Model

Votes:

2

Your Vote:

Up

Down

Introduction

This sensor allows you to monitor the software version of your ProCurve switches and shows the model information in the sensor message. Version is divided into Major, Minor, and Patchlevel. Feel free to set limits accordingly to find old versions. Recommended sensor interval is 24h.

Screenshot

Please have a look at our guide for installing PowerShell based sensors for installation details.

Requirements

Needs snmpget.exe within the EXEXML directory, which can be obtained via
https://www.snmpsoft.com/cmd-tools/snmp-get/

Parameters

ParameterTypeDescription
TargetHostStringThe host address of the target appliance (can be set to %host)
PortIntegerThe used SNMP port, defaulting to 161
CommunityStringThe SNMP community, defaulting to public
OidsString[]The OIDs for the software version and the system info (model name, etc.)

Version History

DateVersionNotes
November 30rd, 20161.0Initial Release

Script

# ___ ___ _____ ___
#| _ \ _ \_   _/ __|
#|  _/   / | || (_ |
#|_| |_|_\ |_| \___|
#    NETWORK MONITOR
#-------------------
# Description: This sensor will show the software version (major, minor, patch) and model information 
# Parameters:
# -TargetHost:      The host address of the target appliance. Using %host within PRTG will work. 
# -Port             The used SNMP port, defaulting to 161
# -Community        The SNMP community
# -Oids             The OIDs for the software version and the system info (model name, etc.)
# 
# Requirements
# ------------------
# - needs snmpget.exe within the EXEXML directory (can be obtained via https://www.snmpsoft.com/cmd-tools/snmp-get/)
# 
# Version History
# ------------------
# Version  Date        Notes
# 1.0      11/30/2016  Initial Release
#
# ------------------
# (c) 2015 Stephan Linke | Paessler AG
param(
    [string]$TargetHost = "localhost", 
    [int]$Port = 161,
    [string]$Community = "public",
    [string[]]$Oids = @("1.3.6.1.2.1.47.1.1.1.1.9",".1.3.6.1.2.1.47.1.1.1.1.2.1")
)

$Result = @"
<?xml version="1.0" encoding="UTF-8" ?>
<prtg>
<result>
<channel>Major Version</channel>
<value>{0}</value>
</result>
<result>
<channel>Minor Version</channel>
<value>{1}</value>
</result>
<result>
<channel>Patch Level</channel>
<value>{2}</value>
</result>
<text>{3}</text>
</prtg>
"@

function getOid([string]$Oid){

$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\snmpget.exe"
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = [string]::Format("-r:{0} -p:{1} -t:10 -c:{2} -o:{3} -q", $TargetHost, $Port,$Community, $Oid); 
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null

#Do Other Stuff Here....
$p.WaitForExit()

return $p.StandardOutput.ReadToEnd();

} 

$Version = (getOid -oid $Oids[0]).Split(".");
$SysInfo = (getOid -oid $Oids[1]);

Write-Host ([string]::Format($result, $Version[0], $Version[1], $Version[2], $SysInfo));  

Notes

The script is provided as is and may or may not work with your installation. If you need any further customizations for your environment, feel free to implement them. If you encounter any bugs, feel free to share them :)

hp-procurve patchlevel powershell procurve snmpget version

Created on Nov 30, 2016 8:04:04 AM by  Stephan Linke [Paessler Support]

Last change on Sep 14, 2017 12:27:56 PM by  Luciano Lingnau [Paessler Support]



2 Replies

Votes:

0

Your Vote:

Up

Down

Hi Stephan,

Thank you for this cool script !

Did you notice that you can do SNMP stuff in Powershell directly without using third party tools ?

Check : https://msdn.microsoft.com/en-us/library/ff554459(v=vs.85).aspx

$snmp = new-object -ComObject olePrn.OleSNMP
$snmp.open($IP,$community,$retry,$timeout)
$snmp.get(".1.3.6.1.2.1.1.5.0")
$snmp.close()

Only drawback : you cannot use it on port other than 161 :'(



Regards.

Created on Apr 19, 2017 11:34:44 AM by  klmj (0) 2



Votes:

0

Your Vote:

Up

Down

Just to mention, that ProCurve J9728A does not hold it's Version on OID 1.3.6.1.2.1.47.1.1.1.1.9 For ProCurve it may be better to use 1.3.6.1.4.1.11.2.14.11.5.1.59.1.4.1.5.1 (tested with a couple of HP Switches like 29xx, 54xx, 18xx Series)

@klmj: the OleSNMP will not work if it could not resolve the OID to a known string. For example if I query for sysObjectId on an Enterasys B-Series Switch, it fails with an error SNMP_ERRORSTATUS_NOSUCHNAME (The requested SNMP operation identified an unknown variable).

regards

Created on Sep 2, 2017 11:38:52 AM by  Nogalj (0)



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.