{"id":1871,"date":"2015-01-02T00:01:31","date_gmt":"2015-01-02T00:01:31","guid":{"rendered":"http:\/\/41j.com\/blog\/?p=1871"},"modified":"2015-01-17T03:02:22","modified_gmt":"2015-01-17T03:02:22","slug":"installing-nagios-debian-jessie-snmp-ups-monitoring","status":"publish","type":"post","link":"https:\/\/41j.com\/blog\/2015\/01\/installing-nagios-debian-jessie-snmp-ups-monitoring\/","title":{"rendered":"Installing Nagios on Debian Jessie and SNMP (UPS) monitoring"},"content":{"rendered":"<pre>\r\nsudo apt-get update;apt-get install nagios3 nagios-plugins nagios-nrpe-plugin apache2 snmp\r\n<\/pre>\n<p>You will be prompted to set a nagios password during installation. And can now navigate to http:\/\/localhost\/nagios3\/ to access nagios. The admin username is nagiosadmin, and the password is that which you set during installation.<\/p>\n<p>The following is based on the example <a href=\"http:\/\/exchange.nagios.org\/directory\/Plugins\/Hardware\/UPS\/APC\/APC-UPS-SNMP-CODE\/details\">here<\/a>. It&#8217;s probably better to refer to that for full APC UPS monitoring instructions. I&#8217;m going to be looking at monitoring the <a href=\"http:\/\/41j.com\/blog\/2014\/12\/arduino-snmp-voltage-monitor\/\">Arduino I previously setup<\/a>.<\/p>\n<p>Add the following to \/etc\/nagios3\/:<\/p>\n<pre>\r\ncfg_file=\/etc\/nagios3\/objects\/ups.cfg\r\n<\/pre>\n<p>Then create the file \/etc\/nagios3\/objects\/ups.cfg, with the following contents (you will also need to create the objects directory):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n###############################################################################\r\n# HOST DEFINITIONS\r\n###############################################################################\r\n# Define the UPS that we'll be monitoring\r\ndefine host{\r\n\tuse\t\t\t\tgeneric-host\r\n\thost_name\t\t\tArduinoVoltMon\r\n\talias\t\t\t\tArduino Voltage Monitor\r\n\tnotification_period\t\t24x7\r\n\tcheck_period\t\t\t24x7\r\n#\tcontacts\t\t\tnagiosadmin\r\n\taddress\t\t\t\t192.168.2.64\r\n\t}\r\n\r\n###############################################################################\r\n# HOST GROUP DEFINITIONS\r\n###############################################################################\r\ndefine hostgroup{\r\n\thostgroup_name\t\t\tups\r\n\talias\t\t\t\tups\r\n\tmembers\t\t\t\tArduinoVoltMon\r\n\t}\r\n\r\n###############################################################################\r\n# SERVICE DEFINITIONS\r\n###############################################################################\r\n# Ping UPS\r\ndefine service{\r\n\tuse\t\t\t\tgeneric-service\r\n\thost_name\t\t\tArduinoVoltMon\r\n\tcheck_period\t\t24x7\r\n\tnotification_interval 10\r\n\tservice_description           \tPING\r\n\tcheck_command\t\t\tcheck_ping!100.0,20%!500.0,60%\r\n\t}\r\n\r\ndefine service{\r\n\tuse\t\t\t\tgeneric-service\r\n\thost_name\t\t\tArduinoVoltMon\r\n\tservice_description           \tUPS Capacity\r\n\tcheck_command\t\t\tsnmp_ups_capacity! -H $HOSTADDRESS$ -C public\r\n\t}\r\n<\/pre>\n<p>Then add the following to the end of \/etc\/nagios3\/commands.cfg:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# 'snmp_ups_capacity' command definition\r\ndefine command{\r\n        command_name    snmp_ups_capacity\r\n        command_line    $USER1$\/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.318.1.1.1.2.2.1.0 -l '\\Battery Charge\\' -u '\\%\\' \r\n        }\r\n<\/pre>\n<p>If you click on Services in Nagios you should now see the following:<\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/ardvolt.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/ardvolt.png\" alt=\"ardvolt\" width=\"865\" height=\"56\" class=\"aligncenter size-full wp-image-1872\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/ardvolt.png 865w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/ardvolt-300x19.png 300w\" sizes=\"auto, (max-width: 865px) 100vw, 865px\" \/><\/a><\/p>\n<p>I might try this with <a href=\"http:\/\/www.cacti.net\/\">cacti<\/a> next. Which in my previous experience seems a lot better than Nagios.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sudo apt-get update;apt-get install nagios3 nagios-plugins nagios-nrpe-plugin apache2 snmp You will be prompted to set a nagios password during installation. And can now navigate to http:\/\/localhost\/nagios3\/ to access nagios. The admin username is nagiosadmin, and the password is that which you set during installation. The following is based on the example here. It&#8217;s probably better [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-1871","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1RRoU-ub","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/1871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/comments?post=1871"}],"version-history":[{"count":2,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/1871\/revisions"}],"predecessor-version":[{"id":1874,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/1871\/revisions\/1874"}],"wp:attachment":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/media?parent=1871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/categories?post=1871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/tags?post=1871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}