{"id":213,"date":"2017-10-24T09:41:37","date_gmt":"2017-10-24T09:41:37","guid":{"rendered":"http:\/\/info.ffteixeira.net\/2017\/10\/24\/nagios-active-checks-check_ncpa-py\/"},"modified":"2017-10-24T09:41:37","modified_gmt":"2017-10-24T09:41:37","slug":"nagios-active-checks-check_ncpa-py","status":"publish","type":"post","link":"https:\/\/blog.ffteixeira.net\/?p=213","title":{"rendered":"Nagios Active Checks (check_ncpa.py)"},"content":{"rendered":"<h3 class=\"post-title entry-title\">Nagios Active Checks (check_ncpa.py)<\/h3>\n<div class=\"post-header\">\n<div class=\"post-header-line-1\">&nbsp;<\/div>\n<div class=\"post-header-line-1\">Nagios plugin:<\/div>\n<div class=\"post-header-line-1\">https:\/\/assets.nagios.com\/downloads\/ncpa\/check_ncpa.tar.gz<\/div>\n<div class=\"post-header-line-1\">&nbsp;<\/div>\n<\/div>\n<div class=\"post-body entry-content\" id=\"post-body-6961642430878473597\">\n<div dir=\"ltr\" style=\"text-align: left\">\n<div>\n<div>Copy check_ncpa.py &nbsp;to \/usr\/local\/nagios\/libexec (plugin directory) or \/usr\/lib64\/nagios\/plugins\/ (plugin directory Centos 6.9)<\/div>\n<div>&nbsp;<\/div>\n<div>ln -s check_ncpa.py check_ncpa<\/div>\n<\/div>\n<div>&nbsp;<\/div>\n<div>\n<div>Define new <b>check_ncpa<\/b> command by adding following lines to <u>\/usr\/local\/nagios\/etc\/objects\/<\/u><b>commands.cfg<\/b><\/div>\n<div>&nbsp;<\/div>\n<div><em>define command {<\/em><\/div>\n<div><em>&nbsp; &nbsp; command_name &nbsp; &nbsp;check_ncpa<\/em><\/div>\n<div><em>&nbsp; &nbsp; command_line &nbsp; &nbsp;$USER1$\/check_ncpa.py -H $HOSTADDRESS$ $ARG1$<\/em><\/div>\n<div><em>}<\/em><\/div>\n<div>&nbsp;<\/div>\n<div>or<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>\n<div><em>define command {<\/em><\/div>\n<div><em>&nbsp; &nbsp; command_name &nbsp; &nbsp;check_ncpa<\/em><\/div>\n<div><em>&nbsp; &nbsp; command_line &nbsp; &nbsp;$USER1$\/check_ncpa -H $HOSTADDRESS$ $ARG1$<\/em><\/div>\n<div><em>}<\/em><\/div>\n<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<div>&nbsp;<\/div>\n<div>\n<div>Create<b> ncpa.cfg<\/b> file &nbsp;in <u>\/usr\/local\/nagios\/etc\/objects<\/u><\/div>\n<div>touch \/usr\/local\/nagios\/etc\/objects\/ncpa.cfg<\/div>\n<div>&nbsp;<\/div>\n<div>Add following lines in <b>ncpa.cfg<\/b> to define host and monitoring services<\/div>\n<\/div>\n<div>\n<div>&nbsp;<\/div>\n<div>define host {<\/div>\n<div>&nbsp; &nbsp; host_name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NCPA 2 Host<\/div>\n<div>&nbsp; &nbsp; address &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 192.168.1.10<\/div>\n<div>&nbsp; &nbsp; check_command &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; check_ncpa!-t &#039;mytoken&#039; -P 5693 -M system\/agent_version<\/div>\n<div>&nbsp; &nbsp; max_check_attempts &nbsp; &nbsp; &nbsp;5<\/div>\n<div>&nbsp; &nbsp; check_interval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5<\/div>\n<div>&nbsp; &nbsp; retry_interval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<\/div>\n<div>&nbsp; &nbsp; check_period &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;24&#215;7<\/div>\n<div>&nbsp; &nbsp; contacts &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nagiosadmin<\/div>\n<div>&nbsp; &nbsp; notification_interval &nbsp; 60<\/div>\n<div>&nbsp; &nbsp; notification_period &nbsp; &nbsp; 24&#215;7<\/div>\n<div>&nbsp; &nbsp; notifications_enabled &nbsp; 1<\/div>\n<div>&nbsp; &nbsp; icon_image &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ncpa.png<\/div>\n<div>&nbsp; &nbsp; statusmap_image &nbsp; &nbsp; &nbsp; &nbsp; ncpa.png<\/div>\n<div>&nbsp; &nbsp; register &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<\/div>\n<div>}<\/div>\n<div>&nbsp;<\/div>\n<div>define service {<\/div>\n<div>&nbsp; &nbsp; host_name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NCPA 2 Host<\/div>\n<div>&nbsp; &nbsp; service_description &nbsp; &nbsp; CPU Usage<\/div>\n<div>&nbsp; &nbsp; check_command &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; check_ncpa!-t &#039;mytoken&#039; -P 5693 -M cpu\/percent -w 20 -c 40 -q &#039;aggregate=avg&#039;<\/div>\n<div>&nbsp; &nbsp; max_check_attempts &nbsp; &nbsp; &nbsp;5<\/div>\n<div>&nbsp; &nbsp; check_interval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5<\/div>\n<div>&nbsp; &nbsp; retry_interval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<\/div>\n<div>&nbsp; &nbsp; check_period &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;24&#215;7<\/div>\n<div>&nbsp; &nbsp; notification_interval &nbsp; 60<\/div>\n<div>&nbsp; &nbsp; notification_period &nbsp; &nbsp; 24&#215;7<\/div>\n<div>&nbsp; &nbsp; contacts &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nagiosadmin<\/div>\n<div>&nbsp; &nbsp; register &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<\/div>\n<div>}<\/div>\n<div>&nbsp;<\/div>\n<div>define service {<\/div>\n<div>&nbsp; &nbsp; host_name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NCPA 2 Host<\/div>\n<div>&nbsp; &nbsp; service_description &nbsp; &nbsp; Memory Usage<\/div>\n<div>&nbsp; &nbsp; check_command &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; check_ncpa!-t &#039;mytoken&#039; -P 5693 -M memory\/virtual -w 50 -c 80 -u G<\/div>\n<div>&nbsp; &nbsp; max_check_attempts &nbsp; &nbsp; &nbsp;5<\/div>\n<div>&nbsp; &nbsp; check_interval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5<\/div>\n<div>&nbsp; &nbsp; retry_interval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<\/div>\n<div>&nbsp; &nbsp; check_period &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;24&#215;7<\/div>\n<div>&nbsp; &nbsp; notification_interval &nbsp; 60<\/div>\n<div>&nbsp; &nbsp; notification_period &nbsp; &nbsp; 24&#215;7<\/div>\n<div>&nbsp; &nbsp; contacts &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nagiosadmin<\/div>\n<div>&nbsp; &nbsp; register &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<\/div>\n<div>}<\/div>\n<div>&nbsp;<\/div>\n<div>define service {<\/div>\n<div>&nbsp; &nbsp; host_name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NCPA 2 Host<\/div>\n<div>&nbsp; &nbsp; service_description &nbsp; &nbsp; Process Count<\/div>\n<div>&nbsp; &nbsp; check_command &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; check_ncpa!-t &#039;mytoken&#039; -P 5693 -M processes -w 150 -c 200<\/div>\n<div>&nbsp; &nbsp; max_check_attempts &nbsp; &nbsp; &nbsp;5<\/div>\n<div>&nbsp; &nbsp; check_interval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5<\/div>\n<div>&nbsp; &nbsp; retry_interval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<\/div>\n<div>&nbsp; &nbsp; check_period &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;24&#215;7<\/div>\n<div>&nbsp; &nbsp; notification_interval &nbsp; 60<\/div>\n<div>&nbsp; &nbsp; notification_period &nbsp; &nbsp; 24&#215;7<\/div>\n<div>&nbsp; &nbsp; contacts &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nagiosadmin<\/div>\n<div>&nbsp; &nbsp; register &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<\/div>\n<div>}<\/div>\n<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>\n<div>And finaly, tell Nagios to add monitoring from new configuration file by adding new <b>cfg_file<\/b> line to <b>nagios.cfg<\/b> file.<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<div><a href=\"\/\/4.bp.blogspot.com\/-LKjpOs0gzkw\/Wa6H3p1hqnI\/AAAAAAAADNo\/dVqUSWEAEUo3dS89kGxB5CsL0ZI-7oC0ACK4BGAYYCw\/s1600\/image-770583.png\"><img decoding=\"async\" alt=\"\" border=\"0\" id=\"BLOGGER_PHOTO_ID_6462251905516153458\" src=\"https:\/\/4.bp.blogspot.com\/-LKjpOs0gzkw\/Wa6H3p1hqnI\/AAAAAAAADNo\/dVqUSWEAEUo3dS89kGxB5CsL0ZI-7oC0ACK4BGAYYCw\/s320\/image-770583.png\" \/><\/a><\/div>\n<div>&nbsp;<\/div>\n<div>\n<div>Change<b> icon_image <\/b>and <b>statusmap_image<\/b> &nbsp;in <b>ncpa.cfg<\/b> file by choosing some png files from<\/div>\n<div><u>\/usr\/local\/nagios\/share\/images<\/u> folder.<\/div>\n<\/div>\n<div><a href=\"\/\/3.bp.blogspot.com\/--h4N-aGGWnw\/Wa6H35j3VyI\/AAAAAAAADNw\/50gkgdvRmN4Mpk2oN3AQPAzGt-Q2KIa_QCK4BGAYYCw\/s1600\/image-771745.png\"><img decoding=\"async\" alt=\"\" border=\"0\" id=\"BLOGGER_PHOTO_ID_6462251909737043746\" src=\"https:\/\/3.bp.blogspot.com\/--h4N-aGGWnw\/Wa6H35j3VyI\/AAAAAAAADNw\/50gkgdvRmN4Mpk2oN3AQPAzGt-Q2KIa_QCK4BGAYYCw\/s320\/image-771745.png\" \/><\/a><br \/>&nbsp;<\/div>\n<div>For example, instead ncpa.png (in ncpa.cfg) choose<b> workstation.png<\/b><\/div>\n<div><b><a href=\"\/\/3.bp.blogspot.com\/-wbTZblGVSAI\/Wa6H4BgePPI\/AAAAAAAADN4\/-ijUjypaZJAlcoX8NMnCol_PuupeAogRwCK4BGAYYCw\/s1600\/image-772834.png\"><img decoding=\"async\" alt=\"\" border=\"0\" id=\"BLOGGER_PHOTO_ID_6462251911870299378\" src=\"https:\/\/3.bp.blogspot.com\/-wbTZblGVSAI\/Wa6H4BgePPI\/AAAAAAAADN4\/-ijUjypaZJAlcoX8NMnCol_PuupeAogRwCK4BGAYYCw\/s320\/image-772834.png\" \/><\/a><\/b><\/div>\n<div>&nbsp;<\/div>\n<div>More info: https:\/\/assets.nagios.com\/downloads\/nagioscore\/docs\/nagioscore\/4\/en\/monitoring-windows.html<\/div>\n<p>Credits: https:\/\/milanorlovic.blogspot.pt\/2017\/09\/nagios-active-checks-checkncpapy.html<\/p>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nagios Active Checks (check_ncpa.py) &nbsp; Nagios plugin: https:\/\/assets.nagios.com\/downloads\/ncpa\/check_ncpa.tar.gz &nbsp; Copy check_ncpa.py &nbsp;to \/usr\/local\/nagios\/libexec (plugin directory) or \/usr\/lib64\/nagios\/plugins\/ (plugin directory Centos 6.9) &nbsp; ln -s check_ncpa.py check_ncpa &nbsp; Define new check_ncpa command by adding following lines to \/usr\/local\/nagios\/etc\/objects\/commands.cfg &nbsp; define command &hellip; <a href=\"https:\/\/blog.ffteixeira.net\/?p=213\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[28],"class_list":["post-213","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-nagios-4"],"_links":{"self":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts\/213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=213"}],"version-history":[{"count":0,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts\/213\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}