.. _diag-command-examples:

.. rst-class:: chapter-with-expand


``diag`` Command Examples
--------------------------

.. index:: diag 

For details, see: :ref:`diagnostic-tools`.

``diag disk``
................


.. index:: diag;diag disk

::

   platform@VOSS:~$ diag disk
   Filesystem               Size  Used Avail Use% Mounted on
   udev                     3.9G     0  3.9G   0% /dev
   tmpfs                    1.6G   80M  1.5G   5% /run
   /dev/sda1                 18G  7.9G  8.9G  47% /
   tmpfs                    3.9G  3.8M  3.9G   1% /dev/shm
   tmpfs                    5.0M     0  5.0M   0% /run/lock
   tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
   none                     3.9G  8.0K  3.9G   1% /tmp
   none                     3.9G     0  3.9G   0% /run/shm
   /dev/sdb1                9.9G  846M  8.6G   9% /var/log
   /dev/sdb2                 40G   15G   23G  39% /opt/platform
   cgmfs                    100K     0  100K   0% /run/cgmanager/fs
   /dev/sdc1                 50G  9.2G   38G  20% /backups
   [...]


``diag monitor``
...................


.. index:: diag;diag monitor

::

   platform@VOSS:~$ diag monitor
   2021-02-15 12:59:32.325225
     4810.5 Mb used, 2252.8 Mb free, 291 processes
    Private  +   Shared  =  RAM used	Files	Sockets	CPU usage	Program 
   
       -0.3 +      0.8 =      0.5		4	0	0	launch.true (20)
       -0.0 +      0.5 =      0.5		10	3	0	qmgr
       -0.0 +      0.6 =      0.6		10	3	0	pickup
        0.0 +      0.2 =      0.2		3	10	0	dbus-daemon
        0.0 +      0.1 =      0.1		7	7	0	systemd-udevd
        0.1 +      0.2 =      0.3		4	0	0	rbash
        0.1 +      0.2 =      0.3		3	21	0	ntpd
        0.7 +      0.7 =      1.4		4	3	0	(sd-pam)
   [...]



``diag monitor list``
.........................


.. index:: diag;diag monitor list

::

   platform@VOSS:~$ diag monitor list
   The following monitor findings were recorded:
   ---------------------------------------------
   launch.true:
      max num_threads = 21 at 2019-10-23 07:10:03.2
   
   systemd:
      avg num_sockets = 31
      max num_sockets = 33 at 2020-10-02 17:30:03.1
      avg num_files = 22
      max num_files = 27 at 2020-10-02 17:30:03.2
   
   metric-collecto:
      max num_files = 27 at 2021-02-04 11:00:03.8
   
   dockerd-ce:
      max mem_private = 94 at 2021-01-27 17:10:03.2
      avg num_sockets = 58
      max num_sockets = 65 at 2019-10-23 08:30:04.8
      avg num_files = 67
      max num_files = 78 at 2019-10-23 07:20:03.5
      max mem_total = 94 at 2021-01-27 17:10:03.2
   
   scripts.py:
      max mem_private = 55 at 2019-10-23 06:20:03.4
      max mem_total = 58 at 2019-10-23 06:20:03.4
   
   nginx:
   [...]




``diag nicstat``
..................


.. index:: diag;diag nicstat

::

   platform@VOSS:~$ diag nicstat
       Time      Int   rKB/s   wKB/s   rPk/s   wPk/s    rAvs    wAvs %Util    Sat
   13:01:28 veth64e996f    1.23    6.86    4.29    2.98   292.7  2357.4  0.00   0.00
   13:01:28    ens32    0.06    0.60    0.22    0.38   300.5  1621.6  0.00   0.00
   13:01:28 veth7b06047    0.00    0.00    0.00    0.00    0.00   72.52  0.00   0.00
   13:01:28 veth143e619    0.45    4.08    0.74    0.68   621.0  6172.7  0.00   0.00
   13:01:28       lo    0.01    0.01    0.24    0.24   61.94   61.94  0.00   0.00
   13:01:28 veth8b143f0   29.02    8.53   28.12   50.87  1056.9   171.8  0.02   0.00
   13:01:28 veth6774425    0.04    0.00    0.00    0.00 15564.9   98.22  0.00   0.00
   13:01:28 veth7f61555    0.00    0.00    0.00    0.00    0.00   72.52  0.00   0.00
   13:01:28 veth1694cf5    0.00    0.00    0.00    0.00    0.00   72.11  0.00   0.00
   13:01:28 veth655de40    0.03    0.05    0.28    0.15   123.8   324.7  0.00   0.00
   13:01:28 veth76b16c9    0.04    0.09    0.05    0.06   855.2  1523.7  0.00   0.00
   13:01:28  docker0   36.91   37.69   78.75   78.69   480.0   490.4  0.00   0.00
   13:01:28 veth6f85a4b    0.35    3.94    1.63    1.17   218.6  3460.7  0.00   0.00
   13:01:28 veth41ddd78    6.82   14.12   43.64   22.78   160.0   634.7  0.01   0.00


