{"id":5389,"date":"2015-11-07T20:24:14","date_gmt":"2015-11-07T12:24:14","guid":{"rendered":"http:\/\/rmohan.com\/?p=5389"},"modified":"2015-11-07T20:24:14","modified_gmt":"2015-11-07T12:24:14","slug":"solaris-system-information","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=5389","title":{"rendered":"Solaris system information"},"content":{"rendered":"<header class=\"entry-header\">\n<h1 class=\"entry-title\">Solaris system information<\/h1>\n<div class=\"comments-link\"><strong>1. Solaris physical memory usage<\/strong><\/div>\n<\/header>\n<div class=\"entry-content\">\n<p>Script to get free\/unused memory on Solaris can be found with command vmstat. Without options, vmstat displays a one-line summary of the virtual memory activity since the system was booted. Tested on Solaris 5.8, 5.9, 5.10. Can be wrong on Zones.<br \/>\n<span id=\"more-194\"><\/span><br \/>\nScript .\/mem_usage.sh<\/p>\n<pre><code>#!\/bin\/sh\r\nmem_free=`vmstat 1 2 | tail -1 | awk '{print $5}' | tail -1`;\r\nmem_free_in_mb=`echo $mem_free\/1024 | bc`;\r\nmem_total_in_mb=`\/usr\/sbin\/prtconf 2&gt;\/dev\/null | grep Memory | awk '{ print $3 }'`;\r\nmem_usage_in_mb=`echo \"$mem_total_in_mb-$mem_free_in_mb\" | bc`;\r\nmem_usage_in_per=`echo \"$mem_usage_in_mb\/($mem_total_in_mb\/100)\" | bc`;\r\necho \"\\tPhysical memory size:\\t\\t $mem_total_in_mb\";\r\necho \"\\tMemory usage in MB:\\t\\t $mem_usage_in_mb\";\r\necho \"\\tMemory usage in %:\\t\\t $mem_usage_in_per%\";\r\n<\/code><\/pre>\n<p>Output:<\/p>\n<pre><code># .\/mem_usage.sh\r\n        Physical memory size:            768\r\n        Memory usage in MB:              633\r\n        Memory usage in %:               90%\r\n<\/code><\/pre>\n<p><strong>2. Solaris swap usage<\/strong><\/p>\n<p>Script .\/swap_usage.sh<\/p>\n<pre><code>#!\/bin\/sh\r\nswap_total=`\/usr\/sbin\/swap -l | grep \"\/\" | awk '{ sum+=$4} END {print sum}'`;\r\nswap_free=`\/usr\/sbin\/swap -l | grep \"\/\" | awk '{ sum+=$5} END {print sum}'`;\r\nswap_in_use_per=`echo \"($swap_total-$swap_free) \/ ($swap_total\/100)\" | bc`;\r\necho \"\\tSwap in use:\\t\\t $swap_in_use_per%\";\r\n<\/code><\/pre>\n<p>Output:<\/p>\n<pre><code># .\/swap_usage.sh\r\n        Swap in use:             27%\r\n<\/code><\/pre>\n<p><strong>3. Determine If system is Solaris Zone<\/strong><\/p>\n<pre><code>#!\/bin\/sh\r\nif [ -f \"\/usr\/sbin\/zoneadm\" ]; then\r\n  \/usr\/sbin\/zoneadm list | grep global 1&gt;\/dev\/null;\r\n  if [ \"$?\" -ne \"0\" ]; then\r\n    zone_num=`\/usr\/sbin\/zoneadm list | wc -l | sed 's\/ \/\/g'`;\r\n    if [ \"$zone_num\" = \"1\" ]; then\r\n      zone_status=\"Zone\";\r\n    fi;\r\n  fi;\r\nfi;\r\necho \"\\tSystem is:\\t\\t $zone_status\";\r\n<\/code><\/pre>\n<p><strong>4. Check RAID status metastatus and ZFS<\/strong><\/p>\n<pre><code>#!\/bin\/sh\r\nif [ -f \"\/usr\/sbin\/metastat\" ]; then\r\n  metastatus_ok=`\/usr\/sbin\/metastat 2&gt;\/dev\/null | grep \"State:\" | wc -l|sed 's\/ \/\/g'`;\r\n  metastatus_err=`\/usr\/sbin\/metastat 2&gt;\/dev\/null | grep \"State:\" | grep -v \"State: Okay\" | wc -l|sed 's\/ \/\/g'`;\r\n  if [ \"$metastatus_ok\" = \"0\" ] &amp;&amp; [ \"$metastatus_err\" = \"0\" ]; then\r\n    raid_status=\"no_meta_raids\";\r\n  fi\r\n  if [ \"$metastatus_ok\" != \"0\" ] &amp;&amp; [ \"$metastatus_err\" = \"0\" ]; then\r\n    raid_status=\"OK\";\r\n  fi;\r\n  if [ \"$metastatus_err\" != \"0\" ]; then\r\n    raid_status=\"metastat_Failed\";\r\n  fi;\r\n  raid_controller=\"Software RAID (metastatus)\";\r\nelse\r\n  raid_status=\"no_metastatus\";\r\nfi;\r\nif [ -f \"\/usr\/sbin\/zpool\" ]; then\r\n  zfs_exists=\"ZFS\"\r\n  zfs_pools=`\/usr\/sbin\/zpool status -v`;\r\n  zfs_failed=`\/usr\/sbin\/zpool status -v | grep \"state:\" | grep -v \"ONLINE\" | wc -l |sed 's\/ \/\/g'`;\r\n  if [ \"$zfs_pools\" = \"no pools available\" ]; then\r\n    zfs_status=\"no_zfs_pools\";\r\n  else\r\n    if [ \"$zfs_failed\" != \"0\" ]; then\r\n      zfs_status=\"ZFS_Failed\";\r\n    else\r\n      zfs_status=\"OK\";\r\n    fi;\r\n  fi;\r\nelse\r\n  zfs_status=\"no_zfs\";\r\nfi;\r\necho \"\\tRAID Controller:\\t $raid_controller, $zfs_exists\";\r\necho \"\\tRAID Status:\\t\\t $raid_status, $zfs_status\";\r\n<\/code><\/pre>\n<p><strong>5. Get serial number on Solaris<\/strong><\/p>\n<pre><code>#!\/bin\/sh\r\nif [ -f \"\/usr\/sbin\/sneep\" ]; then\r\n  serial=`\/usr\/sbin\/sneep`;\r\nelse\r\n  serial=`\/usr\/sbin\/eeprom | grep serial | awk -F= '{ print $2}'`;\r\nfi;\r\necho \"\\tSerial:\\t\\t\\t $serial\";\r\n<\/code><\/pre>\n<p><strong>6. Get Solaris OS name, version, update level<\/strong><\/p>\n<pre><code>#!\/bin\/sh\r\nos_name=\"`uname -s`\";\r\nos_ver=\"`uname -r`\";\r\nif head -1 \/etc\/release | grep u1 1&gt;\/dev\/null ; then update_ver=\"U1\"; fi;\r\nif head -1 \/etc\/release | grep u2 1&gt;\/dev\/null ; then update_ver=\"U2\"; fi;\r\nif head -1 \/etc\/release | grep u3 1&gt;\/dev\/null ; then update_ver=\"U3\"; fi;\r\nif head -1 \/etc\/release | grep u4 1&gt;\/dev\/null ; then update_ver=\"U4\"; fi;\r\nif head -1 \/etc\/release | grep u5 1&gt;\/dev\/null ; then update_ver=\"U5\"; fi;\r\nif head -1 \/etc\/release | grep u6 1&gt;\/dev\/null ; then update_ver=\"U6\"; fi;\r\nif head -1 \/etc\/release | grep u7 1&gt;\/dev\/null ; then update_ver=\"U7\"; fi;\r\nif head -1 \/etc\/release | grep u8 1&gt;\/dev\/null ; then update_ver=\"U8\"; fi;\r\nif head -1 \/etc\/release | grep u9 1&gt;\/dev\/null ; then update_ver=\"U9\"; fi;\r\nif head -1 \/etc\/release | grep u10 1&gt;\/dev\/null ; then update_ver=\"U10\"; fi;\r\nif head -1 \/etc\/release | grep s9_58shwpl3 1&gt;\/dev\/null ; then update_ver=\"FCS\"; fi;\r\necho \"5CtOS version:\\t\\t $os_name $os_ver $update_ver\";\r\n<\/code><\/pre>\n<p><strong>7. Other<\/strong><\/p>\n<p>Vendor<\/p>\n<pre><code>#!\/bin\/sh\r\nvendor=`\/usr\/sbin\/prtconf 2&gt;\/dev\/null | head -1 | awk '{print $3 \" \" $4}'`;\r\necho \"\\tVendor:\\t\\t\\t $vendor\";\r\n<\/code><\/pre>\n<p>Hardware<\/p>\n<pre><code>#!\/bin\/sh\r\nhw=\"`uname -i`\";\r\necho \"\\tHardware:\\t\\t\\t $hw\";\r\n<\/code><\/pre>\n<p>Platform 32\/64bit<\/p>\n<pre><code>#!\/bin\/sh\r\nos_bit=\"`isainfo -kv | awk '{print $1}'`\";\r\necho \"\\tPlatform:\\t\\t $os_bit\";\r\n<\/code><\/pre>\n<p>NTP stratums<\/p>\n<pre><code>#!\/bin\/sh\r\nntp_stratum=`\/usr\/sbin\/ntpq -p 2&gt;\/dev\/null | awk '{ print $3 }'| tail +3`\r\nntp_status=`echo $ntp_stratum`;\r\necho \"\\tNTP:\\t\\t\\t $ntp_status\";\r\n<\/code><\/pre>\n<p>All IP addresses<\/p>\n<pre><code>#!\/bin\/sh\r\nip_all=\"`\/sbin\/ifconfig -a | grep inet | grep -v 127.0.0.1 | awk '{print $2}'`\";\r\nip_all_one_string=\"`echo $ip_all`\";\r\necho \"\\tIP all:\\t\\t\\t $ip_all_one_string\";\r\n<\/code><\/pre>\n<p>Root files system usage<\/p>\n<pre><code>#!\/bin\/sh\r\nfs_root=\"`df -k | grep \"\/$\" | awk '{print $5}'`\";\r\necho \"\\tFS ROOT:\\t\\t $fs_root\";\r\n<\/code><\/pre>\n<p>All files systems usage<\/p>\n<pre><code>#!\/bin\/sh\r\nfs_all=`df -k | grep \"\/\" | grep -v \"\/$\" | grep -v \"\/proc\" | grep -v \"\/etc\/mnttab\" | grep -v \"\/etc\/dfs\/sharetab\" | grep -v \"\/lib\/libc.so.1\" | awk '{print $6 \" \" $5 \",\"}'`\r\nfs_all_one_string=\"`echo $fs_all`\";\r\necho \"\\tFS ALL:\\t\\t\\t $fs_all_one_string\";<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p> Solaris system information 1. Solaris physical memory usage <\/p>\n<p>Script to get free\/unused memory on Solaris can be found with command vmstat. Without options, vmstat displays a one-line summary of the virtual memory activity since the system was booted. Tested on Solaris 5.8, 5.9, 5.10. Can be wrong on Zones. Script .\/mem_usage.sh<\/p>\n<p> #!\/bin\/sh mem_free=`vmstat 1 [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5389"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5389"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5389\/revisions"}],"predecessor-version":[{"id":5390,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5389\/revisions\/5390"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}