Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9bcfc31
Showing
13 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
*.pyc | ||
*.egg-info | ||
build/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
Version 0.1.0 | ||
------------- | ||
|
||
* Initial Version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2017 Arachnys Information Services Ltd and individual contributors. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Network check for Cabot | ||
======================= | ||
|
||
Usage | ||
===== | ||
|
||
Creating a check | ||
---------------- | ||
|
||
When creating a check, you can set a host and an port. That's about it. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11 on 2017-09-13 11:44 | ||
from __future__ import unicode_literals | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('cabotapp', '0006_auto_20170821_1000'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='NetworkStatusCheck', | ||
fields=[ | ||
('statuscheck_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='cabotapp.StatusCheck')), | ||
('host', models.TextField(help_text=b'Host to check.', null=True)), | ||
('port', models.PositiveIntegerField(help_text=b'Port to check.', null=True)), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=('cabotapp.statuscheck',), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import socket | ||
|
||
from django.db import models | ||
|
||
from cabot.cabotapp.models import StatusCheck, StatusCheckResult | ||
|
||
|
||
class NetworkStatusCheck(StatusCheck): | ||
check_name = 'network' | ||
edit_url_name = 'update-network-check' | ||
duplicate_url_name = 'duplicate-network-check' | ||
icon_class = 'glyphicon-transfer' | ||
host = models.TextField( | ||
help_text='Host to check.', | ||
) | ||
port = models.PositiveIntegerField( | ||
help_text='Port to check.', | ||
) | ||
|
||
def _run(self): | ||
result = StatusCheckResult(status_check=self) | ||
|
||
try: | ||
s = socket.create_connection((self.host, self.port), self.timeout) | ||
s.shutdown(socket.SHUT_RDWR) | ||
s.close() | ||
except Exception as e: | ||
result.error = u'Error occurred: %s' % (e.message,) | ||
result.succeeded = False | ||
else: | ||
result.succeeded = True | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.conf.urls import url | ||
|
||
from .views import (NetworkCheckCreateView, NetworkCheckUpdateView, | ||
duplicate_check) | ||
|
||
urlpatterns = [ | ||
|
||
url(r'^networkcheck/create/', | ||
view=NetworkCheckCreateView.as_view(), | ||
name='create-network-check'), | ||
|
||
url(r'^networkcheck/update/(?P<pk>\d+)/', | ||
view=NetworkCheckUpdateView.as_view(), | ||
name='update-network-check'), | ||
|
||
url(r'^networkcheck/duplicate/(?P<pk>\d+)/', | ||
view=duplicate_check, | ||
name='duplicate-network-check') | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from django import forms | ||
from django.core.urlresolvers import reverse | ||
from django.http import HttpResponseRedirect | ||
|
||
from cabot.cabotapp.models import StatusCheck | ||
from cabot.cabotapp.views import (CheckCreateView, CheckUpdateView, | ||
StatusCheckForm, base_widgets) | ||
|
||
from .models import NetworkStatusCheck | ||
|
||
|
||
class NetworkStatusCheckForm(StatusCheckForm): | ||
symmetrical_fields = ('service_set', 'instance_set') | ||
|
||
class Meta: | ||
model = NetworkStatusCheck | ||
fields = ( | ||
'name', | ||
'host', | ||
'port', | ||
'timeout', | ||
'frequency', | ||
'active', | ||
'importance', | ||
'debounce', | ||
) | ||
|
||
widgets = dict(**base_widgets) | ||
widgets.update({ | ||
'host': forms.TextInput(attrs={ | ||
'style': 'width: 100%', | ||
'placeholder': 'service.arachnys.com', | ||
}) | ||
}) | ||
|
||
|
||
class NetworkCheckCreateView(CheckCreateView): | ||
model = NetworkStatusCheck | ||
form_class = NetworkStatusCheckForm | ||
|
||
|
||
class NetworkCheckUpdateView(CheckUpdateView): | ||
model = NetworkStatusCheck | ||
form_class = NetworkStatusCheckForm | ||
|
||
|
||
def duplicate_check(request, pk): | ||
pc = StatusCheck.objects.get(pk=pk) | ||
npk = pc.duplicate() | ||
return HttpResponseRedirect(reverse('update-network-check', kwargs={'pk': npk})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[metadata] | ||
description-file = README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env python | ||
|
||
from setuptools import find_packages, setup | ||
|
||
setup(name='cabot_check_network', | ||
version='0.1.0', | ||
description='A network check plugin for Cabot by Arachnys', | ||
author='Arachnys', | ||
author_email='techteam@arachnys.com', | ||
url='http://cabotapp.com', | ||
packages=find_packages(), | ||
) |