https://github.com/zodman/pingdoomer
Ping hostname monitor and blacklist
https://github.com/zodman/pingdoomer
Last synced: 12 months ago
JSON representation
Ping hostname monitor and blacklist
- Host: GitHub
- URL: https://github.com/zodman/pingdoomer
- Owner: zodman
- Created: 2020-02-20T05:26:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T03:40:55.000Z (over 3 years ago)
- Last Synced: 2025-06-25T04:45:56.634Z (about 1 year ago)
- Language: Python
- Homepage: https://hackmd.io/@CZ7Qf8ZASPiRGhV9236VSQ/BJ6JzKGzI
- Size: 98.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pingdoomer
## django ping monitor and blacklist
### Models
```python
class Account(models.Model):
name = fields.CharField()
externa_id = fields.IntegerField()
class Host(models.Model)
hostname = fields.CharField()
account = fields.ForeignKey()
```
### Django rest framework
- POST create
- PUT update
- DEL delete
#### Api (protected by Apikey for writing and other for reading):
v1/api/account/
v1/api/account//hosts/
v1/api/account//hosts//
- GET for obtain all data to graph. and last result
### TimeserieDB:: InfluxDB
I will store the ping stats using [pingparsing](https://pypi.org/project/pingparsing/) into a [influxdb](https://github.com/influxdata/influxdb-python)
```python=
$ python
>>> from influxdb import InfluxDBClient
>>> json_body = [
{
"measurement": "account_",
"tags": {
"hostname": "",
},
"time": "2009-11-10T23:00:00Z",
"fields": {
"packet_transmit": 10,
"packet_receive": 10,
"packet_loss_rate": 0.0,
"packet_loss_count": 0,
"rtt_min": 34.189,
"rtt_avg": 46.054,
"rtt_max": 63.246,
"rtt_mdev": 9.122,
"packet_duplicate_rate": 0.0,
"packet_duplicate_count": 0
}
}
]
>>> client = InfluxDBClient('localhost', 8086, 'root', 'root', 'example')
>>> client.create_database('example')
>>> client.write_points(json_body)
>>> result = client.query('select * from account_ group by hostname;')
>>> print("Result: {0}".format(result))
```
### Celery tasks
- scheduler()
- Obtain all host and throw everything to workers
- run(account__name, host)
- execute the ping on host
- parse the ping stats
- insert into influxdb
Celery workers to execute the ping and a celery scheduler to execute each time needed.
### commands to add
```
pip install httpie
http POST localhost:8000/api/accounts/ 'Authorization:Token ' name=andres1 external_id=10
http POST localhost:8000/api/accounts/6/hosts/ 'Authorization:Token ' hostname=waifu.ca
```