LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-09-2018, 06:26 PM   #1
alxreds
LQ Newbie
 
Registered: Dec 2017
Posts: 8

Rep: Reputation: Disabled
Script to collect memory usage to generate graphics


Hello

Im try to create a Script to collect Memory information to Graphic
For Daily Statistics

You can help with This ?

Thanks.
 
Old 02-10-2018, 08:44 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,757

Rep: Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983
Quote:
Originally Posted by alxreds View Post
Hello
Im try to create a Script to collect Memory information to Graphic For Daily Statistics You can help with This ?
Absolutely. So post what *YOU* have written/done/tried so far, and tell us where you're stuck; we can certainly HELP you after that.

Otherwise, you need to read the "Question Guidelines" link in my posting signature. We will be happy to help you, but we aren't going to write scripts for you. You, personally, need to show your efforts.
 
Old 02-10-2018, 09:04 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Code:
#!/bin/bash
please insert your code that you have already written so some one hopefully can guild you ...
 
1 members found this post helpful.
Old 02-10-2018, 04:00 PM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
i suggest you look at monitorix.
it's a perl script and how it works is very transparent.
you can easily rip out what you need.
 
1 members found this post helpful.
Old 02-10-2018, 04:28 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
Like Conky?
 
Old 02-12-2018, 01:32 PM   #6
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Nothing yet ? You hoped to find free manpower or you really want to learn ?
 
1 members found this post helpful.
Old 02-13-2018, 09:59 AM   #7
alxreds
LQ Newbie
 
Registered: Dec 2017
Posts: 8

Original Poster
Rep: Reputation: Disabled
Cool Code Bash

Quote:
Originally Posted by BW-userx View Post
Code:
# memory_stat.sh
#!/bin/bash
echo "      date     time $(free -m | grep total | sed -E 's/^    (.*)/\1/g')" > `date "+%d%m%Y"`.txt
while true; do
    echo "$(date '+%Y-%m-%d %H:%M:%S') $(free -m | grep Mem: | sed 's/Mem://g')" >> `date "+%d%m%Y"`.txt
    sleep 30
done
This is my Code, is Working for me Now
Thanks
 
1 members found this post helpful.
Old 02-13-2018, 10:36 AM   #8
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
impressive

Code:
$ cat 13022018.txt
      date     time           total        used        free      shared  buff/cache   available
2018-02-13 10:35:01           15960        1416       13364          39        1179       14377
2018-02-13 10:35:04           15960        1417       13362          39        1179       14375
2018-02-13 10:35:07           15960        1416       13364          39        1179       14376
2018-02-13 10:35:10           15960        1416       13364          39        1179       14377
2018-02-13 10:35:13           15960        1418       13362          39        1179       14375
Good Job!
 
Old 02-13-2018, 06:46 PM   #9
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Good job !
 
Old 02-15-2018, 06:55 AM   #10
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,691
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
Tools like Nagios have already built-out an infrastructure for many types of system monitoring tasks.

If you're wanting to study "memory use," I suggest that the best way to do it is to build some logging capability into your applications-of-interest, then to perform offline statistical analysis of these data. There are two significant sources of error which can occur if you try to do it in real time:
  1. The Presence of the Experimenter ... Your measuring process will either directly measure itself, or it will measure an environment that is being influenced by its own presence there, or both.
  2. Linux is Lazy™ ... If there is right now no pressure for the memory resource, Linux won't clean-up after you. Why should it take the time?

There's also the problem of practical irrelevance. It's like measuring the number of cars on a street at a particular moment, when what you really want to know is how much effect congestion is having on the people who are trying to drive those streets. We've learned that you don't have to do this continuously: we can use random sampling and get a statistically-valid result. And what we would measure is some kind of thing like "number of requests processed" and "time required to complete (say) 1,000 requests." We probably would look more at the standard deviation than the average, or we might set up a "pass/fail" test to determine how often the process did or did not meet some arbitrary but meaningful deadline.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script for CPU usage, memory usage, disk partition space and service status reetesh.amity Linux - Server 6 10-12-2015 07:51 PM
[SOLVED] How can I optimize this script which calculates CPU and memory usage for a process slipstreamed Programming 6 06-02-2014 02:43 AM
Script to execute command if memory usage is over + a question ps1x0 Linux - General 3 01-20-2013 03:11 PM
script to monitor memory and cpu usage s_linux SUSE / openSUSE 3 07-23-2009 02:03 PM
Script for Memory Usage?? ajeetraina Linux - Server 6 03-31-2008 09:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration