{"id":43750,"date":"2026-09-28T09:28:05","date_gmt":"2026-09-28T02:28:05","guid":{"rendered":"https:\/\/interdata.vn\/blog\/?p=43750"},"modified":"2026-09-28T09:38:11","modified_gmt":"2026-09-28T02:38:11","slug":"lenh-pidstat","status":"publish","type":"post","link":"https:\/\/interdata.vn\/blog\/lenh-pidstat\/","title":{"rendered":"H\u01b0\u1edbng D\u1eabn S\u1eed D\u1ee5ng L\u1ec7nh pidstat Gi\u00e1m S\u00e1t Ti\u1ebfn Tr\u00ecnh Linux (K\u00e8m V\u00ed D\u1ee5 Th\u1ef1c T\u1ebf)"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"font-size: 100%;\"><strong>L\u1ec7nh pidstat<\/strong> l\u00e0 c\u00f4ng c\u1ee5 chuy\u00ean s\u00e2u trong g\u00f3i sysstat gi\u00fap qu\u1ea3n tr\u1ecb vi\u00ean gi\u00e1m s\u00e1t ti\u1ebfn tr\u00ecnh Linux theo th\u1eddi gian th\u1ef1c v\u00e0 ghi nh\u1eadn chi ti\u1ebft m\u1ee9c ti\u00eau th\u1ee5 CPU, RAM, Disk I\/O c\u0169ng nh\u01b0 context switch c\u1ee7a t\u1eebng PID ho\u1eb7c Thread. Khi h\u1ec7 th\u1ed1ng g\u1eb7p hi\u1ec7n t\u01b0\u1ee3ng gi\u1eadt lag ho\u1eb7c qu\u00e1 t\u1ea3i m\u00e0 c\u00e1c l\u1ec7nh th\u00f4ng th\u01b0\u1eddng kh\u00f4ng ch\u1ec9 r\u00f5 nguy\u00ean nh\u00e2n, s\u1eed d\u1ee5ng pidstat tr\u00ean m\u00e1y ch\u1ee7 <a href=\"https:\/\/interdata.vn\/\" target=\"_blank\" rel=\"noopener\">InterData<\/a> s\u1ebd gi\u00fap b\u1ea1n khoanh v\u00f9ng ch\u00ednh x\u00e1c ti\u1ebfn tr\u00ecnh g\u00e2y ngh\u1ebdn hi\u1ec7u n\u0103ng ch\u1ec9 trong v\u00e0i gi\u00e2y.<\/span><\/p>\n<div style=\"background-color: #eff6ff; padding: 20px; border: 1.5px solid #BFDBFE; border-radius: 12px; margin-bottom: 40px; box-shadow: 0 8px 20px rgba(37,99,235,0.05);\">\n<p style=\"font-family: 'Be Vietnam Pro', sans-serif; font-weight: bold; font-size: 18px; margin: 0 0 15px; color: #1e3a8a;\">N\u1ed8I DUNG B\u00c0I VI\u1ebeT<\/p>\n<ul style=\"list-style-type: none; padding-left: 0; margin: 0;\">\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section1\">1. L\u1ec7nh pidstat l\u00e0 g\u00ec? C\u01a1 ch\u1ebf gi\u00e1m s\u00e1t ti\u1ebfn tr\u00ecnh Linux nh\u01b0 th\u1ebf n\u00e0o?<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section2\">2. So s\u00e1nh l\u1ec7nh pidstat v\u1edbi top, htop, vmstat v\u00e0 iostat<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section3\">3. C\u00e1ch c\u00e0i \u0111\u1eb7t sysstat pidstat tr\u00ean Ubuntu, Debian, CentOS v\u00e0 RHEL<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section4\">4. C\u00fa ph\u00e1p v\u00e0 c\u00e1c tham s\u1ed1 quan tr\u1ecdng c\u1ee7a l\u1ec7nh pidstat<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section5\">5. H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng l\u1ec7nh pidstat ch\u1ea9n \u0111o\u00e1n l\u1ed7i CPU cao tr\u00ean VPS<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section6\">6. Theo d\u00f5i Disk I\/O v\u00e0 Memory chi ti\u1ebft theo t\u1eebng ti\u1ebfn tr\u00ecnh<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section7\">7. K\u1ebft h\u1ee3p pidstat v\u1edbi gi\u00e1m s\u00e1t t\u1ef1 \u0111\u1ed9ng v\u00e0 b\u1ea3o m\u1eadt h\u1ec7 th\u1ed1ng<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section8\">8. X\u1eed l\u00fd c\u00e1c l\u1ed7i th\u01b0\u1eddng g\u1eb7p khi th\u1ef1c thi l\u1ec7nh pidstat<\/a><\/li>\n<li style=\"margin-bottom: 10px;\"><a style=\"text-decoration: none; color: #2563eb; font-weight: bold;\" href=\"#section9\">9. C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 l\u1ec7nh pidstat (FAQ)<\/a><\/li>\n<\/ul>\n<\/div>\n\n\n<style>\n.interdata-plan-carousel,.interdata-plan-carousel *{box-sizing:border-box}\n.interdata-plan-carousel{--blue:#005bea;--blue-dark:#004dcc;--text:#071832;--muted:#516173;--border:#d8e6fb;--bg:#f3f8ff;--shadow:0 5px 14px rgba(0,62,145,.08);background:var(--bg);padding:14px 56px 18px;position:relative;overflow:hidden;border-radius:20px;}\n.interdata-carousel-heading{color:#f00;font-family:Roboto,sans-serif;font-size:18px;line-height:1.35;font-weight:800;text-align:center;margin:0 0 14px}\n.interdata-plan-viewport{overflow:hidden;width:100%}\n.interdata-plan-track{display:flex;align-items:stretch;gap:12px;overflow:visible;padding:0 0 4px;transform:translate3d(0,0,0);transition:transform .45s ease;will-change:transform;touch-action:pan-y}\n.interdata-plan-card{flex:0 0 calc((100% - 24px)\/3);min-width:0;min-height:0!important;height:auto;background:#fff;border:1px solid var(--border);border-radius:8px;padding:15px 12px 13px;display:flex;flex-direction:column;box-shadow:var(--shadow)}\n.interdata-plan-title{color:var(--blue-dark);font-size:16px;line-height:1.22;font-weight:800;text-align:center;margin:0 0 7px;text-transform:uppercase;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.interdata-plan-price{color:var(--blue-dark);font-size:24px;line-height:1;font-weight:900;text-align:center;margin-bottom:12px;white-space:nowrap;letter-spacing:0}\n.interdata-plan-price span{font-size:10px;font-weight:800;margin-left:2px}\n.interdata-plan-badge{align-self:center;display:inline-flex;align-items:center;justify-content:center;background:#ff3934;color:#fff;border-radius:5px;padding:7px 8px;font-size:9px;line-height:1;font-weight:800;margin-bottom:15px;white-space:nowrap;max-width:100%}\n.interdata-plan-features{list-style:none!important;padding:0!important;margin:0!important}\n.interdata-plan-features li{display:flex;gap:7px;align-items:flex-start;color:var(--text);font-size:12px;line-height:1.35;font-weight:700;text-align:left;margin:0 0 10px!important;padding:0!important}\n.interdata-plan-icon{width:14px;min-width:14px;height:14px;color:#0069ff;margin-top:2px}\n.interdata-plan-icon svg{display:block;width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}\n.interdata-plan-spacer{flex:1;min-height:16px}\n.interdata-plan-button{display:flex;align-items:center;justify-content:center;min-height:42px;width:100%;margin-top:auto!important;margin-bottom:0!important;background:var(--blue);color:#fff!important;border-radius:5px;font-size:13px;font-weight:800;text-decoration:none!important;box-shadow:0 7px 14px rgba(0,91,234,.24);transition:transform .2s ease,background .2s ease}\n.interdata-plan-button:hover{background:var(--blue-dark);color:#fff!important;transform:translateY(-1px)}\n.interdata-carousel-arrow{position:absolute;top:50%;z-index:5;width:44px;height:54px;border:2px solid #fff!important;border-radius:999px;background:var(--blue)!important;color:#fff!important;box-shadow:0 8px 22px rgba(0,62,145,.32);display:flex!important;align-items:center;justify-content:center;cursor:pointer;transform:translateY(-35%);transition:background .2s ease,color .2s ease,opacity .2s ease,transform .2s ease}\n.interdata-carousel-arrow:hover{background:var(--blue-dark)!important;color:#fff!important;transform:translateY(-35%) scale(1.04)}\n.interdata-carousel-arrow:disabled{opacity:.78;cursor:not-allowed;background:#8aa6cf!important;color:#fff!important}\n.interdata-carousel-arrow:disabled:hover{background:#8aa6cf!important;color:#fff!important;transform:translateY(-35%)}\n.interdata-carousel-arrow svg{display:none!important}\n.interdata-carousel-arrow:before{content:none!important;display:none!important}\n.interdata-carousel-mark{display:block!important;color:#fff!important;font-family:Arial,Helvetica,sans-serif!important;font-size:38px!important;font-weight:900!important;line-height:1!important;text-align:center!important;pointer-events:none!important;transform:translateY(-2px)}\n.interdata-carousel-prev{left:14px}\n.interdata-carousel-prev .interdata-carousel-mark{margin-left:-2px}\n.interdata-carousel-next{right:14px}\n.interdata-carousel-next .interdata-carousel-mark{margin-right:-2px}\n@media (max-width:800px){.interdata-plan-carousel{padding:12px 44px 16px}.interdata-plan-card{flex-basis:calc((100% - 12px)\/2)}.interdata-carousel-heading{font-size:16px}.interdata-carousel-prev{left:6px}.interdata-carousel-next{right:6px}}\n@media (max-width:480px){.interdata-plan-carousel{padding:12px 38px 16px}.interdata-plan-card{flex-basis:100%}.interdata-plan-price{font-size:23px}.interdata-carousel-arrow{width:34px;height:44px}.interdata-carousel-mark{font-size:32px!important}.interdata-carousel-prev{left:3px}.interdata-carousel-next{right:3px}}\n<\/style>\n\n<div class=\"interdata-plan-carousel\" data-interdata-carousel>\n  <div class=\"interdata-carousel-heading\">Si\u00eau \u01afu \u0110\u00e3i VPS \/ CLOUD SERVER - Ti\u1ebft Ki\u1ec7m \u0110\u1ebfn 70%<\/div>\n\n  <svg width=\"0\" height=\"0\" style=\"position:absolute;visibility:hidden\" aria-hidden=\"true\">\n    <symbol id=\"id-icon-cpu\" viewBox=\"0 0 24 24\"><rect x=\"7\" y=\"7\" width=\"10\" height=\"10\" rx=\"2\"><\/rect><path d=\"M4 9h3M4 15h3M17 9h3M17 15h3M9 4v3M15 4v3M9 17v3M15 17v3\"><\/path><path d=\"M10 10h4v4h-4z\"><\/path><\/symbol>\n    <symbol id=\"id-icon-ram\" viewBox=\"0 0 24 24\"><rect x=\"4\" y=\"8\" width=\"16\" height=\"8\" rx=\"2\"><\/rect><path d=\"M7 16v2M11 16v2M15 16v2M19 16v2M7 11h1M11 11h1M15 11h1\"><\/path><\/symbol>\n    <symbol id=\"id-icon-storage\" viewBox=\"0 0 24 24\"><rect x=\"6\" y=\"3\" width=\"12\" height=\"18\" rx=\"2\"><\/rect><path d=\"M9 7h6\"><\/path><circle cx=\"12\" cy=\"16\" r=\"1.5\"><\/circle><\/symbol>\n    <symbol id=\"id-icon-network\" viewBox=\"0 0 24 24\"><path d=\"M5 12.5a10 10 0 0 1 14 0\"><\/path><path d=\"M8.5 16a5 5 0 0 1 7 0\"><\/path><path d=\"M12 19h.01\"><\/path><\/symbol>\n    <symbol id=\"id-icon-gift\" viewBox=\"0 0 24 24\"><rect x=\"3\" y=\"8\" width=\"18\" height=\"13\" rx=\"2\"><\/rect><path d=\"M12 8v13M3 12h18\"><\/path><path d=\"M7.5 8C6.1 8 5 6.9 5 5.5S6.1 3 7.5 3C10 3 12 8 12 8\"><\/path><path d=\"M16.5 8C17.9 8 19 6.9 19 5.5S17.9 3 16.5 3C14 3 12 8 12 8\"><\/path><\/symbol>\n  <\/svg>\n\n  <button class=\"interdata-carousel-arrow interdata-carousel-prev\" type=\"button\" aria-label=\"Xem 3 g\u00f3i tr\u01b0\u1edbc\" onclick=\"var r=this.closest('[data-interdata-carousel]');if(!r)return false;var t=r.querySelector('.interdata-plan-track'),c=t?t.querySelectorAll('.interdata-plan-card'):[];if(!t||!c.length)return false;var v=window.matchMedia('(max-width:480px)').matches?1:(window.matchMedia('(max-width:800px)').matches?2:3),m=Math.max(0,c.length-Math.min(v,c.length||1)),s=[],i=0;while(i&lt;m){s.push(i);i+=v}if(!s.length||s[s.length-1]!==m)s.push(m);var p=parseInt(r.getAttribute('data-inline-page')||'0',10);p=(p-1+s.length)%s.length;r.setAttribute('data-inline-page',p);var g=parseFloat(window.getComputedStyle(t).gap)||12,w=c[0].getBoundingClientRect().width;t.style.transition='transform .45s ease';t.style.transform='translate3d('+(-(w+g)*s[p])+'px,0,0)';return false;\">\n    <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M15 18l-6-6 6-6\"><\/path><\/svg>\n    <span class=\"interdata-carousel-mark\" aria-hidden=\"true\">&#8249;<\/span>\n  <\/button>\n\n  <div class=\"interdata-plan-viewport\">\n    <div class=\"interdata-plan-track\">\n      <!-- 7 card d\u1ef1 ph\u00f2ng: JavaScript s\u1ebd \u0111\u1ed3ng b\u1ed9 l\u1ea1i t\u1eeb API portal khi trang t\u1ea3i. -->\n      <article class=\"interdata-plan-card\" data-plan-pid=\"490\">\n        <h3 class=\"interdata-plan-title\">Premium Base<\/h3>\n        <div class=\"interdata-plan-price\">299.000 \u0111<span>\/3 th\u00e1ng<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>2 vCore Intel Xeon Scalable<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>2 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>30 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/best-value-plans-2026\/best-value-plans-premium-base\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"529\">\n        <h3 class=\"interdata-plan-title\">INTER PLATINUM 1<\/h3>\n        <div class=\"interdata-plan-price\">998.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>2 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>3 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>30 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/inter-platinum-series-2026\/inter-platinum-1\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"530\">\n        <h3 class=\"interdata-plan-title\">INTER PLATINUM 2<\/h3>\n        <div class=\"interdata-plan-price\">2.666.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>5 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>8 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>70 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/inter-platinum-series-2026\/inter-platinum-2\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"531\">\n        <h3 class=\"interdata-plan-title\">INTER PLATINUM 3<\/h3>\n        <div class=\"interdata-plan-price\">5.888.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>9 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>16 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>140 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/inter-platinum-series-2026\/inter-platinum-3\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"521\">\n        <h3 class=\"interdata-plan-title\">BD-Cloud 1<\/h3>\n        <div class=\"interdata-plan-price\">988.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>3 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>3 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>30 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/best-plan-real-cloud\/bd-cloud-1\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"522\">\n        <h3 class=\"interdata-plan-title\">BD-Cloud 2<\/h3>\n        <div class=\"interdata-plan-price\">2.988.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>4 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>8 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>80 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>300 Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/best-plan-real-cloud\/bd-cloud-2\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n\n      <article class=\"interdata-plan-card\" data-plan-pid=\"523\">\n        <h3 class=\"interdata-plan-title\">BD-Cloud 3<\/h3>\n        <div class=\"interdata-plan-price\">5.999.000 \u0111<span>\/n\u0103m<\/span><\/div>\n        <div class=\"interdata-plan-badge\">GIA H\u1ea0N KH\u00d4NG \u0110\u1ed4I GI\u00c1<\/div>\n        <ul class=\"interdata-plan-features\">\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-cpu\"><\/use><\/svg><\/span>8 vCore<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-ram\"><\/use><\/svg><\/span>16 GB RAM<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-storage\"><\/use><\/svg><\/span>140 GB SSD NVMe<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>1 IPv4 Private<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>400 Mbps Network Port<\/li>\n          <li><span class=\"interdata-plan-icon\"><svg><use href=\"#id-icon-network\"><\/use><\/svg><\/span>Unlimited Bandwidth<\/li>\n        <\/ul>\n\n        <a class=\"interdata-plan-button\" href=\"https:\/\/support.interdata.vn\/index.php?rp=\/store\/best-plan-real-cloud\/bd-cloud-3\" target=\"_blank\" rel=\"noopener\">\u0110\u0103ng k\u00fd ngay<\/a>\n      <\/article>\n    <\/div>\n  <\/div>\n\n  <button class=\"interdata-carousel-arrow interdata-carousel-next\" type=\"button\" aria-label=\"Xem 3 g\u00f3i ti\u1ebfp theo\" onclick=\"var r=this.closest('[data-interdata-carousel]');if(!r)return false;var t=r.querySelector('.interdata-plan-track'),c=t?t.querySelectorAll('.interdata-plan-card'):[];if(!t||!c.length)return false;var v=window.matchMedia('(max-width:480px)').matches?1:(window.matchMedia('(max-width:800px)').matches?2:3),m=Math.max(0,c.length-Math.min(v,c.length||1)),s=[],i=0;while(i&lt;m){s.push(i);i+=v}if(!s.length||s[s.length-1]!==m)s.push(m);var p=parseInt(r.getAttribute('data-inline-page')||'0',10);p=(p+1)%s.length;r.setAttribute('data-inline-page',p);var g=parseFloat(window.getComputedStyle(t).gap)||12,w=c[0].getBoundingClientRect().width;t.style.transition='transform .45s ease';t.style.transform='translate3d('+(-(w+g)*s[p])+'px,0,0)';return false;\">\n    <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 18l6-6-6-6\"><\/path><\/svg>\n    <span class=\"interdata-carousel-mark\" aria-hidden=\"true\">&#8250;<\/span>\n  <\/button>\n<\/div>\n\n<script>\n(function(){\n  var API_GROUPS=[\n    {url:'https:\/\/support.interdata.vn\/packages.php?gid=89&module',pids:[490]},\n    {url:'https:\/\/support.interdata.vn\/packages.php?gid=100&module',pids:[529,530,531]},\n    {url:'https:\/\/support.interdata.vn\/packages.php?gid=97&module',pids:[521,522,523]}\n  ];\n  var PLAN_CYCLES={\n    490:{key:'quarterly',label:'3 th\u00e1ng'},\n    529:{key:'annually',label:'n\u0103m'},\n    530:{key:'annually',label:'n\u0103m'},\n    531:{key:'annually',label:'n\u0103m'},\n    521:{key:'annually',label:'n\u0103m'},\n    522:{key:'annually',label:'n\u0103m'},\n    523:{key:'annually',label:'n\u0103m'}\n  };\n\n  function fetchPlanData(){\n    if(window.interdataPlanApiPromise)return window.interdataPlanApiPromise;\n\n    window.interdataPlanApiPromise=Promise.all(API_GROUPS.map(function(group){\n      return fetch(group.url,{method:'GET',mode:'cors',cache:'no-store'})\n        .then(function(response){\n          if(!response.ok)throw new Error('API '+response.status);\n          return response.json();\n        })\n        .then(function(data){\n          if(!data||data.success!==true||!Array.isArray(data.products))return [];\n          return data.products.filter(function(product){\n            return group.pids.indexOf(Number(product.pid))!==-1;\n          });\n        })\n        .catch(function(error){\n          console.warn('Kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt nh\u00f3m g\u00f3i InterData:',group.url,error);\n          return [];\n        });\n    })).then(function(groups){\n      return groups.reduce(function(all,products){return all.concat(products);},[]);\n    });\n\n    return window.interdataPlanApiPromise;\n  }\n\n  function parseDescription(html){\n    var source=String(html||'')\n      .replace(\/<brs*\/?>\/gi,'n')\n      .replace(\/<\/(p|div|li)>\/gi,'n');\n    var holder=document.createElement('div');\n    holder.innerHTML=source;\n    var strong=holder.querySelector('strong');\n    var badge=strong?strong.textContent.trim():'';\n    var lines=(holder.textContent||'').split(\/r?n\/).map(function(line){\n      return line.trim();\n    }).filter(Boolean);\n    if(badge&&lines[0]===badge)lines.shift();\n    return {badge:badge,features:lines};\n  }\n\n  function iconForFeature(feature){\n    if(\/ram\/i.test(feature))return 'id-icon-ram';\n    if(\/ssd|nvme|storage|disk\/i.test(feature))return 'id-icon-storage';\n    if(\/vcore|vcpu|cpu|xeon|amd\/i.test(feature))return 'id-icon-cpu';\n    if(\/ipv4|network|mbps|gbps|bandwidth\/i.test(feature))return 'id-icon-network';\n    return 'id-icon-gift';\n  }\n\n  function createFeatureItem(feature){\n    var item=document.createElement('li');\n    var icon=document.createElement('span');\n    var svg=document.createElementNS('http:\/\/www.w3.org\/2000\/svg','svg');\n    var use=document.createElementNS('http:\/\/www.w3.org\/2000\/svg','use');\n    icon.className='interdata-plan-icon';\n    use.setAttribute('href','#'+iconForFeature(feature));\n    svg.appendChild(use);\n    icon.appendChild(svg);\n    item.appendChild(icon);\n    item.appendChild(document.createTextNode(feature));\n    return item;\n  }\n\n  function updateCardFromApi(root,product){\n    var pid=Number(product.pid);\n    var cycle=PLAN_CYCLES[pid];\n    var card=root.querySelector('[data-plan-pid=\"'+pid+'\"]');\n    if(!card||!cycle)return;\n\n    var title=card.querySelector('.interdata-plan-title');\n    var priceBox=card.querySelector('.interdata-plan-price');\n    var badgeBox=card.querySelector('.interdata-plan-badge');\n    var featureList=card.querySelector('.interdata-plan-features');\n    var button=card.querySelector('.interdata-plan-button');\n    var description=parseDescription(product.description);\n    var pricing=product.pricing&&product.pricing.VND;\n    var price=pricing?Number(pricing[cycle.key]):-1;\n\n    if(title&&product.name)title.textContent=product.name;\n    if(priceBox&&Number.isFinite(price)&&price>=0){\n      priceBox.textContent=Math.round(price).toLocaleString('vi-VN')+' \u0111';\n      var suffix=document.createElement('span');\n      suffix.textContent='\/'+cycle.label;\n      priceBox.appendChild(suffix);\n    }\n    if(badgeBox&&description.badge)badgeBox.textContent=description.badge;\n    if(featureList&&description.features.length){\n      featureList.textContent='';\n      description.features.forEach(function(feature){\n        featureList.appendChild(createFeatureItem(feature));\n      });\n    }\n    if(button&&product.product_url)button.href=product.product_url;\n  }\n\n  function setupInterDataCarousel(root){\n    var track=root.querySelector('.interdata-plan-track');\n    var prev=root.querySelector('.interdata-carousel-prev');\n    var next=root.querySelector('.interdata-carousel-next');\n    if(!track||!prev||!next||track.dataset.ready==='1')return;\n    track.dataset.ready='1';\n    prev.disabled=false;\n    next.disabled=false;\n    var activePage=0;\n    var touchStartX=null;\n\n    function visibleCards(){\n      if(window.matchMedia&&window.matchMedia('(max-width:480px)').matches)return 1;\n      if(window.matchMedia&&window.matchMedia('(max-width:800px)').matches)return 2;\n      return 3;\n    }\n\n    function pageStarts(){\n      var total=track.querySelectorAll('.interdata-plan-card').length;\n      var visible=Math.min(visibleCards(),total||1);\n      var maxStart=Math.max(0,total-visible);\n      var starts=[];\n      var start=0;\n      while(start<maxStart){\n        starts.push(start);\n        start+=visible;\n      }\n      if(!starts.length||starts[starts.length-1]!==maxStart)starts.push(maxStart);\n      return starts;\n    }\n\n    function renderSlide(animate){\n      var cards=track.querySelectorAll('.interdata-plan-card');\n      var starts=pageStarts();\n      if(!cards.length||!starts.length)return;\n      if(activePage>=starts.length)activePage=starts.length-1;\n      if(activePage<0)activePage=0;\n\n      var cardWidth=cards[0].getBoundingClientRect().width;\n      var trackStyle=window.getComputedStyle?window.getComputedStyle(track):null;\n      var gap=trackStyle?parseFloat(trackStyle.columnGap||trackStyle.gap):12;\n      if(!Number.isFinite(gap))gap=12;\n      if(cardWidth<=0)return;\n\n      track.style.transition=animate?'transform .45s ease':'none';\n      track.style.transform='translate3d('+(-(cardWidth+gap)*starts[activePage])+'px,0,0)';\n      prev.setAttribute('aria-disabled',starts.length>1?'false':'true');\n      next.setAttribute('aria-disabled',starts.length>1?'false':'true');\n    }\n\n    function move(direction){\n      var starts=pageStarts();\n      if(starts.length<=1)return;\n      activePage=parseInt(root.getAttribute('data-inline-page')||activePage,10)||0;\n      activePage=(activePage+direction+starts.length)%starts.length;\n      root.setAttribute('data-inline-page',activePage);\n      renderSlide(true);\n    }\n\n    track.addEventListener('touchstart',function(event){\n      touchStartX=event.touches&&event.touches[0]?event.touches[0].clientX:null;\n    },{passive:true});\n    track.addEventListener('touchend',function(event){\n      if(touchStartX===null)return;\n      var endX=event.changedTouches&&event.changedTouches[0]?event.changedTouches[0].clientX:touchStartX;\n      var distance=endX-touchStartX;\n      touchStartX=null;\n      if(Math.abs(distance)>=40)move(distance<0?1:-1);\n    },{passive:true});\n\n    function resetAfterResize(){\n      activePage=0;\n      root.setAttribute('data-inline-page','0');\n      renderSlide(false);\n    }\n\n    window.addEventListener('resize',resetAfterResize);\n    window.addEventListener('load',resetAfterResize);\n    if('ResizeObserver' in window){\n      var resizeObserver=new ResizeObserver(function(){renderSlide(false);});\n      resizeObserver.observe(root);\n    }\n    window.requestAnimationFrame(function(){renderSlide(false);});\n    window.setTimeout(function(){renderSlide(false);},250);\n    window.setTimeout(function(){renderSlide(false);},1000);\n\n    fetchPlanData().then(function(products){\n      products.forEach(function(product){updateCardFromApi(root,product);});\n      renderSlide(false);\n    });\n  }\n\n  function initInterDataCarousels(){\n    document.querySelectorAll('[data-interdata-carousel]').forEach(setupInterDataCarousel);\n  }\n\n  if(document.readyState==='loading'){\n    document.addEventListener('DOMContentLoaded',initInterDataCarousels);\n  }else{\n    initInterDataCarousels();\n  }\n\n  if('MutationObserver' in window){\n    var initQueued=false;\n    new MutationObserver(function(){\n      if(initQueued)return;\n      initQueued=true;\n      window.requestAnimationFrame(function(){\n        initQueued=false;\n        initInterDataCarousels();\n      });\n    }).observe(document.documentElement,{childList:true,subtree:true});\n  }\n})();\n<\/script>\n\n\t<div id=\"gap-2013979718\" class=\"gap-element clearfix\" style=\"display:block; height:auto;\">\n\t\t\n<style>\n#gap-2013979718 {\n  padding-top: 15px;\n}\n<\/style>\n\t<\/div>\n\t\n<h2 id=\"section1\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">1. L\u1ec7nh pidstat l\u00e0 g\u00ec? C\u01a1 ch\u1ebf gi\u00e1m s\u00e1t ti\u1ebfn tr\u00ecnh Linux nh\u01b0 th\u1ebf n\u00e0o?<\/h2>\n<p style=\"text-align: justify;\"><strong>L\u1ec7nh pidstat<\/strong> l\u00e0 m\u1ed9t ti\u1ec7n \u00edch d\u00f2ng l\u1ec7nh m\u1ea1nh m\u1ebd thu\u1ed9c b\u1ed9 c\u00f4ng c\u1ee5 sysstat package tr\u00ean h\u1ec7 \u0111i\u1ec1u h\u00e0nh Linux. L\u1ec7nh n\u00e0y \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 theo d\u00f5i c\u00e1c t\u00e1c v\u1ee5 (tasks\/processes) v\u00e0 lu\u1ed3ng (threads) \u0111ang \u0111\u01b0\u1ee3c qu\u1ea3n l\u00fd b\u1edfi Linux kernel, xu\u1ea5t d\u1eef li\u1ec7u \u0111\u1ecbnh k\u1ef3 theo t\u1eebng kho\u1ea3ng th\u1eddi gian x\u00e1c \u0111\u1ecbnh.<\/p>\n<p style=\"text-align: justify;\">Kh\u00e1c v\u1edbi c\u00e1c c\u00f4ng c\u1ee5 t\u1ed5ng quan trong danh m\u1ee5c <a href=\"https:\/\/interdata.vn\/blog\/cac-lenh-linux-thong-dung\/\">c\u00e1c l\u1ec7nh Linux c\u01a1 b\u1ea3n<\/a>, pidstat kh\u00f4ng hi\u1ec3n th\u1ecb t\u00e0i nguy\u00ean g\u1ed9p c\u1ee7a to\u00e0n h\u1ec7 \u0111i\u1ec1u h\u00e0nh m\u00e0 b\u00f3c t\u00e1ch chi ti\u1ebft t\u1eebng Process ID (PID). C\u00f4ng c\u1ee5 \u0111\u1ecdc tr\u1ef1c ti\u1ebfp d\u1eef li\u1ec7u t\u1eeb h\u1ec7 th\u1ed1ng t\u1eadp tin \u1ea3o <code>\/proc<\/code> (nh\u01b0 <code>\/proc\/[PID]\/stat<\/code>, <code>\/proc\/[PID]\/io<\/code>, <code>\/proc\/[PID]\/status<\/code>) \u0111\u1ec3 t\u00ednh to\u00e1n delta (\u0111\u1ed9 bi\u1ebfn thi\u00ean) gi\u1eefa hai l\u1ea7n l\u1ea5y m\u1eabu, t\u1eeb \u0111\u00f3 mang l\u1ea1i k\u1ebft qu\u1ea3 chu\u1ea9n x\u00e1c v\u1ec1:<\/p>\n<ul style=\"line-height: 1.8; text-align: justify;\">\n<li><strong>M\u1ee9c s\u1eed d\u1ee5ng CPU:<\/strong> Ph\u00e2n chia r\u1ea1ch r\u00f2i gi\u1eefa th\u1eddi gian x\u1eed l\u00fd \u1edf kh\u00f4ng gian ng\u01b0\u1eddi d\u00f9ng (<code>%usr<\/code>) v\u00e0 th\u1eddi gian th\u1ef1c thi trong nh\u00e2n Linux kernel (<code>%system<\/code>), c\u0169ng nh\u01b0 \u0111\u1ed9 tr\u1ec5 ch\u1edd CPU (<code>%wait<\/code>).<\/li>\n<li><strong>M\u1ee9c s\u1eed d\u1ee5ng RAM:<\/strong> Theo d\u00f5i dung l\u01b0\u1ee3ng b\u1ed9 nh\u1edb \u1ea3o (VSZ), b\u1ed9 nh\u1edb th\u1ef1c \u0111ang d\u00f9ng (RSS) v\u00e0 t\u1ec9 l\u1ec7 chi\u1ebfm d\u1ee5ng ph\u1ea7n tr\u0103m b\u1ed9 nh\u1edb (<code>%MEM<\/code>).<\/li>\n<li><strong>Ho\u1ea1t \u0111\u1ed9ng Disk I\/O:<\/strong> T\u1ed1c \u0111\u1ed9 \u0111\u1ecdc (kB_rd\/s), t\u1ed1c \u0111\u1ed9 ghi (kB_wr\/s) v\u00e0 t\u1ec9 l\u1ec7 t\u00e1c v\u1ee5 b\u1ecb ho\u00e3n do ch\u1edd \u0111\u0129a (<code>%wait<\/code> \/ I\/O delay).<\/li>\n<li><strong>Chuy\u1ec3n ng\u1eef c\u1ea3nh (Context Switches):<\/strong> S\u1ed1 l\u1ea7n t\u1ef1 nguy\u1ec7n \u0111\u1ed5i ng\u1eef c\u1ea3nh (<code>cswch\/s<\/code>) ho\u1eb7c b\u1ecb \u00e9p bu\u1ed9c nh\u01b0\u1eddng CPU (<code>nvcswch\/s<\/code>) c\u1ee7a t\u1eebng t\u00e1c v\u1ee5.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-43756\" src=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Lenh-pidstat.png\" alt=\"L\u1ec7nh pidstat\" width=\"1000\" height=\"902\" title=\"\" srcset=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Lenh-pidstat.png 1020w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Lenh-pidstat-300x271.png 300w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Lenh-pidstat-768x693.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<div style=\"display: flex; flex-wrap: wrap; background-color: #fff; border: 1.5px solid #BFDBFE; box-shadow: 0 8px 20px rgba(37,99,235,0.08); border-radius: 12px; overflow: hidden; margin: 35px 0;\">\n<div style=\"flex: 1; min-width: 250px; background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%); display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center;\">\n<div>\n<p style=\"color: #fff; font-size: 34px; font-family: 'Be Vietnam Pro', sans-serif; font-weight: bold; margin: 0; line-height: 1.1;\">Thu\u00ea VPS InterData<\/p>\n<p style=\"color: #dbeafe; font-size: 15px; font-weight: 600; margin-top: 12px;\">CPU th\u1ebf h\u1ec7 m\u1edbi, SSD NVMe U.2, h\u1ed7 tr\u1ee3 k\u1ef9 thu\u1eadt 24\/7<\/p>\n<\/div>\n<\/div>\n<div style=\"flex: 2; padding: 25px; min-width: 300px;\">\n<h3 style=\"font-family: 'Be Vietnam Pro', sans-serif; color: #1e3a8a; margin-top: 0; font-size: 20px;\">C\u1ea7n m\u00f4i tr\u01b0\u1eddng m\u00e1y ch\u1ee7 \u0111\u1ed9c l\u1eadp t\u00e0i nguy\u00ean \u0111\u1ec3 v\u1eadn h\u00e0nh h\u1ec7 th\u1ed1ng?<\/h3>\n<p style=\"text-align: justify; font-size: 15px; margin-bottom: 15px;\">Tri\u1ec3n khai website, database hay \u1ee9ng d\u1ee5ng tr\u00ean VPS Linux ri\u00eang bi\u1ec7t gi\u00fap b\u1ea1n l\u00e0m ch\u1ee7 100% CPU, RAM v\u00e0 Disk I\/O v\u1edbi quy\u1ec1n root tuy\u1ec7t \u0111\u1ed1i. H\u1ea1 t\u1ea7ng \u1ed5 c\u1ee9ng SSD NVMe U.2 t\u1ed1c \u0111\u1ed9 cao t\u1ea1i InterData gi\u00fap lo\u1ea1i b\u1ecf tri\u1ec7t \u0111\u1ec3 hi\u1ec7n t\u01b0\u1ee3ng ngh\u1ebdn I\/O hay tranh ch\u1ea5p t\u00e0i nguy\u00ean t\u1eeb c\u00e1c ti\u1ebfn tr\u00ecnh l\u00e2n c\u1eadn.<\/p>\n<p><a style=\"background: linear-gradient(90deg, #2563EB 0%, #1E3A8A 100%); color: #fff; padding: 12px 25px; text-decoration: none; font-weight: 600; border-radius: 8px; font-size: 15px; display: inline-block; box-shadow: 0 5px 15px rgba(37,99,235,0.3);\" href=\"https:\/\/interdata.vn\/thue-vps\/\" target=\"_blank\" rel=\"noopener\">Xem B\u1ea3ng Gi\u00e1 Thu\u00ea VPS \u27f6<\/a><\/p>\n<\/div>\n<\/div>\n<h2 id=\"section2\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">2. So s\u00e1nh l\u1ec7nh pidstat v\u1edbi top, htop, vmstat v\u00e0 iostat<\/h2>\n<p style=\"text-align: justify;\">Trong h\u1ec7 sinh th\u00e1i qu\u1ea3n tr\u1ecb Linux, m\u1ed7i c\u00f4ng c\u1ee5 \u0111\u01b0\u1ee3c thi\u1ebft k\u1ebf ph\u1ee5c v\u1ee5 m\u1ed9t g\u00f3c nh\u00ecn k\u1ef9 thu\u1eadt kh\u00e1c nhau. Trong khi c\u00e1c l\u1ec7nh nh\u01b0 top ho\u1eb7c htop cung c\u1ea5p giao di\u1ec7n t\u01b0\u01a1ng t\u00e1c to\u00e0n c\u1ea3nh, <code>pidstat<\/code> l\u1ea1i v\u01b0\u1ee3t tr\u1ed9i khi c\u1ea7n xu\u1ea5t log l\u1ecbch s\u1eed theo th\u1eddi gian v\u00e0 ph\u00e2n t\u00edch s\u00e2u theo lu\u1ed3ng c\u1ee7a t\u1eebng \u1ee9ng d\u1ee5ng.<\/p>\n<table style=\"width: 100%; border-collapse: collapse; margin: 25px 0; font-size: 14px; text-align: left; border: 1px solid #CBD5E1;\">\n<thead>\n<tr style=\"background-color: #1e3a8a; color: #ffffff;\">\n<th style=\"padding: 12px; border: 1px solid #CBD5E1;\">Ti\u00eau ch\u00ed so s\u00e1nh<\/th>\n<th style=\"padding: 12px; border: 1px solid #CBD5E1;\">L\u1ec7nh pidstat<\/th>\n<th style=\"padding: 12px; border: 1px solid #CBD5E1;\">L\u1ec7nh top \/ htop<\/th>\n<th style=\"padding: 12px; border: 1px solid #CBD5E1;\">L\u1ec7nh vmstat \/ iostat<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background-color: #f8fafc;\">\n<td style=\"padding: 10px; border: 1px solid #CBD5E1; font-weight: 600;\">Ph\u1ea1m vi gi\u00e1m s\u00e1t<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">T\u1eebng ti\u1ebfn tr\u00ecnh (PID) v\u00e0 lu\u1ed3ng (Thread)<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">To\u00e0n b\u1ed9 h\u1ec7 th\u1ed1ng + danh s\u00e1ch top PID<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">To\u00e0n h\u1ec7 th\u1ed1ng ho\u1eb7c theo t\u1eebng ph\u00e2n v\u00f9ng \u0111\u0129a<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1; font-weight: 600;\">\u0110\u1ed9 chi ti\u1ebft Disk I\/O<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">B\u00f3c t\u00e1ch I\/O theo t\u1eebng ti\u1ebfn tr\u00ecnh ri\u00eang bi\u1ec7t<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">Kh\u00f4ng c\u00f3 ho\u1eb7c r\u1ea5t s\u01a1 s\u00e0i (ch\u1ec9 th\u1ea5y I\/O chung)<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">Chi ti\u1ebft theo Block Device (sda, nvme0n1)<\/td>\n<\/tr>\n<tr style=\"background-color: #f8fafc;\">\n<td style=\"padding: 10px; border: 1px solid #CBD5E1; font-weight: 600;\">Kh\u1ea3 n\u0103ng xu\u1ea5t d\u1eef li\u1ec7u (Log)<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">R\u1ea5t t\u1ed1t, d\u1ec5 parse ra file text ho\u1eb7c CSV<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">Kh\u00f3 ghi log t\u1ef1 \u0111\u1ed9ng do giao di\u1ec7n ncurses<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">R\u1ea5t t\u1ed1t theo d\u00f2ng th\u1eddi gian<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1; font-weight: 600;\">Gi\u00e1m s\u00e1t Context Switch<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">H\u1ed7 tr\u1ee3 \u0111o l\u01b0\u1eddng chi ti\u1ebft cho t\u1eebng PID<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">Kh\u00f4ng h\u1ed7 tr\u1ee3<\/td>\n<td style=\"padding: 10px; border: 1px solid #CBD5E1;\">Ch\u1ec9 hi\u1ec3n th\u1ecb t\u1ed5ng context switch to\u00e0n h\u1ec7 th\u1ed1ng<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: justify;\">Khi b\u1ea1n ch\u1ec9 c\u1ea7n nh\u00ecn l\u01b0\u1edbt \u0111\u1ec3 bi\u1ebft CPU \u0111ang \u0111\u1ea7y hay r\u1ed7ng, <code>top<\/code> ho\u1eb7c <code>htop<\/code> l\u00e0 l\u1ef1a ch\u1ecdn nhanh. Tuy nhi\u00ean, khi c\u1ea7n t\u00ecm ra ch\u00ednh x\u00e1c thread n\u00e0o c\u1ee7a MySQL \u0111ang g\u00e2y I\/O ngh\u1ebdn ho\u1eb7c \u1ee9ng d\u1ee5ng Java n\u00e0o \u0111ang chuy\u1ec3n ng\u1eef c\u1ea3nh qu\u00e1 m\u1ee9c, <strong>l\u1ec7nh pidstat<\/strong> l\u00e0 c\u00f4ng c\u1ee5 chuy\u00ean tr\u00e1ch kh\u00f4ng th\u1ec3 thay th\u1ebf.<\/p>\n<h2 id=\"section3\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">3. C\u00e1ch c\u00e0i \u0111\u1eb7t sysstat pidstat tr\u00ean Ubuntu, Debian, CentOS v\u00e0 RHEL<\/h2>\n<p style=\"text-align: justify;\">Ti\u1ec7n \u00edch pidstat kh\u00f4ng ph\u1ea3i l\u00fac n\u00e0o c\u0169ng \u0111\u01b0\u1ee3c c\u00e0i m\u1eb7c \u0111\u1ecbnh tr\u00ean c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i Linux t\u1ed1i gi\u1ea3n. \u0110\u1ec3 s\u1eed d\u1ee5ng, b\u1ea1n c\u1ea7n c\u00e0i \u0111\u1eb7t g\u00f3i <code>sysstat<\/code> t\u01b0\u01a1ng \u1ee9ng v\u1edbi h\u1ec7 \u0111i\u1ec1u h\u00e0nh \u0111ang v\u1eadn h\u00e0nh tr\u00ean m\u00e1y ch\u1ee7.<\/p>\n<h3 style=\"color: #2563eb; font-size: 18px; font-weight: 600; margin: 25px 0 10px;\">3.1. C\u00e0i \u0111\u1eb7t tr\u00ean h\u1ec7 \u0111i\u1ec1u h\u00e0nh Ubuntu v\u00e0 Debian<\/h3>\n<p style=\"text-align: justify;\">C\u00e1c b\u01b0\u1edbc c\u00e0i \u0111\u1eb7t v\u00e0 k\u00edch ho\u1ea1t d\u1ecbch v\u1ee5 thu th\u1eadp d\u1eef li\u1ec7u sysstat tr\u00ean Ubuntu\/Debian:<\/p>\n<p>1\/ C\u1eadp nh\u1eadt danh s\u00e1ch g\u00f3i ph\u1ea7n m\u1ec1m tr\u00ean h\u1ec7 th\u1ed1ng:<\/p>\n<pre><code class=\"language-bash\">sudo apt update<\/code><\/pre>\n<p>2\/ Ti\u1ebfn h\u00e0nh c\u00e0i \u0111\u1eb7t g\u00f3i sysstat:<\/p>\n<pre><code class=\"language-bash\">sudo apt install sysstat -y<\/code><\/pre>\n<p>3\/ K\u00edch ho\u1ea1t t\u00ednh n\u0103ng thu th\u1eadp d\u1eef li\u1ec7u ng\u1ea7m b\u1eb1ng c\u00e1ch c\u1ea5u h\u00ecnh file <code>\/etc\/default\/sysstat<\/code>:<\/p>\n<pre><code class=\"language-bash\">sudo sed -i 's\/ENABLED=\"false\"\/ENABLED=\"true\"\/' \/etc\/default\/sysstat<\/code><\/pre>\n<p>4\/ Kh\u1edfi \u0111\u1ed9ng l\u1ea1i v\u00e0 b\u1eadt t\u1ef1 ch\u1ea1y d\u1ecbch v\u1ee5:<\/p>\n<pre><code class=\"language-bash\">sudo systemctl enable --now sysstat\r\nsudo systemctl status sysstat<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-43752\" src=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Cai-dat-goi-sysstat-tren-Ubuntu.png\" alt=\"C\u00e0i \u0111\u1eb7t g\u00f3i sysstat tr\u00ean Ubuntu\" width=\"1000\" height=\"622\" title=\"\" srcset=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Cai-dat-goi-sysstat-tren-Ubuntu.png 1568w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Cai-dat-goi-sysstat-tren-Ubuntu-300x187.png 300w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Cai-dat-goi-sysstat-tren-Ubuntu-1024x637.png 1024w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Cai-dat-goi-sysstat-tren-Ubuntu-768x478.png 768w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Cai-dat-goi-sysstat-tren-Ubuntu-1536x956.png 1536w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<h3 style=\"color: #2563eb; font-size: 18px; font-weight: 600; margin: 25px 0 10px;\">3.2. C\u00e0i \u0111\u1eb7t tr\u00ean CentOS, RHEL, AlmaLinux v\u00e0 Rocky Linux<\/h3>\n<p style=\"text-align: justify;\">\u0110\u1ed1i v\u1edbi c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i s\u1eed d\u1ee5ng tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i YUM ho\u1eb7c DNF:<\/p>\n<p>1\/ Ch\u1ea1y l\u1ec7nh c\u00e0i \u0111\u1eb7t g\u00f3i sysstat:<\/p>\n<pre><code class=\"language-bash\">sudo dnf install sysstat -y\r\n# Ho\u1eb7c tr\u00ean CentOS 7 c\u0169:\r\nsudo yum install sysstat -y<\/code><\/pre>\n<p>2\/ Kh\u1edfi ch\u1ea1y v\u00e0 thi\u1ebft l\u1eadp kh\u1edfi \u0111\u1ed9ng c\u00f9ng h\u1ec7 th\u1ed1ng:<\/p>\n<pre><code class=\"language-bash\">sudo systemctl enable --now sysstat\r\nsudo systemctl status sysstat<\/code><\/pre>\n<p>3\/ Ki\u1ec3m tra xem l\u1ec7nh \u0111\u00e3 ho\u1ea1t \u0111\u1ed9ng th\u00e0nh c\u00f4ng hay ch\u01b0a:<\/p>\n<pre><code class=\"language-bash\">pidstat -V<\/code><\/pre>\n<h2 id=\"section4\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">4. C\u00fa ph\u00e1p v\u00e0 c\u00e1c tham s\u1ed1 quan tr\u1ecdng c\u1ee7a l\u1ec7nh pidstat<\/h2>\n<p style=\"text-align: justify;\">C\u00fa ph\u00e1p c\u01a1 b\u1ea3n c\u1ee7a l\u1ec7nh pidstat tr\u00ean terminal nh\u01b0 sau:<\/p>\n<pre><code class=\"language-bash\">pidstat [t\u00f9y_ch\u1ecdn] [kho\u1ea3ng_th\u1eddi_gian] [s\u1ed1_l\u1ea7n_l\u1eb7p]<\/code><\/pre>\n<p style=\"text-align: justify;\">V\u00ed d\u1ee5, khi b\u1ea1n ch\u1ea1y <code>pidstat 2 5<\/code>, h\u1ec7 th\u1ed1ng s\u1ebd \u0111o l\u01b0\u1eddng t\u00e0i nguy\u00ean m\u1ed7i 2 gi\u00e2y m\u1ed9t l\u1ea7n v\u00e0 th\u1ef1c hi\u1ec7n l\u1eb7p l\u1ea1i 5 l\u1ea7n, sau \u0111\u00f3 hi\u1ec3n th\u1ecb b\u1ea3ng t\u1ed5ng k\u1ebft gi\u00e1 tr\u1ecb trung b\u00ecnh (Average).<\/p>\n<p style=\"text-align: justify;\">C\u00e1c tham s\u1ed1 th\u01b0\u1eddng d\u00f9ng nh\u1ea5t trong th\u1ef1c t\u1ebf bao g\u1ed3m:<\/p>\n<ul style=\"line-height: 1.8; text-align: justify;\">\n<li><code>-u<\/code>: Gi\u00e1m s\u00e1t m\u1ee9c ti\u00eau th\u1ee5 CPU c\u1ee7a c\u00e1c ti\u1ebfn tr\u00ecnh (tham s\u1ed1 m\u1eb7c \u0111\u1ecbnh khi kh\u00f4ng khai b\u00e1o t\u00f9y ch\u1ecdn kh\u00e1c).<\/li>\n<li><code>-r<\/code>: \u0110o l\u01b0\u1eddng m\u1ee9c chi\u1ebfm d\u1ee5ng b\u1ed9 nh\u1edb RAM, ph\u00e2n trang (page faults) v\u00e0 t\u1ec9 l\u1ec7 r\u00f2 r\u1ec9 b\u1ed9 nh\u1edb.<\/li>\n<li><code>-d<\/code>: Gi\u00e1m s\u00e1t ho\u1ea1t \u0111\u1ed9ng \u0111\u1ecdc\/ghi d\u1eef li\u1ec7u \u1ed5 c\u1ee9ng (Disk I\/O) theo t\u1eebng PID.<\/li>\n<li><code>-w<\/code>: Th\u1ed1ng k\u00ea s\u1ed1 l\u1ea7n chuy\u1ec3n ng\u1eef c\u1ea3nh (Context Switching) c\u1ee7a ti\u1ebfn tr\u00ecnh.<\/li>\n<li><code>-p &lt;PID&gt;<\/code>: Ch\u1ec9 \u0111\u1ecbnh m\u1ed9t Process ID c\u1ee5 th\u1ec3 c\u1ea7n theo d\u00f5i (ho\u1eb7c d\u00f9ng <code>-p ALL<\/code> cho t\u1ea5t c\u1ea3).<\/li>\n<li><code>-t<\/code>: Hi\u1ec3n th\u1ecb chi ti\u1ebft theo t\u1eebng Thread b\u00ean trong ti\u1ebfn tr\u00ecnh thay v\u00ec ch\u1ec9 gom nh\u00f3m theo Task.<\/li>\n<li><code>-l<\/code>: Hi\u1ec3n th\u1ecb \u0111\u1ea7y \u0111\u1ee7 t\u00ean ti\u1ebfn tr\u00ecnh c\u00f9ng v\u1edbi c\u00e1c tham s\u1ed1 d\u00f2ng l\u1ec7nh kh\u1edfi ch\u1ea1y.<\/li>\n<li><code>-C &lt;t\u00ean_chu\u1ed7i&gt;<\/code>: L\u1ecdc danh s\u00e1ch ti\u1ebfn tr\u00ecnh ch\u1ee9a t\u00ean ch\u1ec9 \u0111\u1ecbnh (v\u00ed d\u1ee5: <code>pidstat -C nginx<\/code>).<\/li>\n<\/ul>\n<div style=\"background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%); border: 1.5px solid #2563EB; border-radius: 12px; padding: 28px; margin: 35px 0; text-align: center;\">\n<p style=\"font-family: 'Be Vietnam Pro', sans-serif; font-size: 22px; font-weight: bold; color: #1e3a8a; margin: 0 0 8px;\">S\u0103n \u01afu \u0110\u00e3i Ti\u1ebft Ki\u1ec7m<\/p>\n<p style=\"font-size: 15px; color: #4b5563; margin-bottom: 20px;\">Canh Me t\u1ed5ng h\u1ee3p khuy\u1ebfn m\u00e3i, m\u00e3 gi\u1ea3m gi\u00e1, Hot Deals VPS v\u00e0 Cloud Server m\u1edbi nh\u1ea5t c\u1ee7a InterData \u2014 xem tr\u01b0\u1edbc \u0111\u1ec3 ch\u1ecdn c\u1ea5u h\u00ecnh ph\u00f9 h\u1ee3p v\u1edbi chi ph\u00ed t\u1ed1t nh\u1ea5t.<\/p>\n<p><a style=\"background: #2563EB; color: #fff; padding: 12px 30px; text-decoration: none; font-weight: 600; border-radius: 8px; display: inline-block;\" href=\"https:\/\/interdata.vn\/canhme\/\" target=\"_blank\" rel=\"noopener\">Xem Hot Deals T\u1ea1i Canh Me \u27f6<\/a><\/p>\n<\/div>\n<h2 id=\"section5\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">5. H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng l\u1ec7nh pidstat ch\u1ea9n \u0111o\u00e1n l\u1ed7i CPU cao tr\u00ean VPS<\/h2>\n<p style=\"text-align: justify;\">Khi ki\u1ec3m tra h\u1ec7 th\u1ed1ng theo b\u00e0i vi\u1ebft <a href=\"https:\/\/interdata.vn\/blog\/huong-dan-su-dung-vps\/\">h\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng VPS<\/a> v\u00e0 ph\u00e1t hi\u1ec7n Load Average t\u0103ng \u0111\u1ed9t bi\u1ebfn, b\u1ea1n c\u1ea7n d\u00f9ng <strong>l\u1ec7nh pidstat<\/strong> \u0111\u1ec3 t\u00ecm ra ch\u00ednh x\u00e1c d\u1ecbch v\u1ee5 n\u00e0o \u0111ang chi\u1ebfm gi\u1eef CPU cores.<\/p>\n<h3 style=\"color: #2563eb; font-size: 18px; font-weight: 600; margin: 25px 0 10px;\">5.1. Gi\u00e1m s\u00e1t CPU t\u1ed5ng qu\u00e1t c\u1ee7a t\u1ea5t c\u1ea3 ti\u1ebfn tr\u00ecnh<\/h3>\n<p style=\"text-align: justify;\">\u0110\u1ec3 l\u1ea5y m\u1eabu CPU m\u1ed7i 2 gi\u00e2y trong 3 l\u1ea7n l\u1eb7p:<\/p>\n<pre><code class=\"language-bash\">pidstat -u 2 3<\/code><\/pre>\n<p style=\"text-align: justify;\">D\u1eef li\u1ec7u \u0111\u1ea7u ra m\u1eabu tr\u00ean m\u00e0n h\u00ecnh terminal:<\/p>\n<pre><code class=\"language-text\">14:10:02      UID       PID    %usr %system  %guest   %wait    %CPU   CPU  Command\r\n14:10:04     1000      2145   68.50   12.00    0.00    1.50   80.50     1  mysqld\r\n14:10:04       33      3421   15.00    4.00    0.00    0.50   19.00     0  php-fpm\r\n14:10:04        0       120    0.00    0.50    0.00    0.00    0.50     1  kworker\/u4:1<\/code><\/pre>\n<p style=\"text-align: justify;\">\u00dd ngh\u0129a c\u00e1c ch\u1ec9 s\u1ed1 c\u1ea7n l\u01b0u \u00fd khi ph\u00e2n t\u00edch:<\/p>\n<ul style=\"line-height: 1.8; text-align: justify;\">\n<li><strong>%usr:<\/strong> T\u1ec9 l\u1ec7 CPU ti\u00eau th\u1ee5 \u1edf User Level. N\u1ebfu ch\u1ec9 s\u1ed1 n\u00e0y cao v\u1ecdt \u1edf c\u00e1c ti\u1ebfn tr\u00ecnh nh\u01b0 <code>php-fpm<\/code> ho\u1eb7c <code>mysqld<\/code>, nguy\u00ean nh\u00e2n th\u01b0\u1eddng do m\u00e3 ngu\u1ed3n PHP ch\u01b0a t\u1ed1i \u01b0u ho\u1eb7c truy v\u1ea5n SQL thi\u1ebfu ch\u1ec9 m\u1ee5c Index.<\/li>\n<li><strong>%system:<\/strong> T\u1ec9 l\u1ec7 CPU ti\u00eau th\u1ee5 trong kh\u00f4ng gian Kernel System. N\u1ebfu m\u1ee5c n\u00e0y cao b\u1ea5t th\u01b0\u1eddng, ti\u1ebfn tr\u00ecnh \u0111ang th\u1ef1c hi\u1ec7n qu\u00e1 nhi\u1ec1u System Calls (g\u1ecdi ng\u1eaft I\/O, network socket, c\u1ea5p ph\u00e1t b\u1ed9 nh\u1edb li\u00ean t\u1ee5c).<\/li>\n<li><strong>%wait:<\/strong> Th\u1eddi gian ti\u1ebfn tr\u00ecnh ph\u1ea3i x\u1ebfp h\u00e0ng ch\u1edd CPU s\u1eb5n s\u00e0ng ph\u1ee5c v\u1ee5. Khi k\u1ebft h\u1ee3p v\u1edbi c\u00e1c b\u01b0\u1edbc <a href=\"https:\/\/interdata.vn\/blog\/kiem-tra-thong-tin-tai-nguyen-vps\/\">ki\u1ec3m tra t\u00e0i nguy\u00ean VPS<\/a>, n\u1ebfu %wait cao ch\u1ee9ng t\u1ecf VPS \u0111ang thi\u1ebfu CPU core nghi\u00eam tr\u1ecdng ho\u1eb7c b\u1ecb tranh ch\u1ea5p t\u00e0i nguy\u00ean (CPU Steal \/ Noisy Neighbor).<\/li>\n<li><strong>CPU:<\/strong> S\u1ed1 th\u1ee9 t\u1ef1 l\u00f5i CPU v\u1eadt l\u00fd\/\u1ea3o m\u00e0 ti\u1ebfn tr\u00ecnh \u0111\u00f3 \u0111ang \u0111\u01b0\u1ee3c g\u00e1n x\u1eed l\u00fd.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-43753\" src=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Giam-sat-CPU-tong-quat-cua-tat-ca-tien-trinh-bang-lenh-pidstat.png\" alt=\"Gi\u00e1m s\u00e1t CPU t\u1ed5ng qu\u00e1t c\u1ee7a t\u1ea5t c\u1ea3 ti\u1ebfn tr\u00ecnh b\u1eb1ng l\u1ec7nh pidstat\" width=\"864\" height=\"493\" title=\"\" srcset=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Giam-sat-CPU-tong-quat-cua-tat-ca-tien-trinh-bang-lenh-pidstat.png 864w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Giam-sat-CPU-tong-quat-cua-tat-ca-tien-trinh-bang-lenh-pidstat-300x171.png 300w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Giam-sat-CPU-tong-quat-cua-tat-ca-tien-trinh-bang-lenh-pidstat-768x438.png 768w\" sizes=\"auto, (max-width: 864px) 100vw, 864px\" \/><\/p>\n<h3 style=\"color: #2563eb; font-size: 18px; font-weight: 600; margin: 25px 0 10px;\">5.2. \u0110\u00e0o s\u00e2u ph\u00e2n t\u00edch theo t\u1eebng Thread c\u1ee7a m\u1ed9t PID<\/h3>\n<p style=\"text-align: justify;\">C\u00e1c \u1ee9ng d\u1ee5ng hi\u1ec7n \u0111\u1ea1i nh\u01b0 Java, NodeJS, MySQL hay Nginx th\u01b0\u1eddng ch\u1ea1y \u0111a lu\u1ed3ng. \u0110\u1ec3 t\u00ecm \u0111\u00fang thread g\u00e2y qu\u00e1 t\u1ea3i b\u00ean trong PID 2145:<\/p>\n<pre><code class=\"language-bash\">pidstat -t -p 2145 1 5<\/code><\/pre>\n<p style=\"text-align: justify;\">C\u1ed9t <code>TID<\/code> (Thread ID) s\u1ebd xu\u1ea5t hi\u1ec7n. B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng TID n\u00e0y \u0111\u1ec3 ti\u1ebfp t\u1ee5c debug v\u1edbi <code>gdb<\/code> ho\u1eb7c <code>strace<\/code> nh\u1eb1m xem lu\u1ed3ng \u0111\u00f3 \u0111ang x\u1eed l\u00fd \u0111o\u1ea1n code n\u00e0o trong h\u1ec7 th\u1ed1ng.<\/p>\n<h2 id=\"section6\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">6. Theo d\u00f5i Disk I\/O v\u00e0 Memory chi ti\u1ebft theo t\u1eebng ti\u1ebfn tr\u00ecnh<\/h2>\n<p style=\"text-align: justify;\">Ngh\u1ebdn c\u1ed5 chai \u1ed5 \u0111\u0129a (I\/O Bottleneck) v\u00e0 tr\u00e0n b\u1ed9 nh\u1edb l\u00e0 hai nguy\u00ean nh\u00e2n ph\u1ed5 bi\u1ebfn nh\u1ea5t khi\u1ebfn website b\u1ecb ch\u1eadm ho\u1eb7c m\u00e1y ch\u1ee7 MySQL b\u1ecb treo \u0111\u1ed9t ng\u1ed9t.<\/p>\n<h3 style=\"color: #2563eb; font-size: 18px; font-weight: 600; margin: 25px 0 10px;\">6.1. Gi\u00e1m s\u00e1t Disk I\/O v\u1edbi tham s\u1ed1 -d<\/h3>\n<p style=\"text-align: justify;\">Th\u1ef1c thi l\u1ec7nh sau \u0111\u1ec3 ki\u1ec3m tra t\u1ed1c \u0111\u1ed9 \u0111\u1ecdc\/ghi d\u1eef li\u1ec7u \u1ed5 c\u1ee9ng c\u1ee7a t\u1eebng ti\u1ebfn tr\u00ecnh m\u1ed7i 2 gi\u00e2y:<\/p>\n<pre><code class=\"language-bash\">pidstat -d 2 3<\/code><\/pre>\n<p style=\"text-align: justify;\">M\u1eabu k\u1ebft qu\u1ea3 hi\u1ec3n th\u1ecb:<\/p>\n<pre><code class=\"language-text\">14:15:10      UID       PID   kB_rd\/s   kB_wr\/s kB_ccwr\/s iodelay  Command\r\n14:15:12     1000      2145   5420.00   1200.50      0.00       8  mysqld\r\n14:15:12        0       540      0.00    450.00      0.00       0  jbd2\/sda1-8<\/code><\/pre>\n<ul style=\"line-height: 1.8; text-align: justify;\">\n<li><strong>kB_rd\/s:<\/strong> L\u01b0\u1ee3ng d\u1eef li\u1ec7u ti\u1ebfn tr\u00ecnh y\u00eau c\u1ea7u \u0111\u1ecdc t\u1eeb \u0111\u0129a c\u1ee9ng m\u1ed7i gi\u00e2y (t\u00ednh b\u1eb1ng Kilobytes).<\/li>\n<li><strong>kB_wr\/s:<\/strong> L\u01b0\u1ee3ng d\u1eef li\u1ec7u ti\u1ebfn tr\u00ecnh ghi tr\u1ef1c ti\u1ebfp xu\u1ed1ng \u0111\u0129a m\u1ed7i gi\u00e2y.<\/li>\n<li><strong>kB_ccwr\/s:<\/strong> D\u1eef li\u1ec7u \u0111\u00e3 hu\u1ef7 ghi khi ti\u1ebfn tr\u00ecnh ghi \u0111\u00e8 ho\u1eb7c xo\u00e1 b\u1ecf tr\u01b0\u1edbc khi \u0111\u1ed3ng b\u1ed9 xu\u1ed1ng \u0111\u0129a v\u1eadt l\u00fd.<\/li>\n<li><strong>iodelay:<\/strong> \u0110\u1ed9 tr\u1ec5 I\/O (t\u00ednh b\u1eb1ng \u0111\u01a1n v\u1ecb clock ticks) m\u00e0 ti\u1ebfn tr\u00ecnh ph\u1ea3i ch\u1edd \u0111\u1ee3i. Ch\u1ec9 s\u1ed1 n\u00e0y c\u00e0ng l\u1edbn \u0111\u1ed3ng ngh\u0129a v\u1edbi vi\u1ec7c \u1ed5 c\u1ee9ng kh\u00f4ng \u0111\u00e1p \u1ee9ng k\u1ecbp t\u1ed1c \u0111\u1ed9 x\u1eed l\u00fd c\u1ee7a ph\u1ea7n m\u1ec1m.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-43754\" src=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Giam-sat-Disk-I_O-voi-tham-so-d.png\" alt=\"Gi\u00e1m s\u00e1t Disk I\/O v\u1edbi tham s\u1ed1 -d\" width=\"873\" height=\"519\" title=\"\" srcset=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Giam-sat-Disk-I_O-voi-tham-so-d.png 873w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Giam-sat-Disk-I_O-voi-tham-so-d-300x178.png 300w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Giam-sat-Disk-I_O-voi-tham-so-d-768x457.png 768w\" sizes=\"auto, (max-width: 873px) 100vw, 873px\" \/><\/p>\n<h3 style=\"color: #2563eb; font-size: 18px; font-weight: 600; margin: 25px 0 10px;\">6.2. Ki\u1ec3m tra b\u1ed9 nh\u1edb RAM v\u00e0 l\u1ed7i ph\u00e2n trang v\u1edbi tham s\u1ed1 -r<\/h3>\n<p style=\"text-align: justify;\">\u0110\u1ec3 ph\u00e1t hi\u1ec7n c\u00e1c ti\u1ebfn tr\u00ecnh r\u00f2 r\u1ec9 RAM ho\u1eb7c ti\u00eau t\u1ed1n b\u1ed9 nh\u1edb \u0111\u1ec7m, d\u00f9ng l\u1ec7nh:<\/p>\n<pre><code class=\"language-bash\">pidstat -r 2 3<\/code><\/pre>\n<p style=\"text-align: justify;\">\u00dd ngh\u0129a c\u1ed9t k\u1ebft qu\u1ea3:<\/p>\n<ul style=\"line-height: 1.8; text-align: justify;\">\n<li><strong>minflt\/s:<\/strong> S\u1ed1 l\u01b0\u1ee3ng Minor Faults m\u1ed7i gi\u00e2y (l\u1ed7i n\u1ea1p trang b\u1ed9 nh\u1edb kh\u00f4ng c\u1ea7n truy xu\u1ea5t \u0111\u0129a c\u1ee9ng).<\/li>\n<li><strong>majflt\/s:<\/strong> S\u1ed1 l\u01b0\u1ee3ng Major Faults m\u1ed7i gi\u00e2y. Khi ch\u1ec9 s\u1ed1 n\u00e0y t\u0103ng cao, h\u1ec7 th\u1ed1ng bu\u1ed9c ph\u1ea3i n\u1ea1p trang t\u1eeb ph\u00e2n v\u00f9ng Swap ho\u1eb7c \u1ed5 c\u1ee9ng, l\u00e0m s\u1ee5t gi\u1ea3m t\u1ed1c \u0111\u1ed9 x\u1eed l\u00fd nghi\u00eam tr\u1ecdng.<\/li>\n<li><strong>VSZ (Virtual Size):<\/strong> To\u00e0n b\u1ed9 dung l\u01b0\u1ee3ng b\u1ed9 nh\u1edb \u1ea3o \u0111\u01b0\u1ee3c c\u1ea5p cho ti\u1ebfn tr\u00ecnh (kB).<\/li>\n<li><strong>RSS (Resident Set Size):<\/strong> Dung l\u01b0\u1ee3ng RAM v\u1eadt l\u00fd th\u1ef1c t\u1ebf m\u00e0 ti\u1ebfn tr\u00ecnh \u0111ang chi\u1ebfm d\u1ee5ng (kB).<\/li>\n<li><strong>%MEM:<\/strong> Ph\u1ea7n tr\u0103m dung l\u01b0\u1ee3ng RAM v\u1eadt l\u00fd ti\u1ebfn tr\u00ecnh \u0111ang d\u00f9ng tr\u00ean t\u1ed5ng s\u1ed1 RAM c\u1ee7a m\u00e1y ch\u1ee7.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-43755\" src=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Kiem-tra-bo-nho-RAM-bang-lenh-pidstat.png\" alt=\"Ki\u1ec3m tra b\u1ed9 nh\u1edb RAM b\u1eb1ng l\u1ec7nh pidstat\" width=\"865\" height=\"704\" title=\"\" srcset=\"https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Kiem-tra-bo-nho-RAM-bang-lenh-pidstat.png 865w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Kiem-tra-bo-nho-RAM-bang-lenh-pidstat-300x244.png 300w, https:\/\/interdata.vn\/blog\/wp-content\/uploads\/2026\/09\/Kiem-tra-bo-nho-RAM-bang-lenh-pidstat-768x625.png 768w\" sizes=\"auto, (max-width: 865px) 100vw, 865px\" \/><\/p>\n<h2 id=\"section7\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">7. K\u1ebft h\u1ee3p pidstat v\u1edbi gi\u00e1m s\u00e1t t\u1ef1 \u0111\u1ed9ng v\u00e0 b\u1ea3o m\u1eadt h\u1ec7 th\u1ed1ng<\/h2>\n<p style=\"text-align: justify;\">Vi\u1ec7c ch\u1ea1y <strong>l\u1ec7nh pidstat<\/strong> th\u1ee7 c\u00f4ng ch\u1ec9 \u00e1p d\u1ee5ng khi b\u1ea1n \u0111ang tr\u1ef1c ti\u1ebfp kh\u1eafc ph\u1ee5c s\u1ef1 c\u1ed1. Trong m\u00f4i tr\u01b0\u1eddng v\u1eadn h\u00e0nh l\u00e2u d\u00e0i, b\u1ea1n c\u1ea7n t\u1ef1 \u0111\u1ed9ng h\u00f3a thu th\u1eadp log v\u00e0 k\u1ebft h\u1ee3p v\u1edbi c\u00e1c gi\u1ea3i ph\u00e1p an ninh nh\u1eb1m nh\u1eadn di\u1ec7n s\u1edbm c\u00e1c cu\u1ed9c t\u1ea5n c\u00f4ng DDoS ho\u1eb7c \u0111\u00e0o ti\u1ec1n \u1ea3o ng\u1ea7m.<\/p>\n<p style=\"text-align: justify;\">Sau khi ph\u00e2n t\u00edch c\u00e1c ti\u1ebfn tr\u00ecnh kh\u1ea3 nghi chi\u1ebfm gi\u1eef socket m\u1ea1ng ho\u1eb7c CPU, b\u1ea1n n\u00ean ti\u1ebfn h\u00e0nh <a href=\"https:\/\/interdata.vn\/blog\/cau-hinh-ufw-tren-ubuntu\/\">c\u1ea5u h\u00ecnh UFW tr\u00ean Ubuntu<\/a> \u0111\u1ec3 kh\u00f3a to\u00e0n b\u1ed9 c\u00e1c c\u1ed5ng m\u1ea1ng l\u1ea1 kh\u00f4ng s\u1eed d\u1ee5ng. \u0110\u1ed3ng th\u1eddi, \u00e1p d\u1ee5ng <a href=\"https:\/\/interdata.vn\/blog\/cai-dat-fail2ban-tren-linux\/\">c\u00e0i \u0111\u1eb7t Fail2ban tr\u00ean Linux<\/a> \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng ban IP n\u1ebfu ph\u00e1t hi\u1ec7n c\u00e1c cu\u1ed9c t\u1ea5n c\u00f4ng brute-force li\u00ean t\u1ee5c k\u00edch ho\u1ea1t ti\u1ebfn tr\u00ecnh <code>sshd<\/code>.<\/p>\n<p style=\"text-align: justify;\">B\u00ean c\u1ea1nh \u0111\u00f3, vi\u1ec7c th\u1ef1c hi\u1ec7n \u0111\u00fang chu\u1ea9n <a href=\"https:\/\/interdata.vn\/blog\/cach-bao-mat-ssh-vps\/\">b\u1ea3o m\u1eadt SSH VPS<\/a> (\u0111\u1ed5i c\u1ed5ng m\u1eb7c \u0111\u1ecbnh, t\u1eaft x\u00e1c th\u1ef1c Password, ch\u1ec9 d\u00f9ng SSH Key) s\u1ebd gi\u1ea3m thi\u1ec3u t\u1ed1i \u0111a nguy c\u01a1 m\u00e1y ch\u1ee7 b\u1ecb x\u00e2m nh\u1eadp tr\u00e1i ph\u00e9p.<\/p>\n<p style=\"text-align: justify;\">B\u1ea1n c\u0169ng c\u00f3 th\u1ec3 thi\u1ebft l\u1eadp k\u1ecbch b\u1ea3n shell script t\u1ef1 \u0111\u1ed9ng \u0111\u1ecdc k\u1ebft qu\u1ea3 t\u1eeb <code>pidstat<\/code> v\u00e0 g\u1eedi c\u1ea3nh b\u00e1o khi c\u00f3 ti\u1ebfn tr\u00ecnh chi\u1ebfm tr\u00ean 90% CPU th\u00f4ng qua gi\u1ea3i ph\u00e1p <a href=\"https:\/\/interdata.vn\/blog\/tao-bot-giam-sat-tai-nguyen-vps\/\">gi\u00e1m s\u00e1t t\u00e0i nguy\u00ean VPS qua Telegram<\/a>. V\u00ed d\u1ee5 \u0111o\u1ea1n script m\u1eabu:<\/p>\n<pre><code class=\"language-bash\">#!\/bin\/bash\r\n# Tr\u00edch xu\u1ea5t c\u00e1c PID chi\u1ebfm CPU &gt; 80% trong 5 gi\u00e2y\r\nALERT_LOG=$(pidstat -u 5 1 | awk 'NR&gt;3 &amp;&amp; $8 &gt; 80.0 {print \"PID: \"$3\" - Cmd: \"$9\" - CPU: \"$8\"%\" }')\r\nif [ ! -z \"$ALERT_LOG\" ]; then\r\n    # G\u1eedi th\u00f4ng b\u00e1o \u0111\u1ebfn Telegram Bot API c\u1ee7a b\u1ea1n\r\n    echo \"C\u1ea3nh b\u00e1o ti\u1ebfn tr\u00ecnh CPU cao: $ALERT_LOG\"\r\nfi<\/code><\/pre>\n<div style=\"display: flex; flex-wrap: wrap; background-color: #fff; border: 1.5px solid #BFDBFE; box-shadow: 0 8px 20px rgba(37,99,235,0.08); border-radius: 12px; overflow: hidden; margin: 35px 0;\">\n<div style=\"flex: 1; min-width: 250px; background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%); display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center;\">\n<div>\n<p style=\"color: #fff; font-size: 34px; font-family: 'Be Vietnam Pro', sans-serif; font-weight: bold; margin: 0; line-height: 1.1;\">Cloud Server InterData<\/p>\n<p style=\"color: #dbeafe; font-size: 15px; font-weight: 600; margin-top: 12px;\">N\u00e2ng\/h\u1ea1 t\u00e0i nguy\u00ean nhanh theo t\u1ea3i, m\u1ea1ng t\u1ed1c \u0111\u1ed9 cao<\/p>\n<\/div>\n<\/div>\n<div style=\"flex: 2; padding: 25px; min-width: 300px;\">\n<h3 style=\"font-family: 'Be Vietnam Pro', sans-serif; color: #1e3a8a; margin-top: 0; font-size: 20px;\">M\u00f4i tr\u01b0\u1eddng production c\u1ea7n h\u1ea1 t\u1ea7ng m\u1edf r\u1ed9ng linh ho\u1ea1t?<\/h3>\n<p style=\"text-align: justify; font-size: 15px; margin-bottom: 15px;\">Khi h\u1ec7 th\u1ed1ng \u1ee9ng d\u1ee5ng ph\u1ee5c v\u1ee5 l\u01b0\u1ee3ng truy c\u1eadp l\u1edbn ho\u1eb7c nhi\u1ec1u th\u00e0nh vi\u00ean c\u00f9ng qu\u1ea3n tr\u1ecb, d\u1ecbch v\u1ee5 Cloud Server InterData cho ph\u00e9p b\u1ea1n t\u00f9y bi\u1ebfn n\u00e2ng h\u1ea1 CPU\/RAM\/SSD t\u1ee9c th\u00ec m\u00e0 kh\u00f4ng c\u1ea7n c\u00e0i \u0111\u1eb7t l\u1ea1i h\u1ec7 \u0111i\u1ec1u h\u00e0nh hay gi\u00e1n \u0111o\u1ea1n d\u1ecbch v\u1ee5.<\/p>\n<p><a style=\"background: linear-gradient(90deg, #2563EB 0%, #1E3A8A 100%); color: #fff; padding: 12px 25px; text-decoration: none; font-weight: 600; border-radius: 8px; font-size: 15px; display: inline-block; box-shadow: 0 5px 15px rgba(37,99,235,0.3);\" href=\"https:\/\/interdata.vn\/cloud-server\/\" target=\"_blank\" rel=\"noopener\">Xem B\u1ea3ng Gi\u00e1 Cloud Server \u27f6<\/a><\/p>\n<\/div>\n<\/div>\n<h2 id=\"section8\" style=\"color: #1e3a8a; font-size: 24px; font-weight: bold; text-align: left; border-left: 5px solid #2563EB; padding-left: 15px; margin: 40px 0 20px; line-height: 1.4;\">8. X\u1eed l\u00fd c\u00e1c l\u1ed7i th\u01b0\u1eddng g\u1eb7p khi th\u1ef1c thi l\u1ec7nh pidstat<\/h2>\n<p style=\"text-align: justify;\">Trong qu\u00e1 tr\u00ecnh v\u1eadn h\u00e0nh, qu\u1ea3n tr\u1ecb vi\u00ean th\u01b0\u1eddng g\u1eb7p ph\u1ea3i m\u1ed9t s\u1ed1 l\u1ed7i ph\u1ed5 bi\u1ebfn khi ch\u1ea1y <strong>l\u1ec7nh pidstat<\/strong>. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 c\u00e1ch ki\u1ec3m tra v\u00e0 kh\u1eafc ph\u1ee5c c\u1ee5 th\u1ec3:<\/p>\n<h3 style=\"color: #2563eb; font-size: 18px; font-weight: 600; margin: 25px 0 10px;\">8.1. L\u1ed7i: pidstat: command not found<\/h3>\n<p style=\"text-align: justify;\"><strong>Tri\u1ec7u ch\u1ee9ng:<\/strong> Khi g\u00f5 l\u1ec7nh <code>pidstat<\/code>, terminal b\u00e1o l\u1ed7i kh\u00f4ng t\u00ecm th\u1ea5y c\u00e2u l\u1ec7nh.<\/p>\n<p style=\"text-align: justify;\"><strong>Nguy\u00ean nh\u00e2n:<\/strong> G\u00f3i c\u00f4ng c\u1ee5 <code>sysstat<\/code> ch\u01b0a \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t tr\u00ean h\u1ec7 \u0111i\u1ec1u h\u00e0nh Linux c\u1ee7a b\u1ea1n.<\/p>\n<p style=\"text-align: justify;\"><strong>C\u00e1ch kh\u1eafc ph\u1ee5c:<\/strong> Ch\u1ea1y l\u1ec7nh c\u00e0i \u0111\u1eb7t t\u01b0\u01a1ng \u1ee9ng v\u1edbi distro \u0111ang d\u00f9ng:<\/p>\n<pre><code class=\"language-bash\"># \u0110\u1ed1i v\u1edbi Ubuntu \/ Debian\r\nsudo apt update &amp;&amp; sudo apt install sysstat -y\r\n\r\n# \u0110\u1ed1i v\u1edbi CentOS \/ RHEL \/ AlmaLinux\r\nsudo dnf install sysstat -y<\/code><\/pre>\n<h3 style=\"color: #2563eb; font-size: 18px; font-weight: 600; margin: 25px 0 10px;\">8.2. L\u1ed7i: pidstat kh\u00f4ng hi\u1ec3n th\u1ecb d\u1eef li\u1ec7u ho\u1eb7c b\u1ea3ng k\u1ebft qu\u1ea3 tr\u1ed1ng r\u1ed7ng<\/h3>\n<p style=\"text-align: justify;\"><strong>Tri\u1ec7u ch\u1ee9ng:<\/strong> Ch\u1ea1y <code>pidstat -d<\/code> ho\u1eb7c <code>pidstat -u<\/code> nh\u01b0ng kh\u00f4ng xu\u1ea5t hi\u1ec7n b\u1ea5t k\u1ef3 ti\u1ebfn tr\u00ecnh n\u00e0o ngo\u00e0i ti\u00eau \u0111\u1ec1 c\u00e1c c\u1ed9t.<\/p>\n<p style=\"text-align: justify;\"><strong>Nguy\u00ean nh\u00e2n:<\/strong> M\u1eb7c \u0111\u1ecbnh pidstat ch\u1ec9 hi\u1ec3n th\u1ecb c\u00e1c ti\u1ebfn tr\u00ecnh \u0111ang c\u00f3 ph\u00e1t sinh ho\u1ea1t \u0111\u1ed9ng (Active Tasks) trong kho\u1ea3ng th\u1eddi gian l\u1ea5y m\u1eabu. N\u1ebfu h\u1ec7 th\u1ed1ng \u1edf tr\u1ea1ng th\u00e1i Idle, c\u00e1c ti\u1ebfn tr\u00ecnh kh\u00f4ng ti\u00eau th\u1ee5 t\u00e0i nguy\u00ean s\u1ebd b\u1ecb \u1ea9n.<\/p>\n<p style=\"text-align: justify;\"><strong>C\u00e1ch kh\u1eafc ph\u1ee5c:<\/strong> S\u1eed d\u1ee5ng tham s\u1ed1 <code>-p ALL<\/code> \u0111\u1ec3 bu\u1ed9c pidstat hi\u1ec3n th\u1ecb t\u1ea5t c\u1ea3 ti\u1ebfn tr\u00ecnh tr\u00ean h\u1ec7 th\u1ed1ng:<\/p>\n<pre><code class=\"language-bash\">pidstat -u -p ALL 1 1<\/code><\/pre>\n<h3 style=\"color: #2563eb; font-size: 18px; font-weight: 600; margin: 25px 0 10px;\">8.3. Thi\u1ebfu quy\u1ec1n xem th\u00f4ng tin Disk I\/O c\u1ee7a ng\u01b0\u1eddi d\u00f9ng kh\u00e1c<\/h3>\n<p style=\"text-align: justify;\"><strong>Tri\u1ec7u ch\u1ee9ng:<\/strong> Ng\u01b0\u1eddi d\u00f9ng th\u00f4ng th\u01b0\u1eddng (Non-root user) ch\u1ea1y <code>pidstat -d<\/code> th\u1ea5y c\u00e1c c\u1ed9t I\/O tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb 0 ho\u1eb7c thi\u1ebfu th\u00f4ng tin c\u1ee7a c\u00e1c ti\u1ebfn tr\u00ecnh d\u1ecbch v\u1ee5 nh\u01b0 Nginx, MySQL.<\/p>\n<p style=\"text-align: justify;\"><strong>Nguy\u00ean nh\u00e2n:<\/strong> Linux kernel b\u1ea3o v\u1ec7 quy\u1ec1n ri\u00eang t\u01b0 v\u00e0 an ninh b\u1eb1ng c\u00e1ch ch\u1eb7n ng\u01b0\u1eddi d\u00f9ng th\u01b0\u1eddng \u0111\u1ecdc file <code>\/proc\/[PID]\/io<\/code> c\u1ee7a c\u00e1c ti\u1ebfn tr\u00ecnh thu\u1ed9c s\u1edf h\u1eefu t\u00e0i kho\u1ea3n kh\u00e1c.<\/p>\n<p style=\"text-align: justify;\"><strong>C\u00e1ch kh\u1eafc ph\u1ee5c:<\/strong> Th\u1ef1c thi l\u1ec7nh v\u1edbi quy\u1ec1n qu\u1ea3n tr\u1ecb t\u1ed1i cao:<\/p>\n<pre><code class=\"language-bash\">sudo pidstat -d 1 3<\/code><\/pre>\n<div style=\"background-color: #f8fafc; border: 1.5px solid #E2E8F0; border-radius: 12px; padding: 30px; margin: 40px 0;\">\n<h2 id=\"section9\" style=\"color: #1e3a8a; font-size: 22px; font-weight: bold; margin-top: 0;\">C\u00e2u H\u1ecfi Th\u01b0\u1eddng G\u1eb7p v\u1ec1 l\u1ec7nh pidstat<\/h2>\n<h3 style=\"color: #2563eb; font-size: 17px; font-weight: 600; margin-top: 20px;\">L\u00e0m th\u1ebf n\u00e0o \u0111\u1ec3 gi\u00e1m s\u00e1t to\u00e0n b\u1ed9 CPU, RAM v\u00e0 I\/O c\u00f9ng m\u1ed9t l\u00fac b\u1eb1ng pidstat?<\/h3>\n<p style=\"text-align: justify; margin-bottom: 0;\">B\u1ea1n c\u00f3 th\u1ec3 k\u1ebft h\u1ee3p c\u00e1c tham s\u1ed1 <code>-d -r -u -w<\/code> trong c\u00f9ng m\u1ed9t c\u00e2u l\u1ec7nh. V\u00ed d\u1ee5, th\u1ef1c thi <code>pidstat -durw 2 3<\/code> s\u1ebd y\u00eau c\u1ea7u c\u00f4ng c\u1ee5 xu\u1ea5t l\u1ea7n l\u01b0\u1ee3t b\u1ea3ng th\u1ed1ng k\u00ea CPU, RAM, Disk I\/O v\u00e0 s\u1ed1 l\u01b0\u1ee3t context switch c\u1ee7a t\u1eebng ti\u1ebfn tr\u00ecnh sau m\u1ed7i 2 gi\u00e2y.<\/p>\n<h3 style=\"color: #2563eb; font-size: 17px; font-weight: 600; margin-top: 20px;\">Ch\u1ec9 s\u1ed1 %wait trong k\u1ebft qu\u1ea3 CPU c\u1ee7a pidstat c\u00f3 \u00fd ngh\u0129a g\u00ec?<\/h3>\n<p style=\"text-align: justify; margin-bottom: 0;\">Ch\u1ec9 s\u1ed1 <code>%wait<\/code> th\u1ec3 hi\u1ec7n ph\u1ea7n tr\u0103m th\u1eddi gian m\u00e0 ti\u1ebfn tr\u00ecnh ho\u1eb7c lu\u1ed3ng \u0111\u00f3 ph\u1ea3i n\u1eb1m trong h\u00e0ng \u0111\u1ee3i ch\u1edd CPU c\u1ea5p ph\u00e1t th\u1eddi gian x\u1eed l\u00fd. Khi ch\u1ec9 s\u1ed1 n\u00e0y v\u01b0\u1ee3t qu\u00e1 5-10%, m\u00e1y ch\u1ee7 c\u1ee7a b\u1ea1n \u0111ang b\u1ecb ngh\u1ebdn CPU ho\u1eb7c chia s\u1ebb t\u00e0i nguy\u00ean kh\u00f4ng \u0111\u1ee7 \u0111\u00e1p \u1ee9ng t\u00e1c v\u1ee5.<\/p>\n<h3 style=\"color: #2563eb; font-size: 17px; font-weight: 600; margin-top: 20px;\">L\u00e0m sao \u0111\u1ec3 l\u1ecdc theo d\u00f5i m\u1ed9t ti\u1ebfn tr\u00ecnh c\u1ee5 th\u1ec3 theo t\u00ean \u1ee9ng d\u1ee5ng?<\/h3>\n<p style=\"text-align: justify; margin-bottom: 0;\">S\u1eed d\u1ee5ng tham s\u1ed1 <code>-C<\/code> theo sau l\u00e0 t\u1eeb kh\u00f3a t\u00ean ti\u1ebfn tr\u00ecnh. V\u00ed d\u1ee5, \u0111\u1ec3 theo d\u00f5i m\u1ecdi ho\u1ea1t \u0111\u1ed9ng CPU c\u1ee7a web server Nginx m\u1ed7i gi\u00e2y m\u1ed9t l\u1ea7n, b\u1ea1n ch\u1ea1y l\u1ec7nh <code>pidstat -C nginx 1<\/code>.<\/p>\n<h3 style=\"color: #2563eb; font-size: 17px; font-weight: 600; margin-top: 20px;\">L\u1ec7nh pidstat l\u1ea5y d\u1eef li\u1ec7u t\u1eeb \u0111\u00e2u trong h\u1ec7 \u0111i\u1ec1u h\u00e0nh Linux?<\/h3>\n<p style=\"text-align: justify; margin-bottom: 0;\">L\u1ec7nh pidstat \u0111\u1ecdc tr\u1ef1c ti\u1ebfp t\u1eeb h\u1ec7 th\u1ed1ng t\u1eadp tin \u1ea3o <code>\/proc<\/code> c\u1ee7a Linux kernel, c\u1ee5 th\u1ec3 l\u00e0 c\u00e1c file <code>\/proc\/[PID]\/stat<\/code>, <code>\/proc\/[PID]\/io<\/code> v\u00e0 <code>\/proc\/[PID]\/status<\/code>, sau \u0111\u00f3 t\u00ednh to\u00e1n t\u1ec9 l\u1ec7 ch\u00eanh l\u1ec7ch gi\u1eefa hai th\u1eddi \u0111i\u1ec3m \u0111o l\u01b0\u1eddng \u0111\u1ec3 xu\u1ea5t ra s\u1ed1 li\u1ec7u.<\/p>\n<h3 style=\"color: #2563eb; font-size: 17px; font-weight: 600; margin-top: 20px;\">Pidstat c\u00f3 \u1ea3nh h\u01b0\u1edfng nhi\u1ec1u \u0111\u1ebfn hi\u1ec7u n\u0103ng c\u1ee7a m\u00e1y ch\u1ee7 khi ch\u1ea1y kh\u00f4ng?<\/h3>\n<p style=\"text-align: justify; margin-bottom: 0;\">Pidstat ti\u00eau t\u1ed1n r\u1ea5t \u00edt t\u00e0i nguy\u00ean do c\u01a1 ch\u1ebf \u0111\u1ecdc tr\u1ef1c ti\u1ebfp t\u1eeb kernel interface tr\u00ean RAM. Tuy nhi\u00ean, n\u1ebfu b\u1ea1n theo d\u00f5i h\u00e0ng ngh\u00ecn ti\u1ebfn tr\u00ecnh \u0111\u1ed3ng th\u1eddi v\u1edbi chu k\u1ef3 qu\u00e1 ng\u1eafn (d\u01b0\u1edbi 0.1 gi\u00e2y), m\u1ee9c ti\u00eau th\u1ee5 CPU c\u00f3 th\u1ec3 t\u0103ng nh\u1eb9 trong qu\u00e1 tr\u00ecnh qu\u00e9t.<\/p>\n<\/div>\n<div style=\"border-top: 2px dashed #BFDBFE; margin-top: 50px; padding-top: 30px;\">\n<h2 style=\"color: #1e3a8a; font-size: 22px; font-weight: bold;\">K\u1ebft lu\u1eadn v\u1ec1 vi\u1ec7c s\u1eed d\u1ee5ng l\u1ec7nh pidstat trong qu\u1ea3n tr\u1ecb Linux<\/h2>\n<p style=\"text-align: justify;\"><strong>L\u1ec7nh pidstat<\/strong> l\u00e0 c\u00f4ng c\u1ee5 ph\u00e2n t\u00edch ti\u1ebfn tr\u00ecnh kh\u00f4ng th\u1ec3 thi\u1ebfu \u0111\u1ed1i v\u1edbi m\u1ecdi Linux System Administrator khi c\u1ea7n ch\u1ea9n \u0111o\u00e1n s\u00e2u c\u00e1c \u0111i\u1ec3m ngh\u1ebdn hi\u1ec7u n\u0103ng v\u1ec1 CPU, Disk I\/O v\u00e0 b\u1ed9 nh\u1edb RAM. B\u1eb1ng c\u00e1ch n\u1eafm v\u1eefng c\u00e1c t\u00f9y ch\u1ecdn <code>-u<\/code>, <code>-d<\/code>, <code>-r<\/code>, <code>-t<\/code> v\u00e0 k\u1ebft h\u1ee3p v\u1edbi c\u00e1c ph\u01b0\u01a1ng ph\u00e1p <a href=\"https:\/\/interdata.vn\/blog\/huong-dan-toi-uu-hoa-vps-linux\/\">t\u1ed1i \u01b0u h\u00f3a VPS Linux<\/a>, b\u1ea1n ho\u00e0n to\u00e0n c\u00f3 th\u1ec3 ch\u1ee7 \u0111\u1ed9ng ki\u1ec3m so\u00e1t t\u00e0i nguy\u00ean m\u00e1y ch\u1ee7 v\u00e0 duy tr\u00ec ho\u1ea1t \u0111\u1ed9ng \u1ed5n \u0111\u1ecbnh cho c\u00e1c d\u1ecbch v\u1ee5 c\u1ed1t l\u00f5i.<\/p>\n<\/div>\n<p style=\"text-align: justify; font-size: 13px; font-style: italic; color: #6b7280; margin-top: 30px; border-top: 1px solid #E5E7EB; padding-top: 15px;\"><em>N\u1ed9i dung mang t\u00ednh tham kh\u1ea3o. L\u1ec7nh, c\u00fa ph\u00e1p, \u0111\u01b0\u1eddng d\u1eabn file v\u00e0 t\u00f9y ch\u1ecdn c\u1ea5u h\u00ecnh c\u00f3 th\u1ec3 thay \u0111\u1ed5i theo phi\u00ean b\u1ea3n h\u1ec7 \u0111i\u1ec1u h\u00e0nh, phi\u00ean b\u1ea3n ph\u1ea7n m\u1ec1m v\u00e0 m\u00f4i tr\u01b0\u1eddng c\u1ee5 th\u1ec3. N\u00ean ki\u1ec3m th\u1eed, sao l\u01b0u d\u1eef li\u1ec7u v\u00e0 \u0111\u00e1nh gi\u00e1 r\u1ee7i ro tr\u01b0\u1edbc khi \u00e1p d\u1ee5ng l\u00ean server production.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>L\u1ec7nh pidstat l\u00e0 c\u00f4ng c\u1ee5 chuy\u00ean s\u00e2u trong g\u00f3i sysstat gi\u00fap qu\u1ea3n tr\u1ecb vi\u00ean gi\u00e1m s\u00e1t ti\u1ebfn tr\u00ecnh Linux theo th\u1eddi gian th\u1ef1c v\u00e0 ghi nh\u1eadn chi ti\u1ebft m\u1ee9c ti\u00eau th\u1ee5 CPU, RAM, Disk I\/O c\u0169ng nh\u01b0 context switch c\u1ee7a t\u1eebng PID ho\u1eb7c Thread. Khi h\u1ec7 th\u1ed1ng g\u1eb7p hi\u1ec7n t\u01b0\u1ee3ng gi\u1eadt lag ho\u1eb7c qu\u00e1 t\u1ea3i<\/p>\n","protected":false},"author":2,"featured_media":43758,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[],"class_list":["post-43750","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kien-thuc-it"],"_links":{"self":[{"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/posts\/43750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/comments?post=43750"}],"version-history":[{"count":5,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/posts\/43750\/revisions"}],"predecessor-version":[{"id":43761,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/posts\/43750\/revisions\/43761"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/media\/43758"}],"wp:attachment":[{"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/media?parent=43750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/categories?post=43750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/interdata.vn\/blog\/wp-json\/wp\/v2\/tags?post=43750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}