Skip to content

Commit e6dcc41

Browse files
committed
Update README.md for new version
1 parent 247c187 commit e6dcc41

File tree

1 file changed

+36
-44
lines changed

1 file changed

+36
-44
lines changed

README.md

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,61 @@
44
[![foryou](https://img.shields.io/static/v1?label=For&message=You&color=aqua&labelColor=blue&style=for-the-badge)]()
55
[![license](https://img.shields.io/static/v1?label=License&message=OPENSOURCE&color=green&labelColor=darkgreen&style=for-the-badge)]()
66
<br><br>
7-
An opensource library to use SNMP get/bulk/set/walk in Python
7+
An opensource library to use SNMP get/set/bulk/walk/table more easily in Python
88

99
## Features
10-
11-
* Work with OIDS json list [Find Here](#OIDS List)
1210
* [GET](#GET) command
1311
* [SET](#SET) command
1412
* [WALK](#WALK) command
1513
* [BULK](#BULK) command
16-
* [CHECK IF DEVICE CONNECTED](#CHECK)
17-
18-
## OIDS List
19-
20-
Change `PATH_TO_LIST` to your OIDS list if you want to use it.
14+
* [TABLE](#TABLE) command
15+
* [CHECK IF DEVICE IS ONLINE](#CHECK)
2116

22-
Example for `OIDS.json`
17+
## Link with oids.json
2318

24-
```
25-
{
26-
"system": {
27-
"name": "1.3.6.1.2.1.1.5",
28-
"uptime": "1.3.6.1.2.1.1.3",
29-
"mac_address": "1.3.6.1.2.1.2.2.1.6",
30-
"temperature": "1.3.6.1.4.1.6296.9.1.1.2.5.1.3"
31-
}
32-
}
33-
```
34-
35-
When constructor `SnmpUtils()` is called, the method `defineOIDsList()` is automaticaly called. So you can use the list
36-
like this:
37-
38-
```
39-
switch = SnmpUtils("10.0.0.1")
40-
print(switch.oids.system.name) #return 1.3.6.1.2.1.1.5
19+
```python
20+
import json
21+
oids = None
22+
with open('OIDS.json', 'r') as file:
23+
oids = json.load(file)
4124
```
4225

4326
## GET
4427

4528
GET SNMP Command return the value of a specific OID. \
4629
`get(oid)`
4730

48-
```
31+
```python
4932
switch = SnmpUtils("10.0.0.1")
50-
switch_name = switch.get(switch.oids.system.name)
33+
switch_name = switch.get(oids['system']['name']) # return name of device
5134
```
5235

53-
You can also use `getByID(oid, id)` which returns the value of the inferior OID.
36+
You can also use `get_by_id(oid, id)` which returns the value of the inferior OID.
5437

55-
```
38+
```python
5639
switch = SnmpUtils("10.0.0.1")
57-
switch_interface_3_description = switch.getByID(switch.oids.interfaces.description, 3) # return the description of the third interface
40+
switch_interface_3_description = switch.get_by_id(oids['interfaces']['description'], 3) # return the description of the third interface
5841
```
5942

6043
## SET
6144

6245
SET SNMP is use for set value of a specific OID. \
63-
`set(oid, value)`
64-
65-
```
46+
`set(oid, value_type, value)` \
47+
*value_type can be one of i/u/t/a/o/s/x/d/b*
48+
```python
6649
switch = SnmpUtils("10.0.0.1")
67-
switch_name = switch.set(switch.oids.system.name, "Test")
50+
switch_name = switch.set(oids['system']['name'], 's', "Test")
6851
```
6952

7053
## WALK
7154

7255
WALK SNMP Command return a dict of all values of inferiors OIDs. \
73-
`walk(oid, numberOfIterations, dotPrefix)`
74-
75-
You can specify the number of value do you want in second parameter.
76-
`dotPrefix` is used for add . in front of OID.
56+
`walk(oid)`
7757

7858
```
7959
switch = SnmpUtils("10.0.0.1")
80-
switch_10_interfaces_description = switch.walk(switch.oids.interfaces.description, 10) # return a dict with key/value
81-
for k,v in switch_10_interfaces_description.items():
60+
switch_interfaces_description = switch.walk(oids['interfaces']['description']) # return a dict with key/value
61+
for k,v in switch_interfaces_description.items():
8262
print(k,v)
8363
```
8464

@@ -89,23 +69,35 @@ BULK SNMP returns all following items up to a limit for an/several item(s). \
8969

9070
```
9171
switch = SnmpUtils("10.0.0.1")
92-
switch_interfaces_description = switch.bulk(switch.oids.interfaces.description) #return a dict with description for all interfaces
72+
switch_interfaces_description = switch.bulk(oids['interfaces']['description']) #return a dict with description for all interfaces
73+
```
74+
75+
## TABLE
76+
77+
TABLE SNMP returns list of dicts \
78+
`get_table(oid, sort_key)`
79+
80+
```
81+
switch = SnmpUtils("10.0.0.1")
82+
switch_interfaces = switch.get_table('1.3.6.1.2.1.2.2') # return list of dicts
9383
```
9484

85+
9586
## CHECK
9687

9788
You can easily check if a device is online \
98-
`isConnected()`
89+
`is_online()`
9990

10091
```
10192
switch = ("10.0.0.1")
102-
if switch.isConnected():
93+
if switch.is_online():
10394
print("Switch online")
10495
```
10596

10697
## Dependencies
10798

10899
* [PySNMP](https://pysnmp.readthedocs.io/en/latest/)
100+
* [SNMP-CMDS](https://snmp-cmds.readthedocs.io/en/latest/)
109101

110102
## Contributors
111103

0 commit comments

Comments
 (0)