summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2016-03-12 10:47:48 +0100
committerIlya Etingof <etingof@gmail.com>2016-03-12 10:47:48 +0100
commitd524518183dd023915324f0ed2b666a61bc0d39f (patch)
tree64f5222d88c4689589c31d30c118bb17108a28af /README.md
parent6f0ba0a5fc6b4db5e6a8d6f3eb1442b4d340017c (diff)
downloadpysnmp-git-d524518183dd023915324f0ed2b666a61bc0d39f.tar.gz
highlighing fixes
Diffstat (limited to 'README.md')
-rw-r--r--README.md82
1 files changed, 41 insertions, 41 deletions
diff --git a/README.md b/README.md
index 11b75d40..1911fb2b 100644
--- a/README.md
+++ b/README.md
@@ -44,9 +44,9 @@ Installation
Just run:
- ```bash
- $ pip install pysnmp
- ```
+```bash
+$ pip install pysnmp
+```
to download and install PySNMP along with its dependencies:
@@ -57,16 +57,16 @@ to download and install PySNMP along with its dependencies:
Besides the library, command-line [SNMP utilities](https://github.com/etingof/pysnmp-apps)
written in pure-Python could be installed via:
- ```bash
- $ pip install pysnmp-apps
- ```
+```bash
+$ pip install pysnmp-apps
+```
and used in the very similar manner as conventional Net-SNMP tools:
- ```bash
- $ snmpget.py -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 demo.snmplabs.com sysDescr.0
- SNMPv2-MIB::sysDescr.0 = DisplayString: SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m
- ```
+```bash
+$ snmpget.py -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 demo.snmplabs.com sysDescr.0
+SNMPv2-MIB::sysDescr.0 = DisplayString: SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m
+```
Examples
--------
@@ -74,43 +74,43 @@ Examples
PySNMP is designed highly modular and implements many programming interfaces. Most
high-level and easy to use API is called *hlapi* and can be used like this:
- ```python
- from pysnmp.hlapi import *
-
- iterator = getCmd(
- SnmpEngine(),
- CommunityData('public'),
- UdpTransportTarget(('demo.snmplabs.com', 161)),
- ContextData(),
- ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))
- )
-
- errorIndication, errorStatus, errorIndex, varBinds = next(iterator)
-
- if errorIndication: # SNMP engine errors
- print errorIndication
+```python
+from pysnmp.hlapi import *
+
+iterator = getCmd(
+ SnmpEngine(),
+ CommunityData('public'),
+ UdpTransportTarget(('demo.snmplabs.com', 161)),
+ ContextData(),
+ ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))
+)
+
+errorIndication, errorStatus, errorIndex, varBinds = next(iterator)
+
+if errorIndication: # SNMP engine errors
+ print errorIndication
+else:
+ if errorStatus: # SNMP agent errors
+ print(%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex)-1] or '?'))
else:
- if errorStatus: # SNMP agent errors
- print(%s at %s' % (errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1] or '?'))
- else:
- for varBind in varBinds: # SNMP response contents
- print('='.join([x.prettyPrint() for x in varBind]))
- ```
+ for varBind in varBinds: # SNMP response contents
+ print('='.join([x.prettyPrint() for x in varBind]))
+```
We maintain publically available SNMP Agent and TRAP sink at
[demo.snmplabs.com](http://snmpsim.sourceforge.net/public-snmp-simulator.html). You are
welcome to play with it while experimenting with your PySNMP scripts.
- ```bash
- $ python3 examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py
- SNMPv2-MIB::sysDescr.0 = SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m
- $
- $ python3 examples//hlapi/asyncore/sync/agent/ntforg/v3-inform.py
- SNMPv2-MIB::sysUpTime.0 = 0
- SNMPv2-MIB::snmpTrapOID.0 = SNMPv2-MIB::warmStart
- SNMPv2-MIB::sysName.0 = system name
- ```
+```bash
+$ python3 examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py
+SNMPv2-MIB::sysDescr.0 = SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m
+$
+$ python3 examples//hlapi/asyncore/sync/agent/ntforg/v3-inform.py
+SNMPv2-MIB::sysUpTime.0 = 0
+SNMPv2-MIB::snmpTrapOID.0 = SNMPv2-MIB::warmStart
+SNMPv2-MIB::sysName.0 = system name
+```
Other than that, PySNMP is capable to automatically fetch required MIBs from HTTP, FTP sites
or local directories. You could configure any MIB source available to you (including