``diag ntp``
...............


.. index:: diag;diag ntp

::

   platform@VOSS:~$ diag ntp
          Server: 91.189.91.157 (za.pool.ntp.org)  
   Poll interval: 1min 4s (min: 32s; max 34min 8s)
            Leap: normal                          
         Version: 4                               
         Stratum: 2                               
       Reference: 8CCBCC4D                        
       Precision: 1us (-24)                       
   Root distance: 64.781ms (max: 5s)              
          Offset: -88.040ms                       
           Delay: 754.084ms                       
          Jitter: 78.200ms                        
     Packet count: 8                               
        Frequency: -187.812ppm  


``diag free``
...............


.. index:: diag;diag free

::

   platform@VOSS:~$ diag free
                 total        used        free      shared  buff/cache   available
   Mem:        8174732     5024144      127472       59840     3023116     2714864
   Swap:       2096124      270168     1825956



``diag iostat``
................


.. index:: diag;diag iostat


::

   platform@VOSS:~$ diag iostat
   Linux 4.4.0-151-generic (VOSS) 	02/15/2021 	_x86_64_	(4 CPU)
   
   avg-cpu:  %user   %nice %system %iowait  %steal   %idle
              1.86    0.00    1.08    0.09    0.00   96.97
   
   Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
   sdb               2.31        37.31         6.40   47828330    8197356
   sdc               0.90       114.40         0.01  146633661      14176
   sdd               2.10         0.42        18.24     533207   23383024
   sda               1.40        26.37         6.98   33802387    8949616
   dm-0              2.53         0.41        18.24     530915   23383024




``diag top``
.............


.. index:: diag;diag top

::

   platform@VOSS:~$ diag top
   top - 12:48:53 up 14 days, 20:03,  1 user,  load average: 0.53, 0.48, 0.30
   Tasks: 297 total,   2 running, 295 sleeping,   0 stopped,   0 zombie
   %Cpu(s):  1.9 us,  1.0 sy,  0.0 ni, 97.0 id,  0.1 wa,  0.0 hi,  0.1 si,  0.0 st
   KiB Mem :  8174732 total,   149012 free,  5032732 used,  2992988 buff/cache
   KiB Swap:  2096124 total,  1825764 free,   270360 used.  2706380 avail Mem 
   
       PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
   3165010 root      20   0   40656   3868   3180 R  11.1  0.0   0:00.04 top
      3783 snmp      20   0   59296   5968   2960 S   5.6  0.1  27:33.32 snmpd
      4915 root      20   0   15944   3184   1352 S   5.6  0.0 134:38.96 docker-p+
      8213 www-data  20   0  649084 332456   9660 S   5.6  4.1 445:08.94 python
         1 root      20   0   38036   4952   3108 S   0.0  0.1   1:07.13 systemd
         2 root      20   0       0      0      0 S   0.0  0.0   0:00.41 kthreadd




``diag config platform``
.........................


.. index:: diag;diag config platform

