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
a074fdc2
Commit
a074fdc2
authored
1 year ago
by
root
Browse files
Options
Downloads
Patches
Plain Diff
Converted check_geist_pdu to Python3 with easysnmp
parent
79cf9595
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_geist_pdu
+23
-13
23 additions, 13 deletions
check_geist_pdu
with
23 additions
and
13 deletions
check_geist_pdu
+
23
−
13
View file @
a074fdc2
#!/usr/bin/python
#!/usr/bin/python
3
# Author: Devon Merner (dmerner)
# Date: July 16th, 2021
...
...
@@ -23,7 +23,8 @@ PERFDATA = ""
import
sys
import
argparse
import
netsnmp
from
easysnmp
import
Session
from
easysnmp.exceptions
import
*
# OIDs
firmwareTree
=
"
SNMPv2-MIB::sysObjectID.0
"
...
...
@@ -70,13 +71,22 @@ parser.add_argument("host", default="localhost", nargs="?", help="Agent to retri
parser
.
add_argument
(
"
-d
"
,
action
=
"
store_true
"
,
dest
=
"
debug
"
,
help
=
"
Print debug information
"
)
options
=
parser
.
parse_args
()
args
=
{
"
Version
"
:
int
(
options
.
version
),
"
DestHost
"
:
options
.
host
,
"
Community
"
:
options
.
community
}
firmwareTreeRoot
=
netsnmp
.
snmpget
(
netsnmp
.
Varbind
(
firmwareTree
),
**
args
)[
0
]
def
snmpGet
(
oid
):
try
:
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
))
firmwareTreeRoot
=
snmpGet
(
firmwareTree
)
if
firmwareTreeRoot
is
None
:
print
(
"
UNKNOWN - PDU did not respond (network timeout). |
"
)
sys
.
exit
(
STATE_UNKNOWN
)
...
...
@@ -84,17 +94,17 @@ elif ".3.6.1.4.1.21239.2" in str(firmwareTreeRoot):
if
options
.
debug
:
print
(
"
PDU is running V3 firmware
"
)
productTitle
=
net
snmp
.
snmpget
(
netsnmp
.
Varbind
(
v3_productTitle
)
,
**
args
)[
0
]
productVersion
=
net
snmp
.
snmpget
(
netsnmp
.
Varbind
(
v3_productVersion
)
,
**
args
)[
0
]
productTitle
=
snmp
Get
(
v3_productTitle
)
productVersion
=
snmp
Get
(
v3_productVersion
)
OUTPUT_TEXT
+=
"
[
"
+
str
(
productTitle
)
+
"
v
"
+
str
(
productVersion
)
+
"
]
"
for
circuit
,
oids
in
v3_power
.
iter
items
():
for
circuit
,
oids
in
v3_power
.
items
():
if
options
.
debug
:
print
(
"
Circuit
"
+
circuit
)
for
key
,
oid
in
oids
.
iter
items
():
value
=
net
snmp
.
snmpget
(
netsnmp
.
Varbind
(
oid
),
**
args
)[
0
]
for
key
,
oid
in
oids
.
items
():
value
=
snmp
Get
(
oid
)
if
"
Amp
"
in
key
:
value
=
float
(
value
)
/
10
...
...
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