Archive

Archive for November, 2014

FreeBSD View Memory Usage

November 17, 2014 Leave a comment

Get memory from dmesg:

[root@freebitch10 /]# dmesg | grep memory
real memory = 134152192 (127 MB)
avail memory = 102039552 (97 MB)

To see swap memory only

[root@freebitch10 /]# swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/ada0p3        314368    13052   301316     4%

Total physical memory in the system (with sysctl):

[root@freebitch10 /]# sysctl hw.physmem
hw.physmem: 110563328

Another way is to use top command

[root@freebitch10 /]# top -n | grep Mem
Mem: 3704K Active, 35M Inact, 41M Wired, 940K Cache, 20M Buf, 20M Free

Just to see free memory

[root@freebitch10 /]# top -d 1|grep '^Mem:'|cut -d ',' -f 6
 20M Free

You can also install sysinfo (utility used to gather system configuration information)

[root@freebitch10 /]# pkg install sysinfo
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 1 packages will be affected (of 0 checked):

New packages to be INSTALLED:
	sysinfo: 1.0.1_2

The process will require 39 KB more space.
16 KB to be downloaded.

Proceed with this action? [y/N]: y
Fetching sysinfo-1.0.1_2.txz: 100%   16 KB  16.7k/s    00:01    
Checking integrity... done (0 conflicting)
[1/1] Installing sysinfo-1.0.1_2: 100%

And get the memory information:

[root@freebitch10 /]# sysinfo mem
Generated by SysInfo v1.0.1 by Daniel Gerzo

RAM information

Memory information from dmidecode(8)
WARNING: You will need to install the sysutils/dmidecode port in order to obtain this information.

System memory summary
Total real memory available:	105 MB
Logically used memory:		51 MB
Logically available memory:	53 MB

Swap information
Device          1K-blocks     Used    Avail Capacity
/dev/ada0p3        314368      13M     294M     4%

Or install freecolor ( like Linux free command )

[root@freebitch10 /]# pkg install freecolor
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 2 packages will be affected (of 0 checked):

New packages to be INSTALLED:
	freecolor: 0.9.2_1
	libstatgrab: 0.91

The process will require 549 KB more space.
118 KB to be downloaded.

Proceed with this action? [y/N]: y
Fetching freecolor-0.9.2_1.txz: 100%    5 KB   5.3k/s    00:01    
Fetching libstatgrab-0.91.txz: 100%  113 KB 115.7k/s    00:01    
Checking integrity... done (0 conflicting)
[1/2] Installing libstatgrab-0.91: 100%
[2/2] Installing freecolor-0.9.2_1: 100%

To view memory information in text mode

[root@freebitch10 /]# freecolor -t -m -o
             total       used       free     shared    buffers     cached
Mem:           101         45         56          0          0          0
Swap:          307         12        294
Total:         408 = (      57 (used) +      351 (free))

To view memory information in graphical mode

