# Simple resource logging tool/script for Linux?

**URL:** <https://discourse.julialang.org/t/simple-resource-logging-tool-script-for-linux/96040>\
**Category:** Offtopic\
**Created:** [March 14, 2023, 8:42am UTC](https://discourse.julialang.org/t/simple-resource-logging-tool-script-for-linux/96040 "2023-03-14T08:42:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [March 14, 2023, 8:42am UTC](https://discourse.julialang.org/t/simple-resource-logging-tool-script-for-linux/96040/1 "2023-03-14T08:42:37Z")

</div>

Hello, I need to evaluate “how much” of my lab computational server resources are actually used (RAM,CPU,disk, network) and which are the bottlenecks before eventually update the server to a bigger one.  
So, I plan to have some, let’s say hour observations of these parameters, and after a month or so evaluate the average resources usage/peak frequency.  
Is there some “simple” tool that allow me to do that? I have saw stuff like [prometheus](https://prometheus.io/) but it seems overwhelm for this simple job. Perhaps someone already wrote a simple script can can be run with cron and do the job…

My server is Ubuntu 20.04

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [March 14, 2023, 10:51am UTC](https://discourse.julialang.org/t/simple-resource-logging-tool-script-for-linux/96040/2 "2023-03-14T10:51:26Z")

</div>

I have solved with the following script (adapted from [this blog](https://kloudvm.com/linux/bash-script-monitor-cpu-memory-disk-usage-on-linux/#comment-458)):

```julia
nano /var/log/resource_usage.csv
>>>
TIME	MEMORY	DISK	CPU
<<<

chmod 664 /var/log/resource_usage.csv 

nano /usr/bin/logResourceUsage.sh
>>>
#! /bin/bash
printf -v TIME '%(%Y%m%d%H%M%S)T\t'
MEMORY=$(free -m | awk 'NR==2{printf "%.3f\t", $3/$2 }')
DISK=$(df -h | awk '$NF=="/"{printf "%.3f\t", $5/100}')
CPU=$(top -bn1 | grep load | awk '{printf "%.3f\t\n", $(NF-2)/100}')
echo "$TIME$MEMORY$DISK$CPU"
<<<

nano /etc/crontab
>>>
*/5 * * * * root /usr/bin/logResourceUsage.sh >> /var/log/resource_usage.csv
<<<

```

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [March 14, 2023, 10:53am UTC](https://discourse.julialang.org/t/simple-resource-logging-tool-script-for-linux/96040/3 "2023-03-14T10:53:01Z")

</div>

I am currently monitoring some of my private VMs with [monitorix](https://www.monitorix.org/).
