{"id":15706572,"url":"https://github.com/farshidnooshi/computer-networking-final-project","last_synced_at":"2025-05-12T19:02:14.507Z","repository":{"id":41545606,"uuid":"498432142","full_name":"FarshidNooshi/Computer-Networking-Final-Project","owner":"FarshidNooshi","description":"Computer Networking final project for CE at AUT Course","archived":false,"fork":false,"pushed_at":"2022-07-03T21:56:18.000Z","size":9876,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T01:51:08.614Z","etag":null,"topics":["computer-networking","computer-networks-course","prometheus"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FarshidNooshi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-31T17:24:05.000Z","updated_at":"2024-12-24T11:56:53.000Z","dependencies_parsed_at":"2022-09-06T08:22:29.063Z","dependency_job_id":null,"html_url":"https://github.com/FarshidNooshi/Computer-Networking-Final-Project","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FarshidNooshi%2FComputer-Networking-Final-Project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FarshidNooshi%2FComputer-Networking-Final-Project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FarshidNooshi%2FComputer-Networking-Final-Project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FarshidNooshi%2FComputer-Networking-Final-Project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FarshidNooshi","download_url":"https://codeload.github.com/FarshidNooshi/Computer-Networking-Final-Project/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253805850,"owners_count":21967052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-networking","computer-networks-course","prometheus"],"created_at":"2024-10-03T20:24:27.499Z","updated_at":"2025-05-12T19:02:14.436Z","avatar_url":"https://github.com/FarshidNooshi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1\u003eIn The Name of GOD\u003c/h1\u003e\n\u003c/div\u003e\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n# Computer Networking Project\n\nThe final project of Computer Network course at the Amirkabir University of Technology. The project is the\nimplementation of a monitoring prometheus metric client that receive metrics from different agent programs and merge\nthem in prometheus metrics and expose them for Prometheus Scraper.\n\n## What is Prometheus?\n\nPrometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. Since its inception\nin 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user\ncommunity. It is now a standalone open source project and maintained independently of any company. To emphasize this,\nand to clarify the project's governance structure, Prometheus joined the Cloud Native Computing Foundation in 2016 as\nthe second hosted project, after Kubernetes.\\\nPrometheus collects and stores its metrics as time series data, i.e. metrics information is stored with the timestamp at\nwhich it was recorded, alongside optional key-value pairs called labels.\n\n# Requirements\n\nthe following requirements are needed for the project:\n\n```\npsutil\ncolorama\nsetuptools\nprometheus-client\n```\n\nyou should also download and install the prometheus for your system from the following link:\\\n[Prometheus Download Page](https://prometheus.io/download/)\n\nFor installation, you can run the following command:\n```console\npip install -r requirements.txt\n```\n\n## How to run the project\n\n1. replace the `Project/prometheus.yml` file with the `prometheus.yml` file of the one you downloaded from the link above.\n2. run `prometheus` in your system.\n\n3. inorder to run the project, you should run the following command in the `Project/src/Client` folder:\n```console\npython3 main.py\n```\n\n4. In a separate terminal, you should run the following command in the `Project/src/Server` folder:\n```console\npython3 main.py\n```\n\n# Metrics\n\nI have implemented 5 metrics, but you can add more metrics by following the following steps:\n\n1. Add the metrics name in `metrics` field in `Project/src/Business/json/data.json` data file.\n2. Add the same metrics name in the `metrics` dictionary at the `create_metrics` method in the `client.py` file and give\n   its value for each message to server.\n\n ```python\n@staticmethod\ndef create_metrics():\n    metrics = {\n        'cpu_utilization_percent': psutil.cpu_percent(interval=1),\n        'memory_available': psutil.virtual_memory().available,\n        'num_bytes_sent': psutil.net_io_counters().bytes_sent,\n        'num_errors_recv': psutil.net_io_counters().errin,\n    }\n    return metrics\n ```\n\n3. Create the required metric at server side for handling in the `Project/src/Server/Utils/ClientHandler.py` file.\n```python\ndef create_metrics(self):\n    self.cpu = Gauge(f'cpu_utilization_percent', 'percentage of cpu usage right now.', labelnames=['client_name'])\n    self.mem = Gauge(f'memory_available', 'available memory in bytes.', labelnames=['client_name'])\n    self.net = Counter(f'network_usage_total', 'total number of received bytes.', labelnames=['client_name'])\n    self.client_net = Counter(f'network_send_total', 'total number of send bytes.', labelnames=['client_name'])\n    self.err_net = Counter(f'received_error_total', 'total number of errors while receiving.',\n                           labelnames=['client_name'])\n```\n4. At the same file like 3 you should add the update instruction for each metric like below:\n```python\ndef update_metrics(self, client_name, metrics, sz):\n    self.cpu.labels(client_name=client_name).set(metrics['cpu_utilization_percent'])\n    self.net.labels(client_name=client_name).inc(sz)\n    self.mem.labels(client_name=client_name).set(metrics['memory_available'])\n    self.client_net.labels(client_name=client_name).inc(metrics['num_bytes_sent'])\n    self.err_net.labels(client_name=client_name).inc(metrics['num_errors_recv'])\n```\n5. done!\n\n# Screenshots\n![Image][1]\n![Image][2]\n![Image][3]\n![Image][4]\n# Contributors\n* [Farshid Nooshi](https://github.com/FarshidNooshi)\n\n[1]: https://github.com/FarshidNooshi/Computer-Networking-CE.AUT/blob/main/Project/doc/screenshots/prometheus1.png\n[2]: https://github.com/FarshidNooshi/Computer-Networking-CE.AUT/blob/main/Project/doc/screenshots/prometheus2.png\n[3]: https://github.com/FarshidNooshi/Computer-Networking-CE.AUT/blob/main/Project/doc/screenshots/terminal.png\n[4]: https://github.com/FarshidNooshi/Computer-Networking-CE.AUT/blob/main/Project/doc/screenshots/prometheus_client.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarshidnooshi%2Fcomputer-networking-final-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarshidnooshi%2Fcomputer-networking-final-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarshidnooshi%2Fcomputer-networking-final-project/lists"}