[root@freebitch10 /]# freecolor -t -m
Physical  : [###################................] 56%	(57/101)
Swap      : [#################################..] 95%	(294/307)
Total     : [##############################%%%%%] (408=351+56)
Advertisements

Backup Remote Linux Servers

November 10, 2014 Leave a comment

Here is small script to backup multiple remote servers to local machine and then delete remote file after the operation.

You need ssh key setup with remote machines for the script to login.

Of course you can use the same script(after desired modification) to automate any operation on remote machines from your local machine cron.

#!/bin/sh

hosts="192.168.1.2 192.168.1.3 192.168.1.4"
TIMESTAMP=`date +%Y%m%d_%H%M`

for i in $hosts;
do
  echo $i
  FILENAME="$TIMESTAMP"_"$i"
  ssh $i tar -czvpPf /root/mysqlbackup_"$TIMESTAMP".tar.gz /var/lib/mysql/
  scp root@$i:/root/mysqlbackup_"$TIMESTAMP".tar.gz /mnt/mysqlbackup/mysql_"$FILENAME".tar.gz
  ssh $i rm -f /root/mysqlbackup_"$TIMESTAMP".tar.gz
done;

Centos 7 systemd temp files

November 9, 2014 1 comment

So this entry is not written to discuss about cons and/or pros of systemd. Apparently systemd owns complete linux its everywhere and you can not get rid of it easily. Here is what happened 2 days ago. I installed centos 7 on my main machine. While debugging one of php project i was working on, i needed to check my debug file which normally i write with “error_log” function:

return error_log($log, 3, "/tmp/ErrorLog")

it was writing to /tmp/ directory but when i tried to tail the file system coulnd’t find it. No entry in nginx or php-fpm log files , no errors but i’m not able to find the file. So i tried to read the file :

$filename="/tmp/ErrorLog";
$myfile = fopen($filename, "r") or die("Unable to open file!");
echo fread($myfile,filesize($filename));

and boom its reading the contents. So i wasted ~45 minutes try to debug my application and then nginx and php-fpm (bottom line this was a fresh install centos 7 so first time im checking this log file)

then i tried to search the file (first time i cancelled the search as it could take long time and decided to check my source code which was mistake)

[root@marko tmp]# find / -name ErrorLog
/tmp/systemd-private-kJHrTu/tmp/ErrorLog

What the fuck?????

So seems like systemd is doing something shady behind my back. Till today i was never curious about systemd as im not a network administrator anymore. As long as i can run my system with my past experiences i do not care about the changes. Instead i focus on software development.

So i started digging into systemd stuff. After 10 sec search i hit to this page

http://fedoraproject.org/wiki/Features/ServicesPrivateTmp

Seems like this proposal is reality now. With one difference it says default value is FALSE which is not the case with centos 7.

So another post mentions

> Also you can get which directories are used by which process with the
> following command:
> 
> $ sudo grep systemd-private /proc/*/mountinfo

So lets try it

[root@marko tmp]# grep systemd-private /proc/*/mountinfo
/proc/20991/mountinfo:271 201 253:0 /tmp/systemd-private-nunEbg/tmp /tmp rw,relatime shared:213 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/20991/mountinfo:273 201 253:0 /var/tmp/systemd-private-JCyn7Y/tmp /var/tmp rw,relatime shared:214 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/21148/mountinfo:271 201 253:0 /tmp/systemd-private-nunEbg/tmp /tmp rw,relatime shared:213 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/21148/mountinfo:273 201 253:0 /var/tmp/systemd-private-JCyn7Y/tmp /var/tmp rw,relatime shared:214 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/2970/mountinfo:110 80 253:0 /tmp/systemd-private-gBrQ6F/tmp /tmp rw,relatime shared:93 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/2970/mountinfo:111 80 253:0 /var/tmp/systemd-private-8kjTJV/tmp /var/tmp rw,relatime shared:94 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3486/mountinfo:151 119 253:0 /tmp/systemd-private-tAXBDZ/tmp /tmp rw,relatime shared:133 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3486/mountinfo:152 119 253:0 /var/tmp/systemd-private-BPzvqo/tmp /var/tmp rw,relatime shared:134 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3689/mountinfo:279 242 253:0 /tmp/systemd-private-kJHrTu/tmp /tmp rw,relatime shared:256 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3689/mountinfo:280 242 253:0 /var/tmp/systemd-private-oHMLFF/tmp /var/tmp rw,relatime shared:257 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3691/mountinfo:279 242 253:0 /tmp/systemd-private-kJHrTu/tmp /tmp rw,relatime shared:256 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3691/mountinfo:280 242 253:0 /var/tmp/systemd-private-oHMLFF/tmp /var/tmp rw,relatime shared:257 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3692/mountinfo:279 242 253:0 /tmp/systemd-private-kJHrTu/tmp /tmp rw,relatime shared:256 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3692/mountinfo:280 242 253:0 /var/tmp/systemd-private-oHMLFF/tmp /var/tmp rw,relatime shared:257 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3693/mountinfo:279 242 253:0 /tmp/systemd-private-kJHrTu/tmp /tmp rw,relatime shared:256 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3693/mountinfo:280 242 253:0 /var/tmp/systemd-private-oHMLFF/tmp /var/tmp rw,relatime shared:257 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3694/mountinfo:279 242 253:0 /tmp/systemd-private-kJHrTu/tmp /tmp rw,relatime shared:256 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3694/mountinfo:280 242 253:0 /var/tmp/systemd-private-oHMLFF/tmp /var/tmp rw,relatime shared:257 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3695/mountinfo:279 242 253:0 /tmp/systemd-private-kJHrTu/tmp /tmp rw,relatime shared:256 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/3695/mountinfo:280 242 253:0 /var/tmp/systemd-private-oHMLFF/tmp /var/tmp rw,relatime shared:257 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/4210/mountinfo:199 164 253:0 /tmp/systemd-private-q1NXco/tmp /tmp rw,relatime shared:178 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/4210/mountinfo:236 164 253:0 /var/tmp/systemd-private-UbiRCk/tmp /var/tmp rw,relatime shared:216 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/4211/mountinfo:199 164 253:0 /tmp/systemd-private-q1NXco/tmp /tmp rw,relatime shared:178 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/4211/mountinfo:236 164 253:0 /var/tmp/systemd-private-UbiRCk/tmp /var/tmp rw,relatime shared:216 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/5000/mountinfo:279 242 253:0 /tmp/systemd-private-kJHrTu/tmp /tmp rw,relatime shared:256 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered
/proc/5000/mountinfo:280 242 253:0 /var/tmp/systemd-private-oHMLFF/tmp /var/tmp rw,relatime shared:257 master:1 - ext4 /dev/mapper/centos-root rw,data=ordered

Not that useful, lets try to find php-fpm pid and try to see the details with findmnt. At least we’ll know what we are looking for:

[root@marko tmp]# ps -ax | grep php-fpm
3689 ?        Ss     0:00 php-fpm: master process (/etc/php-fpm.conf)
3691 ?        S      0:00 php-fpm: pool www
3692 ?        S      0:00 php-fpm: pool www
3693 ?        S      0:00 php-fpm: pool www
3694 ?        S      0:00 php-fpm: pool www
3695 ?        S      0:00 php-fpm: pool www
5000 ?        S      0:00 php-fpm: pool www
5188 pts/3    S+     0:00 grep --color=auto php-fpm

 

[root@marko tmp]# findmnt -N 3689
TARGET                           SOURCE                FSTYPE          OPTIONS
/                                /dev/mapper/centos-root
ext4            rw,relatime,data=ordered
├─/dev                           devtmpfs              devtmpfs        rw,nosuid,size=3950776k,nr_inodes=987694,mode=755
│ ├─/dev/shm                     tmpfs                 tmpfs           rw,nosuid,nodev
│ ├─/dev/pts                     devpts                devpts          rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
│ ├─/dev/mqueue                  mqueue                mqueue          rw,relatime
│ └─/dev/hugepages               hugetlbfs             hugetlbfs       rw,relatime
├─/proc                          proc                  proc            rw,nosuid,nodev,noexec,relatime
│ ├─/proc/sys/fs/binfmt_misc     systemd-1             autofs          rw,relatime,fd=34,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
│ │ └─/proc/sys/fs/binfmt_misc   binfmt_misc           binfmt_misc     rw,relatime
│ └─/proc/fs/nfsd                sunrpc                nfsd            rw,relatime
├─/sys                           sysfs                 sysfs           rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security         securityfs            securityfs      rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup               tmpfs                 tmpfs           rw,nosuid,nodev,noexec,mode=755
│ │ ├─/sys/fs/cgroup/systemd     cgroup                cgroup          rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
│ │ ├─/sys/fs/cgroup/cpuset      cgroup                cgroup          rw,nosuid,nodev,noexec,relatime,cpuset
│ │ ├─/sys/fs/cgroup/cpu,cpuacct cgroup                cgroup          rw,nosuid,nodev,noexec,relatime,cpuacct,cpu
│ │ ├─/sys/fs/cgroup/memory      cgroup                cgroup          rw,nosuid,nodev,noexec,relatime,memory
│ │ ├─/sys/fs/cgroup/devices     cgroup                cgroup          rw,nosuid,nodev,noexec,relatime,devices
│ │ ├─/sys/fs/cgroup/freezer     cgroup                cgroup          rw,nosuid,nodev,noexec,relatime,freezer
│ │ ├─/sys/fs/cgroup/net_cls     cgroup                cgroup          rw,nosuid,nodev,noexec,relatime,net_cls
│ │ ├─/sys/fs/cgroup/blkio       cgroup                cgroup          rw,nosuid,nodev,noexec,relatime,blkio
│ │ ├─/sys/fs/cgroup/perf_event  cgroup                cgroup          rw,nosuid,nodev,noexec,relatime,perf_event
│ │ └─/sys/fs/cgroup/hugetlb     cgroup                cgroup          rw,nosuid,nodev,noexec,relatime,hugetlb
│ ├─/sys/fs/pstore               pstore                pstore          rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/config           configfs              configfs        rw,relatime
│ ├─/sys/kernel/debug            debugfs               debugfs         rw,relatime
│ └─/sys/fs/fuse/connections     fusectl               fusectl         rw,relatime
├─/run                           tmpfs                 tmpfs           rw,nosuid,nodev,mode=755
│ └─/run/user/1000/gvfs          gvfsd-fuse            fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000

/dev/sda6             ext4            rw,nosuid,nodev,relatime,data=ordered
├─/var/lib/nfs/rpc_pipefs        sunrpc                rpc_pipefs      rw,relatime
├─/boot                          /dev/sda1             ext4            rw,relatime,stripe=4,data=ordered
├─/mnt/media                     //192.168.1.xx/media/ cifs            rw,relatime,vers=1.0,cache=strict,username=admin,domain=LS-W,uid=1000,forceuid,gid=0,noforcegid,addr=192.168.1.xx,file_mode=0644,dir_mode=0755,nounix,serverino,r
├─/mnt/backup1               //192.168.1.xx/backup1/
cifs            rw,relatime,vers=1.0,cache=strict,username=admin,domain=LS-W,uid=1000,forceuid,gid=0,noforcegid,addr=192.168.1.xx,file_mode=0644,dir_mode=0755,nounix,serverino,r
├─/mnt/backup2                     //192.168.1.xx/backup2/ cifs            rw,relatime,vers=1.0,cache=strict,username=admin,domain=LS-W,uid=1000,forceuid,gid=0,noforcegid,addr=192.168.1.xx,file_mode=0644,dir_mode=0755,nounix,serverino,r
├─/tmp                           /dev/mapper/centos-root[/tmp/systemd-private-kJHrTu/tmp]
ext4            rw,relatime,data=ordered
└─/var/tmp                       /dev/mapper/centos-root[/var/tmp/systemd-private-oHMLFF/tmp]
ext4            rw,relatime,data=ordered

 
Now we know its definitely system as last 4 line indicates its writing my file to “/var/tmp/systemd-private-oHMLFF/tmp” without my knowledge. i have to find where are these systemd unit files (basicly service based conf files)

ok they are store “/usr/lib/systemd/system/”

[root@marko tmp]# ls /usr/lib/systemd/system/
[root@marko tmp]# ls /usr/lib/systemd/system/nginx.service
/usr/lib/systemd/system/nginx.service
.
.

And the content of the file:

[root@marko tmp]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Directive we are looking for is there “PrivateTmp” I wont argue if this is a good feature or not. And do not tell me i have to check change logs etc… basically i should be comfortable with a linux system whenever i use it either its 2000 or 2014.

One last tip files under /tmp/ will be removed if related service is stopped and/or restarted. So you can not store your log files under /tmp/ anymore.

Also during this time (5 days on centos 7) system crashed 1 time pretty interestingly but that story is for some other time

Linux is changing…Its time to move back to BSD system i guess….

Freebsd 10 pkg manager

November 8, 2014 Leave a comment

With the fresh install when you try to install any package you will get something like: No package found

To solve this issue:

# cp /usr/local/etc/pkg.conf.sample /usr/local/etc/pkg.conf
# pkg update

or

/etc/pkg/FreeBSD.conf

replace -> url: “pkg+http://pkg.FreeBSD.org/${ABI}/latest”
with      -> url: “pkg+http://pkg.FreeBSD.org/${ABI}/release_1”

Nginx Uniq Visitors

November 6, 2014 Leave a comment

Total hits per day:

[root@marko nginx]# awk '/06.Nov.2014/ {print $1}' < www.xxx.com.access.log | sort | uniq |wc -l
182

Hits Per IP

[root@marko nginx]# awk '/06.Nov.2014/ {print $1}' < www.xxx.com.access.log | sort | uniq -c
2 xx.30.xx.62
1 xx.9.xx.191
1 xx.131.xx.112
4 xx.21.xx.193
2 xx.27.xx.127

Mysql Query Cache Optimization Review

November 5, 2014 Leave a comment

Query Cache:

my.cnf:
query_cache_type = 1
query_cache_size = 20M
query_cache_limit = 1M

mysql> SHOW STATUS LIKE 'Qcache%';
+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_free_blocks      | 537      |
| Qcache_free_memory      | 14197176 |
| Qcache_hits             | 24170    |
| Qcache_inserts          | 4697     |
| Qcache_lowmem_prunes    | 0        |
| Qcache_not_cached       | 68       |
| Qcache_queries_in_cache | 2895     |
| Qcache_total_blocks     | 6481     |
+-------------------------+----------+
8 rows in set (0.00 sec)

Query Cache Formulas:

Query cache hit rate = ((Qcache_hits / (Qcache_hits + Qcache_inserts + Qcache_not_cached))*100)

Query cache use percentage = ((query_cache_size – Qcache_free_memory) / query_cache_size )*100

Average size of the queries = (query_cache_size – Qcache_free_memory) / Qcache_queries_in_cache

Threads:
my.cnf:
thread_cache_size = 30

mysql> SHOW GLOBAL STATUS LIKE 'Connections';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections   | 91082 |
+---------------+-------+
1 row in set (0.00 sec)

mysql> SHOW GLOBAL STATUS LIKE 'Threads_created';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| Threads_created | 12    |
+-----------------+-------+
1 row in set (0.00 sec)

mysql> SHOW GLOBAL STATUS LIKE 'Max_used_connections';

+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 12    |
+----------------------+-------+
1 row in set (0.00 sec)

Attention:
Threads_created / Connections should be < 0.01 (if needed increase thread_cache_size)
thread_cache_size should be > Max_used_connections

Thread Formulas:
Thread cache hit rate = 100 – ((Threads_created / Connections) * 100)

Connection Formulas:

Percentage of used connections: processlist / MAX_CONNECTIONS

mysql> select (( pl.connections / gv.max_connections ) * 100) as percentage_used_connections from ( select count(*) as connections from information_schema.processlist ) as pl, ( select VARIABLE_VALUE as max_connections from information_schema.global_variables where variable_name = 'MAX_CONNECTIONS' ) as gv;

+-----------------------------+
| percentage_used_connections |
+-----------------------------+
|          0.6622516556291391 |
+-----------------------------+
1 row in set (0.00 sec)

Maintenance

mysql> RESET QUERY CACHE; 

will clear out the query cache

if Qcache_free_blocks approaches Qcache_total_blocks / 2, your query cache is severely fragmented.

mysql> FLUSH QUERY CACHE; 

does NOT clear out the query cache but rather defrags the cache and leaving the cached query results in place

Problem:
Qcache_lowmem_prunes value is increasing and you have a lot of Qcache_free_blocks
Reason 1:
Fragmentation is causing queries to be deleted from the cache.
In this case, increase query_cache_limit or query_cache_size, or both of them.
Reason 2:
The query cache allocates blocks with a minimum size given by the query_cache_min_res_unit system variable (default value 4096 bytes). When a query is executed, the last result block is trimmed to the actual data size so that unused memory is freed. Depending on the types of queries your server executes, you might find it helpful to tune the value of query_cache_min_res_unit:

If you have a lot of queries with small results, the default block size may lead to memory fragmentation, as indicated by a large number of free blocks. Fragmentation can force the query cache to prune (delete) queries from the cache due to lack of memory. In this case, you should decrease the value of query_cache_min_res_unit (minimum value 512 bytes). The number of free blocks and queries removed due to pruning are given by the values of the Qcache_free_blocks and Qcache_lowmem_prunes status variables.

To change in runtime

mysql> Set global query_cache_min_res_unit = 1024;

To change in my.cnf

query_cache_min_res_unit = 1024

mysql> show variables like "query%";
+------------------------------+----------+
| Variable_name                | Value    |
+------------------------------+----------+
| query_alloc_block_size       | 8192     |
| query_cache_limit            | 1048576  |
| query_cache_min_res_unit     | 1024     |
| query_cache_size             | 20971520 |
| query_cache_type             | ON       |
| query_cache_wlock_invalidate | OFF      |
| query_prealloc_size          | 8192     |
+------------------------------+----------+
7 rows in set (0.00 sec)

Linux System Statistics (sysstat)

November 2, 2014 Leave a comment

iostat – Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions

[x@mar nodes]$ iostat -d 2
Linux 3.10.0-123.8.1.el7.x86_64 (mar) 	11/02/2014 	_x86_64_	(4 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               8.06        63.19       158.29   75199083  188364685
scd0              0.01         0.88         0.00    1048848          0
dm-0              8.30        35.15        87.59   41825965  104228088

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0.50         2.00         0.00          4          0
scd0              0.00         0.00         0.00          0          0
dm-0              0.00         0.00         0.00          0          0

prtstat – print statistics of a process

[x@mar nodes]$ prtstat -r 495
         pid: 495            	                  comm: su
       state: S              	                  ppid: 22738
        pgrp: 495            	               session: 22738
      tty_nr: 34820          	                 tpgid: 501
       flags: 406100         	                minflt: 1803
     cminflt: 1694           	                majflt: 5
     cmajflt: 4              	                 utime: 0
       stime: 1              	                cutime: 2
      cstime: 1              	              priority: 20
        nice: 0              	           num_threads: 1
 itrealvalue: 0              	             starttime: 107674910
       vsize: 187473920      	                   rss: 543
      rsslim: 18446744073709551615	             startcode: 1
     endcode: 1              	            startstack: 0
     kstkesp: 0              	               kstkeip: 0
       wchan: 18446744073709551615	                 nswap: 0
      cnswap: 18446744073709551615	           exit_signal: 17
   processor: 0              	           rt_priority: 0
      policy: 0              	 delayaccr_blkio_ticks: 48
  guest_time: 0              	           cguest_time: 0

nfsiostat – Report input/output statistics for network filesystems (NFS)

stat – display file or file system status

[x@mar nodes]$ stat recognizer.py 
  File: ‘recognizer.py’
  Size: 6476      	Blocks: 16         IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 1312342     Links: 1
Access: (0775/-rwxrwxr-x)  Uid: ( 1000/   x)   Gid: ( 1000/   x)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2014-10-23 21:45:10.041988240 -0400
Modify: 2014-10-23 21:44:21.157301676 -0400
Change: 2014-10-23 21:44:21.157301676 -0400
 Birth: -
[root@mar nodes]$ stat /dev/sda
  File: ‘/dev/sda’
  Size: 0         	Blocks: 0          IO Block: 4096   block special file
Device: 5h/5d	Inode: 8544        Links: 1     Device type: 8,0
Access: (0660/brw-rw----)  Uid: (    0/    root)   Gid: (    6/    disk)
Context: system_u:object_r:fixed_disk_device_t:s0
Access: 2014-11-02 10:52:15.531399767 -0500
Modify: 2014-10-20 03:58:56.852349054 -0400
Change: 2014-10-20 03:58:56.852349054 -0400
 Birth: -

ntpstat – show network time synchronisation status
netstat – Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships

[x@mar nodes]$ netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      943/dovecot         
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1017/nginx          
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      516/sshd            
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      975/sendmail        
tcp        0      0 0.0.0.0:443                 0.0.0.0:*                   LISTEN      1017/nginx          
tcp        0      0 0.0.0.0:993                 0.0.0.0:*                   LISTEN      943/dovecot         
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      999/php-fpm         
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      906/mysqld          
tcp        0      0 0.0.0.0:587                 0.0.0.0:*                   LISTEN      975/sendmail        
tcp        0      0 :::143                      :::*                        LISTEN      943/dovecot         
tcp        0      0 :::22                       :::*                        LISTEN      516/sshd            
tcp        0      0 :::993                      :::*                        LISTEN      943/dovecot

turbostat – Report processor frequency and idle statistics

[root@mar nodes]# turbostat -i 5
cor CPU    %c0  GHz  TSC SMI    %c1    %c3    %c6    %c7 CTMP PTMP   %pc2   %pc3   %pc6   %pc7  Pkg_W  Cor_W GFX_W
         33.42 2.67 2.29   0  44.56   3.82   0.09  18.10   70   70   0.97   0.52   1.22   0.13  16.62  13.12  0.22
  0   0  30.49 2.65 2.30   0  45.78   4.31   0.12  19.29   66   70   0.97   0.52   1.22   0.13  16.62  13.12  0.22
  0   2  33.77 2.70 2.29   0  42.50
  1   1  30.31 2.62 2.29   0  49.39   3.33   0.06  16.90   70
  1   3  39.12 2.70 2.29   0  40.58
cor CPU    %c0  GHz  TSC SMI    %c1    %c3    %c6    %c7 CTMP PTMP   %pc2   %pc3   %pc6   %pc7  Pkg_W  Cor_W GFX_W
         33.54 2.64 2.29   0  44.24   3.31   0.18  18.74   70   70   1.12   0.38   1.62   0.28  16.55  12.97  0.31
  0   0  30.91 2.62 2.29   0  45.92   3.59   0.04  19.52   67   70   1.12   0.38   1.62   0.28  16.55  12.97  0.31
  0   2  35.41 2.65 2.29   0  41.43
  1   1  29.13 2.60 2.29   0  49.58   3.03   0.31  17.95   70
  1   3  38.69 2.69 2.29   0  40.02

vmstat – Report virtual memory statistics. vmstat reports information about processes, memory, paging, block IO, traps, disks and cpu activity

Usage:
 vmstat [options] [delay [count]]

Options:
 -a, --active           active/inactive memory
 -f, --forks            number of forks since boot
 -m, --slabs            slabinfo
 -n, --one-header       do not redisplay header
 -s, --stats            event counter statistics
 -d, --disk             disk statistics
 -D, --disk-sum         summarize disk statistics
 -p, --partition   partition specific statistics
 -S, --unit       define display unit
 -w, --wide             wide output
 -t, --timestamp        show timestamp

 -h, --help     display this help and exit
 -V, --version  output version information and exit

lpstat – print cups status information. lpstat displays status information about the current classes, jobs, and printers.

[root@marko nodes]# lpstat -s
system default destination: HP-LaserJet-200-color-M251nw
device for HP-LaserJet-200-color-M251nw: dnssd://HP%20LaserJet%20200%20color%20M251nw%20(0520CB)._pdl-datastream._tcp.local/

cifsiostat – Report CIFS statistics.Displays statistics about read and write operations on CIFS filesystems.

[root@marko Downloads]# cifsiostat
Linux 3.10.0-123.8.1.el7.x86_64 (mar) 	11/02/2014 	_x86_64_	(4 CPU)

Filesystem:                    rB/s         wB/s    rops/s    wops/s         fo/s         fc/s         fd/s
\\192.168.1.50\backup0      1044.03       899.66      0.02      0.01         0.00         0.00         0.00 
\\192.168.1.50\backup1     11373.32       473.36      0.25      0.08         0.06         0.06         0.00 
\\192.168.1.50\backup2         7.45      1919.59      0.00      0.03         0.00         0.00         0.00 
\\192.168.1.50\media           0.00         0.00      0.00      0.00         0.00         0.00         0.00 

pidstat – Report statistics for Linux tasks. Used for monitoring individual tasks currently being managed by the Linux kernel.

[root@mar ~]# pidstat -U apache
Linux 3.10.0-123.8.1.el7.x86_64 (mar) 	11/02/2014 	_x86_64_	(4 CPU)

10:08:25 PM     USER       PID    %usr %system  %guest    %CPU   CPU  Command
10:08:25 PM   apache      1366    0.00    0.00    0.00    0.00     1  httpd
10:08:25 PM   apache      1450    0.00    0.00    0.00    0.00     2  httpd
10:08:25 PM   apache      1592    0.00    0.00    0.00    0.00     2  httpd
10:08:25 PM   apache      1905    0.00    0.00    0.00    0.00     0  httpd
10:08:25 PM   apache      7216    0.00    0.00    0.00    0.00     0  httpd
10:08:25 PM   apache      7283    0.00    0.00    0.00    0.00     3  httpd
10:08:25 PM   apache     17114    0.00    0.00    0.00    0.00     3  httpd
10:08:25 PM   apache     29815    0.00    0.00    0.00    0.00     2  httpd
10:08:25 PM   apache     30103    0.00    0.00    0.00    0.00     1  httpd
10:08:25 PM   apache     30912    0.00    0.00    0.00    0.00     1  httpd

db_stat – Displays statistics for Berkeley DB environments.