{"id":34050,"date":"2025-11-10T11:40:55","date_gmt":"2025-11-10T08:40:55","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=34050"},"modified":"2025-11-10T11:40:55","modified_gmt":"2025-11-10T08:40:55","slug":"nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/","title":{"rendered":"Nagios Plugin&#8217;lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi"},"content":{"rendered":"<p><body><\/p>\n<h2>Nagios Plugin&#8217;lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi<\/h2>\n<p>Nagios, sistem y\u00f6neticilerinin altyap\u0131lar\u0131n\u0131 izlemeleri i\u00e7in vazge\u00e7ilmez bir ara\u00e7t\u0131r. Sunucular, a\u011f cihazlar\u0131, uygulamalar ve hizmetler gibi bir\u00e7ok farkl\u0131 bile\u015fenin durumunu s\u00fcrekli olarak denetleyerek potansiyel sorunlar\u0131 proaktif bir \u015fekilde tespit etmeye yard\u0131mc\u0131 olur. Nagios&#8217;un g\u00fcc\u00fc, esnek eklenti (plugin) mimarisinden gelir. Bu makalede, CentOS 6 ortam\u0131nda Bash betikleri kullanarak kendi Nagios eklentilerinizi nas\u0131l olu\u015fturaca\u011f\u0131n\u0131z\u0131 ad\u0131m ad\u0131m inceleyece\u011fiz.<\/p>\n<h3>Nagios Plugin Temelleri<\/h3>\n<p>Nagios, izlemek istedi\u011fi bir hizmetin veya kayna\u011f\u0131n durumunu belirlemek i\u00e7in harici betikleri veya y\u00fcr\u00fct\u00fclebilir dosyalar\u0131 \u00e7al\u0131\u015ft\u0131r\u0131r. Bu betikler, Nagios taraf\u0131ndan &#8220;plugin&#8221; olarak adland\u0131r\u0131l\u0131r. Bir plugin&#8217;in temel g\u00f6revi, belirli bir kontrol\u00fc ger\u00e7ekle\u015ftirmek, ard\u0131ndan bu kontrol\u00fcn sonucunu standart \u00e7\u0131kt\u0131ya (stdout) yazd\u0131rmak ve bir d\u00f6n\u00fc\u015f kodu (exit code) ile Nagios&#8217;a bildirmektir.<\/p>\n<h4>\u00c7al\u0131\u015fma Prensibi<\/h4>\n<p>Nagios, yap\u0131land\u0131rma dosyas\u0131nda tan\u0131mlanan bir komutu belirli aral\u0131klarla \u00e7al\u0131\u015ft\u0131r\u0131r. Bu komut genellikle bir plugin&#8217;i ve ona iletilecek arg\u00fcmanlar\u0131 i\u00e7erir. Plugin \u00e7al\u0131\u015ft\u0131\u011f\u0131nda, yapt\u0131\u011f\u0131 kontrol sonucunda d\u00f6rt ana durumdan birini Nagios&#8217;a bildirir:<\/p>\n<p>*   <strong>OK (0):<\/strong> Her \u015fey yolunda. Kaynak normal \u00e7al\u0131\u015f\u0131yor.<br \/>\n*   <strong>WARNING (1):<\/strong> Bir sorun olabilir. Kaynak hala \u00e7al\u0131\u015f\u0131yor ancak belirli bir e\u015fi\u011fe yakla\u015f\u0131yor veya k\u00fc\u00e7\u00fck bir anormallik var.<br \/>\n*   <strong>CRITICAL (2):<\/strong> Ciddi bir sorun var. Kaynak d\u00fczg\u00fcn \u00e7al\u0131\u015fm\u0131yor veya tamamen ba\u015far\u0131s\u0131z oldu.<br \/>\n*   <strong>UNKNOWN (3):<\/strong> Plugin, kontrol\u00fc ger\u00e7ekle\u015ftiremedi veya beklenmedik bir hata olu\u015ftu. Bu durum genellikle plugin&#8217;in kendisinde bir sorun oldu\u011funu veya yeterli bilgiye sahip olmad\u0131\u011f\u0131n\u0131 g\u00f6sterir.<\/p>\n<p>Bu d\u00f6n\u00fc\u015f kodlar\u0131, Nagios&#8217;un web aray\u00fcz\u00fcnde g\u00f6r\u00fcnen renkli durum g\u00f6stergelerini ve bildirim tetikleyicilerini do\u011frudan etkiler.<\/p>\n<h4>Standart \u00c7\u0131kt\u0131 ve Performans Verileri<\/h4>\n<p>Bir Nagios plugin&#8217;i, durum kodunun yan\u0131 s\u0131ra, kontrol\u00fcn sonucunu a\u00e7\u0131klayan bir metin mesaj\u0131n\u0131 standart \u00e7\u0131kt\u0131ya yazmal\u0131d\u0131r. Bu mesaj genellikle tek bir sat\u0131r olmal\u0131 ve hizmetin veya kayna\u011f\u0131n mevcut durumu hakk\u0131nda k\u0131sa bir \u00f6zet sunmal\u0131d\u0131r.<\/p>\n<p>Opsiyonel olarak, plugin performans verilerini de sa\u011flayabilir. Performans verileri, Nagios&#8217;un izleme verilerini grafiklere d\u00f6n\u00fc\u015ft\u00fcrmek ve trendleri analiz etmek i\u00e7in kulland\u0131\u011f\u0131 say\u0131sal de\u011ferlerdir. Performans verileri, ana \u00e7\u0131kt\u0131 mesaj\u0131ndan dikey \u00e7izgi (<code>|<\/code>) ile ayr\u0131l\u0131r ve belirli bir format\u0131 takip eder:<\/p>\n<p><code>SERVICE STATUS: Descriptive message | 'metric_name'=valueUOM;warning;critical;min;max<\/code><\/p>\n<p>*   <strong>SERVICE STATUS:<\/strong> OK, WARNING, CRITICAL, UNKNOWN<br \/>\n*   <strong>Descriptive message:<\/strong> \u0130nsan taraf\u0131ndan okunabilir durum \u00f6zeti.<br \/>\n*   <strong>metric_name:<\/strong> \u0130zlenen metri\u011fin ad\u0131 (\u00f6rn. &#8216;disk_usage&#8217;, &#8216;cpu_load&#8217;).<br \/>\n*   <strong>value:<\/strong> Metri\u011fin mevcut de\u011feri.<br \/>\n*   <strong>UOM (Units of Measure):<\/strong> Birim (\u00f6rn. %, MB, s).<br \/>\n*   <strong>warning:<\/strong> Uyar\u0131 e\u015fi\u011fi.<br \/>\n*   <strong>critical:<\/strong> Kritik e\u015fik.<br \/>\n*   <strong>min:<\/strong> Metri\u011fin alabilece\u011fi minimum de\u011fer.<br \/>\n*   <strong>max:<\/strong> Metri\u011fin alabilece\u011fi maksimum de\u011fer.<\/p>\n<p><strong>\u00d6rnek \u00c7\u0131kt\u0131:<\/strong><br \/>\n<code>DISK OK: \/dev\/sda1 is 20% utilized | 'disk_usage'=20%;80;90;0;100<\/code><\/p>\n<p>Bu yap\u0131, Nagios&#8217;un izleme verilerini anlamland\u0131rmas\u0131 ve g\u00f6rselle\u015ftirmesi i\u00e7in kritik \u00f6neme sahiptir.<\/p>\n<h3>Geli\u015ftirme Ortam\u0131n\u0131n Haz\u0131rlanmas\u0131<\/h3>\n<p>Nagios plugin&#8217;leri geli\u015ftirmek i\u00e7in \u00f6zel bir IDE&#8217;ye veya karma\u015f\u0131k ara\u00e7lara ihtiyac\u0131n\u0131z yoktur. Temel bir Linux terminali ve metin d\u00fczenleyici yeterlidir.<\/p>\n<h4>CentOS 6 \u00dczerinde Temel Ara\u00e7lar<\/h4>\n<p>CentOS 6, Bash kabu\u011funu varsay\u0131lan olarak i\u00e7erir. Bu nedenle, Bash betiklerini \u00e7al\u0131\u015ft\u0131rmak i\u00e7in ek bir kurulum yapman\u0131za gerek yoktur. Metin d\u00fczenleyici olarak <code>vi<\/code>, <code>vim<\/code> veya <code>nano<\/code> gibi ara\u00e7lar\u0131 kullanabilirsiniz. <code>yum<\/code> paket y\u00f6neticisi ve <code>sudo<\/code> komutu da sistem y\u00f6netimi g\u00f6revleri i\u00e7in elinizin alt\u0131nda olacakt\u0131r.<\/p>\n<p>Bu makalede, Nagios sunucusunun veya Nagios Remote Plugin Executor (NRPE) istemcisinin CentOS 6 \u00fczerinde kurulu ve \u00e7al\u0131\u015f\u0131r durumda oldu\u011funu varsay\u0131yoruz. E\u011fer kurulu de\u011filse, \u00f6ncelikle Nagios veya NRPE kurulumunu tamamlaman\u0131z gerekmektedir.<\/p>\n<h4>Plugin Dizini ve \u0130zinler<\/h4>\n<p>Nagios plugin&#8217;leri genellikle <code>\/usr\/local\/nagios\/libexec\/<\/code> dizininde veya <code>\/opt\/nagios\/libexec\/<\/code> gibi benzer bir konumda bulunur. Bu dizin, Nagios&#8217;un plugin&#8217;leri arad\u0131\u011f\u0131 varsay\u0131lan yerdir. Kendi plugin&#8217;inizi olu\u015fturdu\u011funuzda, onu bu dizine kaydetmelisiniz.<\/p>\n<p>Plugin dosyas\u0131n\u0131n Nagios taraf\u0131ndan \u00e7al\u0131\u015ft\u0131r\u0131labilmesi i\u00e7in y\u00fcr\u00fctme iznine sahip olmas\u0131 gerekir. Bunu <code>chmod<\/code> komutuyla ayarlayabilirsiniz:<\/p>\n<pre><code class=\"language-bash\">sudo chmod +x \/usr\/local\/nagios\/libexec\/my_custom_plugin.sh<\/code><\/pre>\n<p>Ayr\u0131ca, plugin&#8217;i \u00e7al\u0131\u015ft\u0131racak olan Nagios kullan\u0131c\u0131s\u0131n\u0131n (genellikle <code>nagios<\/code> kullan\u0131c\u0131s\u0131) bu dosyaya okuma ve y\u00fcr\u00fctme yetkisine sahip oldu\u011fundan emin olun. Gerekirse dosyan\u0131n sahipli\u011fini <code>nagios<\/code> kullan\u0131c\u0131s\u0131na ve grubuna atayabilirsiniz:<\/p>\n<pre><code class=\"language-bash\">sudo chown nagios:nagios \/usr\/local\/nagios\/libexec\/my_custom_plugin.sh<\/code><\/pre>\n<h3>Basit Bir Nagios Plugin&#8217;i Olu\u015fturma<\/h3>\n<p>\u015eimdi, Nagios i\u00e7in ilk Bash plugin&#8217;imizi olu\u015ftural\u0131m.<\/p>\n<h4>&#8220;Hello World&#8221; Plugin&#8217;i<\/h4>\n<p>En basit plugin, sadece bir mesaj yaz\u0131p ba\u015far\u0131l\u0131 bir durum kodu d\u00f6nd\u00fcren bir betiktir.<\/p>\n<p>1.  <strong>Plugin dosyas\u0131n\u0131 olu\u015fturun:<\/strong><\/p>\n<pre><code class=\"language-bash\">sudo vi \/usr\/local\/nagios\/libexec\/check_hello_world.sh<\/code><\/pre>\n<p>2.  <strong>A\u015fa\u011f\u0131daki i\u00e7eri\u011fi dosyaya yap\u0131\u015ft\u0131r\u0131n:<\/strong><\/p>\n<pre><code class=\"language-bash\">#!\/bin\/bash\n    #\n    # Nagios Plugin: check_hello_world\n    # A simple \"Hello World\" plugin for Nagios\n    #\n\n    echo \"HELLO WORLD OK: This is my first Nagios plugin!\"\n    exit 0<\/code><\/pre>\n<p>3.  <strong>Dosyay\u0131 kaydedin ve kapat\u0131n.<\/strong><\/p>\n<p>4.  <strong>Y\u00fcr\u00fctme izni verin:<\/strong><\/p>\n<pre><code class=\"language-bash\">sudo chmod +x \/usr\/local\/nagios\/libexec\/check_hello_world.sh<\/code><\/pre>\n<p>5.  <strong>Test edin:<\/strong> Plugin&#8217;i komut sat\u0131r\u0131ndan manuel olarak \u00e7al\u0131\u015ft\u0131rarak do\u011fru \u00e7\u0131kt\u0131y\u0131 verdi\u011finden ve do\u011fru d\u00f6n\u00fc\u015f kodunu d\u00f6nd\u00fcrd\u00fc\u011f\u00fcnden emin olun:<\/p>\n<pre><code class=\"language-bash\">\/usr\/local\/nagios\/libexec\/check_hello_world.sh\n    echo $? # D\u00f6n\u00fc\u015f kodunu kontrol edin, 0 olmal\u0131<\/code><\/pre>\n<p>    \u00c7\u0131kt\u0131 \u015f\u00f6yle olmal\u0131:<br \/>\n    <code>HELLO WORLD OK: This is my first Nagios plugin!<\/code><br \/>\n    <code>0<\/code><\/p>\n<p>Bu basit plugin, Nagios&#8217;un temel gereksinimlerini kar\u015f\u0131lar.<\/p>\n<h4>Arg\u00fcmanlarla \u00c7al\u0131\u015fma<\/h4>\n<p>Ger\u00e7ek d\u00fcnya plugin&#8217;leri genellikle dinamiktir ve belirli parametrelere (e\u015fikler, dosya yollar\u0131 vb.) ihtiya\u00e7 duyar. Bash betiklerinde arg\u00fcmanlar\u0131 <code>$1<\/code>, <code>$2<\/code>, <code>$3<\/code> gibi de\u011fi\u015fkenlerle alabilirsiniz.<\/p>\n<p>Bir \u00f6rnek olarak, bir metin dosyas\u0131nda belirli bir kelimenin olup olmad\u0131\u011f\u0131n\u0131 kontrol eden ve uyar\u0131\/kritik e\u015fikleri arg\u00fcman olarak alan bir plugin olu\u015ftural\u0131m.<\/p>\n<p>1.  <strong>Plugin dosyas\u0131n\u0131 olu\u015fturun:<\/strong><\/p>\n<pre><code class=\"language-bash\">sudo vi \/usr\/local\/nagios\/libexec\/check_file_keyword.sh<\/code><\/pre>\n<p>2.  <strong>A\u015fa\u011f\u0131daki i\u00e7eri\u011fi dosyaya yap\u0131\u015ft\u0131r\u0131n:<\/strong><\/p>\n<pre><code class=\"language-bash\">#!\/bin\/bash\n    #\n    # Nagios Plugin: check_file_keyword\n    # Checks for the occurrence of a keyword in a file\n    #\n    # Usage: check_file_keyword.sh <file_path> <keyword> <warning_threshold> <critical_threshold>\n    #\n\n    FILE_PATH=$1\n    KEYWORD=$2\n    WARNING_THRESHOLD=$3\n    CRITICAL_THRESHOLD=$4\n\n    # Check if all arguments are provided\n    if [ -z \"$FILE_PATH\" ] || [ -z \"$KEYWORD\" ] || [ -z \"$WARNING_THRESHOLD\" ] || [ -z \"$CRITICAL_THRESHOLD\" ]; then\n        echo \"UNKNOWN: Usage: $0 <file_path> <keyword> <warning_threshold> <critical_threshold>\"\n        exit 3\n    fi\n\n    # Check if file exists\n    if [ ! -f \"$FILE_PATH\" ]; then\n        echo \"UNKNOWN: File not found: $FILE_PATH\"\n        exit 3\n    fi\n\n    # Count occurrences of the keyword\n    COUNT=$(grep -o -i \"$KEYWORD\" \"$FILE_PATH\" | wc -l)\n\n    # Determine status based on thresholds\n    if [ \"$COUNT\" -ge \"$CRITICAL_THRESHOLD\" ]; then\n        echo \"CRITICAL: Keyword '$KEYWORD' found $COUNT times in $FILE_PATH | 'keyword_count'=$COUNT;$WARNING_THRESHOLD;$CRITICAL_THRESHOLD;0;\"\n        exit 2\n    elif [ \"$COUNT\" -ge \"$WARNING_THRESHOLD\" ]; then\n        echo \"WARNING: Keyword '$KEYWORD' found $COUNT times in $FILE_PATH | 'keyword_count'=$COUNT;$WARNING_THRESHOLD;$CRITICAL_THRESHOLD;0;\"\n        exit 1\n    else\n        echo \"OK: Keyword '$KEYWORD' found $COUNT times in $FILE_PATH | 'keyword_count'=$COUNT;$WARNING_THRESHOLD;$CRITICAL_THRESHOLD;0;\"\n        exit 0\n    fi<\/code><\/pre>\n<p>3.  <strong>Dosyay\u0131 kaydedin ve kapat\u0131n.<\/strong><\/p>\n<p>4.  <strong>Y\u00fcr\u00fctme izni verin:<\/strong><\/p>\n<pre><code class=\"language-bash\">sudo chmod +x \/usr\/local\/nagios\/libexec\/check_file_keyword.sh<\/code><\/pre>\n<p>5.  <strong>Test i\u00e7in bir deneme dosyas\u0131 olu\u015fturun:<\/strong><\/p>\n<pre><code class=\"language-bash\">echo \"This is a test file.\" > \/tmp\/test_log.txt\n    echo \"It contains some keywords.\" >> \/tmp\/test_log.txt\n    echo \"ERROR: Something went wrong.\" >> \/tmp\/test_log.txt\n    echo \"Another line.\" >> \/tmp\/test_log.txt\n    echo \"ERROR: Critical failure.\" >> \/tmp\/test_log.txt<\/code><\/pre>\n<p>6.  <strong>Plugin&#8217;i farkl\u0131 arg\u00fcmanlarla test edin:<\/strong><\/p>\n<pre><code class=\"language-bash\">\/usr\/local\/nagios\/libexec\/check_file_keyword.sh \/tmp\/test_log.txt \"ERROR\" 1 2\n    echo $? # \u00c7\u0131kt\u0131 CRITICAL ve 2 olmal\u0131\n\n    \/usr\/local\/nagios\/libexec\/check_file_keyword.sh \/tmp\/test_log.txt \"test\" 1 2\n    echo $? # \u00c7\u0131kt\u0131 WARNING ve 1 olmal\u0131\n\n    \/usr\/local\/nagios\/libexec\/check_file_keyword.sh \/tmp\/test_log.txt \"nonexistent\" 1 2\n    echo $? # \u00c7\u0131kt\u0131 OK ve 0 olmal\u0131\n\n    \/usr\/local\/nagios\/libexec\/check_file_keyword.sh # Arg\u00fcman eksikli\u011fi, UNKNOWN ve 3 olmal\u0131\n    echo $?<\/code><\/pre>\n<p>Bu \u00f6rnek, arg\u00fcmanlar\u0131n nas\u0131l al\u0131nd\u0131\u011f\u0131n\u0131, temel hata kontrollerinin (dosya varl\u0131\u011f\u0131, arg\u00fcman eksikli\u011fi) nas\u0131l yap\u0131ld\u0131\u011f\u0131n\u0131 ve performans verilerinin nas\u0131l eklendi\u011fini g\u00f6stermektedir.<\/p>\n<h3>Pratik Nagios Plugin \u00d6rnekleri<\/h3>\n<p>\u015eimdi, daha yayg\u0131n izleme senaryolar\u0131 i\u00e7in birka\u00e7 pratik Bash plugin&#8217;i olu\u015ftural\u0131m.<\/p>\n<h4>Disk Kullan\u0131m\u0131n\u0131 Kontrol Eden Plugin<\/h4>\n<p>Bu plugin, belirli bir dosya sisteminin disk kullan\u0131m\u0131n\u0131 kontrol edecek ve belirlenen e\u015fiklere g\u00f6re durum d\u00f6nd\u00fcrecektir.<\/p>\n<pre><code class=\"language-bash\">#!\/bin\/bash\n<h2># Nagios Plugin: check_disk_usage.sh<\/h2>\n<h2>Checks disk usage for a specified mount point<\/h2>\n<h2># Usage: check_disk_usage.sh <mount_point> <warning_percent> <critical_percent><\/h2>\n<h2>MOUNT_POINT=$1<\/h2>\nWARNING_PERCENT=$2\nCRITICAL_PERCENT=$3\n\n<h2>Help message if no arguments or --help is passed<\/h2>\nif [ -z \"$MOUNT_POINT\" ] || [ -z \"$WARNING_PERCENT\" ] || [ -z \"$CRITICAL_PERCENT\" ] || [ \"$1\" == \"--help\" ] || [ \"$1\" == \"-h\" ]; then\n    echo \"Usage: $0 <mount_point> <warning_percent> <critical_percent>\"\n    echo \"Example: $0 \/ 80 90\"\n    exit 3\nfi\n\n<h2>Get disk usage for the specified mount point<\/h2>\n<h2>Use 'df -P' for POSIX compliant output, easier to parse<\/h2>\nDISK_INFO=$(df -P \"$MOUNT_POINT\" 2>\/dev\/null)\n\nif [ $? -ne 0 ]; then\n    echo \"UNKNOWN: Could not get disk info for $MOUNT_POINT. Check mount point or permissions.\"\n    exit 3\nfi\n\n<h2>Extract percentage used (5th column)<\/h2>\n<h2>Example df -P output:<\/h2>\n<h2>Filesystem     1K-blocks    Used Available Use% Mounted on<\/h2>\n<h2>\/dev\/sda1       20642280 4128456  15456244  22% \/<\/h2>\nUSED_PERCENT=$(echo \"$DISK_INFO\" | awk 'NR==2 {print $5}' | sed 's\/%\/\/')\n\n<h2>Check if USED_PERCENT is a valid number<\/h2>\nif ! [[ \"$USED_PERCENT\" =~ ^[0-9]+$ ]]; then\n    echo \"UNKNOWN: Failed to parse disk usage percentage for $MOUNT_POINT.\"\n    exit 3\nfi\n\n<h2>Determine status<\/h2>\nif [ \"$USED_PERCENT\" -ge \"$CRITICAL_PERCENT\" ]; then\n    echo \"CRITICAL: $MOUNT_POINT is ${USED_PERCENT}% utilized! | 'disk_usage'=${USED_PERCENT}%;$WARNING_PERCENT;$CRITICAL_PERCENT;0;100\"\n    exit 2\nelif [ \"$USED_PERCENT\" -ge \"$WARNING_PERCENT\" ]; then\n    echo \"WARNING: $MOUNT_POINT is ${USED_PERCENT}% utilized! | 'disk_usage'=${USED_PERCENT}%;$WARNING_PERCENT;$CRITICAL_PERCENT;0;100\"\n    exit 1\nelse\n    echo \"OK: $MOUNT_POINT is ${USED_PERCENT}% utilized. | 'disk_usage'=${USED_PERCENT}%;$WARNING_PERCENT;$CRITICAL_PERCENT;0;100\"\n    exit 0\nfi<\/code><\/pre>\n<p>Kaydedin: <code>\/usr\/local\/nagios\/libexec\/check_disk_usage.sh<\/code><br \/>\n\u0130zin verin: <code>sudo chmod +x \/usr\/local\/nagios\/libexec\/check_disk_usage.sh<\/code><br \/>\nTest edin: <code>\/usr\/local\/nagios\/libexec\/check_disk_usage.sh \/ 80 90<\/code><\/p>\n<h4>Bir Servisin Durumunu Kontrol Eden Plugin<\/h4>\n<p>Bu plugin, CentOS 6&#8217;daki <code>service<\/code> komutunu kullanarak belirli bir sistem hizmetinin (\u00f6rne\u011fin <code>httpd<\/code> veya <code>mysqld<\/code>) \u00e7al\u0131\u015f\u0131p \u00e7al\u0131\u015fmad\u0131\u011f\u0131n\u0131 kontrol edecektir.<\/p>\n<pre><code class=\"language-bash\">#!\/bin\/bash\n<h2># Nagios Plugin: check_service_status.sh<\/h2>\n<h2>Checks the status of a specified system service on CentOS 6<\/h2>\n<h2># Usage: check_service_status.sh <service_name><\/h2>\n<h2>SERVICE_NAME=$1<\/h2>\n\n<h2>Help message<\/h2>\nif [ -z \"$SERVICE_NAME\" ] || [ \"$1\" == \"--help\" ] || [ \"$1\" == \"-h\" ]; then\n    echo \"Usage: $0 <service_name>\"\n    echo \"Example: $0 httpd\"\n    exit 3\nfi\n\n<h2>Check service status using 'service' command (CentOS 6 specific)<\/h2>\n<h2>The 'service' command returns 0 for running, non-zero for stopped\/unknown<\/h2>\nservice \"$SERVICE_NAME\" status > \/dev\/null 2>&1\n\nif [ $? -eq 0 ]; then\n    echo \"OK: Service '$SERVICE_NAME' is running.\"\n    exit 0\nelse\n    # Check if the service exists at all, otherwise it's UNKNOWN\n    # We can check for init script existence\n    if [ -f \"\/etc\/init.d\/$SERVICE_NAME\" ]; then\n        echo \"CRITICAL: Service '$SERVICE_NAME' is stopped!\"\n        exit 2\n    else\n        echo \"UNKNOWN: Service '$SERVICE_NAME' does not exist or init script not found.\"\n        exit 3\n    fi\nfi<\/code><\/pre>\n<p>Kaydedin: <code>\/usr\/local\/nagios\/libexec\/check_service_status.sh<\/code><br \/>\n\u0130zin verin: <code>sudo chmod +x \/usr\/local\/nagios\/libexec\/check_service_status.sh<\/code><br \/>\nTest edin: <code>\/usr\/local\/nagios\/libexec\/check_service_status.sh httpd<\/code> (E\u011fer httpd kuruluysa)<\/p>\n<h4>Bir Dosya Boyutunu Kontrol Eden Plugin<\/h4>\n<p>Bu plugin, belirli bir dosyan\u0131n boyutunu kontrol edecek ve belirlenen e\u015fiklere g\u00f6re durum d\u00f6nd\u00fcrecektir. \u00d6zellikle log dosyalar\u0131n\u0131n beklenenden fazla b\u00fcy\u00fcmesini izlemek i\u00e7in kullan\u0131\u015fl\u0131d\u0131r.<\/p>\n<pre><code class=\"language-bash\">#!\/bin\/bash\n<h2># Nagios Plugin: check_file_size.sh<\/h2>\n<h2>Checks the size of a specified file<\/h2>\n<h2># Usage: check_file_size.sh <file_path> <warning_size_MB> <critical_size_MB><\/h2>\n<h2>FILE_PATH=$1<\/h2>\nWARNING_SIZE_MB=$2\nCRITICAL_SIZE_MB=$3\n\n<h2>Help message<\/h2>\nif [ -z \"$FILE_PATH\" ] || [ -z \"$WARNING_SIZE_MB\" ] || [ -z \"$CRITICAL_SIZE_MB\" ] || [ \"$1\" == \"--help\" ] || [ \"$1\" == \"-h\" ]; then\n    echo \"Usage: $0 <file_path> <warning_size_MB> <critical_size_MB>\"\n    echo \"Example: $0 \/var\/log\/messages 100 500\"\n    exit 3\nfi\n\n<h2>Check if file exists<\/h2>\nif [ ! -f \"$FILE_PATH\" ]; then\n    echo \"UNKNOWN: File not found: $FILE_PATH\"\n    exit 3\nfi\n\n<h2>Get file size in bytes<\/h2>\nFILE_SIZE_BYTES=$(stat -c %s \"$FILE_PATH\" 2>\/dev\/null)\n\nif [ $? -ne 0 ]; then\n    echo \"UNKNOWN: Could not get file size for $FILE_PATH. Check permissions.\"\n    exit 3\nfi\n\n<h2>Convert to MB for comparison<\/h2>\nFILE_SIZE_MB=$(awk \"BEGIN {print $FILE_SIZE_BYTES \/ (1024*1024)}\")\n\n<h2>Determine status<\/h2>\nif (( $(echo \"$FILE_SIZE_MB >= $CRITICAL_SIZE_MB\" | bc -l) )); then\n    echo \"CRITICAL: File $FILE_PATH size is $(printf \"%.2f\" \"$FILE_SIZE_MB\")MB! | 'file_size'=$(printf \"%.2f\" \"$FILE_SIZE_MB\")MB;$WARNING_SIZE_MB;$CRITICAL_SIZE_MB;0;\"\n    exit 2\nelif (( $(echo \"$FILE_SIZE_MB >= $WARNING_SIZE_MB\" | bc -l) )); then\n    echo \"WARNING: File $FILE_PATH size is $(printf \"%.2f\" \"$FILE_SIZE_MB\")MB. | 'file_size'=$(printf \"%.2f\" \"$FILE_SIZE_MB\")MB;$WARNING_SIZE_MB;$CRITICAL_SIZE_MB;0;\"\n    exit 1\nelse\n    echo \"OK: File $FILE_PATH size is $(printf \"%.2f\" \"$FILE_SIZE_MB\")MB. | 'file_size'=$(printf \"%.2f\" \"$FILE_SIZE_MB\")MB;$WARNING_SIZE_MB;$CRITICAL_SIZE_MB;0;\"\n    exit 0\nfi<\/code><\/pre>\n<p>Kaydedin: <code>\/usr\/local\/nagios\/libexec\/check_file_size.sh<\/code><br \/>\n\u0130zin verin: <code>sudo chmod +x \/usr\/local\/nagios\/libexec\/check_file_size.sh<\/code><br \/>\nTest edin: <code>\/usr\/local\/nagios\/libexec\/check_file_size.sh \/var\/log\/messages 100 500<\/code><\/p>\n<h3>Geli\u015fmi\u015f Plugin Teknikleri<\/h3>\n<p>Plugin&#8217;lerinizi daha sa\u011flam ve kullan\u0131\u015fl\u0131 hale getirmek i\u00e7in baz\u0131 geli\u015fmi\u015f teknikler uygulayabiliriz.<\/p>\n<h4>Hata Y\u00f6netimi ve UNKNOWN Durumu<\/h4>\n<p>Plugin&#8217;lerinizin beklenmedik durumlar\u0131 do\u011fru bir \u015fekilde ele almas\u0131 \u00f6nemlidir. \u00d6rne\u011fin, yanl\u0131\u015f arg\u00fcmanlar verildi\u011finde, bir dosya bulunamad\u0131\u011f\u0131nda veya bir komut ba\u015far\u0131s\u0131z oldu\u011funda <code>UNKNOWN<\/code> (exit 3) durumunu d\u00f6nd\u00fcrmek en iyi uygulamad\u0131r. Yukar\u0131daki \u00f6rneklerde bu durumlar\u0131 kontrol eden <code>if<\/code> bloklar\u0131 bulunmaktad\u0131r. Her zaman olas\u0131 hata durumlar\u0131n\u0131 d\u00fc\u015f\u00fcn\u00fcn ve uygun bir \u00e7\u0131k\u0131\u015f kodu ile mesaj sa\u011flay\u0131n.<\/p>\n<h4>Performans Verilerinin Detayland\u0131r\u0131lmas\u0131<\/h4>\n<p>Performans verileri, Nagios&#8217;un uzun vadeli trendleri izlemesi ve grafikler olu\u015fturmas\u0131 i\u00e7in \u00e7ok de\u011ferlidir. Birden fazla metri\u011fi tek bir plugin \u00e7\u0131kt\u0131s\u0131nda sa\u011flayabilirsiniz:<\/p>\n<p><code>OK: Everything is fine | 'metric1'=value1UOM;w1;c1;min1;max1 'metric2'=value2UOM;w2;c2;min2;max2<\/code><\/p>\n<p>Do\u011fru birimlerin (UOM &#8211; Units of Measure) kullan\u0131lmas\u0131 ve min\/max de\u011ferlerinin belirtilmesi, verilerin do\u011fru \u015fekilde yorumlanmas\u0131na yard\u0131mc\u0131 olur.<\/p>\n<p><strong>\u00d6rnek:<\/strong> <code>check_cpu_load.sh<\/code> plugin&#8217;i i\u00e7in:<br \/>\n<code>OK: Load average: 0.10, 0.20, 0.30 | 'load1'=0.10;1.0;2.0;0; 'load5'=0.20;0.8;1.5;0; 'load15'=0.30;0.6;1.0;0;<\/code><br \/>\nBurada <code>min<\/code> de\u011feri 0 olarak belirtilmi\u015f, <code>max<\/code> de\u011feri ise bo\u015f b\u0131rak\u0131lm\u0131\u015ft\u0131r, bu da maksimumun s\u0131n\u0131rs\u0131z oldu\u011fu anlam\u0131na gelir.<\/p>\n<h4>Yard\u0131m Mesaj\u0131 (Usage\/Help)<\/h4>\n<p>Plugin&#8217;lerinize bir <code>--help<\/code> veya <code>-h<\/code> arg\u00fcman\u0131 ile \u00e7a\u011fr\u0131ld\u0131\u011f\u0131nda kullan\u0131m talimatlar\u0131n\u0131 g\u00f6steren bir yard\u0131m mesaj\u0131 eklemek, plugin&#8217;in ba\u015fkalar\u0131 (veya gelecekteki siz) taraf\u0131ndan daha kolay anla\u015f\u0131lmas\u0131n\u0131 sa\u011flar.<\/p>\n<pre><code class=\"language-bash\"># ... (ba\u015flang\u0131\u00e7taki de\u011fi\u015fken tan\u0131mlamalar\u0131) ...\n\n<h2>Help message function<\/h2>\nprint_usage() {\n    echo \"Usage: $0 <mount_point> <warning_percent> <critical_percent>\"\n    echo \"Example: $0 \/ 80 90\"\n    echo \"Checks disk usage for a specified mount point.\"\n    exit 3\n}\n\n<h2>Check for help argument or missing arguments<\/h2>\nif [ -z \"$MOUNT_POINT\" ] || [ -z \"$WARNING_PERCENT\" ] || [ -z \"$CRITICAL_PERCENT\" ] || [ \"$1\" == \"--help\" ] || [ \"$1\" == \"-h\" ]; then\n    print_usage\nfi\n\n<h2>... (plugin'in geri kalan\u0131) ...<\/code><\/pre>\n<\/h2>\n<p>Bu yakla\u015f\u0131m, plugin&#8217;in kendi kendine a\u00e7\u0131klay\u0131c\u0131 olmas\u0131na yard\u0131mc\u0131 olur.<\/p>\n<h3>Nagios ile Plugin&#8217;i Entegre Etme<\/h3>\n<p>Plugin&#8217;inizi olu\u015fturup test ettikten sonra, Nagios&#8217;un onu kullanabilmesi i\u00e7in yap\u0131land\u0131rman\u0131z gerekir.<\/p>\n<h4><code>commands.cfg<\/code> Dosyas\u0131<\/h4>\n<p>Nagios, \u00e7al\u0131\u015ft\u0131raca\u011f\u0131 komutlar\u0131 <code>commands.cfg<\/code> dosyas\u0131nda (veya Nagios yap\u0131land\u0131rma dizininizdeki ba\u015fka bir <code>.cfg<\/code> dosyas\u0131nda) tan\u0131mlar. Bu dosya, Nagios&#8217;a plugin&#8217;inizin ad\u0131n\u0131 ve nas\u0131l \u00e7a\u011fr\u0131laca\u011f\u0131n\u0131 s\u00f6yler.<\/p>\n<p>1.  <strong><code>commands.cfg<\/code> dosyas\u0131n\u0131 d\u00fczenleyin:<\/strong><\/p>\n<pre><code class=\"language-bash\">sudo vi \/etc\/nagios\/objects\/commands.cfg<\/code><\/pre>\n<p>2.  <strong>Yeni bir komut tan\u0131mlay\u0131n:<\/strong><br \/>\n    \u00d6rne\u011fin, <code>check_disk_usage.sh<\/code> plugin&#8217;imiz i\u00e7in:<\/p>\n<pre><code class=\"language-nagios\">define command {\n        command_name    check_disk_custom\n        command_line    $USER1$\/check_disk_usage.sh $ARG1$ $ARG2$ $ARG3$\n    }<\/code><\/pre>\n<p>    *   <code>command_name<\/code>: Nagios i\u00e7inde bu komutu referans alaca\u011f\u0131n\u0131z isim.<br \/>\n    *   <code>command_line<\/code>: Nagios&#8217;un \u00e7al\u0131\u015ft\u0131raca\u011f\u0131 ger\u00e7ek komut.<br \/>\n        *   <code>$USER1$<\/code>: Genellikle <code>\/usr\/local\/nagios\/libexec\/<\/code> dizinini i\u015faret eden bir makrodur. <code>resource.cfg<\/code> dosyas\u0131nda tan\u0131ml\u0131d\u0131r.<br \/>\n        *   <code>$ARG1$<\/code>, <code>$ARG2$<\/code>, <code>$ARG3$<\/code>: Bu makrolar, hizmet tan\u0131m\u0131n\u0131zda plugin&#8217;e iletece\u011finiz arg\u00fcmanlar\u0131 temsil eder.<\/p>\n<h4><code>services.cfg<\/code> veya \u0130lgili Host Konfig\u00fcrasyonu<\/h4>\n<p>Bir komutu tan\u0131mlad\u0131ktan sonra, bu komutu belirli bir hizmetle ili\u015fkilendirmeniz gerekir. Bu genellikle <code>services.cfg<\/code> dosyas\u0131nda veya belirli bir ana bilgisayar\u0131n yap\u0131land\u0131rma dosyas\u0131nda yap\u0131l\u0131r.<\/p>\n<p>1.  <strong>Hizmet tan\u0131m\u0131n\u0131 ekleyin:<\/strong><\/p>\n<pre><code class=\"language-bash\">sudo vi \/etc\/nagios\/objects\/services.cfg<\/code><\/pre>\n<p>2.  <strong>A\u015fa\u011f\u0131daki hizmet tan\u0131m\u0131n\u0131 ekleyin:<\/strong><\/p>\n<pre><code class=\"language-nagios\">define service {\n        use                     generic-service\n        host_name               localhost\n        service_description     Disk Usage \/\n        check_command           check_disk_custom!\/!80!90\n        notifications_enabled   1\n    }<\/code><\/pre>\n<p>    *   <code>host_name<\/code>: Bu hizmetin izlenece\u011fi ana bilgisayar\u0131n ad\u0131.<br \/>\n    *   <code>service_description<\/code>: Nagios web aray\u00fcz\u00fcnde g\u00f6r\u00fcnecek hizmetin a\u00e7\u0131klamas\u0131.<br \/>\n    *   <code>check_command<\/code>: Kullan\u0131lacak komut ad\u0131 (<code>commands.cfg<\/code> dosyas\u0131nda tan\u0131mlad\u0131\u011f\u0131n\u0131z) ve arg\u00fcmanlar\u0131. Arg\u00fcmanlar \u00fcnlem i\u015fareti (<code>!<\/code>) ile ayr\u0131l\u0131r. Burada <code>\/<\/code> (mount point), <code>80<\/code> (warning %) ve <code>90<\/code> (critical %) arg\u00fcman olarak iletilir.<\/p>\n<p>3.  <strong>Nagios yap\u0131land\u0131rmas\u0131n\u0131 do\u011frulay\u0131n ve yeniden ba\u015flat\u0131n:<\/strong><br \/>\n    Yap\u0131land\u0131rma dosyalar\u0131nda bir hata olup olmad\u0131\u011f\u0131n\u0131 kontrol etmek i\u00e7in:<\/p>\n<pre><code class=\"language-bash\">sudo \/usr\/local\/nagios\/bin\/nagios -v \/etc\/nagios\/nagios.cfg<\/code><\/pre>\n<p>    Her \u015fey yolundaysa, Nagios hizmetini yeniden ba\u015flat\u0131n:<\/p>\n<pre><code class=\"language-bash\">sudo service nagios restart<\/code><\/pre>\n<p>Art\u0131k Nagios web aray\u00fcz\u00fcnde yeni hizmetinizi g\u00f6rmelisiniz.<\/p>\n<h4>NRPE ile Uzak Sunucu Kontrol\u00fc<\/h4>\n<p>E\u011fer plugin&#8217;iniz Nagios sunucusunun kendisinde de\u011fil, uzak bir sunucuda \u00e7al\u0131\u015facaksa, Nagios Remote Plugin Executor (NRPE) kullanman\u0131z gerekir. NRPE, uzak sunucuda \u00e7al\u0131\u015f\u0131r, Nagios sunucusundan gelen istekleri dinler, plugin&#8217;i \u00e7al\u0131\u015ft\u0131r\u0131r ve \u00e7\u0131kt\u0131y\u0131 Nagios sunucusuna geri g\u00f6nderir.<\/p>\n<p>1.  <strong>Uzak Sunucuda <code>nrpe.cfg<\/code> Dosyas\u0131:<\/strong><br \/>\n    Uzak CentOS 6 sunucusunda <code>nrpe.cfg<\/code> dosyas\u0131n\u0131 (genellikle <code>\/etc\/nagios\/nrpe.cfg<\/code> veya <code>\/usr\/local\/nagios\/etc\/nrpe.cfg<\/code>) d\u00fczenleyin.<\/p>\n<p>2.  <strong>NRPE Komutunu Tan\u0131mlay\u0131n:<\/strong><br \/>\n    <code>nrpe.cfg<\/code> i\u00e7inde, plugin&#8217;inizi \u00e7a\u011f\u0131racak bir komut tan\u0131mlay\u0131n:<\/p>\n<pre><code class=\"language-nagios\">command[check_disk_root]=\/usr\/local\/nagios\/libexec\/check_disk_usage.sh \/ $ARG1$ $ARG2$<\/code><\/pre>\n<p>    *   Burada <code>$ARG1$<\/code> ve <code>$ARG2$<\/code> NRPE taraf\u0131ndan Nagios sunucusundan gelen arg\u00fcmanlar\u0131 alacakt\u0131r.<br \/>\n    *   <strong>\u00d6NEML\u0130:<\/strong> NRPE&#8217;nin g\u00fcvenlik varsay\u0131lanlar\u0131 gere\u011fi, komutlara arg\u00fcman ge\u00e7i\u015fi varsay\u0131lan olarak devre d\u0131\u015f\u0131d\u0131r. Bunu etkinle\u015ftirmek i\u00e7in <code>nrpe.cfg<\/code> dosyas\u0131nda <code>dont_blame_nrpe=1<\/code> sat\u0131r\u0131n\u0131 uncomment etmeniz gerekebilir. Ancak bu bir g\u00fcvenlik riski olu\u015fturabilir, dikkatli olun.<\/p>\n<p>3.  <strong>NRPE Hizmetini Yeniden Ba\u015flat\u0131n:<\/strong><\/p>\n<pre><code class=\"language-bash\">sudo service nrpe restart<\/code><\/pre>\n<p>4.  <strong>Nagios Sunucusunda Komutu Tan\u0131mlay\u0131n:<\/strong><br \/>\n    Nagios sunucunuzdaki <code>commands.cfg<\/code> dosyas\u0131nda NRPE arac\u0131l\u0131\u011f\u0131yla uzak plugin&#8217;i \u00e7a\u011f\u0131rmak i\u00e7in bir komut tan\u0131mlay\u0131n:<\/p>\n<pre><code class=\"language-nagios\">define command {\n        command_name    check_nrpe_disk_remote\n        command_line    $USER1$\/check_nrpe -H $HOSTADDRESS$ -c check_disk_root -a $ARG1$ $ARG2$\n    }<\/code><\/pre>\n<p>    *   <code>check_nrpe<\/code>: Nagios&#8217;un NRPE istemcisi ile ileti\u015fim kurmak i\u00e7in kulland\u0131\u011f\u0131 plugin.<br \/>\n    *   <code>-H $HOSTADDRESS$<\/code>: Uzak sunucunun IP adresi veya ana bilgisayar ad\u0131.<br \/>\n    *   <code>-c check_disk_root<\/code>: Uzak NRPE istemcisinde tan\u0131mlanan komut ad\u0131.<br \/>\n    *   <code>-a $ARG1$ $ARG2$<\/code>: Nagios&#8217;tan NRPE&#8217;ye g\u00f6nderilecek arg\u00fcmanlar.<\/p>\n<p>5.  <strong>Nagios Sunucusunda Hizmeti Tan\u0131mlay\u0131n:<\/strong><br \/>\n    Uzak ana bilgisayar\u0131n hizmet yap\u0131land\u0131rmas\u0131nda bu komutu kullan\u0131n:<\/p>\n<pre><code class=\"language-nagios\">define service {\n        use                     generic-service\n        host_name               remote_server_name\n        service_description     Remote Disk Usage \/\n        check_command           check_nrpe_disk_remote!80!90\n        notifications_enabled   1\n    }<\/code><\/pre>\n<p>    Unutmay\u0131n, <code>remote_server_name<\/code> i\u00e7in Nagios&#8217;unuzda bir <code>define host<\/code> blo\u011fu tan\u0131mlanm\u0131\u015f olmal\u0131d\u0131r.<\/p>\n<h3>Sorun Giderme ve En \u0130yi Uygulamalar<\/h3>\n<p>Plugin geli\u015ftirirken veya da\u011f\u0131t\u0131rken kar\u015f\u0131la\u015fabilece\u011finiz baz\u0131 yayg\u0131n sorunlar ve bunlara y\u00f6nelik \u00e7\u00f6z\u00fcmler ile en iyi uygulamalar.<\/p>\n<h4>Hata Ay\u0131klama (Debugging)<\/h4>\n<p>*   <strong>Manuel \u00c7al\u0131\u015ft\u0131rma:<\/strong> Plugin&#8217;i her zaman Nagios&#8217;a entegre etmeden \u00f6nce komut sat\u0131r\u0131ndan manuel olarak \u00e7al\u0131\u015ft\u0131r\u0131n. Do\u011fru \u00e7\u0131kt\u0131y\u0131 ve d\u00f6n\u00fc\u015f kodunu verdi\u011finden emin olun.<br \/>\n*   <strong><code>set -x<\/code>:<\/strong> Bash beti\u011finizin ba\u015f\u0131na <code>set -x<\/code> ekleyerek beti\u011fin her sat\u0131r\u0131n\u0131 \u00e7al\u0131\u015ft\u0131r\u0131rken izleyebilirsiniz. Bu, de\u011fi\u015fken de\u011ferlerini ve komut \u00e7\u0131kt\u0131s\u0131n\u0131 g\u00f6rmenize yard\u0131mc\u0131 olur.<br \/>\n*   <strong>Nagios Loglar\u0131:<\/strong> Nagios log dosyas\u0131 (<code>\/var\/log\/nagios\/nagios.log<\/code>), plugin&#8217;lerin \u00e7al\u0131\u015ft\u0131r\u0131lmas\u0131yla ilgili hatalar\u0131 veya Nagios&#8217;un plugin \u00e7\u0131kt\u0131s\u0131n\u0131 i\u015flerken kar\u015f\u0131la\u015ft\u0131\u011f\u0131 sorunlar\u0131 i\u00e7erebilir.<br \/>\n*   <strong>NRPE Loglar\u0131:<\/strong> E\u011fer NRPE kullan\u0131yorsan\u0131z, uzak sunucudaki syslog&#8217;u veya NRPE&#8217;nin kendi loglar\u0131n\u0131 kontrol edin.<\/p>\n<h4>G\u00fcvenlik<\/h4>\n<p>*   <strong>Minimum Yetki:<\/strong> Plugin&#8217;ler genellikle <code>nagios<\/code> kullan\u0131c\u0131s\u0131 alt\u0131nda \u00e7al\u0131\u015f\u0131r. Bu kullan\u0131c\u0131n\u0131n sadece ihtiyac\u0131 olan dosyalara ve komutlara eri\u015fimi oldu\u011fundan emin olun. Root yetkisi gerektiren i\u015flemlerden ka\u00e7\u0131n\u0131n.<br \/>\n*   <strong>Giri\u015f Do\u011frulama:<\/strong> Plugin&#8217;inize iletilen arg\u00fcmanlar\u0131 her zaman do\u011frulay\u0131n. \u00d6rne\u011fin, say\u0131 bekliyorsan\u0131z, gelen de\u011ferin ger\u00e7ekten bir say\u0131 oldu\u011fundan emin olun. Kabuk enjeksiyonu gibi sald\u0131r\u0131lar\u0131 \u00f6nlemek i\u00e7in kullan\u0131c\u0131 girdilerini dikkatlice i\u015fleyin.<br \/>\n*   <strong><code>dont_blame_nrpe=1<\/code>:<\/strong> NRPE&#8217;de bu se\u00e7ene\u011fi etkinle\u015ftirmek, uzak plugin&#8217;lere rastgele arg\u00fcmanlar\u0131n ge\u00e7irilmesine izin verir ve potansiyel bir g\u00fcvenlik a\u00e7\u0131\u011f\u0131d\u0131r. Gerekliyse kullan\u0131n, ancak sadece g\u00fcvenilir arg\u00fcmanlar\u0131 ge\u00e7irin ve plugin&#8217;in kendi i\u00e7inde arg\u00fcmanlar\u0131 do\u011frulay\u0131n.<\/p>\n<h4>Performans<\/h4>\n<p>*   <strong>H\u0131zl\u0131 \u00c7al\u0131\u015fma:<\/strong> Nagios plugin&#8217;leri genellikle s\u0131k aral\u0131klarla \u00e7al\u0131\u015ft\u0131r\u0131l\u0131r. Plugin&#8217;lerinizin h\u0131zl\u0131 \u00e7al\u0131\u015fmas\u0131 ve minimum kaynak t\u00fcketmesi \u00f6nemlidir. Uzun s\u00fcren veya \u00e7ok fazla CPU\/bellek kullanan plugin&#8217;ler Nagios sunucusunu yava\u015flatabilir veya izleme gecikmelerine neden olabilir.<br \/>\n*   <strong>\u00d6nbellekleme:<\/strong> E\u011fer bir plugin&#8217;in veri toplama s\u00fcreci pahal\u0131ysa, sonu\u00e7lar\u0131 k\u0131sa bir s\u00fcre i\u00e7in \u00f6nbelle\u011fe almay\u0131 d\u00fc\u015f\u00fcnebilirsiniz. Ancak bu, verilerin g\u00fcncelli\u011fini etkileyebilir, dikkatli kullan\u0131lmal\u0131d\u0131r.<\/p>\n<h4>S\u00fcrd\u00fcr\u00fclebilirlik<\/h4>\n<p>*   <strong>Yorumlar:<\/strong> Kodunuzu bolca yorumlay\u0131n. Plugin&#8217;in ne yapt\u0131\u011f\u0131n\u0131, arg\u00fcmanlar\u0131n\u0131 ve \u00f6nemli mant\u0131k par\u00e7alar\u0131n\u0131 a\u00e7\u0131klay\u0131n.<br \/>\n*   <strong>Okunabilir Kod:<\/strong> Anla\u015f\u0131l\u0131r de\u011fi\u015fken adlar\u0131 kullan\u0131n ve kodu mant\u0131ksal bloklara ay\u0131r\u0131n.<br \/>\n*   <strong>Versiyon Kontrol\u00fc:<\/strong> Plugin&#8217;lerinizi bir versiyon kontrol sistemi (\u00f6rn. Git) alt\u0131nda y\u00f6netin. Bu, de\u011fi\u015fiklikleri izlemenize, geri alman\u0131za ve ekip i\u00e7inde i\u015fbirli\u011fi yapman\u0131za olanak tan\u0131r.<\/p>\n<h3>Sonu\u00e7<\/h3>\n<p>Nagios plugin&#8217;leri olu\u015fturmak, izleme ihtiya\u00e7lar\u0131n\u0131za \u00f6zel \u00e7\u00f6z\u00fcmler geli\u015ftirmenize olanak tan\u0131yan g\u00fc\u00e7l\u00fc bir yetenektir. Bash betikleri, Linux ortamlar\u0131nda bu plugin&#8217;leri h\u0131zl\u0131 ve etkili bir \u015fekilde yazmak i\u00e7in m\u00fckemmel bir ara\u00e7t\u0131r. Bu makalede ele al\u0131nan temel prensipleri, \u00f6rnekleri ve en iyi uygulamalar\u0131 takip ederek, CentOS 6 \u00fczerinde kendi Nagios izleme \u00e7\u00f6z\u00fcmlerinizi g\u00fcvenle olu\u015fturabilirsiniz.<\/p>\n<p>Unutmay\u0131n, iyi yaz\u0131lm\u0131\u015f bir plugin sadece i\u015flevsel olmakla kalmaz, ayn\u0131 zamanda kolayca anla\u015f\u0131labilir, s\u00fcrd\u00fcr\u00fclebilir ve g\u00fcvenli olmal\u0131d\u0131r. Nagios&#8217;un esnekli\u011fi sayesinde, altyap\u0131n\u0131zdaki hemen hemen her \u015feyi izlemek i\u00e7in kendi plugin&#8217;lerinizi geli\u015ftirebilir, b\u00f6ylece potansiyel sorunlar\u0131 daha ortaya \u00e7\u0131kmadan \u00f6nce tespit edebilirsiniz.<\/body><\/p>\n","protected":false},"excerpt":{"rendered":"Nagios Plugin&#8217;lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi\nNagios, sistem y\u00f6neticilerinin altyap\u0131lar\u0131n\u0131 izlemeleri i\u00e7in vazge\u00e7ilmez bi","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[1328],"tags":[],"class_list":{"0":"post-34050","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-bash","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nagios Plugin&#039;lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nagios Plugin&#039;lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi\" \/>\n<meta property=\"og:description\" content=\"Nagios Plugin&#039;lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi Nagios, sistem y\u00f6neticilerinin altyap\u0131lar\u0131n\u0131 izlemeleri i\u00e7in vazge\u00e7ilmez bi\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2025-11-10T08:40:55+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"19 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"Nagios Plugin&#8217;lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi\",\"datePublished\":\"2025-11-10T08:40:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/\"},\"wordCount\":2372,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"articleSection\":[\"Bash\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/#respond\"]}],\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/\",\"name\":\"Nagios Plugin'lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2025-11-10T08:40:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nagios Plugin&#8217;lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Nagios Plugin'lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/","og_locale":"tr_TR","og_type":"article","og_title":"Nagios Plugin'lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi","og_description":"Nagios Plugin'lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi Nagios, sistem y\u00f6neticilerinin altyap\u0131lar\u0131n\u0131 izlemeleri i\u00e7in vazge\u00e7ilmez bi","og_url":"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2025-11-10T08:40:55+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"19 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"Nagios Plugin&#8217;lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi","datePublished":"2025-11-10T08:40:55+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/"},"wordCount":2372,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"articleSection":["Bash"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/#respond"]}],"copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/","url":"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/","name":"Nagios Plugin'lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2025-11-10T08:40:55+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/nagios-pluginlerini-centos-6-uzerinde-bash-ile-olusturma-rehberi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Nagios Plugin&#8217;lerini CentOS 6 \u00dczerinde Bash ile Olu\u015fturma Rehberi"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/34050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=34050"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/34050\/revisions"}],"predecessor-version":[{"id":34051,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/34050\/revisions\/34051"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=34050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=34050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=34050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}