::

   platform@VOSS:~$ diag config platform
       platform: 
           backup: 
               default: localbackup
               locations: 
                   localbackup: 
                       uri: file:///backups
               passphrase: sftp://nobody:********@nowhere/
           credstore: ********
           disa: 
               inactive_lock_days: 35
               max_password_age: 60
               max_simultaneous_logins: 10
               min_password_age: 1
               system_default_umask: 077
               user_password_history: 10
               user_password_length: 8
           drivemounts: 
               mongodb: 
                   dbroot: 
                       disk: 3a4085ec-b88d-411d-a6c6-e2ea6bb2fefa
                       format: xfs
                       mountpoint: /opt/platform/apps/mongodb/dbroot
                       reserve: 10
               services: 
                   SWAPSPACE: 
                       mountpoint: /SWAPSPACE
                   backups: 
                       disk: a2a3c270-5541-4cfe-87ba-7d61d0f6ccde
                       mountpoint: /backups
                       onassign: /opt/platform/apps/services/backup.py --name=localbackup --register-location=file:///backups --force
                       permission: 1777
           location: cpt
   [...]




``diag config app snmp``
..........................


.. index:: diag;diag config app snmp

::

   platform@VOSS:~$ diag config app snmp
       load1: 4
       load15: 2
       load5: 1
       query: value not set
       syscontact: localhost
       syslocation: None
       sysname: None




``diag proc``
..............


.. index:: diag;diag proc

