Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-plugins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cscf
icinga-plugins
Commits
79cf9595
Commit
79cf9595
authored
1 year ago
by
root
Browse files
Options
Downloads
Patches
Plain Diff
Updated check_mellanox to Python3 with easysnmp
parent
3c6c73dd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_mellanox
+30
-22
30 additions, 22 deletions
check_mellanox
with
30 additions
and
22 deletions
check_mellanox
+
30
−
22
View file @
79cf9595
#!/usr/bin/python
#!/usr/bin/python
3
# Author: Devon Merner (dmerner)
# Author: Devon Merner (dmerner)
# Date: November 17th, 2016
# Date: November 17th, 2016
...
@@ -14,7 +14,8 @@ CRITICAL_TEXT=""
...
@@ -14,7 +14,8 @@ CRITICAL_TEXT=""
import
sys
import
sys
import
argparse
import
argparse
import
netsnmp
from
easysnmp
import
Session
from
easysnmp.exceptions
import
*
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
-c
"
,
default
=
"
public
"
,
dest
=
"
community
"
,
parser
.
add_argument
(
"
-c
"
,
default
=
"
public
"
,
dest
=
"
community
"
,
...
@@ -38,31 +39,39 @@ parser.add_argument("-fC", default="1000", dest="fancrit",
...
@@ -38,31 +39,39 @@ parser.add_argument("-fC", default="1000", dest="fancrit",
help
=
"
Fan monitor critical threshold in RPM (returns critical if equivelant or less than this number) Default: 1000
"
)
help
=
"
Fan monitor critical threshold in RPM (returns critical if equivelant or less than this number) Default: 1000
"
)
options
=
parser
.
parse_args
()
options
=
parser
.
parse_args
()
args
=
{
"
Version
"
:
int
(
options
.
version
),
def
snmpGet
(
oid
):
"
DestHost
"
:
options
.
host
,
try
:
"
Community
"
:
options
.
community
return
session
.
get
(
oid
).
value
}
except
EasySNMPNoSuchNameError
:
return
None
def
snmpWalk
(
oid
):
try
:
return
session
.
walk
(
oid
)
except
EasySNMPNoSuchNameError
:
return
None
session
=
Session
(
hostname
=
options
.
host
,
community
=
options
.
community
,
version
=
int
(
options
.
version
))
dataReturned
=
0
dataReturned
=
0
# Collect fan/temperature sensor data
# Collect fan/temperature sensor data
for
idx
in
netsnmp
.
snmpwalk
(
netsnmp
.
Varbind
(
"
.1.3.6.1.2.1.99.1.1
"
),
**
args
):
for
idx
in
snmpWalk
(
"
.1.3.6.1.2.1.99.1.1
"
):
idx
=
idx
.
value
dataReturned
=
1
dataReturned
=
1
# Mellanox indexes start with 200 for some reason.
# Mellanox indexes start with 200 for some reason.
if
not
idx
.
startswith
(
"
200
"
):
if
not
idx
.
startswith
(
"
200
"
):
continue
continue
sensortype
,
desc
,
units
,
value
=
netsnmp
.
snmpget
(
sensortype
=
snmpGet
(
"
.1.3.6.1.2.1.47.1.1.1.1.7.
"
+
idx
)
netsnmp
.
Varbind
(
"
.1.3.6.1.2.1.47.1.1.1.1.7
"
,
idx
),
desc
=
snmpGet
(
"
.1.3.6.1.2.1.47.1.1.1.1.2.
"
+
idx
)
netsnmp
.
Varbind
(
"
.1.3.6.1.2.1.47.1.1.1.1.2
"
,
idx
),
units
=
snmpGet
(
"
.1.3.6.1.2.1.99.1.1.1.6.
"
+
idx
)
netsnmp
.
Varbind
(
"
.1.3.6.1.2.1.99.1.1.1.6
"
,
idx
),
value
=
snmpGet
(
"
.1.3.6.1.2.1.99.1.1.1.4.
"
+
idx
)
netsnmp
.
Varbind
(
"
.1.3.6.1.2.1.99.1.1.1.4
"
,
idx
),
**
args
)
if
(
sensortype
is
None
):
if
(
sensortype
is
None
):
continue
continue
# Convert into actual units if using SNMP v1
# Convert into actual units if using SNMP v1
if
(
int
(
options
.
version
)
==
1
)
and
sensortype
.
startswith
(
"
Temperature
"
):
if
(
int
(
options
.
version
)
==
1
)
and
sensortype
.
startswith
(
"
Temperature
"
):
...
@@ -90,13 +99,12 @@ if dataReturned == 0:
...
@@ -90,13 +99,12 @@ if dataReturned == 0:
sys
.
exit
(
STATE_UNKNOWN
)
sys
.
exit
(
STATE_UNKNOWN
)
# Collect power supply information
# Collect power supply information
for
idx
in
netsnmp
.
snmpwalk
(
netsnmp
.
Varbind
(
"
.1.3.6.1.2.1.47.1.1.1.1.1
"
),
**
args
):
for
idx
in
snmpWalk
(
"
.1.3.6.1.2.1.47.1.1.1.1.1
"
):
idx
=
idx
.
value
sensortype
,
desc
,
alarm
=
netsnmp
.
snmpget
(
sensorType
=
snmpGet
(
"
.1.3.6.1.2.1.47.1.1.1.1.7.
"
+
idx
)
netsnmp
.
Varbind
(
"
.1.3.6.1.2.1.47.1.1.1.1.7
"
,
idx
),
desc
=
snmpGet
(
"
.1.3.6.1.2.1.47.1.1.1.1.2.
"
+
idx
)
netsnmp
.
Varbind
(
"
.1.3.6.1.2.1.47.1.1.1.1.2
"
,
idx
),
alarm
=
snmpGet
(
"
.1.3.6.1.2.1.131.1.1.1.5.
"
+
idx
)
netsnmp
.
Varbind
(
"
.1.3.6.1.2.1.131.1.1.1.5
"
,
idx
),
**
args
)
if
sensortype
is
None
:
if
sensortype
is
None
:
continue
continue
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment