[chef] Re: Re: nagios plugins


Chronological Thread 
  • From: Nikhil Shah < >
  • To:
  • Subject: [chef] Re: Re: nagios plugins
  • Date: Wed, 28 Aug 2013 13:50:26 -0400

The above lines above that are as follow:



Recipe: <Dynamically Defined Resource>
  * file[/etc/nagios/nrpe.d/check_procs.cfg] action create (up to date)
Recipe: nagios::custom_plugins
  * remote_directory[/usr/lib64/nagios/plugins] action createRecipe: <Dynamically Defined Resource>
  * cookbook_file[/usr/lib64/nagios/plugins/nagios_helper.rb] action create (up to date)
  * cookbook_file[/usr/lib64/nagios/plugins/file_queues.rb] action create (up to date)
  * cookbook_file[/usr/lib64/nagios/plugins/db_queues.rb] action create (up to date)
  * cookbook_file[/usr/lib64/nagios/plugins/check_solr.rb] action create (up to date)
  * cookbook_file[/usr/lib64/nagios/plugins/check_redis.py] action create
    - create new file /usr/lib64/nagios/plugins/check_redis.py
    - update content in file /usr/lib64/nagios/plugins/check_redis.py from none to e1fb11
        --- /usr/lib64/nagios/plugins/check_redis.py 2013-08-28 12:39:07.000000000 -0400
        +++ /tmp/.check_redis.py20130828-10728-1bhiecr 2013-08-28 12:39:07.000000000 -0400
        @@ -0,0 +1,57 @@
        +#!/usr/bin/python
        + 
        +import socket
        +import sys
        +from optparse import OptionParser
        + 
        +EXIT_OK = 0
        +EXIT_WARN = 1
        +EXIT_CRITICAL = 2
        + 
        +def get_info(host, port, timeout):
        +    socket.setdefaulttimeout(timeout or None)
        +    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        +    s.connect((host, port))
        +    s.send("*1\r\n$4\r\ninfo\r\n")
        +    buf = ""
        +    while '\r\n\r\n' not in buf:
        +        buf += s.recv(1024)
        +    s.close()
        +    return dict(x.split(':', 1) for x in buf.split('\r\n') if ':' in x)
        + 
        +def build_parser():
        +    parser = OptionParser()
        +    parser.add_option("-s", "--server", dest="server", help="Redis server to connect to.", default="127.0.0.1")
        +    parser.add_option("-p", "--port", dest="port", help="Redis port to connect to.", type="int", default=6379)
        +    parser.add_option("-w", "--warn", dest="warn_memory", help="Memory utilization (in MB) that triggers a warning status.", type="int")
        +    parser.add_option("-c", "--critical", dest="crit_memory", help="Memory utilization (in MB) that triggers a critical status.", type="int")
        +    parser.add_option("-t", "--timeout", dest="timeout", help="Number of milliesconds to wait before timing out and considering redis down", type="int", default=2000)
        +    return parser
        + 
        +def main():
        +    parser = build_parser()
        +    options, _args = parser.parse_args()
        +    if not options.warn_memory:
        +        parser.error("Warning level required")
        +    if not options.crit_memory:
        +        parser.error("Critical level required")
        +    
        +    try:
        +        info = get_info(options.server, int(options.port), timeout=options.timeout / 1000.0)
        +    except socket.error, exc:
        +        print "CRITICAL: Error connecting or getting INFO from redis %s:%s: %s" % (options.server, options.port, exc)
        +        sys.exit(EXIT_CRITICAL)
        +    
        +    memory = int(info.get("used_memory_rss") or info["used_memory"]) / (1024*1024)
        +    if memory > options.crit_memory:
        +        print "CRITICAL: Redis memory usage is %dMB (threshold %dMB)" % (memory, options.crit_memory)
        +        sys.exit(EXIT_CRITICAL)
        +    elif memory > options.warn_memory:
        +        print "WARN: Redis memory usage is %dMB (threshold %dMB)" % (memory, options.warn_memory)
        +        sys.exit(EXIT_WARN)
        +    
        +    print "OK: Redis memory usage is %dMB" % memory
        +    sys.exit(EXIT_OK)
        + 
        +if __name__ == "__main__":
        +    main()

Nikhil Shah  System Administrator

The Orchard® / www.theorchard.com

t (+1) 212.308.5648 / f (+1) 212.201.9203
23 E. 4th St., 3rd Fl / New York, NY 10003

The Daily Rind™ / www.dailyrindblog.com
Facebook / @orchtweets

Privileged And Confidential Communication.
This electronic transmission, and any documents attached hereto, (a) are protected by the Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may contain confidential and/or legally privileged information, and (c) are for the sole use of the intended recipient named above. If you have received this electronic message in error, please notify the sender and delete the electronic message. Any disclosure, copying, distribution, or use of the contents of the information received in error is strictly prohibited.
 

On Aug 28, 2013, at 1:09 PM, Daniel DeLeo < "> > wrote:


On Wednesday, August 28, 2013 at 10:05 AM, "> wrote:

With some difficulties, I was able to deploy out the nagios cookbook.



However, I noticed there was no "custom plugins location" so I created one
under files with the following recipe:

remote_directory node['nagios']['plugin_dir'] do
source "plugins"
owner "nagios"
group "nagios"
mode 0775
recursive true
end



However, everytime I push up a new custom plugin, it's not accepting my mode
0755 and I keep getting the following when I run chef-client


change mode from '' to '0644

What is right above this line? You should see the name of the resource that's making the change.

-- 
Daniel DeLeo





Archive powered by MHonArc 2.6.16.

§