Avatar of marrowyung
marrowyung
 asked on

linux command for adminstration

hi,

in redhatl linux and AIX unix, how to use command to check:

1) CPU used ?
2) RAM used and left
3) diskspace used and left

how to add volume using command  ?

anyway to use Graphic mode to present that in linux without monitoring tools ?
LinuxShell Scripting

Avatar of undefined
Last Comment
MURUGESAN N

8/22/2022 - Mon
MURUGESAN N

/usr/bin/vmstat
/usr/bin/top -n 1
/usr/bin/free -b
/usr/bin/free -k
/usr/bin/free -m
/usr/bin/man vmstat 2>&1 | /usr/bin/col -bx > vmstat.txt
/usr/bin/man free
/usr/bin/man top
/usr/bin/df
# or
/usr/bin/bdf
if [ -f /proc/meminfo ]; then /usr/bin/grep Free /proc/meminfo;fi
/usr/bin/cat /proc/meminfo
marrowyung

ASKER
hi,

tks. any high level explaination on what the above command do ?
MURUGESAN N

@marrowyung

Executing man command
>> man vmstat

it used to display related details and usage of those commands.
From man vmstat command:

vmstat - Report virtual memory statistics
...
The -d reports disk statistics (2.5.70 or above required)

Press space bar to read more
press 1G to go to first line of manual
press Shift G to go to end of manual

you can redirect manual output:
example:
/usr/bin/man vmstat 2>&1 | /usr/bin/col -bx > vmstat.txt
After this you can view vmstat.txt
vi vmstat.txt

/usr/bin/free -b
byte kilobyte megabyt -b -k -m... from manual

df / bdf commands available based on operating system.
View manual of df / bdf / top

At Linux system /proc/meminfo
file used to have MemFree HighFree LowFree SwapFree.
you can use
/usr/bin/cat /proc/meminfo
for more information.
if you execute
/usr/bin/top
it will quit until you press q
/usr/bin/top -n 1
to display current status.
-n representing iterations => -n : Number of iterations limit as:  -n number
from man top

Inside manual search using
/-n
Enter
press n to go to next line having -n
press N to go to previous line having -N
press q to quit manual
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
madunix

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
hi,

those commands are the same in AIX solars UNIX?
MURUGESAN N

@marrowyung

Currently I am not having AIX/HP-UX/UNIX/SunOS OS.
Used them still 2013 (still AIX 5.3 and SunOS 2.8 HP-UX 11.00 still 11.23 PA-RISC IPF) .

Most probably used to be the same.

Few commands(df/bdf) varies.
Hence informed use
1) which ls
which df
which bdf
...
2) type ls
type ...
3) alias ls 2>/dev/null
4)
bdf at HP-UX
5) man df
man bdf
...
6) Verify that PATH environment variable having:

$ echo "$PATH"
/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/bin:.
$ # From above output I have removed my personal directories.

Open in new window



/usr/local/sbin
/usr/sbin
/sbin
/usr/local/bin
/usr/bin
/bin
/bin
.

Following line may be out of scope
C C++ Compiler commands varies based on OS/installed binaries by admin
g++
gcc
xlC
aCC
c++
CC
cc
cl.exe
TC.EXE
TCC.EXE
SOLUTION
David Favor

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
noci

Maybe you need tools like sysstat to make some recording in time so you can more or less see the varying data.
(sysstat should also be available UNIX systems at least on AIX and i guess also on Solaris).
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
murugesandins,

/usr/bin/top -n 1
to display current status.
-n representing iterations => -n : Number of iterations limit as:  -n number
from man top

Inside manual search using
/-n
Enter
press n to go to next line having -n
press N to go to previous line having -N
press q to quit manual

I do not understand that, is that means type "man top" to read the manual to understand the top command ?

David Favor,

"# cat /proc/cpuinfo | grep -i "model name" | sort -u"

what is sort -u means ?
I also can see only one column but what actually u means?


"free -hg"

then what should be this:

/usr/bin/free -b

/usr/bin/free -k
/usr/bin/free -m

?

"For inode usage..."

what is inode?


noci,

usually what tools for linux and unix proactive monitoring ?
SOLUTION
noci

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
MURUGESAN N

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
noci,

why use this :
-u, --unique

return only one record! as all the SAME so just report once?

"-h report size in Human units (autoscaling)."

I do not understand what human unit here means.

