-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into wordcloud_generator
- Loading branch information
Showing
60 changed files
with
2,477 additions
and
182 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
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 @@ | ||
name: DNS Entry Checker Unittest | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
paths: | ||
- "jsm_metric_collection/**" | ||
- ".github/workflows/jsm_metric_collection.yaml" | ||
|
||
jobs: | ||
test_with_unit_test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.9"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r jsm_metric_collection/requirements.txt | ||
- name: Test with unittest | ||
run: | | ||
cd jsm_metric_collection | ||
python3 -m unittest discover -s ./test -p "test_*.py" |
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,40 @@ | ||
name: Pynetbox Codecov | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
paths: | ||
- "pynetbox_data_uploader/**" | ||
- ".github/workflows/pynetbox.yaml" | ||
|
||
jobs: | ||
Codecov: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
python-version: ["3.x"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
cd pynetbox_query | ||
pip install -r requirements.txt | ||
- name: Run tests and collect coverage | ||
run: cd pynetbox_query && python3 -m pytest --cov-report xml:coverage.xml --cov | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{secrets.CODECOV_TOKEN}} | ||
files: ./pynetbox_query/coverage.xml |
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,35 @@ | ||
name: Pynetbox Pylint | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
paths: | ||
- "pynetbox_data_uploader/**" | ||
- ".github/workflows/pynetbox.yaml" | ||
|
||
jobs: | ||
Pylint: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
python-version: ["3.x"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
cd pynetbox_query | ||
pip install -r requirements.txt | ||
- name: Analyse with pylint | ||
run: cd pynetbox_query && pylint $(git ls-files '*.py') |
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,34 @@ | ||
name: Pynetbox Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
paths: | ||
- "pynetbox_data_uploader/**" | ||
- ".github/workflows/pynetbox.yaml" | ||
|
||
jobs: | ||
Test: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
python-version: ["3.x"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
cd pynetbox_query | ||
pip install -r requirements.txt | ||
- name: Run tests and collect coverage | ||
run: cd pynetbox_query && python3 -m pytest |
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
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
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
2.3.4 | ||
2.3.5 |
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 @@ | ||
[database] | ||
connection =mysql+pymysql://<dbusername>:<dbpassword>@<dbhost>:3306 |
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,23 @@ | ||
# TheCount | ||
|
||
|
||
## Prerequisites | ||
|
||
The following packages are required: | ||
- python3-requests | ||
- python36-sqlalchemy | ||
- python36-PyMySQL | ||
|
||
A database user with read access to the relevant databases for each OpenStack component you are accounting for | ||
|
||
## Installation | ||
|
||
Copy the scripts into `/usr/local/sbin` as shown in this repo | ||
Create a config file with a database connection string in the format shown in `/etc/thecount/thecount.conf.example` in `/etc/thecount/thecount.conf` | ||
Create the stored procedures in the `sql` directory appropriate db. | ||
|
||
## Use | ||
|
||
`now-accounting.sh` generates accounting for the last 24 hours - recommend setting up a cron to run this at midnight | ||
`past-accounting.sh` takes a start date and an end date in the format "%Y-%m-%d %H:%M" to generate accounting for past usage where possible | ||
`*-extract_accounting.py` takes a start date and an end date in the format "%Y-%m-%d %H:%M" to generate accounting for that component |
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,3 @@ | ||
python3-requests | ||
python36-sqlalchemy | ||
python36-PyMySQL |
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,44 @@ | ||
CREATE PROCEDURE `get_accounting_data`(IN starttime datetime, IN endtime datetime) | ||
BEGIN | ||
/* | ||
This procedure generates accounting data for cinder | ||
*/ | ||
SELECT | ||
IFNULL(v.availability_zone, 'nova') AS AvailabilityZone, | ||
p.name AS Project, | ||
pp.name AS Department, | ||
COUNT(v.id) AS Volumes, | ||
"Volume" as CinderType, | ||
@VolumeSeconds:=SUM(IF(v.created_at <= starttime /* Captures Volumes which were created outside of the period deleted out of the period */ | ||
AND (v.deleted_at >= endtime | ||
OR ISNULL(v.deleted_at)), | ||
TIMESTAMPDIFF(SECOND, | ||
starttime, | ||
endtime), | ||
IF(v.created_at <= starttime /* Captures Volumes which were created before the period and deleted during the period */ | ||
AND v.deleted_at < endtime, | ||
TIMESTAMPDIFF(SECOND, | ||
starttime, | ||
v.deleted_at), | ||
IF(v.created_at > starttime /* Captures Volumes which were created during the period and deleted outside the period */ | ||
AND (v.deleted_at >= endtime | ||
OR ISNULL(v.deleted_at)), | ||
TIMESTAMPDIFF(SECOND, | ||
v.created_at, | ||
endtime), | ||
TIMESTAMPDIFF(SECOND, | ||
v.created_at, | ||
v.deleted_at))))) AS Volume_Seconds, /* Generates a count of seconds Volumes were running */ | ||
v.size AS Volume_GB | ||
FROM | ||
cinder.volumes v | ||
JOIN | ||
keystone.project p ON v.project_id = p.id | ||
JOIN | ||
keystone.project pp ON p.parent_id = pp.id | ||
WHERE | ||
v.created_at <= endtime | ||
AND (v.deleted_at >= starttime | ||
OR ISNULL(v.deleted_at)) | ||
GROUP BY v.availability_zone , v.size , p.name , pp.name; | ||
END |
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,48 @@ | ||
CREATE PROCEDURE `get_accounting_data`(IN starttime datetime, IN endtime datetime) | ||
BEGIN | ||
/* | ||
This procedure generates accounting data for glance | ||
*/ | ||
SELECT | ||
p.name AS Project, | ||
pp.name AS Department, | ||
COUNT(g.id) AS Images, | ||
ip.value as GlanceType, | ||
if(il.value like "%rbd%", "RBD" ,if(il.value like "%swift%","OBJECT","UNKNONWN")) as StorageBackend, | ||
@ImageSeconds:=SUM(IF(g.created_at <= starttime /* Captures Images which were created outside of the period deleted out of the period */ | ||
AND (g.deleted_at >= endtime | ||
OR ISNULL(g.deleted_at)), | ||
TIMESTAMPDIFF(SECOND, | ||
starttime, | ||
endtime), | ||
IF(g.created_at <= starttime /* Captures Images which were created before the period and deleted during the period */ | ||
AND g.deleted_at < endtime, | ||
TIMESTAMPDIFF(SECOND, | ||
starttime, | ||
g.deleted_at), | ||
IF(g.created_at > starttime /* Captures Images which were created during the period and deleted outside the period */ | ||
AND (g.deleted_at >= endtime | ||
OR ISNULL(g.deleted_at)), | ||
TIMESTAMPDIFF(SECOND, | ||
g.created_at, | ||
endtime), | ||
TIMESTAMPDIFF(SECOND, | ||
g.created_at, | ||
g.deleted_at))))) AS Image_Seconds, /* Generates a count of seconds Images were running */ | ||
g.size/(1024 * 1024 * 1024) AS Glance_GB | ||
FROM | ||
glance.images g | ||
join | ||
glance.image_properties ip on g.id = ip.image_id and ip.name = "image_type" | ||
join | ||
glance.image_locations il on g.id = il.image_id | ||
JOIN | ||
keystone.project p ON g.owner = p.id | ||
JOIN | ||
keystone.project pp ON p.parent_id = pp.id | ||
WHERE | ||
g.created_at <= endtime | ||
AND (g.deleted_at >= starttime | ||
OR g.deleted_at is null ) | ||
GROUP BY ip.value, g.size , p.name , pp.name,if(il.value like "%rbd%", "SIRIUS" ,if(il.value like "%swift%","ECHO","UNKNONWN")); | ||
END |
Oops, something went wrong.