::

   platform@VOSS:~$ diag proc
   systemd-+-VGAuthService
           |-accounts-daemon-+-{gdbus}
           |                 `-{gmain}
           |-agetty
           |-atd
           |-auditd-+-audispd---{audispd}
           |        `-{auditd}
           |-cgmanager
           |-containerd-+-containerd-shim-+-nginx---nginx---4*[nginx]
           |            |                 `-11*[{containerd-shim}]
           |            |-containerd-shim-+-mongodb---sudo---mongod-+-{ApplyBa.Journal}
           |            |                 |                         |-{Backgro.kSource}
   [...]
           |-ntpd
           |-rsyslogd-+-syslog_alert.py
           |          |-{in:imklog}
           |          |-{in:impstats}
           |          |-{in:imuxsock}
           |          `-{rs:main Q:Reg}
           |-snmpd
           |-snmptrapd
           |-sshd---sshd---sshd---rbash---diag---sh---sudo---ui-real.py---execute---pstree
           |-stunnel4
           |-systemd---(sd-pam)
           |-systemd-journal
           |-systemd-logind
           |-systemd-udevd
           `-vmtoolsd---{gmain}




``diag stats``
..............


.. index:: diag;diag stats

::

   platform@VOSS:~$ diag stats
   CONTAINER ID   NAME                  CPU %  MEM USAGE / LIMIT    MEM %   NET I/O          BLOCK I/O       PIDS
   selenium       selenium              0.18%  58.8MiB / 7.796GiB   0.74%   32.1kB / 0B      78.9MB / 0B     30
   selfservice_   selfservice_node      0.00%  101.9MiB / 7.796GiB  1.28%   32.1kB / 0B      32.6MB / 0B     31
   voss-portal    voss-portal           0.00%  14.81MiB / 7.796GiB  0.19%   349kB / 58.9MB   31MB / 0B       5
   voss-wsgi      voss-wsgi             0.90%  570.2MiB / 7.796GiB  7.14%   5.17GB / 456MB   186MB / 0B      10
   voss-monitor   voss-monitoring       1.29%  189MiB / 7.796GiB    2.37%   62.5MB / 43.8MB  34.8MB / 0B     23
   voss-risapi_   voss-risapi_collector 0.10%  106MiB / 7.796GiB    1.33%   5.35GB / 589MB   4.71MB / 0B     3
   voss-queue     voss-queue            3.57%  315.3MiB / 7.796GiB  3.95%   18.5GB / 8.96GB  5.89MB / 0B     4
   voss-cnf_col   voss-cnf_collector    0.15%  105.1MiB / 7.796GiB  1.32%   9.02GB / 1.61GB  31MB / 0B       3
   mongoarbiter   mongoarbiter          1.45%  31.75MiB / 7.796GiB  0.40%   32.3kB / 0B      151MB / 520kB   27
   mongodb        mongodb               3.22%  2.98GiB / 7.796GiB   38.23%  11.2GB / 38.1GB  1.2GB / 37.4GB  109
   nginx          nginx                 0.03%  21.03MiB / 7.796GiB  0.26%   118MB / 56.1MB   28.4MB / 0B     6




``diag tasks``
...............


.. index:: diag;diag tasks

::

   platform@VOSS:~$ diag tasks
   top - 13:04:13 up 14 days, 20:18,  1 user,  load average: 0.07, 0.30, 0.27
   Tasks: 294 total,   1 running, 293 sleeping,   0 stopped,   0 zombie
   %Cpu(s):  1.9 us,  1.0 sy,  0.0 ni, 97.0 id,  0.1 wa,  0.0 hi,  0.1 si,  0.0 st
   KiB Mem :  8174732 total,   390904 free,  5046048 used,  2737780 buff/cache
   KiB Swap:  2096124 total,  1828992 free,   267132 used.  2655756 avail Mem 
   
       PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
   3168836 root      20   0   40680   3916   3200 R  22.2  0.0   0:00.07 /usr/bin/top -b -n 1 -c -w 230
      6680 www-data  20   0  578060   8168   5536 S   5.6  0.1 136:09.89 /opt/voss-deviceapi/go/bin/sysmon
      8213 www-data  20   0  649084 332120   9332 S   5.6  4.1 445:41.70 /usr/bin/python /opt/voss-deviceapi/bin/python /opt/voss-deviceapi/src/deviceapi/background/queue.py 30
         1 root      20   0   38036   4896   3108 S   0.0  0.1   1:07.29 /sbin/init
         2 root      20   0       0      0      0 S   0.0  0.0   0:00.41 [kthreadd]
         3 root      20   0       0      0      0 S   0.0  0.0   0:35.52 [ksoftirqd/0]
         7 root      20   0       0      0      0 S   0.0  0.0   6:54.66 [rcu_sched]
         8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 [rcu_bh]
         9 root      rt   0       0      0      0 S   0.0  0.0   0:08.10 [migration/0]
        10 root      rt   0       0      0      0 S   0.0  0.0   0:04.14 [watchdog/0]
        11 root      rt   0       0      0      0 S   0.0  0.0   0:04.03 [watchdog/1]
        12 root      rt   0       0      0      0 S   0.0  0.0   0:07.98 [migration/1]
        13 root      20   0       0      0      0 S   0.0  0.0   0:34.08 [ksoftirqd/1]
        15 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 [kworker/1:0H]
   [...]




``diag test_connection <host> <port>``
........................................


.. index:: diag;diag test_connection

::

   platform@VOSS:~$ diag test_connection www.voss.com 80
   Successfully connected to www.voss.com:80
   
   platform@VOSS:~$ diag test_connection www.voss.com 81
   Failed to connect to www.voss.com:81



``diag top``
.............


.. index:: diag;diag top

::

   platform@VOSS:~$ diag top
   top - 13:04:43 up 14 days, 20:19,  1 user,  load average: 0.04, 0.27, 0.26
   Tasks: 295 total,   1 running, 294 sleeping,   0 stopped,   0 zombie
   %Cpu(s):  1.9 us,  1.0 sy,  0.0 ni, 97.0 id,  0.1 wa,  0.0 hi,  0.1 si,  0.0 st
   KiB Mem :  8174732 total,   379256 free,  5053288 used,  2742188 buff/cache
   KiB Swap:  2096124 total,  1835344 free,   260780 used.  2644160 avail Mem 
   
       PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
   3168863 root      20   0   40656   3860   3176 R  23.5  0.0   0:00.06 top
         1 root      20   0   38036   4896   3108 S   0.0  0.1   1:07.29 systemd
         2 root      20   0       0      0      0 S   0.0  0.0   0:00.41 kthreadd
         3 root      20   0       0      0      0 S   0.0  0.0   0:35.52 ksoftirq+
         7 root      20   0       0      0      0 S   0.0  0.0   6:54.69 rcu_sched
         8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh
         9 root      rt   0       0      0      0 S   0.0  0.0   0:08.10 migratio+
        10 root      rt   0       0      0      0 S   0.0  0.0   0:04.14 watchdog+
        11 root      rt   0       0      0      0 S   0.0  0.0   0:04.03 watchdog+
        12 root      rt   0       0      0      0 S   0.0  0.0   0:07.98 migratio+
        13 root      20   0       0      0      0 S   0.0  0.0   0:34.08 ksoftirq+
   [...]




``diag vmstat``
................


.. index:: diag;diag vmstat

::

   platform@VOSS:~$ diag vmstat
   procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
    r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
    1  0 260780 378512 273412 2468844    0    0    45     8    4    6  2  1 97  0  0

