-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
183 additions
and
1 deletion.
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 @@ | ||
[{"bounty_hunters": {"rank": "-1", "count": "-1"}, "bh_rogues": {"rank": "-1", "count": "-1"}, "dominion_tower": {"rank": "-1", "count": "-1"}, "the_crucible": {"rank": "-1", "count": "-1"}, "castle_wars_games": {"rank": "-1", "count": "-1"}, "ba_attackers": {"rank": "-1", "count": "-1"}, "ba_defenders": {"rank": "-1", "count": "-1"}, "ba_collectors": {"rank": "-1", "count": "-1"}, "ba_healers": {"rank": "-1", "count": "-1"}, "duel_tournament": {"rank": "-1", "count": "-1"}, "mobilising_armies": {"rank": "-1", "count": "-1"}, "conquest": {"rank": "-1", "count": "-1"}, "fist_of_guthix": {"rank": "-1", "count": "-1"}, "gg_resource_race": {"rank": "-1", "count": "-1"}, "gg_athletics": {"rank": "-1", "count": "-1"}, "we2_armadyl_lifetime_contribution": {"rank": "-1", "count": "-1"}, "we2_bandos_lifetime_contribution": {"rank": "-1", "count": "-1"}, "we2_armadyl_pvp_kills": {"rank": "-1", "count": "-1"}, "we2_bandos_pvp_kills": {"rank": "-1", "count": "-1"}, "heist_guard_level": {"rank": "-1", "count": "-1"}, "heist_robber_level": {"rank": "-1", "count": "-1"}, "cfp_5_game_average": {"rank": "-1", "count": "-1"}, "af15_cow_tipping": {"rank": "-1", "count": "-1"}, "af15_rats_killed_after_the_miniquest": {"rank": "-1", "count": "-1"}, "runescore": {"rank": "515947", "count": "1680"}, "clue_scrolls_easy": {"rank": "270489", "count": "1"}, "clue_scrolls_medium": {"rank": "-1", "count": "-1"}, "clue_scrolls_hard": {"rank": "-1", "count": "-1"}, "clue_scrolls_elite": {"rank": "-1", "count": "-1"}, "clue_scrolls_master": {"rank": "-1", "count": "-1"}}, {"overall": {"rank": "630141", "level": "1320", "experience": "11873488"}, "attack": {"rank": "742376", "level": "61", "experience": "310269"}, "defence": {"rank": "714948", "level": "62", "experience": "347636"}, "strength": {"rank": "953242", "level": "48", "experience": "91140"}, "constitution": {"rank": "879492", "level": "56", "experience": "186595"}, "ranged": {"rank": "726222", "level": "53", "experience": "141384"}, "prayer": {"rank": "904877", "level": "35", "experience": "24121"}, "magic": {"rank": "988600", "level": "38", "experience": "32525"}, "cooking": {"rank": "886096", "level": "45", "experience": "66311"}, "woodcutting": {"rank": "861846", "level": "52", "experience": "132894"}, "fletching": {"rank": "553164", "level": "66", "experience": "534619"}, "fishing": {"rank": "771923", "level": "53", "experience": "145622"}, "firemaking": {"rank": "591287", "level": "65", "experience": "462120"}, "crafting": {"rank": "706162", "level": "53", "experience": "137178"}, "smithing": {"rank": "322628", "level": "85", "experience": "3578450"}, "mining": {"rank": "290242", "level": "88", "experience": "4702486"}, "herblore": {"rank": "754284", "level": "21", "experience": "5553"}, "agility": {"rank": "579411", "level": "52", "experience": "129055"}, "thieving": {"rank": "568782", "level": "52", "experience": "132134"}, "slayer": {"rank": "837812", "level": "17", "experience": "3452"}, "farming": {"rank": "601566", "level": "31", "experience": "15022"}, "runecrafting": {"rank": "632726", "level": "46", "experience": "69860"}, "hunter": {"rank": "623177", "level": "35", "experience": "23292"}, "construction": {"rank": "605745", "level": "41", "experience": "42705"}, "summoning": {"rank": "652056", "level": "21", "experience": "5080"}, "dungeoneering": {"rank": "745585", "level": "28", "experience": "11714"}, "divination": {"rank": "419786", "level": "63", "experience": "406968"}, "invention": {"rank": "-1", "level": "0", "experience": "-1"}, "archaeology": {"rank": "288442", "level": "52", "experience": "135303"}}] |
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,80 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "c2a08d43-6da6-492e-a32d-5eaa5f909358", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import psutil\n", | ||
"\n", | ||
"\n", | ||
"def getService(name):\n", | ||
" service = None\n", | ||
" try:\n", | ||
" service = psutil.win_service_get(name)\n", | ||
" service = service.as_dict()\n", | ||
" except Exception as ex:\n", | ||
" print(str(ex))\n", | ||
"\n", | ||
" return service" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "be11dd6d-cf8a-4e1b-88a0-eeca855c9720", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"service = getService(\"myservice\")\n", | ||
"print(service)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "01dbb397-eb95-450d-b5bc-d676128db782", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if service:\n", | ||
" if service[\"status\"] == \"running\":\n", | ||
" print(\"service is running\")\n", | ||
" else:\n", | ||
" print(\"service is not running\")\n", | ||
"else:\n", | ||
" print(\"service not found\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.6" | ||
}, | ||
"widgets": { | ||
"application/vnd.jupyter.widget-state+json": { | ||
"state": {}, | ||
"version_major": 2, | ||
"version_minor": 0 | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 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
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,101 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "497507d2-59ea-482a-b3cf-aed5055657da", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#!/usr/bin/python\n", | ||
"import json\n", | ||
"import smtplib\n", | ||
"import sys\n", | ||
"import time\n", | ||
"from email.mime.text import MIMEText\n", | ||
"from pathlib import Path\n", | ||
"\n", | ||
"\n", | ||
"def debounce(timeout=300):\n", | ||
" p = Path(\"EmailDebounceTracker.lock\")\n", | ||
" if p.exists():\n", | ||
" if time.time() - p.stat().st_mtime > timeout:\n", | ||
" p.unlink()\n", | ||
" p.touch()\n", | ||
" return True\n", | ||
" else:\n", | ||
" return False\n", | ||
" else:\n", | ||
" p.touch()\n", | ||
" return True\n", | ||
"\n", | ||
"\n", | ||
"p = Path(\"config.json\")\n", | ||
"if p.exists() == False:\n", | ||
" config = {\n", | ||
" \"smtp_host\": \"\",\n", | ||
" \"from\": \"\",\n", | ||
" \"to\": [\"\"],\n", | ||
" \"subject\": \"Automation - Service Down\",\n", | ||
" \"message\": \"The service has gone down\",\n", | ||
" \"Debounce_Seconds\": 300,\n", | ||
" }\n", | ||
" p.write_text(json.dumps(config, indent=4))\n", | ||
" print(\"Config created, exiting\")\n", | ||
" sys.exit(1)\n", | ||
"else:\n", | ||
" config = json.loads(p.read_text())\n", | ||
"\n", | ||
"try:\n", | ||
" msg = MIMEText(config[\"message\"])\n", | ||
" msg[\"Subject\"] = config[\"subject\"]\n", | ||
" msg[\"From\"] = config[\"from\"]\n", | ||
" msg[\"To\"] = \",\".join(config[\"to\"])\n", | ||
" smtpObj = smtplib.SMTP(config[\"smtp_host\"])\n", | ||
" if debounce(config[\"Debounce_Seconds\"]):\n", | ||
" smtpObj.sendmail(config[\"from\"], config[\"to\"], msg.as_string())\n", | ||
" print(\"Successfully sent email\")\n", | ||
" else:\n", | ||
" print(\"debounce\")\n", | ||
"except Exception as e:\n", | ||
" print(e)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "bfe9b55e-54a6-4973-ba5b-e04c79a4d63d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.6" | ||
}, | ||
"widgets": { | ||
"application/vnd.jupyter.widget-state+json": { | ||
"state": {}, | ||
"version_major": 2, | ||
"version_minor": 0 | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |