{"id":46331,"date":"2024-05-27T02:03:25","date_gmt":"2024-05-27T02:03:25","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=46331"},"modified":"2024-05-29T03:05:07","modified_gmt":"2024-05-29T03:05:07","slug":"icinga2-how-to-install-icinga2-plugins-in-linux","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/icinga2-how-to-install-icinga2-plugins-in-linux\/","title":{"rendered":"icinga2: How to install icinga2 plugins in Linux?"},"content":{"rendered":"<pre class=\"wp-block-code\"><span><code class=\"hljs\">Installing Icinga2 plugins on a Linux system enables you to extend the monitoring capabilities of Icinga2 by adding checks for various services and metrics. Here's how you can install Icinga2 plugins step-by-step:\n\nStep 1: Install Icinga2\nEnsure that Icinga2 is already installed on your system. If not, you can install it using the commands mentioned in the previous answer for either Ubuntu\/Debian or CentOS\/RHEL systems.\n\nStep 2: Install the Monitoring Plugins\nMost Icinga2 installations use the Monitoring Plugins (formerly Nagios Plugins) package, which provides a standard set of checks. Install them as follows:\n\nFor Ubuntu\/Debian:\nsudo apt update\nsudo apt install monitoring-plugins\n\nFor CentOS\/RHEL:\nsudo yum install epel-release\nsudo yum install nagios-plugins-all\n\nStep 3: Install Additional Plugins\nYou might need more specific plugins than those provided by the default Monitoring Plugins package. You can find additional plugins at the Icinga Exchange or other repositories like GitHub.\n\nTo install a plugin from a source other than the package manager:\n\nDownload the plugin script (usually a .sh or .pl file).\nMake the script executable and place it in the plugins directory (typically \/usr\/lib\/nagios\/plugins or \/usr\/lib64\/nagios\/plugins depending on your architecture).\n\nFor example:\nsudo wget -O \/usr\/lib\/nagios\/plugins\/check_example.sh https:\/\/example.com\/plugins\/check_example.sh\nsudo chmod +x \/usr\/lib\/nagios\/plugins\/check_example.sh\n\nStep 4: Test the Plugin\nBefore using the plugin with Icinga2, test it directly from the command line to ensure it works as expected:\n\n\n\/usr\/lib\/nagios\/plugins\/check_example.sh -option1 -option2\nReplace check_example.sh with your plugin and adjust the options according to the plugin\u2019s requirements.\n\nStep 5: Configure Icinga2 to Use the Plugin\nCreate a new command definition in Icinga2 for the plugin. This involves editing the configuration files found in \/etc\/icinga2\/conf.d or wherever you manage your Icinga2 configurations.\n\nHere\u2019s an example command definition for a custom plugin:\n\nobject CheckCommand \"check-example\" {\n    import \"plugin-check-command\"\n    command = &#91; PluginDir + \"\/check_example.sh\" ]\n    arguments = {\n        \"-option1\" = \"$arg1$\"\n        \"-option2\" = \"$arg2$\"\n    }\n}\nStep 6: Add the Check to a Host or Service\nNow, apply the new command to a host or service object. For example, to monitor a service using your new plugin:\n\napply Service \"example-service\" {\n    import \"generic-service\"\n    check_command = \"check-example\"\n    vars.arg1 = \"value1\"\n    vars.arg2 = \"value2\"\n    assign where host.name == \"YourHost\"\n}\nStep 7: Reload Icinga2\nAfter adding the new configuration, reload Icinga2 to apply changes:\n\nsudo systemctl reload icinga2\nStep 8: Verify the Configuration\n\nFinally, verify that the new plugin is working correctly through the Icinga Web 2 interface or by checking the Icinga2 logs for any errors.\n\nThis completes the installation and configuration of new Icinga2 plugins on your Linux system.<\/code><\/span><\/pre>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[8217],"tags":[],"class_list":["post-46331","post","type-post","status-publish","format-standard","hentry","category-icinga"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=46331"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46331\/revisions"}],"predecessor-version":[{"id":46333,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46331\/revisions\/46333"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=46331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=46331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=46331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}