"Monitoring tools:  icinga, nagios, munin, mrtg, cacti, sysstat, logrotate, calamaris, telegraf, nessus, grafana and then some;  all with their own focus, etc. so take your pick.
"

so no one is the best, nagios is too general ?

murugesandins,

"After this creating soft link for the file ./testing/testing"

inode is the 6 digit number on the left ?


"ls -ltrid"

what is the use of it ?
SOLUTION
MURUGESAN N

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
noci

If you have  32 core machine you will get 32 blocks of lines, the grep gets a certain item, and the sort -u makes it into a single line.
If you only get ONE line with your system, you have a single core machine... Those are getting extinct.... (or a VM   ;-).
(how about running that command on a super computer with 64K cores......)

Human units.....
0-1024 =   units
1024 -- 1024 * 1024 = 0-1024 K
1024*1024 --  1024 * 1024 * 1024 = 0-1024 M
etc. etc.  Auto scaling the untis to a Human comprehensible form
1073741824 = 1Gi

Define BEST....
Best in storing measurements in 100 of data points / second, ro 1M data points / second
Best in fastest for detecting anomalies (what kind of anomalies)...
Best in Graphing image plots
Best in Rasing Alarms...
All monitor software has starting point with a vision of it's developpers. So there's a whole lot of differences.
Some started as raising alarms for anomalies and later also take measurements
Other started as massive datapoint collectors  that can  later started warning about strange results.

So FIRST you need to decide what you want from ANY Monitor (most important stuff, net important item....) Then you compare that to what the various software can do for you. THEN you can decide on what is best. I cannot decide for you what criteria to use for your situation etc. and advise on that.

wrt. Inode:    The Inode = a data structure. I hold all meta data of the file. The Inode-ID is indeed the 0-n digit number on the left hen you do ls -li
The number of preallocated file description structures is determined when you format a disk.  It cannot be chnged unless you enlarge the disk. If all i-nodes are in use you get a disk-full error even if there are still free blocks.
You can test this with a dummy disk if you like where you only allow for 20 inodes or so. Try to create some files. (nice excersize: use the loopback mount option use a pseudo disk in a file.
You can create a filesystem like Ext2 in a file created with
dd if=/dev/zero of=pseudodisk.dsk bs=1M count=1024,
mke2fs -N 20 pseudodisk.dsk ,
mkdir /tmp/test
mount -o loop pseudodisk.dsk test
ls -l /tmp/test
touch /tmp/test/file1
touch /tmp/test/file2
....
until you get an error....
remove:
umount /tmp/test
rm pseudodisk.dsk
rmdir /tmp/test
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
marrowyung

ASKER
murugesandins,

"you can under stand the meaning of human readable format having"'

ok

noci,

"Define BEST...."

me, provide meaningful information to troubleshoot, and tell us clearly what should we do !

"The number of preallocated file description structures is determined when you format a disk.  It cannot be chnged unless you enlarge the disk. If all i-nodes are in use you get a disk-full error even if there are still free blocks."

so actaully we don'tuse the inode number,right ?I wonder how userfull it is .


"You can test this with a dummy disk if you like where you only allow for 20 inodes or so"

20 disk  therefore ?

"until you get an error....
remove:
umount /tmp/test
rm pseudodisk.dsk
rmdir /tmp/test

what is the error for ?
marrowyung

ASKER
hi,

top commmand is dynamic and it change over time, is there any command how RAM and disk usage in real time like top ?
SOLUTION
noci

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
madunix

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
MURUGESAN N

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
noci

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
noci,

"sysstat might even be more handy then fiddeling with top/vmstat etc.  "

I don't have this command in CentOS.

what can I do ?  any screenshot the result of sysstat ?


"CDP is a tool to help simple graphing, otherwise you can look into grafana for graphs."

third party chargable tools ?


murugesandins,

"SampleRam ()"

you are creating a SampleRam.sh as a script and run it by doing ./SampleRam.sh ?


madunix,

I don't have iostat, what package I have to yum install ?

any screenshot the result of iostat ?

by your link:
https://lintut.com/best-command-line-tools-for-linux-performance-monitring/


I also don't not have dstat

any screenshot the result of dstat ?

BTW, other than top command for CPU, what other command can provide more information than top and also dynamic ?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
noci

sysstat is the package, sa1 sa2 etc. are the command to run it and produce intermediate files (data collection) and reporting.
man sysstat  can help, you may need to install it first.

CGP, Grafana should all be FOSS.
https://grafana.org
https://github.com/pommi/CGP

iotop can be a dynamic viewer without recording on io statistics.
marrowyung

ASKER
"man sysstat
"

I don't have sysstat at all, can't man it

"iotop can be a dynamic viewer without recording on io statistics."

iotop also can't find in CentOS, what is missing?
MURUGESAN N

>> "SampleRam ()"
>> you are creating a SampleRam.sh as a script and run it by doing ./SampleRam.sh ?
Yes.

sysstat iotop / ... (a. handle disk space b. Confirmation to install any applications c. git/svn/TFS/SMTP d. HTML document having the description, requirement, steps followed, Changes viewed before and after installation Example: /usr/bin/df -h, approved by, command executed by, dd-mmm-yyyy HH:mm:SS NN, start date, end date, location)
$#From root user or
$ /usr/bin/yum -y install sysstat
$ /usr/bin/sudo /usr/bin/yum -y install sysstat
$ /usr/bin/sudo /usr/bin/yum -y install iotop

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
MURUGESAN N

Because of your comment I have installed dstat :) at my system
$ /usr/bin/yum -y install dstat

