Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit 4542d7a

Browse files
authored
Merge pull request #10 from minitriga/update_version
Update version
2 parents 601c745 + e20c2d1 commit 4542d7a

File tree

14 files changed

+119
-11
lines changed

14 files changed

+119
-11
lines changed

LICENCE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright 2020 Axians UK <[email protected]>
2+
Axians UK
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.

README.md

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
A plugin for [Netbox](https://github.com/netbox-community/netbox) to get power distribution unit Information.
44

5-
`axians-netbox-plugin-pdu` is using [Easy SNMP](https://easysnmp.readthedocs.io/en/latest/), [Django-RQ](https://github.com/rq/django-rq) and [RQ-Scheduler](https://github.com/rq/rq-scheduler) to display PDU information within Netbox.
5+
`axians-netbox-plugin-pdu` is using [Easy SNMP](https://easysnmp.readthedocs.io/en/latest/), [Django-RQ](https://github.com/rq/django-rq) and [RQ-Scheduler](https://github.com/rq/rq-scheduler) to display PDU information within Netbox.
66

77
## Installation
8+
The plugin is available as a Python package in pypi and can be installed with pip
9+
10+
```
11+
pip install axians-netbox-plugin-pdu
12+
```
813

914
> The plugin is compatible with NetBox 2.8.1 and higher
1015
@@ -20,6 +25,68 @@ PLUGINS = ["axians_netbox_pdu"]
2025
# }
2126
```
2227

28+
There are a number of default settings that can be altered using the following list of settings:
29+
30+
* `schedule`: Boolean (default True). If True, this will enable automatic polling of your PDU Devices.
31+
* `schedule_interval`: Integer (default 300 seconds). Length of time between each scheduled poll.
32+
* `snmp_read`: String (default public) SNMP read value for your SNMP enabled PDU's.
33+
* `snmp_write`: String (default private) SNMP write value for your SNMP enabled PDU's.
34+
* `rack_view_pdu_devices`: Boolean (default True), if True, the power usage per PDU will be displayed on the rack page.
35+
* `rack_view_usage_summary`: Boolean (default True), if True, the a summary information tile will appear within the rack page to show true power utilization within the rack.
36+
* `rack_view_summary_unit`: String (default watts), option to display watts/kilowatts on the rack summary view. If "kilowatts" is used the power usage summary will display in Kilowatts.
37+
38+
## Usage
39+
### Preparation
40+
For this plugin to work there must be a new worker added to your Netbox installation. The new worker is a custom scheduler that will schedule the PDU Tasks to run on an interval and utilize the django-rq library.
41+
42+
> You can utilize this library without the automated tasks by feeding Netbox the power usage information via the `axians_netbox_pdu` API.
43+
44+
### Default Environment
45+
For the standard install please use the included [netbox-pdu.service](contrib/netbox-pdu.service) and install using the standard [Netbox Documentation](https://netbox.readthedocs.io/en/stable/installation/migrating-to-systemd/).
46+
47+
### Docker Environment
48+
To use within Docker make sure you have a container running that runs the following command: `python manage.py pduschedule`
49+
50+
### Adding a new PDU Configuration
51+
Once installed and the `pduscheduler` is running you can attach a `PDUConfig` to a DeviceType. To do this you must have a DeviceType configured with PowerOutlets. You can specify the DeviceType, PDU SNMP OID and the Unit. This enables the plugin to know what SNMP OID to collect per DeviceType.
52+
53+
Now a PDUConfig has been created a device must be created with a management IP. Once this is done the plugin can poll the PDU via SNMP and save the power usage.
54+
55+
This can also be done via Bulk Import or via the API.
56+
57+
> If a a PDUConfig is not created for a DeviceType and the Device does not have a Primary IP no data will be collected.
58+
59+
### API
60+
The plugin includes several endpoints to manage the PDUConfig and PDUStatus.
61+
62+
```
63+
GET /api/plugins/pdu/pdu-config/ List PDUConfig
64+
POST /api/plugins/pdu/pdu-config/ Create PDUConfig
65+
PATCH/PUT /api/plugins/pdu/pdu-config/{id}/ Edit a specific PDUConfig
66+
DELETE /api/plugins/pdu/pdu-config/{id}/ Delete a specific PDUConfig
67+
68+
GET /api/plugins/pdu/pdu-status/ List PDUStatus
69+
POST /api/plugins/pdu/pdu-status/ Create PDUStatus
70+
PATCH/PUT /api/plugins/pdu/pdu-status/{id}/ Edit a specific PDUStatus
71+
DELETE /api/plugins/pdu/pdu-status/{id}/ Delete a specific PDUStatus
72+
```
73+
74+
## Screen Shots
75+
List of PDUConfig Instances
76+
![PDUConfig List View](docs/images/PDUConfig_list.png)
77+
78+
Import PDUConfig Instances
79+
![PDUConfig Import View](docs/images/PDUConfig_import.png)
80+
81+
Edit PDUConfig Instances
82+
![PDUConfig Edit View](docs/images/PDUConfig_edit.png)
83+
84+
View PDUStatus Device View
85+
![PDUStatus Device View](docs/images/PDUStatus_device.png)
86+
87+
View PDUStatus Rack View
88+
![PDUStatus Rack View](docs/images/PDUStatus_rack.png)
89+
2390
## Contributing
2491

2592
Pull requests are welcomed.
@@ -45,14 +112,14 @@ Each command can be executed with `invoke <command>`. All commands support the a
45112
```
46113

47114

48-
#### Utility
115+
#### Utility
49116
```
50117
cli Launch a bash shell inside the running NetBox container.
51118
create-user Create a new user in django (default: admin), will prompt for password.
52119
makemigrations Run Make Migration in Django.
53120
nbshell Launch a nbshell session.
54121
```
55-
#### Testing
122+
#### Testing
56123

57124
```
58125
tests Run all tests for this plugin.

axians_netbox_pdu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.0.1"
1+
__version__ = "0.0.2"
22

33
from extras.plugins import PluginConfig
44

axians_netbox_pdu/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PDUConfig(models.Model):
1919
csv_headers = ["device_type", "power_usage_oid", "power_usage_unit"]
2020

2121
def __str__(self):
22-
"""String representation of an OnboardingTask."""
22+
"""String representation of an PDUConfig."""
2323
return f"{self.device_type}"
2424

2525

axians_netbox_pdu/navigation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
title="Add",
1313
icon_class="fa fa-plus",
1414
color=ButtonColorChoices.GREEN,
15-
permissions=["netbox_onboarding.add_pduconfig"],
15+
permissions=["axians_netbox_pdu.add_pduconfig"],
1616
),
1717
PluginMenuButton(
1818
link="plugins:axians_netbox_pdu:pduconfig_import",
1919
title="Bulk Add",
2020
icon_class="fa fa-download",
2121
color=ButtonColorChoices.BLUE,
22-
permissions=["netbox_onboarding.add_pduconfig"],
22+
permissions=["axians_netbox_pdu.add_pduconfig"],
2323
),
2424
),
2525
),

axians_netbox_pdu/templates/axians_netbox_pdu/device_type_pduconfig.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
</tr>
1717
</tbody>
1818
</table>
19+
{% if perms.axians_netbox_pdu.change_pduconfig %}
1920
<div class="panel-footer noprint">
2021
<a href="{% url 'plugins:axians_netbox_pdu:pduconfig_edit' pk=pduconfig.pk %}"
2122
class="btn btn-xs btn-warning"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
2223
Edit</a>
2324
<div class="clearfix"></div>
2425
</div>
26+
{% endif %}
2527
</div>

contrib/netbox-pdu.service

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[Unit]
2+
Description=NetBox Axians PDU Plugin Scheduler
3+
Documentation=https://github.com/minitriga/netbox-axians-pdu
4+
After=network-online.target
5+
Wants=network-online.target
6+
7+
[Service]
8+
Type=simple
9+
10+
User=netbox
11+
Group=netbox
12+
WorkingDirectory=/opt/netbox
13+
14+
ExecStart=/opt/netbox/venv/bin/python3 /opt/netbox/netbox/manage.py pduscheduler
15+
16+
Restart=on-failure
17+
RestartSec=30
18+
PrivateTmp=true
19+
20+
[Install]
21+
WantedBy=multi-user.target

docs/images/PDUConfig_edit.png

49.7 KB
Loading

docs/images/PDUConfig_import.png

32.1 KB
Loading

docs/images/PDUConfig_list.png

29.5 KB
Loading

0 commit comments

Comments
 (0)