{"id":473,"date":"2020-02-05T20:52:29","date_gmt":"2020-02-05T19:52:29","guid":{"rendered":"https:\/\/codedoneright.eu\/?page_id=473"},"modified":"2021-01-01T18:51:20","modified_gmt":"2021-01-01T17:51:20","slug":"data-collection-for-performance","status":"publish","type":"page","link":"https:\/\/codedoneright.eu\/?page_id=473","title":{"rendered":"Basic data collection"},"content":{"rendered":"\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The below script will allow for basic data collection. You can set up a <a href=\"https:\/\/codedoneright.eu\/?page_id=1389\" target=\"_blank\" rel=\"noreferrer noopener\">crontab<\/a> so that it runs every five minutes and updates a file, from which you can copy the data to Excel or <a href=\"https:\/\/www.libreoffice.org\/discover\/calc\/\">Libre Offiec Calc<\/a> to create a chart showing overall performance.<\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">The data collection script gathers the following information<\/h4>\n\n\n\n<ul><li>Date<\/li><li>Time<\/li><li>CPU temperature<\/li><li>RAM usage<\/li><li>Average 5 minute CPU load<\/li><\/ul>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Additional packages required<\/h4>\n\n\n\n<ul><li>bc<\/li><\/ul>\n\n\n\n<p>In order for the script to neatly display temperature, you have to install a package that helps with math. <\/p>\n\n\n\n<p>Run the following code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install bc<\/code><\/pre>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Data collection script code<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\ndata_output=\/var\/zzz_log\/performance.log\n\ndate=\"$(which date)\"\ntimestamp=`$date '+%Y-%m-%d %H:%M'`\n\ncur_temp=$(cat \/sys\/class\/thermal\/thermal_zone0\/temp)\ncur_temp=\"$(echo \"$cur_temp \/ 1000\" | bc -l | xargs printf \"%1.0f\")\"\n\nram_used=\"$(free -t -m | grep \"Mem\" | awk '{print $3}')\"\n\nread -r loadavg_five rest &lt; \/proc\/loadavg\n\necho \"$timestamp ; $cur_temp ; $ram_used ; $loadavg_five\" 1&gt;&gt; $data_output\n<\/code><\/pre>\n\n\n\n<p>Performance data will be saved in the following location<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>data_output=\/var\/zzz_log\/performance.log<\/code><\/pre>\n\n\n\n<p><strong>CAUTION<\/strong>! Folder, in which data is supposed to be saved has to exist. If you do not have <em>\/var\/zzz_log\/<\/em> folder, create it or change the script so that data is written to an existing place. If the file is missing, it will be created on the first run.<\/p>\n\n\n\n<p>After<strong> <\/strong>you run the script for the first time, check if the data is actually being written to the file with the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/var\/zzz_log\/performance.log<\/code><\/pre>\n\n\n\n<p>You should see output similar to this<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2020-02-05 20:32 ; 41 ; 251 ; 0.00<\/code><\/pre>\n\n\n\n<p>Once you have enough data, you can construct a chart to showcase the performance of your server<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The below script will allow for basic data collection. You can set up a crontab so that it runs every five minutes and updates a file, from which you can copy the data to Excel or Libre Offiec Calc to&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":414,"menu_order":5,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Basic data collection \u2013 show performance of your Pi &#8212; Code Done Right!<\/title>\n<meta name=\"description\" content=\"Check out data collection script to grab the most useful data output about our Raspberry Pi server to easily construct a chart showcasing performance!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codedoneright.eu\/?page_id=473\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Basic data collection \u2013 show performance of your Pi &#8212; Code Done Right!\" \/>\n<meta name=\"twitter:description\" content=\"Check out data collection script to grab the most useful data output about our Raspberry Pi server to easily construct a chart showcasing performance!\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=473\",\"url\":\"https:\/\/codedoneright.eu\/?page_id=473\",\"name\":\"Basic data collection \u2013 show performance of your Pi &#8212; Code Done Right!\",\"isPartOf\":{\"@id\":\"https:\/\/codedoneright.eu\/#website\"},\"datePublished\":\"2020-02-05T19:52:29+00:00\",\"dateModified\":\"2021-01-01T17:51:20+00:00\",\"description\":\"Check out data collection script to grab the most useful data output about our Raspberry Pi server to easily construct a chart showcasing performance!\",\"breadcrumb\":{\"@id\":\"https:\/\/codedoneright.eu\/?page_id=473#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codedoneright.eu\/?page_id=473\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=473#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codedoneright.eu\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\",\"item\":\"https:\/\/codedoneright.eu\/?page_id=1026\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Running script\",\"item\":\"https:\/\/codedoneright.eu\/?page_id=414\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Basic data collection\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codedoneright.eu\/#website\",\"url\":\"https:\/\/codedoneright.eu\/\",\"name\":\"Code Done Right!\",\"description\":\"Raspberry Pi server guides\",\"publisher\":{\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codedoneright.eu\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568\",\"name\":\"CodeDoneRight\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png\",\"contentUrl\":\"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png\",\"width\":120,\"height\":120,\"caption\":\"CodeDoneRight\"},\"logo\":{\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/codedoneright.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Basic data collection \u2013 show performance of your Pi &#8212; Code Done Right!","description":"Check out data collection script to grab the most useful data output about our Raspberry Pi server to easily construct a chart showcasing performance!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codedoneright.eu\/?page_id=473","twitter_card":"summary_large_image","twitter_title":"Basic data collection \u2013 show performance of your Pi &#8212; Code Done Right!","twitter_description":"Check out data collection script to grab the most useful data output about our Raspberry Pi server to easily construct a chart showcasing performance!","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/codedoneright.eu\/?page_id=473","url":"https:\/\/codedoneright.eu\/?page_id=473","name":"Basic data collection \u2013 show performance of your Pi &#8212; Code Done Right!","isPartOf":{"@id":"https:\/\/codedoneright.eu\/#website"},"datePublished":"2020-02-05T19:52:29+00:00","dateModified":"2021-01-01T17:51:20+00:00","description":"Check out data collection script to grab the most useful data output about our Raspberry Pi server to easily construct a chart showcasing performance!","breadcrumb":{"@id":"https:\/\/codedoneright.eu\/?page_id=473#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codedoneright.eu\/?page_id=473"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/codedoneright.eu\/?page_id=473#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codedoneright.eu\/"},{"@type":"ListItem","position":2,"name":"Linux","item":"https:\/\/codedoneright.eu\/?page_id=1026"},{"@type":"ListItem","position":3,"name":"Running script","item":"https:\/\/codedoneright.eu\/?page_id=414"},{"@type":"ListItem","position":4,"name":"Basic data collection"}]},{"@type":"WebSite","@id":"https:\/\/codedoneright.eu\/#website","url":"https:\/\/codedoneright.eu\/","name":"Code Done Right!","description":"Raspberry Pi server guides","publisher":{"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codedoneright.eu\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568","name":"CodeDoneRight","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/","url":"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png","contentUrl":"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png","width":120,"height":120,"caption":"CodeDoneRight"},"logo":{"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/codedoneright.eu"]}]}},"_links":{"self":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/473"}],"collection":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=473"}],"version-history":[{"count":9,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/473\/revisions"}],"predecessor-version":[{"id":1423,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/473\/revisions\/1423"}],"up":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/414"}],"wp:attachment":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}