Open in new window

marrowyung

ASKER
yum -y install  ok, tks man.

"yum -y install sysstat"

but this one, once installed, still say command not found! iotop is ok


madunix,

"You can use iostat, it  can be used to report the disk read/write rate"

iostat is not dynamic, the result is not chaning over time.

I have to keep typing this command.
SOLUTION
MURUGESAN N

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
hi,

are both query doing the same thing ?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
MURUGESAN N

@marrowyung

Leave my old comment.
I have given old comment on replacing special characters using sed.
Example:
$ /usr/bin/top -n 1 -p 1 | /usr/bin/head -1  > delete.txt

Open in new window

Content of delete.txt
(Btop - 07:16:17 up  1:45,  2 users,  load average: 0.00, 0.00, 0.00(B

Open in new window

Using sed we can obtain that file content at readable format:
$ /usr/bin/sed -i 's/^[//g;s/\[H//g;s/\[2J//g;s/(B//g;s/\[m//g;s/\[[0-9][0-9]\;[0-9][0-9]m\[K//g;' delete.txt

Open in new window

^[ => Ctrl v Ctrl => without space
Content of delete.txt
top - 07:16:17 up  1:45,  2 users,  load average: 0.00, 0.00, 0.00

Open in new window

SOLUTION
MURUGESAN N

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
MURUGESAN N

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
tks will check it soon as I am preparing other task, tks for it.

seems i need to learn bash command and linux script?

so I need to create a .sh file and when run it  with your content above, I just do that on the command line:

#/<my sh file>.sh ?
MURUGESAN N

Yes.
I feel that $PS1 at your current terminal is #
Assume that your file name is 29175082.sh

Example codes to execute ./29175082.sh
$ echo "Value of PS1 [$PS1]"
Value of PS1 [$ ]
$ export PS1='# '
# echo "Value of PS1 [$PS1]"
Value of PS1 [# ]
# ./29175082.sh
....
...
related output
....
#

Open in new window

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
noci

sysstat commands are: sar sadc .  (iostat, mpstat, tapestat, etc.)  and consists of some cron jobs & config files.
( /etc/sysstat  & /etc/sysstat.ioconf ).

reports & files are left in /var/log/sa
marrowyung

ASKER
murugesandins,

$ echo "Value of PS1 [$PS1]"

the command prompt is #, so why the $ is need in this case ?

or $ is just say it is a variable ?

I feel that $PS1 at your current terminal is #

so you mean $ is the terminal command prompt symbol at my end ?

noci,

reports & files are left in /var/log/sa

tks , but what is this suppose to mean?

sysstat commands are: sar sadc .  (iostat, mpstat, tapestat, etc.)  and consists of some cron jobs & config files.
( /etc/sysstat  & /etc/sysstat.ioconf ).

so for SOME command only I need to vi the config file too if I need to run them ? seems too much work to run a command to check OS resource..
marrowyung

ASKER
tks al. but I will come back later as I still have other things to do.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
noci

Monitoring system resources is watching for trends... that is load over time... (days, weeks, months) with various densities in intervals.

sysstat is something that runs permanently (from cron) and produces daily reports. you will have to configure if you want 5 days retension or 20 days retension. etc.
most of the monitoring tools need some kind of configuration. Even top might need that. (unless the defaults are sufficient).

Prompt are: by default: # denoting root, $  indicating normal user.
PS1 is a variable,.. to make a more elaborate prompt. in setting the PS1 string normal bash exapnsions rules are used:
so X="-$Y-"   means X get the vaue of Y with a dash before & after.  (the expansion is done during assigning the string, not when showing the prompt).

For PS1 prompt there are also some expantions done during showing of the prompt: \h, \u etc for hostname & username.
MURUGESAN N

$ echo wELcOME | /usr/bin/wc > /dev/null 2>&1
marrowyung

ASKER
so sysstat and iotop is dynamic to to show RAM usage and disk usage? what is the full command ?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
noci

iotop just is iotop....

with sysstat -- use sadf ( man sadf  is your friend)

marrowyung

ASKER
hi,

I dont' have sysstat, CentOS keep saying command not found. can't install using yum install sysstate as well ,I test internet connection and tried yum update, package can be download. so it is not the internet connection has problem. but I fix it later on myself, it is the CentOS store files problem! not related to yum install anyway.

or what you said about this is :

sysstat commands are: sar sadc .  (iostat, mpstat, tapestat, etc.)  and consists of some cron jobs & config files.
( /etc/sysstat  & /etc/sysstat.ioconf ).

there are no sysstat command as it just the collection package of a lot of command ?sar sadc . iostat, mpstat, tapestat, etc. ? that's why I can't run that/download that?  but it seems I can install sysstat by

yum -y install sysstate

but i just can't run sysstat, it is just a package name and we need to run the command it contains ?

tapestat,
, what is that command ?

I also do not have htop ! I run the update and install using
yum install
and
yum update

this one is a command however....can't download it in CentrOS

my yum can download update package for me and I tested it, it just downlaod 325MB update for me, so the internet connection and yum is working fine.

just the command.

with sysstat -- use sadf ( man sadf  is your friend)

when I check sadf comand I see this from web:

The  sadf  command is used for displaying the contents of data files created by the sar(1)
       command. But unlike sar, sadf can write its data in  many  different  formats  (CSV,  XML,
       etc.

what is sar(1) ? any example on how you use it  is appreicated?

currently only want to check the real time usage of the linux/unix running oracle , so top is good to go and just want  to know more on getting dynamic picture on disk and RAM, so I don't want to get into too complex on linux command, just enough for me to handle oracle on linux related checkign.

but it seems checking SAN realtime disk usage statistic is not possilbe by linux command ?

and I see this :

https://www.youtube.com/watch?v=J7nCRDCmJM0

show this, and is this make sense:

ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

worth to try ? but the result of this is not dynamic ! how can I order by RAM ?  this format is good looking ! just like Windows task manager !

and it only returns few top row and any way to make sure show more than 20 top result ?

iotop just is iotop....

yeah, it is dynamic and I like that but it seems do not say anything like, how many CPU usage involve by that IO.

that command is sort bywhat ?
noci

When installing sysstat, sar is running through some cron entries installed by sysstat package.
So if installed the files will be created for you. In /etc/sysstat  the configuration is given.
(how long to keep files, if the should be compressed and after how many days etc. etc.)
the cronjobs are sa1 (collection) & sa2 (report on yesterday).
sa1 invokes the sadc (data collector), and sa2 invokes the reporting ("format") tool (sadf).

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
with sysstat -- use sadf ( man sadf  is your friend)

sa1 invokes the sadc (data collector), and sa2 invokes the reporting ("format") tool (sadf).

any real life example on how to use sadf with sa1 and sa2?

so we can't use sysstat command anyway as it is just a collection of files ? like iostat and tapestat ?

the cronjobs are sa1 (collection) & sa2 (report on yesterday).
these 2 x cronjob created by yum install sysstate?
noci

sa1 & sa2 are delivered WITH sysstat. They are called on your behalf by cron.
So your question is quite meaningless.   sa1/ sa2 are not for general consumption and are regular shell scripts invoking other stuff.
Anyway here is the sa1 script as reference:
#!/bin/sh
# /usr/lib/sa/sa1
# (C) 1999-2019 Sebastien Godard (sysstat <at> orange.fr)
#
#@(#) sysstat-12.2.1
#@(#) sa1: Collect and store binary data in system activity data file.
#

# Set default value for some variables.
# Used only if ${SYSCONFIG_DIR}/${SYSCONFIG_FILE} doesn't exist!
HISTORY=0
SADC_OPTIONS=""
SA_DIR=/var/log/sa
SYSCONFIG_DIR=/etc
SYSCONFIG_FILE=sysstat
UMASK=0022

[ -r ${SYSCONFIG_DIR}/${SYSCONFIG_FILE} ] && . ${SYSCONFIG_DIR}/${SYSCONFIG_FILE}

umask ${UMASK}

[ -d ${SA_DIR} ] || SA_DIR=/var/log/sa

if [ ${HISTORY} -gt 28 ]
then
        SADC_OPTIONS="${SADC_OPTIONS} -D"
fi

ENDIR=/usr/lib/sa
cd ${ENDIR}
[ "$1" = "--boot" ] && shift && BOOT=y || BOOT=n
if [ $# = 0 ] && [ "${BOOT}" = "n" ]
then
# Note: Stats are written at the end of previous file *and* at the
# beginning of the new one (when there is a file rotation) only if
# outfile has been specified as '-' on the command line...
        exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} 1 1 ${SA_DIR}
else
        exec ${ENDIR}/sadc -F -L ${SADC_OPTIONS} $* ${SA_DIR}
fi

Open in new window

And sa2 as well:
#!/bin/sh
# /usr/lib/sa/sa2
# (C) 1999-2019 Sebastien Godard (sysstat <at> orange.fr)
#
#@(#) sysstat-12.2.1
#@(#) sa2: Write a daily report
#
S_TIME_FORMAT=ISO ; export S_TIME_FORMAT
prefix=/usr
exec_prefix=${prefix}
SA_DIR=/var/log/sa
SYSCONFIG_DIR=/etc
SYSCONFIG_FILE=sysstat
HISTORY=7
COMPRESSAFTER=10
ZIP="xz"
UMASK=0022
ENDIR=

# Read configuration file, overriding variables set above
[ -r ${SYSCONFIG_DIR}/${SYSCONFIG_FILE} ] && . ${SYSCONFIG_DIR}/${SYSCONFIG_FILE}

umask ${UMASK}

[ -d ${SA_DIR} ] || SA_DIR=/var/log/sa

# if YESTERDAY=no then today's summary is generated
if [ x$YESTERDAY = xno ]
then
        DATE_OPTS=
else
        DATE_OPTS="--date=yesterday"
fi

if [ ${HISTORY} -gt 28 ]
then
        DATE=`date ${DATE_OPTS} +%Y%m%d`
else
        DATE=`date ${DATE_OPTS} +%d`
fi
CURRENTFILE=sa${DATE}
CURRENTRPT=sar${DATE}

RPT=${SA_DIR}/${CURRENTRPT}
DFILE=${SA_DIR}/${CURRENTFILE}
if [ -z "${ENDIR}" ];
then
       ENDIR=${exec_prefix}/bin
fi

[ -f "${DFILE}" ] || exit 0
cd ${ENDIR}
if [ x${REPORTS} != xfalse ]
then
        ${ENDIR}/sar $* -f ${DFILE} > ${RPT}
fi

SAFILES_REGEX='/sar?[0-9]{2,8}(\.(Z|gz|bz2|xz|lz|lzo))?$'

find "${SA_DIR}" -type f -mtime +${HISTORY} \
        | egrep "${SAFILES_REGEX}" \
        | xargs   rm -f

UNCOMPRESSED_SAFILES_REGEX='/sar?[0-9]{2,8}$'

find "${SA_DIR}" -type f -mtime +${COMPRESSAFTER} \
        | egrep "${UNCOMPRESSED_SAFILES_REGEX}" \
        | xargs   "${ZIP}" > /dev/null

exit 0

Open in new window

noci

Most packages are a collection of commands that are installed together. when you install apache  you also get apachectl, and some other tools to help management.   not each command has it's own installation package.
(Most install packages are either a zip, tar, cpio library containing several files amongst some are the intended toolkit and some describe varius checksums and other tell the install what to do with the file and what commands to execute during before, during and after install and also what commands to execute before, during and after removal of a package.

man sadf has all the options possible, as well as some examples. Many software packages also install man pages for reference.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
marrowyung

ASKER
hi,

I learned htop,ioping today and it is a good tools for linux (but I still like Windows tools, just task manger or system monitor), I can't see why there are no tools to show CPU, RAM and disk read/write and network thoughput by a single command and result keep updating like all sysstat command in a single console.

what do you suggest if there are any single command can do it?  it seems we must monitor separatly for the disk usage/state by dstat and can't include network thoughput at all !

this is better to me as I know which program use the most disk access , and how much RAM and CPU cycle it takes and network bandwidth it use.

can dstat show ppid and pid so that I can relate it to what htop output ? is there any interactive disk stat tools look like htop ?

tools like nmon also can't ! it just have one more MAIN SCREEEN ! it doesn't relate disk activities to a process and the CPU and RAM that process takes on the SAME SCREEN. we have to keep switch BETWEEN screen ! and in order to change another monitor option we have to quite nmon and run again, VERY not flexible!

Windows only use ONE single building application call TASK MANAGER (processs tab) already shows what I need instead of keep installing new rpm for it.

also for glances, it needs python package:
1) python-psutil
2) python-setuptools

but seems can't yum install it ! without python glances can't run, what rpm package you can suggest me to yum install for glance to run ?

I have EPEL on CentOS already
yum install epel-release
but still can't run :

yum -y install python-pip!

it said
no match for argument: python-pip
error: Unable to find a match: python-pip

so still looking for the python library!

but what i need is, again, a single tools to see CPU, and RAM and disk activity related to EACH PROCESS, like windows task manager already very ok

and the output of dstat (at this moment, the best disk tools I can see), still very hard to understand:

e.g.:

dstat output
I knew the one circle in yellow is CPU cost but which process/pid is using it??? I don't know by dstat !

and in dstat, what is the different between read writ and #read #writ?  seems about the SAME disk ? in the diagram above, which is device sda ?

and it seems only can shows the disk access of one disk only ! not all the disk. probably i am not right but please tell me .

back to the htop, the command column is the file/program executing and each row has CPU cost, RAM cost, can I expand each row to include disk access/thoughput and network usage or that command related?


and I watch this: https://www.youtube.com/watch?v=JHGvzMFKIUU for glances... again how can I relate the process to the disk thoughput it use, which disk and the network it takes?
noci

The IO system is completely different from Windows (which look a bit more like OpenVMS 's IO model).
In Unix/Linux all write are done to a memory pool... if the memory pool is full, or when the OS feels like it, or when a FLUSH is scheduled for a device all pending IO blocks are written to the disk for which the flush is initiated (not all disks).
So linking IO to a process is very hard to do.
This is done so many small write are more or less done in RAM without the need to reread a partial block from disk.

Without a flush there is no guarantee any data is on disk. (On older systems there was a separate process that once a minute forced a flush for all disks).
For serious measurements data is logged and later queried from databases. (collectd , grafana etc.). 
marrowyung

ASKER
sa1 & sa2 are delivered WITH sysstat.

the cronjobs are sa1 (collection) & sa2 (report on yesterday).

I installed sysstate but I don't have :

/usr/lib/sa/sa1
and
/usr/lib/sa/sa2

sa1 & sa2 are delivered WITH sysstat.

but I have the tools
sar

and I read this one: https://www.youtube.com/watch?v=7P3JfexK-dk

and I know only sar command, it is for statistic purpose, pretty ok !
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
noci

gentoo store those sa1 & sa2 at /usr/lib/sa/ .. your distro might store them at a different place.
Debian store them at: /usr/lib/sysstat/sa1
Try: find / -name sa1    and find / -name sa2
marrowyung

ASKER
The IO system is completely different from Windows (which look a bit more like OpenVMS 's IO model)

but should  offer convenience on showing system information, not matter how OS design, it just combine of information .

Try: find / -name sa1    and find / -name sa2

tks.

I see these file, and when I go to that directory, how can I run it ? type sa1.sh ?

once sa1 is collecting data, where it store it ?
noci

read the man page... really this IS documented software.
either /var/log/sa or sysstat or /var/lib/sa or .....

if iocounters are on disk level and processes dump data in a buffer pool then there no connection between a process and io. so it is impossible to provide per process io statistics.
Your help has saved me hundreds of hours of internet surfing.
fblack61
marrowyung

ASKER
now it seems that I need more than one command to monitoring loading on linux and what commnad you use first? then what information you need form that command to check deeper with other command (what command you use next ?), spid ? ppid ?
MURUGESAN N

@marrowyung

Need to know your comments given at:
https://www.experts-exchange.com/questions/29175082/linux-command-for-adminstration.html?anchorAnswerId=43044555#a43044555

if looking for a particular process => Example: process id of current shell  => $$
top -n 1 -p $$ -b 2>&1 > delete.txt

Open in new window


>> what command you use first?
obtain the process id of required process.
Assume that I want to get the pid of sendmail
$ ps -eaf | grep sendmail
smmsp     5619     1  0 13:34 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      5769  5298  0 13:55 pts/1    00:00:00 grep sendmail
$ ps -eaf | grep -E "sendmail|PID" | grep -E -v "grep|ps|awk"
UID        PID  PPID  C STIME TTY          TIME CMD
smmsp     5619     1  0 13:34 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
$ ps -eaf | grep -E "sendmail" | grep -E -v "grep|ps|awk" | awk '{ print $2}'
5619
$ SENDMAILPID=$(ps -eaf | grep -E "sendmail" | grep -E -v "grep|ps|awk" | awk '{ print $2}')
$ top -n 1 -b -p $SENDMAILPID
top - 13:56:31 up 47 min,  3 users,  load average: 0.00, 0.00, 0.05
Tasks:   1 total,   0 running,   1 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.6%us,  1.3%sy,  0.0%ni, 96.4%id,  0.5%wa,  1.1%hi,  0.1%si,  0.0%st
Mem:   2572484k total,   809872k used,  1762612k free,   165120k buffers
Swap:  1048568k total,        0k used,  1048568k free,   479616k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 5619 smmsp     15   0 57732 1764  600 S  0.0  0.1   0:00.00 sendmail
$ top -n 1 -b -p $SENDMAILPID > delete.txt
$ cat  delete.txt
top - 13:56:47 up 47 min,  3 users,  load average: 0.00, 0.00, 0.05
Tasks:   1 total,   0 running,   1 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.5%us,  1.3%sy,  0.0%ni, 96.4%id,  0.5%wa,  1.1%hi,  0.1%si,  0.0%st
Mem:   2572484k total,   809960k used,  1762524k free,   165128k buffers
Swap:  1048568k total,        0k used,  1048568k free,   479616k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 5619 smmsp     15   0 57732 1764  600 S  0.0  0.1   0:00.00 sendmail

Open in new window

Sample commands to get parent process id
$ ps -eaf | grep -E "sendmail|PID"
UID        PID  PPID  C STIME TTY          TIME CMD
smmsp     5619     1  0 13:34 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      5811  5298  0 13:57 pts/1    00:00:00 grep -E sendmail|PID
$ ps -eaf | grep -E "sendmail|PID" | grep -E -v "awk|ps|grep"
UID        PID  PPID  C STIME TTY          TIME CMD
smmsp     5619     1  0 13:34 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
$ ps -eaf | grep -E "sendmail" | grep -E -v "awk|ps|grep" | awk '{ print $3}'
1
$ PARENTPID=$(ps -eaf | grep -E "sendmail" | grep -E -v "awk|ps|grep" | awk '{ print $3}')
$ ps -lp $PARENTPID
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S     0     1     0  0  75   0 -  2590 -      ?        00:00:03 init
$ top -n 1 -b -p $PARENTPID
top - 13:58:56 up 49 min,  3 users,  load average: 0.00, 0.00, 0.04
Tasks:   1 total,   0 running,   1 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.5%us,  1.2%sy,  0.0%ni, 96.6%id,  0.5%wa,  1.1%hi,  0.1%si,  0.0%st
Mem:   2572484k total,   810112k used,  1762372k free,   165224k buffers
Swap:  1048568k total,        0k used,  1048568k free,   479620k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      15   0 10360  760  632 S  0.0  0.0   0:03.42 init

Open in new window

we cannot use PPID variable since
$PPID environment variable referring the parent process of current terminal.
$ echo $$
5853
$ ps -lp $$
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S     0  5853  5851  0  75   0 - 16679 wait   pts/2    00:00:00 bash
$ echo $PPID
5851

Open in new window

5851 => parent process of current bash shell.
marrowyung

ASKER
Need to know your comments given at:
https://www.experts-exchange.com/questions/29175082/linux-command-for-adminstration.html?anchorAnswerId=43044555#a43044555

The command is high level and I want more and based on my comment you can see where I am up to, I test Htop and Glances as well , but I can't run glances as it ineed python, as you can see the comment above.

if looking for a particular process => Example: process id of current shell  => $$

sorry what is that for ?

I prefer to know this too:

Try: find / -name sa1    and find / -name sa2

tks.

I see these file, and when I go to that directory, how can I run it ? type sa1.sh ?

once sa1 is collecting data, where it store it ?


Assume that I want to get the pid of sendmail

the point is at the beginning of the troubleshooting process how can we know the sendmail program cause problem, what command you used to check this out ?

top -n 1 -b -p $SENDMAILPID

you getting the pid of sendmail?

$ top -n 1 -b -p $SENDMAILPID
top - 13:56:31 up 47 min,  3 users,  load average: 0.00, 0.00, 0.05
Tasks:   1 total,   0 running,   1 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.6%us,  1.3%sy,  0.0%ni, 96.4%id,  0.5%wa,  1.1%hi,  0.1%si,  0.0%st
Mem:   2572484k total,   809872k used,  1762612k free,   165120k buffers
Swap:  1048568k total,        0k used,  1048568k free,   479616k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 5619 smmsp     15   0 57732 1764  600 S  0.0  0.1   0:00.00 sendmail

are you using a command to check out which program cause problem, and where is the program?  what is the command you use for it?

Then, by that we find out the pid of that process, then what command to use, based on that pid to find out RAM, disk and network usage?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
marrowyung

ASKER
hi,

any update for me?

the linux box has a many partitions, how can I know which partitiion I am using ?
MURUGESAN N

@marrowyung

sample command I tried here
$ sudo fdisk -l 2>&1 | sort -u | grep dev | grep -E "^\/dev"
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14         783     6185025   8e  Linux LVM
/dev/hda3             784        1958     9438187+  83  Linux
/dev/hdb1               1         130     1044193+  8e  Linux LVM
/dev/hdc1               1         261     2096451   8e  Linux LVM
/dev/hdd1               1         130     1044193+  8e  Linux LVM
/dev/hde1               1         391     3140676   8e  Linux LVM
/dev/hdf1               1         391     3140676   8e  Linux LVM

Open in new window

When I press Ctrl D at vmplayer.exe => Virtual machine settings => it is having following HARD Disk:
Hard Disk
Hard Disk 2
Hard Disk 3
Hard Disk 4
Hard Disk 5
Hard Disk 6

However fdisk -l => having /dev/hd* having 8 count.
/dev/hda1 => start block 1 end block 13
/dev/hda2 => start block 14 end block 783
/dev/hda3 => start block 784 end block 1958
referring to one Hard Disk.

sudo sfdisk -l /dev/sd[a-f]
sudo sfdisk => to display help

sudo parted /dev/sda
p
q


sudo parted -l 2>/dev/null | grep "^Disk"

df -h
or bdf at HP-UX
MURUGESAN N

>> I need more than one command to monitoring loading on linux and what commnad you use first?
Assume that you want to monitor bash shell performance(current shell)
if looking for a particular process => Example: process id of current shell  => $$
you can use
top -n 1 -p $$
if you want to check performance of process whose process is 1023
top -n 1 -p 1023
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
marrowyung

ASKER
df -h

this one show everything but it don't show which one is the current disk ! agree ?
marrowyung

ASKER
f looking for a particular process => Example: process id of current shell  => $$
you can use
top -n 1 -p $$
if you want to check performance of process whose process is 1023
top -n 1 -p 1023


pass the number to the last part of the command
top -n 1 -p <pid>
for it?

df -h

this do not shows which one is the disk I am using.

sudo sfdisk -l /dev/sd[a-f]

the star symbol near the deve is the one I am using ?


sudo fdisk -l 2>&1 | sort -u | grep dev | grep -E "^\/dev"

like the output from this , the one with * is the major one?

but with this result":

find diks
the * from this result point to a 1GB partition only but not the 126GB one, so it is not the "star" one is the major disk ?
MURUGESAN N

your comment making me to write comments.

/dev/sda1 starts at 2048 and ends at 2099199
/dev/sda2 starts using next number 2099200
sohe thing like giving block device number like people(data) standing in a queue at floppy disk where each byte occupying idex number(like student unique roll number)

>> top -n 1 -p <pid>
yes where pid being the process which is there in execution/waiting for signal/data/...

read example on https://unix.stackexchange.com/questions/11311/how-do-i-find-on-which-physical-device-a-folder-is-located
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.