{"id":852,"date":"2016-08-19T00:03:27","date_gmt":"2016-08-18T18:33:27","guid":{"rendered":"http:\/\/www.middlewareprimer.com\/blog\/?p=852"},"modified":"2016-08-19T00:03:27","modified_gmt":"2016-08-18T18:33:27","slug":"nagios-hard-soft-states","status":"publish","type":"post","link":"http:\/\/www.middlewareprimer.com\/blog\/2016\/08\/19\/nagios-hard-soft-states\/","title":{"rendered":"Nagios hard soft states"},"content":{"rendered":"<p>Nagios hard soft states for reference below.<\/p>\n<p>Recently I was working on gathering nagios state history reports on when the hosts went down and when they were up and running. I could see two specific State Types,<\/p>\n<p>Hard<br \/>\nSoft<\/p>\n<p>and also I could see that both Hard and Soft state types were referring to DOWN State. I was wondering what could be the difference if they mention the same for DOWN state. Sample screenshots for reference,<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-858\" src=\"http:\/\/www.middlewareprimer.com\/blog\/wp-content\/uploads\/2016\/08\/nstate4.png\" alt=\"nstate4\" width=\"349\" height=\"131\" srcset=\"http:\/\/www.middlewareprimer.com\/blog\/wp-content\/uploads\/2016\/08\/nstate4.png 349w, http:\/\/www.middlewareprimer.com\/blog\/wp-content\/uploads\/2016\/08\/nstate4-300x113.png 300w\" sizes=\"auto, (max-width: 349px) 100vw, 349px\" \/><\/p>\n<p>States description during monitoring,<\/p>\n<p><strong>Hard<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-857\" src=\"http:\/\/www.middlewareprimer.com\/blog\/wp-content\/uploads\/2016\/08\/nstate3.png\" alt=\"nstate3\" width=\"250\" height=\"82\" \/><\/p>\n<p><strong>Soft<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-855\" src=\"http:\/\/www.middlewareprimer.com\/blog\/wp-content\/uploads\/2016\/08\/nstate1.png\" alt=\"nstate1\" width=\"231\" height=\"210\" \/><\/p>\n<p>There is a detailed information on these state types in Nagios site and below link for reference,<\/p>\n<p><a href=\"https:\/\/assets.nagios.com\/downloads\/nagioscore\/docs\/nagioscore\/3\/en\/statetypes.html\" target=\"_blank\">https:\/\/assets.nagios.com\/downloads\/nagioscore\/docs\/nagioscore\/3\/en\/statetypes.html<\/a><\/p>\n<p>As mentioned in the link (content taken from the site),<\/p>\n<p>There are two state types in Nagios &#8211; SOFT states and HARD states. These state types are a crucial part of the monitoring logic, as they are used to determine when event handlers are executed and when notifications are initially sent out.<\/p>\n<p>In order to prevent false alarms from transient problems, Nagios allows you to define how many times a service or host should be (re)checked before it is considered to have a &#8220;real&#8221; problem. This is controlled by the max_check_attempts option in the host and service definitions. Understanding how hosts and services are (re)checked in order to determine if a real problem exists is important in understanding how state types work.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Soft States<\/strong><\/span><\/p>\n<p>Soft states occur in the following situations,<\/p>\n<p>1. When a service or host check results in a non-OK or non-UP state and the service check has not yet been (re)checked the number of times specified by the max_check_attempts directive in the service or host definition. This is called a soft error.<br \/>\n2. When a service or host recovers from a soft error. This is considered a soft recovery.<\/p>\n<p>The following things occur when hosts or services experience SOFT state changes:<\/p>\n<p>The SOFT state is logged.<br \/>\nEvent handlers are executed to handle the SOFT state.<\/p>\n<p>The only important thing that really happens during a soft state is the execution of event handlers. Using event handlers can be particularly useful if you want to try and proactively fix a problem before it turns into a HARD state. The $HOSTSTATETYPE$ or $SERVICESTATETYPE$ macros will have a value of &#8220;SOFT&#8221; when event handlers are executed, which allows your event handler scripts to know when they should take corrective action.<\/p>\n<p><strong>Hard states <\/strong><\/p>\n<p>Hard state occur for hosts and services in the following situations:<\/p>\n<p>1. When a host or service check results in a non-UP or non-OK state and it has been (re)checked the number of times specified by the max_check_attempts option in the host or service definition. This is a hard error state.<br \/>\n2. When a host or service transitions from one hard error state to another error state (e.g. WARNING to CRITICAL).<br \/>\n3. When a service check results in a non-OK state and its corresponding host is either DOWN or UNREACHABLE.<br \/>\n4. When a host or service recovers from a hard error state. This is considered to be a hard recovery.<br \/>\n5. When a passive host check is received. Passive host checks are treated as HARD unless the passive_host_checks_are_soft option is enabled.<\/p>\n<p>The following things occur when hosts or services experience HARD state changes:<\/p>\n<p>The HARD state is logged.<br \/>\nEvent handlers are executed to handle the HARD state.<br \/>\nContacts are notifified of the host or service problem or recovery.<\/p>\n<p>The $HOSTSTATETYPE$ or $SERVICESTATETYPE$ macros will have a value of &#8220;HARD&#8221; when event handlers are executed, which allows your event handler scripts to know when they should take corrective action.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nagios hard soft states for reference below. Recently I was working on gathering nagios state history reports on when the hosts went down and when they were up and running. I could see two specific State Types, Hard Soft and also I could see that both Hard and Soft state types were referring to DOWN [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[153],"tags":[118,253,156],"class_list":["post-852","post","type-post","status-publish","format-standard","hentry","category-nagios","tag-nagios","tag-nagios-hard-soft","tag-nagios-xi"],"_links":{"self":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts\/852","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/comments?post=852"}],"version-history":[{"count":2,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts\/852\/revisions"}],"predecessor-version":[{"id":859,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts\/852\/revisions\/859"}],"wp:attachment":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/media?parent=852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/categories?post=852"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/tags?post=852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}