commit d4d4074b1bfc0b981a9a18b15964e7371cf19126 Author: mpana Date: Mon Aug 12 11:59:29 2019 +0300 initial import diff --git a/README.md b/README.md new file mode 100644 index 0000000..90af95d --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +This is a repo containing all (hopefully) of our check_mk plugins. diff --git a/ansible-check_mk/README.md b/ansible-check_mk/README.md new file mode 100644 index 0000000..bffeaac --- /dev/null +++ b/ansible-check_mk/README.md @@ -0,0 +1,84 @@ +# INTRO +These are ansible playbooks used for deploying an OMD instance as well as a simple haproxy and two web servers. These are the playbooks that were used by Marius Pana at the 2nd Check_MK conference in Munich, Germany. The presentation will be made available online shortly for those that are interested. + +Alert handlers (as defined by Check_MK) can be used from within Check_MK to signal the execution of specific handlers (as defined by Ansible) from the ansible playbooks so as to provide a simple feedback loop which provides self healing. + +*We are still looking for a good mapping of services between check_mk and ansible. One solution that was recommended was the use of service attributes(nagios macros) which could then be mapped one-to-one with ansible tags. As soon as we have something functional we will update this. If anyone else has ideas we are interested in hearing them.* + +These examples are fairly simple but can and should be expanded to include more logic for repairing your specific systems/services. We intended these as a starting point. + +## About these playbooks +We are assuming you are using a RedHat based distro. These playbooks will deploy for you an OMD instance on a freshly installed system, they will configure an HAProxy for load balancing between two apache web servers. + +We do not do the initial provisioning via these playbooks but this could be included in the future (i.e. deploy to joyent, cobbler or others). In other words we expect that you have the systems freshly installed and configured with a root user that is allowed SSH access as defined in the cmkconfinv (inventory) file. + +### ansible inventory file +The cmkconvinf file contains our inventory. In it we define three groups of hosts, a variable named folder which is the OMD folder we create via the WATO API for the respective host(s) and the IP address where these hosts can be reached. + +You must have these installed and configured before running these playbooks. You will also need to know the root user password. + +## Prerequisites +Make sure you change the users and ssh keys via the common role. Upload you ssh keys in roles/common/files and edit roles/common/vars/usersandpsks.yml. + +### Ansible +You will need a functional ansible set-up. Setting it up can be as easy as cloning the ansible repo or installing via your operating system package manager. More information about installing ansible can be found here: http://docs.ansible.com/ansible/intro_installation.html . + +You will also need to clone this repository to play around with these playbooks. + +### Check_MK +We are assuming you are using the CEE (Check_MK Enterprise Edition). While this should work with any recent version of Check_MK we are specifically targeting the use of the current innovation branch (1.2.7i) because of the new Alert Handlers (Werk #8275). + +If you would like to deploy your OMD instance via these playbooks you will need to download Check_MK CEE in RPM format and place it in the following directory: + +> roles/omd/files + +## Deploying OMD via Ansible +This is a very simple way to deploy an OMD instance and create a site named "prod". The following command will deploy OMD to your preinstalled server. It will prompt for the root users password (-k). + +> ansible-playbook -i cmkconfinv site.yml -l omd -u root -k --skip-tags check_mk_agent,check_mk_discovery,check_mk_apply + +Notice the use of the --skip-tags switch which is necessary as in this first run we do not have an OMD instance running from which to pull the agent, discovery, etc. + +You now need to create an Automation user in our Check_MK site and use that information in the roles/omd/vars/main.yml file. + +Now we can deploy the check_mk_agent to our monitoring instance as well. Notice we are running just the check_mk_agent, discovery and pply steps now. Also after bootstrapping your system you can use your own user if you created one and uploaded the ssh keys. In this case you could use ansible with sudo (-u *your_username* -s instead of -u root). + +> ansible-playbook -i cmkconfinv site.yml -l omd -u root --tags check_mk_agent,check_mk_discovery,check_mk_apply + + +## Deploying the webserver and loadbalancer +The following will configure your webservers and loadbalancer. It will prompt for the root users password (-k). Once it is done you should have in your OMD instance 4 hosts (1 omd, 2 web servers and one lb) and their services monitored. + +> ansible-playbook -i cmkconfinv site.yml -l loadbalancers,webservers -u root -k + +## Check_MK Alert Handlers +We have created two alert handlers to showcase two different scenarios: + +1. services.sh - Restarting of apache web services if they are failed +2. instantiate.sh - Deploying a loadbalancer if it fails (state DOWN) + +These are specific to the setup we were using for the presentation at the conference however they serve as a good starting point. + +Add the following two Alert Handlers to your Check_MK site and place the scripts in ~/local/share/check_mk/alert_handlers (make sure they are executable): + +services.sh +![image of services.sh ](http://i67.tinypic.com/jgqqzm.png) +``` +#!/bin/bash +ansible-playbook -i /omd/sites/prod/ansible/cmkconfinv /omd/sites/prod/ansible/site.yml -l webservers -u root --tags httpd +``` + +instantiate.sh +![image of instantiate.sh ](http://i65.tinypic.com/14c9s8w.png) +``` +#!/bin/bash +ssh root@10.88.88.145 vmadm create -f /etc/zones/loadbalancer.json + +ansible-playbook -i /omd/sites/prod/ansible/cmkconfinv /omd/sites/prod/ansible/site.yml -l loadbalancers -u root +``` +The first line is specific to my setup which is using SmartOS available at 10.88.88.145. There I have already created a manifest file (loadbalancer.json) to create a loadbalancer instance. You will want to change this for your particular set-up. + +## TODO +You may notice an extra two check_mk checks named up_upscale and down_scale on your loadbalancer instance. These are not finished yet however they are an example of how you could use check_mk and ansible to do autoscaling. Based on feedback received via your monitoring you can bring up or down more instances effectively doing autoscaling. This is a work in progress and will be updated in the near future. The ansible tags are add_backend and del_backend, these may be useful if you plan on extending these. + +There are certainly more things to be done here ... diff --git a/ansible-check_mk/bootstrap.yml b/ansible-check_mk/bootstrap.yml new file mode 100644 index 0000000..2355a79 --- /dev/null +++ b/ansible-check_mk/bootstrap.yml @@ -0,0 +1,7 @@ +--- +# file: bootstrap.yml +- hosts: all + #vars: + vars_files: [roles/common/vars/usersandpsks.yml, roles/omd/vars/main.yml] + roles: + - common diff --git a/ansible-check_mk/cmkconfinv b/ansible-check_mk/cmkconfinv new file mode 100644 index 0000000..915893d --- /dev/null +++ b/ansible-check_mk/cmkconfinv @@ -0,0 +1,9 @@ +[loadbalancers] +lb01 ansible_ssh_host=10.88.88.127 folder=loadbalancers + +[webservers] +web1 ansible_ssh_host=10.88.88.128 folder=webservers +web2 ansible_ssh_host=10.88.88.129 folder=webservers + +[omd] +omd ansible_ssh_host=10.88.88.150 folder=omd diff --git a/ansible-check_mk/loadbalancers.yml b/ansible-check_mk/loadbalancers.yml new file mode 100644 index 0000000..d97fd1f --- /dev/null +++ b/ansible-check_mk/loadbalancers.yml @@ -0,0 +1,7 @@ +--- +# file: loadbalancers.yml +- hosts: loadbalancers + vars_files: [roles/common/vars/usersandpsks.yml, roles/omd/vars/main.yml] + roles: + - common + - loadbalancers diff --git a/ansible-check_mk/omd.yml b/ansible-check_mk/omd.yml new file mode 100644 index 0000000..634404c --- /dev/null +++ b/ansible-check_mk/omd.yml @@ -0,0 +1,7 @@ +--- +# file: omd.yml +- hosts: omd + #vars: + #vars_files: + roles: + - omd diff --git a/ansible-check_mk/roles/common/files/ssh_keys/mariusp.pub b/ansible-check_mk/roles/common/files/ssh_keys/mariusp.pub new file mode 100644 index 0000000..694f8e5 --- /dev/null +++ b/ansible-check_mk/roles/common/files/ssh_keys/mariusp.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/asZXkhLJVGIcPQGUxZDLl/yMwslgn6GyJd6QGKUmR+Snr1hMz01y7WEWPvfXXUqNym6rMU5fAMUr+alcyzMGZYKyymTLfjgp0SUuWG3TGpl3EPxnfGwNcXOvuJE9cnY0q3nhZgQjvn6EdEFDKAmLG1WXlKYjbQUUrHp0wFvEx3TNIXMVJqHxbKi8Uwyvn5EB1emdeJkaAaXJbk1TxALu400Ts0KYJUUyMn5njJjVELwtPVsnb0skmKSXd4dgBLN+wo94YQLpdfCnmho0uPhZfTHHi0+jtJNtUSycOSuOr/TxYGirxOYcb5FoOvzg9L0RyQAj6O+Hzs3RkHB+qast mariusp@marduk.local diff --git a/ansible-check_mk/roles/common/handlers/main.yml b/ansible-check_mk/roles/common/handlers/main.yml new file mode 100644 index 0000000..079c4f1 --- /dev/null +++ b/ansible-check_mk/roles/common/handlers/main.yml @@ -0,0 +1,15 @@ +--- +# file: roles/common/handlers/main.yml +- name: restart ntp + service: name=ntp state=restarted + tags: + - ntpd + +- name: restart xinetd + service: name=xinetd state=restarted + tags: xinetd + +- name: restart sshd + service: name=sshd state=restarted + tags: + - sshd diff --git a/ansible-check_mk/roles/common/tasks/main.yml b/ansible-check_mk/roles/common/tasks/main.yml new file mode 100644 index 0000000..31c70b9 --- /dev/null +++ b/ansible-check_mk/roles/common/tasks/main.yml @@ -0,0 +1,73 @@ +--- +# file: roles/common/tasks/main.yml +- name: make sure ntp,epel,etc. are installed + yum: pkg={{ item }} state=installed + with_items: + - ntp + - xinetd + - epel-release + #- screen + #- vim-enhanced + #- mc + tags: packages + +- name: add sphs group + action: group name=sphs state=present + +- name: add our users + action: user name={{ item }} groups=sphs state=present append=yes + with_items: usersAdd + when: item != 'none' + +- name: Add SSH public key to user mariusp + action: authorized_key user=mariusp key="{{ lookup('file', "../files/ssh_keys/mariusp.pub") }}" + +- name: Remove users + action: user name={{ item }} state=absent remove=yes + with_items: usersDel + when: item != 'none' + +# Enable sudo for sphs group with no password +- name: Enable sudo without password for sudo group + action: 'lineinfile "dest=/etc/sudoers" state=present regexp="^%sphs ALL" line="%sphs ALL=(ALL) NOPASSWD: ALL"' + +- name: install check_mk agent + yum: pkg=http://{{ omdhost }}/{{ omdsite }}/check_mk/agents/{{ rpmagent }} state=installed + tags: + - check_mk_agent + +# change to get_uri - do some error checking +- name: add host to omd + uri: + method: POST + body_format: json + url: http://{{omdhost}}/{{omdsite}}/check_mk/webapi.py?action=add_host&_username={{automationuser}}&_secret={{autosecret}} + body: 'request={"attributes":{"alias":"{{inventory_hostname}}","ipaddress":"{{ansible_default_ipv4["address"]}}"},"hostname":"{{inventory_hostname}}","folder":"{{folder}}"}' + delegate_to: 127.0.0.1 + tags: + - check_mk_agent + notify: + - cmk_discovery + - cmk_apply + +- name: cmk_discovery + uri: + method: POST + url: http://{{ omdhost }}/{{ omdsite }}/check_mk/webapi.py?action=discover_services&_username={{ automationuser }}&_secret={{ autosecret }}&mode=refresh + body: 'request={"hostname":"{{ inventory_hostname }}"}' + body_format: json + status_code: 200 + tags: + - check_mk_discovery + delegate_to: 127.0.0.1 + +- name: cmk_apply + uri: + method: POST + url: http://{{ omdhost }}/{{ omdsite }}/check_mk/webapi.py?action=activate_changes&_username={{ automationuser }}&_secret={{ autosecret }}&mode=specific + body: request={"sites":["{{ omdsite }}"]} + body_format: json + status_code: 200 + tags: + - check_mk_apply + delegate_to: 127.0.0.1 diff --git a/ansible-check_mk/roles/common/vars/usersandpsks.yml b/ansible-check_mk/roles/common/vars/usersandpsks.yml new file mode 100644 index 0000000..059f83a --- /dev/null +++ b/ansible-check_mk/roles/common/vars/usersandpsks.yml @@ -0,0 +1,8 @@ +--- +usersAdd: + - mariusp +usersDel: + - none +usersPSK: + - name: mariusp + psk: ["../files/ssh_keys/mariusp.pub"] diff --git a/ansible-check_mk/roles/loadbalancers/files/check_ha.sh b/ansible-check_mk/roles/loadbalancers/files/check_ha.sh new file mode 100644 index 0000000..b1e599c --- /dev/null +++ b/ansible-check_mk/roles/loadbalancers/files/check_ha.sh @@ -0,0 +1,24 @@ +#!/bin/bash +CONN=`echo "show info" | socat /var/lib/haproxy/stats stdio |grep CurrConns | cut -d' ' -f2` +SRVS=`cat /etc/haproxy/haproxy.cfg |grep check | grep server |wc -l` +if [ $CONN = 0 ]; then + CONN=4 +fi +if [ $SRVS = 0 ]; then + echo "<<>>" + echo "up_scale 1000" + echo "<<>>" + echo "down_scale 1000" +else + let "CONNPERSRV=$CONN/$SRVS" + echo "<<>>" + echo "up_scale $CONNPERSRV" + if [ $SRVS -le 2 ]; then + echo "<<>>" + echo "down_scale 16" + else + echo "<<>>" + echo "down_scale $CONNPERSRV" + fi + +fi diff --git a/ansible-check_mk/roles/loadbalancers/files/haproxy.cfg.j2 b/ansible-check_mk/roles/loadbalancers/files/haproxy.cfg.j2 new file mode 100644 index 0000000..ea75cc9 --- /dev/null +++ b/ansible-check_mk/roles/loadbalancers/files/haproxy.cfg.j2 @@ -0,0 +1,57 @@ +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + daemon + stats socket /var/lib/haproxy/stats mode 644 level admin + stats timeout 2m + +#--------------------------------------------------------------------- +# common defaults that all the 'listen' and 'backend' sections will +# use if not designated in their block +#--------------------------------------------------------------------- +defaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +#--------------------------------------------------------------------- +# main frontend which proxys to the backends +#--------------------------------------------------------------------- +frontend main *:5000 + acl url_static path_beg -i /static /images /javascript /stylesheets + acl url_static path_end -i .jpg .gif .png .css .js + + #use_backend static if url_static + #default_backend appname + +## +listen appname 0.0.0.0:80 + mode http + stats enable + stats uri /haproxy?stats + stats realm Strictly\ Private + stats auth marius:marius + balance roundrobin + option httpclose + option forwardfor + # we are adding our hosts manually .. + # we could populate this dynamically from our inventory + server web1 10.88.88.128:80 check + server web2 10.88.88.129:80 check diff --git a/ansible-check_mk/roles/loadbalancers/handlers/main.yml b/ansible-check_mk/roles/loadbalancers/handlers/main.yml new file mode 100644 index 0000000..d2c9b73 --- /dev/null +++ b/ansible-check_mk/roles/loadbalancers/handlers/main.yml @@ -0,0 +1,29 @@ +--- +- name: restart haproxy + service: name=haproxy state=restarted + tags: haproxy + +#la executie scriptul va seta cu -e o noua variabila de genul new_server=' server web2 10.88.88.129:80 check' + +- name: add_backend + action: 'lineinfile "dest=/etc/haproxy/haproxy.cfg" state=present regexp="{{new_server}}" line="{{new_Server}}"' + tags: + - add_backend + +#la executie scriptul va seta cu -e o noua variabila de genul old_server=' server web2 10.88.88.129:80 check' +- name: del_backend + action: 'lineinfile "dest=/etc/haproxy/haproxy.cfg" state=absent regexp="{{old_server}}" line="{{old_Server}}"' + tags: + - del_backend + +- name: cmk_discovery + command: curl 'http://{{ omdhost }}/{{ omdsite }}/check_mk/webapi.py?action=discover_services&_username={{ automationuser }}&_secret={{ autosecret }}&mode=refresh' -d 'request={"hostname":"{{ inventory_hostname }}"}' + tags: + - check_mk_agent + - check_mk_discovery + +- name: cmk_apply + command: curl 'http://{{ omdhost }}/{{ omdsite }}/check_mk/webapi.py?action=activate_changes&_username={{ automationuser }}&_secret={{ autosecret }}&mode=specific' -d 'request={"sites":["{{ omdsite }}"]}' + tags: + - check_mk_agent + - check_mk_discovery diff --git a/ansible-check_mk/roles/loadbalancers/tasks/main.yml b/ansible-check_mk/roles/loadbalancers/tasks/main.yml new file mode 100644 index 0000000..899d49b --- /dev/null +++ b/ansible-check_mk/roles/loadbalancers/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: make sure haproxy and socat is installed + yum: name={{ item}} state=latest + with_items: + - socat + - haproxy + tags: packages + +- name: copy haproxy configuration files + copy: src=../files/haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg backup=yes mode=0644 + notify: + - restart haproxy + +- name: deploy ha_check.sh (autoscale) + copy: src=../files/check_ha.sh dest=/usr/lib/check_mk_agent/plugins/check_sa.sh mode=755 + tags: check_sa + notify: + - cmk_discovery + - cmk_apply + +- name: enable haproxy + service: name=haproxy enabled=yes state=started diff --git a/ansible-check_mk/roles/omd/tasks/main.yml b/ansible-check_mk/roles/omd/tasks/main.yml new file mode 100644 index 0000000..a0a9ca2 --- /dev/null +++ b/ansible-check_mk/roles/omd/tasks/main.yml @@ -0,0 +1,27 @@ +--- +# file: roles/common/tasks/main.yml +# we need omd host/site from omd role +- include_vars: roles/omd/vars/main.yml + +- name: make sure epel is installed + yum: pkg={{ item }} state=installed + with_items: + - epel-release + tags: packages + +- name: upload omd package + copy: src=roles/omd/files/check-mk-enterprise-1.2.7i3p1-el6-36.x86_64.rpm dest=/tmp + +- name: install omd server + yum: name=/tmp/check-mk-enterprise-1.2.7i3p1-el6-36.x86_64.rpm state=present + +# might be nice to create ansible module for omd +- name: create prod instance + command: /usr/bin/omd create prod + tags: + - omdcreate + +- name: start our prod instance + command: /usr/bin/omd start prod + tags: + - omdstart diff --git a/ansible-check_mk/roles/omd/vars/main.yml b/ansible-check_mk/roles/omd/vars/main.yml new file mode 100644 index 0000000..c56c487 --- /dev/null +++ b/ansible-check_mk/roles/omd/vars/main.yml @@ -0,0 +1,7 @@ +--- +automationuser: "automaton" +autosecret: "GUVKRNECLRGFBTQJCRFY" +omdhost: "10.88.88.150" +#omdhost: "192.168.217.129" +omdsite: "prod" +rpmagent: "check-mk-agent-1.2.7i3p1-1.noarch.rpm" diff --git a/ansible-check_mk/roles/webservers/files/konf.jpg b/ansible-check_mk/roles/webservers/files/konf.jpg new file mode 100644 index 0000000..fd91efe Binary files /dev/null and b/ansible-check_mk/roles/webservers/files/konf.jpg differ diff --git a/ansible-check_mk/roles/webservers/files/status.conf.j2 b/ansible-check_mk/roles/webservers/files/status.conf.j2 new file mode 100644 index 0000000..cfb047e --- /dev/null +++ b/ansible-check_mk/roles/webservers/files/status.conf.j2 @@ -0,0 +1,6 @@ + + SetHandler server-status + Order deny,allow + Deny from all + Allow from 10.88.88.150 127.0.0.1 ::1 + diff --git a/ansible-check_mk/roles/webservers/handlers/main.yml b/ansible-check_mk/roles/webservers/handlers/main.yml new file mode 100644 index 0000000..df85424 --- /dev/null +++ b/ansible-check_mk/roles/webservers/handlers/main.yml @@ -0,0 +1,20 @@ +--- +- name: restart httpd + service: name=httpd state=restarted + tags: + - httpd + notify: + - cmk_discovery + - cmk_apply + +- name: cmk_discovery + command: curl 'http://{{ omdhost }}/{{ omdsite }}/check_mk/webapi.py?action=discover_services&_username={{ automationuser }}&_secret={{ autosecret }}&mode=refresh' -d 'request={"hostname":"{{ inventory_hostname }}"}' + tags: + - check_mk_agent + - check_mk_discovery + +- name: cmk_apply + command: curl 'http://{{ omdhost }}/{{ omdsite }}/check_mk/webapi.py?action=activate_changes&_username={{ automationuser }}&_secret={{ autosecret }}&mode=specific' -d 'request={"sites":["{{ omdsite }}"]}' + tags: + - check_mk_agent + - check_mk_discovery diff --git a/ansible-check_mk/roles/webservers/tasks/main.yml b/ansible-check_mk/roles/webservers/tasks/main.yml new file mode 100644 index 0000000..13f45a8 --- /dev/null +++ b/ansible-check_mk/roles/webservers/tasks/main.yml @@ -0,0 +1,36 @@ +--- +- name: make sure httpd is installed + yum: name=httpd state=latest + tags: httpd + +- name: enable httpd + service: name=httpd enabled=yes state=started + tags: + - httpd + +- name: enable http status + copy: src=../files/status.conf.j2 dest=/etc/httpd/conf.d/status.conf backup=yes mode=0644 + notify: + - restart httpd + tags: + - http_status + - cmk_discovery + - cmk_apply + +- name: add apache_status plugin + get_url: url=http://{{ omdhost }}/{{ omdsite }}/check_mk/agents/plugins/apache_status dest=/usr/lib/check_mk_agent/plugins/apache_status mode=0755 + tags: + - apache_status + notify: + - cmk_discovery + - cmk_apply + +- name: copy images to sites + copy: src=../files/konf.jpg dest=/var/www/html/ mode=0644 + tags: + - webcontent + +- name: copy index.html to sites + template: src=../templates/index.html.j2 dest=/var/www/html/index.html mode=0644 + tags: + - webcontent diff --git a/ansible-check_mk/roles/webservers/templates/index.html.j2 b/ansible-check_mk/roles/webservers/templates/index.html.j2 new file mode 100644 index 0000000..b91c123 --- /dev/null +++ b/ansible-check_mk/roles/webservers/templates/index.html.j2 @@ -0,0 +1,16 @@ + + +Welcome to the 2ND Check_MK Conference! + + + + +
+
+Welcome to the 2ND Check_MK Conference! +
+ +

Im running on {{ inventory_hostname }}.

+

Running on {{ ansible_os_family }} ;-}

+ + diff --git a/ansible-check_mk/site.yml b/ansible-check_mk/site.yml new file mode 100644 index 0000000..8431a9f --- /dev/null +++ b/ansible-check_mk/site.yml @@ -0,0 +1,5 @@ +--- +- include: bootstrap.yml +- include: webservers.yml +- include: loadbalancers.yml +- include: omd.yml diff --git a/ansible-check_mk/webservers.yml b/ansible-check_mk/webservers.yml new file mode 100644 index 0000000..bab7828 --- /dev/null +++ b/ansible-check_mk/webservers.yml @@ -0,0 +1,7 @@ +--- +# file: webservers.yml +- hosts: webservers + vars_files: [roles/common/vars/usersandpsks.yml, roles/omd/vars/main.yml] + roles: + - common + - webservers diff --git a/check_ibm_flex/README.MD b/check_ibm_flex/README.MD new file mode 100644 index 0000000..49f187d --- /dev/null +++ b/check_ibm_flex/README.MD @@ -0,0 +1 @@ +# check_ibm_flex repository diff --git a/check_ibm_flex/check_ibm_flex-1.0.mkp b/check_ibm_flex/check_ibm_flex-1.0.mkp new file mode 100644 index 0000000..c862615 Binary files /dev/null and b/check_ibm_flex/check_ibm_flex-1.0.mkp differ diff --git a/check_ibm_flex/flex_blade_bays b/check_ibm_flex/flex_blade_bays new file mode 100644 index 0000000..5faa72c --- /dev/null +++ b/check_ibm_flex/flex_blade_bays @@ -0,0 +1,61 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# SpearHead Systems +# + + +flex_blade_bays_module_state = { + 0: 'standby', + 1: 'on', + 2: 'notPresent', + 255: 'notApplicable', +} + +def flex_blade_bays_make_item(line): + # "3.IO Module 5" + pd, name = line[0].split(".", 1) + if pd == '2': + power_domain = 1 + else: + power_domain = 2 + return "PD%d %s" % (power_domain, name) + +def inventory_flex_blade_bays(info): + # find only modules that are present and switched on or standby + inventory = [] + for line in info: + if line[1] in [ '0', '1' ]: + item = flex_blade_bays_make_item(line) + inventory.append((item, None)) + return inventory + +def check_flex_blade_bays(item, _no_params, info): + for line in info: + if item == flex_blade_bays_make_item(line): + state = saveint(line[1]) + type = line[2].split('(')[0] + if state == 1: + return (0, "State %s (Type: %s, ID: %s)" % + (flex_blade_bays_module_state.get(state, 'Unhandled'), type, line[3])) + elif state == 2: + return (1, "Not present") + elif state == 3: + return (1, "Device is switched off") + elif state == 0: + return (1, "Device is in standby") + else: + return (2, "invalid state %d" % state) + return (3, "no data for '%s' in SNMP info" % item) + +check_info["flex_blade_bays"] = { + 'check_function': check_flex_blade_bays, + 'inventory_function': inventory_flex_blade_bays, + 'service_description': 'IBM Flex Bay %s', + 'snmp_info': ( + ".1.3.6.1.4.1.2.3.51.2.2.10", [ + "2", # powerDomain1 + "3", # powerDomain2 + ], [ "1.1.5", "1.1.6", "1.1.2", "1.1.1" ] ), # BLADE-MIB + 'snmp_scan_function': \ + lambda oid: re.match('IBM Flex Chassis Management Module', oid(".1.3.6.1.2.1.1.1.0")) != None, +} diff --git a/check_ibm_flex/flex_blade_blades b/check_ibm_flex/flex_blade_blades new file mode 100644 index 0000000..ca3a007 --- /dev/null +++ b/check_ibm_flex/flex_blade_blades @@ -0,0 +1,83 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# ails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +# Author: Lars Michelsen + +# Mappings for translating SNMP states to nagios states +flex_blade_blades_exists_states = (2, 0) +flex_blade_blades_power_states = (1, 0) +flex_blade_blades_health_states = (3, 0, 1, 2) + +# Name mappings +flex_blade_blades_exists_labels = ('no', 'yes') +flex_blade_blades_power_labels = ('off', 'on') +flex_blade_blades_health_labels = ('unknown', 'good', 'warning', 'bad') + +def inventory_flex_blade_blades(info): + # find only blades that are powered on + return [ (line[0], '', line[1]) for line in info if line[2] == '1' ] + +def check_flex_blade_blades(item, params, info): + for line in info: + if line[0] == item: + exists, power_state, health_state = map(saveint, line[1:4]) + name = line[4] + + state = 0 + output = '%s: ' % (name) + + for label, part_state, nag_state, state_label in ( + ('Exists', exists, flex_blade_blades_exists_states[exists], flex_blade_blades_exists_labels[exists]), + ('Power', power_state, flex_blade_blades_power_states[power_state], flex_blade_blades_power_labels[power_state]), + ('Health', health_state, flex_blade_blades_health_states[health_state], flex_blade_blades_health_labels[health_state])): + output += '%s: %s' % (label, state_label) + if nag_state == 1: + output += ' (!)' + elif nag_state == 2: + output += ' (!!)' + elif nag_state == 3: + output += ' (UNKNOWN)' + state = max(state, nag_state) + output += ', ' + + return (state, output.rstrip(', ')) + return (3, "no data for '%s' in SNMP info" % item) + +check_info["flex_blade_blades"] = { + 'check_function': check_flex_blade_blades, + 'inventory_function': inventory_flex_blade_blades, + 'service_description': 'Flex Blade %s', + 'snmp_info': ( + ".1.3.6.1.4.1.2.3.51.2.22.1.5.1.1", [ # BLADE-MIB + 2, # bladeId + 3, # bladeExists + 4, # bladePowerState + 5, # bladeHealthState + 6, # bladeName + ]), + 'snmp_scan_function': \ + lambda oid: re.match('IBM Flex Chassis Management Module', oid(".1.3.6.1.2.1.1.1.0")) != None, +} diff --git a/check_ibm_flex/flex_blade_blowers b/check_ibm_flex/flex_blade_blowers new file mode 100644 index 0000000..5be670a --- /dev/null +++ b/check_ibm_flex/flex_blade_blowers @@ -0,0 +1,89 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- + +# SpearHead Systems + +# The BLADE-MIB is somewhat goofy redarding the blower +# information. The blowers are listed sequentially +# below the same subtrees: + +# BLADE-MIB::blower1speed.0 = STRING: "50% of maximum" +# BLADE-MIB::blower2speed.0 = STRING: "50% of maximum" +# BLADE-MIB::blower1State.0 = INTEGER: good(1) +# BLADE-MIB::blower2State.0 = INTEGER: good(1) +# BLADE-MIB::blowers.20.0 = STRING: "1712" +# BLADE-MIB::blowers.21.0 = STRING: "1696" +# BLADE-MIB::blowers.30.0 = INTEGER: 0 +# BLADE-MIB::blowers.31.0 = INTEGER: 0 +# +# The same with -On: +# .1.3.6.1.4.1.2.3.51.2.2.3.1.0 = STRING: "49% of maximum" +# .1.3.6.1.4.1.2.3.51.2.2.3.2.0 = STRING: "No Blower" +# .1.3.6.1.4.1.2.3.51.2.2.3.10.0 = INTEGER: good(1) +# .1.3.6.1.4.1.2.3.51.2.2.3.11.0 = INTEGER: unknown(0) +# .1.3.6.1.4.1.2.3.51.2.2.3.20.0 = STRING: "1696" +# .1.3.6.1.4.1.2.3.51.2.2.3.21.0 = STRING: "No Blower" +# .1.3.6.1.4.1.2.3.51.2.2.3.30.0 = INTEGER: 0 +# .1.3.6.1.4.1.2.3.51.2.2.3.31.0 = INTEGER: 2 +# +# How can we safely determine the number of blowers without +# assuming that each blower has four entries? + +# We assume that all blowers are in state OK (used for +# inventory only) +def number_of_flex_blowers(info): + n = 0 + while len(info) > n and len(info[n][0]) > 1: # state lines + n += 1 + return n + +def inventory_flex_blade_blowers(info): + inventory = [] + n = number_of_flex_blowers(info) + for i in range(0, n): + if info[i + n][0] != "0": # skip unknown blowers + inventory.append( ("%d/%d" % (i+1,n), None, None) ) + return inventory + +def check_flex_blade_blowers(item, _no_params, info): + blower, num_flex_blowers = map(int, item.split("/")) + text = info[blower-1][0] + perfdata = [] + output = '' + + state = info[blower-1 + num_blowers][0] + + try: + rpm = int(info[blower-1 + 2*num_blowers][0]) + perfdata += [("rpm", rpm)] + output += 'Flex Speed at %d RMP' % rpm + except: + pass + + try: + perc = int(text.split("%")[0]) + perfdata += [("perc", perc, None, None, 0, 100)] + if output == '': + output += 'Flex Speed is at %d%% of max' % perc + else: + output += ' (%d%% of max)' % perc + except: + pass + + if state == "1": + return (0, output, perfdata) + else: + return (2, output, perfdata) + + + + +check_info["flex_blade_blowers"] = { + 'check_function': check_flex_blade_blowers, + 'inventory_function': inventory_flex_blade_blowers, + 'service_description': 'IBM Flex Blower %s', + 'has_perfdata': True, + 'snmp_info': ('.1.3.6.1.4.1.2.3.51.2.2', [3]), + 'snmp_scan_function': \ + lambda oid: re.match('IBM Flex Chassis Management Module', oid(".1.3.6.1.2.1.1.1.0")) != None, +} diff --git a/check_ibm_flex/flex_blade_health b/check_ibm_flex/flex_blade_health new file mode 100644 index 0000000..a0f5313 --- /dev/null +++ b/check_ibm_flex/flex_blade_health @@ -0,0 +1,42 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# SpearHead Systems +# + +# Example excerpt from SNMP data: +# .1.3.6.1.4.1.2.3.51.2.2.7.1.0 255 +# .1.3.6.1.4.1.2.3.51.2.2.7.2.1.1.1 1 +# .1.3.6.1.4.1.2.3.51.2.2.7.2.1.2.1 "Good" +# .1.3.6.1.4.1.2.3.51.2.2.7.2.1.3.1 "No critical or warning events" +# .1.3.6.1.4.1.2.3.51.2.2.7.2.1.4.1 "No timestamp" + + +def inventory_flex_blade_health(info): + if len(info) == 1: + return [(None, None, None)] + +def check_flex_blade_health(_no_item, _no_params, info): + state = info[0][0] + descr = ": " + ", ".join([ line[1] for line in info if len(line) > 1 ]) + + if state == "255": + return (0, "State is good") + elif state == "2": + return (2, "State is degraded (non critical)" + descr) + elif state == "4": + return (1, "State is degraded (system level)" + descr) + elif state == "0": + return (2, "State is critical!" + descr) + else: + return (3, "Undefined state code %s%s" % (state, descr)) + + + +check_info["flex_blade_health"] = { + 'check_function': check_flex_blade_health, + 'inventory_function': inventory_flex_blade_health, + 'service_description': 'IBM Flex Summary health state', + 'snmp_info': ('.1.3.6.1.4.1.2.3.51.2.2.7', ['1.0', '2.1.3.1']), + 'snmp_scan_function': \ + lambda oid: re.match('IBM Flex Chassis Management Module', oid(".1.3.6.1.2.1.1.1.0")) != None, +} diff --git a/check_ibm_flex/flex_blade_powerfan b/check_ibm_flex/flex_blade_powerfan new file mode 100644 index 0000000..af4304e --- /dev/null +++ b/check_ibm_flex/flex_blade_powerfan @@ -0,0 +1,63 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# ails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + + +def inventory_flex_blade_powerfan(info): + return [ (line[0], '(50, 60)') for line in info if line[0] != '' and line[1] == '1' ] + +def check_flex_blade_powerfan(item, params, info): + warn_perc, crit_perc = params + for index, present, status, fancount, speedperc, rpm, ctrlstate in info: + if index != item: continue + perfdata=[ ('perc', speedperc, warn_perc, crit_perc, "0", "100" ), + ('rpm', rpm ) ] + speedperc_int = saveint(speedperc) + if present != "1": + return (2, "Fan not present", perfdata) + elif status != "1": + return (2, "Status not OK", perfdata) + elif ctrlstate != "0": + return (2, "Controller state not OK", perfdata) + elif speedperc <= crit_perc: + return (2, "Speed at %d%% of max (crit at %d%%)" % (speedperc_int, crit_perc), perfdata) + elif speedperc <= warn_perc: + return (1, "Speed at %d%% of max (warning at %d%%)" % (speedperc_int, warn_perc), perfdata) + else: + return (0, "Speed at %s RPM (%d%% of max)" % (rpm, speedperc_int), perfdata) + + return (3, "Device %s not found in SNMP data" % item) + + + +check_info["flex_blade_powerfan"] = { + 'check_function': check_flex_blade_powerfan, + 'inventory_function': inventory_flex_blade_powerfan, + 'service_description': 'IBM Flex Power Module Cooling Device %s', + 'has_perfdata': True, + 'snmp_info': ('.1.3.6.1.4.1.2.3.51.2.2.6.1.1', [1, 2, 3, 4, 5, 6, 7]), + 'snmp_scan_function': \ + lambda oid: re.match('IBM Flex Chassis Management Module', oid(".1.3.6.1.2.1.1.1.0")) != None, +} diff --git a/check_ibm_flex/flex_blade_powermod b/check_ibm_flex/flex_blade_powermod new file mode 100644 index 0000000..4373cfe --- /dev/null +++ b/check_ibm_flex/flex_blade_powermod @@ -0,0 +1,31 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# SpearHead Systems +# + +def inventory_flex_blade_powermod(info): + return [ (line[0], '', '""') for line in info if line[1] == '1' ] + +def check_flex_blade_powermod(index, _no_param, info): + for line in info: + if line[0] == index: + present, status, text = line[1:] + if present != "1": + return (2, "Not present") + elif status != "1": + return (2, "%s" % text) + else: + return (0, "%s" % text) + return (3, "Module %s not found in SNMP info" % index) + + + + +check_info["flex_blade_powermod"] = { + 'check_function': check_flex_blade_powermod, + 'inventory_function': inventory_flex_blade_powermod, + 'service_description': 'IBM Flex Power Module %s', + 'snmp_info': ('.1.3.6.1.4.1.2.3.51.2.2.4.1.1', [1, 2, 3, 4]), + 'snmp_scan_function': \ + lambda oid: re.match('IBM Flex Chassis Management Module', oid(".1.3.6.1.2.1.1.1.0")) != None, +} diff --git a/check_mk-check-nfsiostat/.gitignore b/check_mk-check-nfsiostat/.gitignore new file mode 100644 index 0000000..722d5e7 --- /dev/null +++ b/check_mk-check-nfsiostat/.gitignore @@ -0,0 +1 @@ +.vscode diff --git a/check_mk-check-nfsiostat/agents/bakery/mk_nfsiostat b/check_mk-check-nfsiostat/agents/bakery/mk_nfsiostat new file mode 100644 index 0000000..c7946ab --- /dev/null +++ b/check_mk-check-nfsiostat/agents/bakery/mk_nfsiostat @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +def bake_nfsiostat(opsys, conf, conf_dir, plugins_dir): + source = cmk.paths.local_agents_dir + "/plugins/mk_nfsiostat" + dest = plugins_dir + "/mk_nfsiostat" + shutil.copy2(source, dest) + +bakery_info["mk_nfsiostat"] = { + "bake_function" : bake_nfsiostat, + "os" : [ "linux", ], +} diff --git a/check_mk-check-nfsiostat/agents/plugins/mk_nfsiostat b/check_mk-check-nfsiostat/agents/plugins/mk_nfsiostat new file mode 100644 index 0000000..4bea8ef --- /dev/null +++ b/check_mk-check-nfsiostat/agents/plugins/mk_nfsiostat @@ -0,0 +1,6 @@ +#!/bin/bash + +if command nfsiostat > /dev/null ; then + echo '<<>>' + nfsiostat | paste -sd " " - | tr -s ' ' +fi diff --git a/check_mk-check-nfsiostat/checkman/nfsiostat b/check_mk-check-nfsiostat/checkman/nfsiostat new file mode 100644 index 0000000..e76e07c --- /dev/null +++ b/check_mk-check-nfsiostat/checkman/nfsiostat @@ -0,0 +1,16 @@ +title: Check NFS IO Stats +agents: linux +catalog: os/storage +distribution: +author: Marius Pana +license: GPL +description: + This check monitors the performance of NFS mounts on client systems by way of + the nfsiostat command. This requires the nfs-utils (Red Hat) or nfs-common + (Debian) packages to be installed. + It monitors every nfs mount point found and provides the following metrics: + operations per second, rpc backlog, read/write: operations per second, bytes per + second, bytes per operation, retransmissions (%), average RTT (ms) and average + exe (ms). + + \ No newline at end of file diff --git a/check_mk-check-nfsiostat/checks/nfsiostat b/check_mk-check-nfsiostat/checks/nfsiostat new file mode 100644 index 0000000..f43e56d --- /dev/null +++ b/check_mk-check-nfsiostat/checks/nfsiostat @@ -0,0 +1,119 @@ +#!/usr/bin/python +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2018 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + + +# example output +# +#y.y.y.y:/mount/name mounted on /var/log/da: +# +# op/s rpc bklog +#2579.20 0.00 +#read: ops/s kB/s kB/op retrans avg RTT (ms) avg exe (ms) +# 0.000 0.000 0.000 0 (0.0%) 0.000 0.000 +#write: ops/s kB/s kB/op retrans avg RTT (ms) avg exe (ms) +# 2578.200 165768.087 64.296 0 (0.0%) 21.394 13980.817 +# +#x.x.x.x:/mount/name mounted on /data: +# ... + +param_name = { + "0" : ("op_s","Operations", 1, "%.2f/s"), + "1" : ("rpc_backlog", "RPC Backlog", 1, "%.2f"), + "2" : ("read_ops", "Read operations /s", 1, "%.3f/s"), + "3" : ("read_b_s", "Reads size /s", 1000, "%.3fB/s"), + "4" : ("read_b_op", "Read bytes per operation", 1000, "%.3fB/op"), + "5" : ("read_retrans", "Read Retransmission", 1, "%.1f%%"), + "6" : ("read_retrans", "Read Retransmission", 1, "%.1f%%"), + "7" : ("read_avg_rtt_ms", "Read average RTT", 1000, "%.3f/s",), + "8" : ("read_avg_exe_ms", "Read average EXE", 1000, "%.3f/s",), + "9" : ("write_ops_s", "Write operations /s", 1, "%.3f/s"), + "10" : ("write_b_s", "Writes size /s", 1000, "%.3fkB/s"), + "11" : ("write_b_op", "Write bytes per operation", 1000, "%.3fB/op"), + "12" : ("write_retrans", "Write Retransmission", 1, "%.1f%%"), + "13" : ("write_retrans", "Write Retransmission", 1, "%.3f%%"), + "14" : ("write_avg_rtt_ms", "Write Average RTT", 1, "%.3f/ms"), + "15" : ("write_avg_exe_ms", "Write Average EXE", 1, "%.3f/ms"), +} + + +def parse_nfsiostat(info): + #removes double list + [new_info] = info + import re + # provides a dictionary with mountpoint as key and a list of 16 metrics + # in exact order + parsed = {m[0]: m[1:] for m in re.findall(r'(\S+:/\S+)%s' % \ + (r'.*?([\d.]+)' * 16), str(new_info).strip('[]'), flags=re.DOTALL)} + return parsed + + +def inventory_nfsiostat(parsed): + inventory = [] + for mountname in parsed.keys(): + yield mountname, {} + + +def check_nfsiostat(item, params, parsed): + # check the value we recieved against our map of values + # assign appropriate type to value + def check_nfsiostat_params(count, value): + item = param_name[str(count)][0] + title = param_name[str(count)][1] + factor = param_name[str(count)][2] + fmt = param_name[str(count)][3] + value = float(value) + + if params: + if params.get(item, 0): + crit = float(params[item][1]) + warn = float(params[item][0]) + if value >= crit: + perfdata = [ (item, value, warn, crit ) ] + return(2, "%s: %s" % (title, fmt % value), perfdata) + elif value >= warn: + perfdata = [ (item, value, warn, crit ) ] + return(1, "%s: %s" % (title, fmt % value), perfdata) + + perfdata = [ (item, value ) ] + return(0, "%s: %s" % (title, fmt % value), perfdata) + + for mountpoint, values in parsed.items(): + # We have duplicate items at index 5 and 12. We exclude the dupes here + if mountpoint == item: + count = 0 + for value in values: + if count != 5 and count != 12: + yield(check_nfsiostat_params(count, value)) + count = count + 1 + + +check_info['nfsiostat'] = { + 'parse_function' : parse_nfsiostat, + 'inventory_function' : inventory_nfsiostat, + 'check_function' : check_nfsiostat, + 'service_description' : 'NFS IO stats %s', + 'group' : 'nfsiostats', + 'has_perfdata' : True, +} \ No newline at end of file diff --git a/check_mk-check-nfsiostat/info b/check_mk-check-nfsiostat/info new file mode 100644 index 0000000..b82ac67 --- /dev/null +++ b/check_mk-check-nfsiostat/info @@ -0,0 +1,27 @@ +{'author': 'Marius Pana (mp@spearhead.systems)', + 'description': 'The nfsiostat checks nfs IO statictics.', + 'download_url': 'https://code.spearhead.cloud/Spearhead/check_mk-check-nfsiostat', + 'files': {'agents': ['agents/bakery/mk_nfsiostat', + 'agents/plugins/mk_nfsiostat', + 'bakery/mk_nfsiostat', + 'plugins/mk_nfsiostat'], + 'alert_handlers': [], + 'bin': [], + 'checkman': ['nfsiostat'], + 'checks': ['nfsiostat'], + 'doc': [], + 'inventory': [], + 'lib': [], + 'locales': [], + 'mibs': [], + 'notifications': [], + 'pnp-templates': [], + 'web': ['plugins/metrics/metrics_nfsiostat.py', + 'plugins/perfometer/nfsiostat.py', + 'plugins/wato/agent_bakery_nfsiostat.py', + 'plugins/wato/check_parameters_nfsiostat.py']}, + 'name': 'nfsiostat', + 'title': 'Check NFS IO stats', + 'version': '1.0', + 'version.min_required': '1.4.0', + 'version.packaged': '1.5.0'} diff --git a/check_mk-check-nfsiostat/nfsiostat-1.0.mkp b/check_mk-check-nfsiostat/nfsiostat-1.0.mkp new file mode 100644 index 0000000..0f43999 Binary files /dev/null and b/check_mk-check-nfsiostat/nfsiostat-1.0.mkp differ diff --git a/check_mk-check-nfsiostat/web/plugins/metrics/metrics_nfsiostat.py b/check_mk-check-nfsiostat/web/plugins/metrics/metrics_nfsiostat.py new file mode 100644 index 0000000..32aa4c9 --- /dev/null +++ b/check_mk-check-nfsiostat/web/plugins/metrics/metrics_nfsiostat.py @@ -0,0 +1,86 @@ +metric_info['op_s'] = { + 'title': _('Operations per second'), + 'unit': 'count', + 'color': '#90ee90', +} + +metric_info['rpc_backlog'] = { + 'title': _('RPC Backlog'), + 'unit': 'count', + 'color': '#90ee90', +} + +metric_info['read_ops'] = { + 'title': _('Read operations'), + 'unit': '1/s', + 'color': '34/a', +} + +metric_info['read_b_s'] = { + 'title': _('Read size per second'), + 'unit': 'bytes/s', + 'color': '#80ff20', +} + +unit_info['bytes/op'] = { + 'title': _('Read size per operation'), + 'unit': 'bytes/op', + 'color': '#4080c0', + "render" : bytes_human_readable, +} + +metric_info['read_b_op'] = { + 'title': _('Read size per operation'), + 'unit': 'bytes/op', + 'color': '#4080c0', + "render" : bytes_human_readable, +} + +metric_info['read_retrans'] = { + 'title': _('Read retransmission'), + 'unit': '%', + 'color': '#90ee90', +} + +metric_info['read_avg_rtt_ms'] = { + 'title': _('Read average rtt'), + 'unit': 's', + 'color': '#90ee90', +} + +metric_info['read_avg_exe_ms'] = { + 'title': _('Read average exe'), + 'unit': 's', + 'color': '#90ee90', +} + +metric_info['write_ops_s'] = { + 'title': _('Write operations'), + 'unit': '1/s', + 'color': '34/a', +} + +metric_info['write_b_s'] = { + 'title': _('Writes size per second'), + 'unit': 'bytes/s', + 'color': '#80ff20', +} + +metric_info['write_b_op'] = { + 'title': _('Writes size per operation'), + 'unit': 'bytes/op', + 'color': '#4080c0', + "render" : bytes_human_readable, +} + +metric_info['write_avg_rtt_ms'] = { + 'title': _('Write average rtt'), + 'unit': 's', + 'color': '#90ee90', +} + +metric_info['write_avg_exe_ms'] = { + 'title': _('Write average exe'), + 'unit': 's', + 'color': '#90ee90', +} \ No newline at end of file diff --git a/check_mk-check-nfsiostat/web/plugins/perfometer/nfsiostat.py b/check_mk-check-nfsiostat/web/plugins/perfometer/nfsiostat.py new file mode 100644 index 0000000..9c10a39 --- /dev/null +++ b/check_mk-check-nfsiostat/web/plugins/perfometer/nfsiostat.py @@ -0,0 +1,8 @@ +def perfometer_nfsiostat(row, check_command, perf_data): + for pd in perf_data: + if pd[0] == u'op_s': + ops = float(pd[1]) + color = '#ff6347' + return '%d op/s' % ops, perfometer_linear(ops, color) + +perfometers["check_mk-nfsiostat"] = perfometer_nfsiostat diff --git a/check_mk-check-nfsiostat/web/plugins/wato/agent_bakery_nfsiostat.py b/check_mk-check-nfsiostat/web/plugins/wato/agent_bakery_nfsiostat.py new file mode 100644 index 0000000..6e4f5ad --- /dev/null +++ b/check_mk-check-nfsiostat/web/plugins/wato/agent_bakery_nfsiostat.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# -*- encoding: utf-8; py-indent-offset: 4 -*- + +group = "agents/" + _("Agent Plugins") + +register_rule(group, + "agent_config:mk_nfsiostat", + DropdownChoice( + title = _("NFS IO Stats (Linux)"), + help = _("This will deploy the agent plugin mk_nfsiostat to check various client side NFS IO stats."), + choices = [ + ( True, _("Deploy plugin for NFS IO Stats") ), + ( None, _("Do not deploy plugin for NFS IO Stats") ), + ] + ) +) diff --git a/check_mk-check-nfsiostat/web/plugins/wato/check_parameters_nfsiostat.py b/check_mk-check-nfsiostat/web/plugins/wato/check_parameters_nfsiostat.py new file mode 100644 index 0000000..e21d98d --- /dev/null +++ b/check_mk-check-nfsiostat/web/plugins/wato/check_parameters_nfsiostat.py @@ -0,0 +1,114 @@ +register_check_parameters( + subgroup_storage, + "nfsiostats", + _("NFS IO Statistics"), + Dictionary( + title=_("NFS IO Statistics"), + optional_keys=True, + elements=[ + ("op_s", + Tuple( + title=_("Operations"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="1/s"), + Float(title=_("Critical at"), default_value=None, unit="1/s"), + ])), + ("rpc_backlog", + Tuple( + title=_("RPC Backlog"), + elements=[ + Float(title=_("Warning below"), default_value=None, unit="queue"), + Float(title=_("Critical below"), default_value=None, unit="queue"), + ])), + ("read_ops", + Tuple( + title=_("Read Operations /s"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="1/s"), + Float(title=_("Critical at"), default_value=None, unit="1/s"), + ])), + ("read_b_s", + Tuple( + title=_("Reads size /s"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="bytes/s"), + Float(title=_("Critical at"), default_value=None, unit="bytes/s"), + ])), + ("read_b_op", + Tuple( + title=_("Read bytes per operation"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="bytes/op"), + Float(title=_("Critical at"), default_value=None, unit="bytes/op"), + ])), + ("read_retrans", + Tuple( + title=_("Read Retransmissions"), + elements=[ + Percentage(title=_("Warning at"), default_value=None), + Percentage(title=_("Critical at"), default_value=None), + ])), + ("read_avg_rtt_ms", + Tuple( + title=_("Read Average RTT (ms)"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="ms"), + Float(title=_("Critical at"), default_value=None, unit="ms"), + ])), + ("read_avg_exe_ms", + Tuple( + title=_("Read Average Executions (ms)"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="ms"), + Float(title=_("Critical at"), default_value=None, unit="ms"), + ])), + ("write_ops_s", + Tuple( + title=_("Write Operations/s"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="1/s"), + Float(title=_("Critical at"), default_value=None, unit="1/s"), + ])), + ("write_b_s", + Tuple( + title=_("Write size /s"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="bytes/s"), + Float(title=_("Critical at"), default_value=None, unit="bytes/s"), + ])), + ("write_b_op", + Tuple( + title=_("Write bytes per operation"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="bytes/s"), + Float(title=_("Critical at"), default_value=None, unit="bytes/s"), + ])), + ("write_retrans", + Tuple( + title=_("Write Retransmissions"), + elements=[ + Percentage(title=_("Warning at"), default_value=None), + Percentage(title=_("Critical at"), default_value=None), + ])), + ("write_avg_rtt_ms", + Tuple( + title=_("Write Avg RTT (ms)"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="ms"), + Float(title=_("Critical at"), default_value=None, unit="ms"), + ])), + ("write_avg_exe_ms", + Tuple( + title=_("Write Avg exe (ms)"), + elements=[ + Float(title=_("Warning at"), default_value=None, unit="ms"), + Float(title=_("Critical at"), default_value=None, unit="ms"), + ])), + ] + ), + + TextAscii( + title=_("NFS IO Statistics"), + ), + match_type="dict", +) \ No newline at end of file diff --git a/check_mk-exch-mbox/LICENSE b/check_mk-exch-mbox/LICENSE new file mode 100644 index 0000000..d6a9326 --- /dev/null +++ b/check_mk-exch-mbox/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/check_mk-exch-mbox/README.md b/check_mk-exch-mbox/README.md new file mode 100644 index 0000000..8a8ba31 --- /dev/null +++ b/check_mk-exch-mbox/README.md @@ -0,0 +1,47 @@ +check_mk-exch-mbox +================== + +Check_mk check for individual exchange mailbox sizes. + +title: Check for users Exchange Mailbox size +agents: windows +catalog: os/windows +license: GPL +distribution: +description: + This check checks for individual exchange mailbox sizes. + You need to install the plugin {SPH-Exchange-MailboxSize.ps1} + into the {plugins} directory of your windows agent. + This check was tested with Exchange 2010 and must have PowerShell + installed. + + The check gets critical if there mailbox is over 2000 MB and warning + if over 1500MB. Both are definable in Wato under "Parameters for + Inventorized Checks", "Applications, Processes & Services". + +inventory: + One service will be created for each user mailbox where the + {SPH-Exchange-MailboxSize.ps1} plugin produces a non-empty output. + +perfdata: + One variable: {size}: the current size of the mailbox in MB. + +The agent uses a caching mechanism and runs once only every 24 hours. + +#----------------- +#Quick HOWTO +#----------------- +INSTALL PACKAGE +On your OMD/Check_mk server run the following: + + cmk -P install exchange_user_mbx_size-1.0.mkp + +The agent will be in ~/local/share/check_mk/agents/plugins/SPH-Exchange-MailboxSize.ps1 + +COPY AGENT TO DESTINATION +Copy the agent part (SPH-Exchange-MailboxSize.ps1) to your MS Exchange server. This +is usually in C:\Program Files\check_mk\plugins + + + + diff --git a/check_mk-exch-mbox/agents/plugins/SPH-Exchange-MailboxSize.ps1 b/check_mk-exch-mbox/agents/plugins/SPH-Exchange-MailboxSize.ps1 new file mode 100644 index 0000000..40cf4ce --- /dev/null +++ b/check_mk-exch-mbox/agents/plugins/SPH-Exchange-MailboxSize.ps1 @@ -0,0 +1,57 @@ +#[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 +#write-output "" # workaround to prevent the byte order mark to be at the beginning of the first section +##################################################################################### +# Exchange 2010 : per user mailbox size +# Author: Marius Pana +# Company: Spearhead Systems +# Date 12/16/14 +##################################################################################### + +add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 + +# measure time +#Measure-Command {$(Foreach ($mailbox in Get-Recipient -ResultSize Unlimited -RecipientType UserMailbox){ +#$Stat = $mailbox | Get-MailboxStatistics | Select TotalItemSize +# New-Object PSObject -Property @{ +# PrimarySmtpAddress = $mailbox.PrimarySmtpAddress +# TotalItemSize = $Stat.TotalItemSize.value.ToMB() +# } +#}) | Select PrimarySmtpAddress,TotalItemSize | +#Export-CSV C:\CMK-MailboxReport.csv -NTI} + +# filename for timestamp +$remote_host = $env:REMOTE_HOST +$agent_dir = $env:MK_CONFDIR + +$timestamp = $agent_dir + "\timestamp."+ $remote_host + +# execute agent only every $delay seconds - 24 hours +$delay = 86400 + +# does $timestamp exist? +If (Test-Path $timestamp){ + # cat existing outut + write-host "<<>>" + Get-Content C:\CMK-MailboxReport.csv + $filedate = (ls $timestamp).LastWriteTime + $now = Get-Date + $earlier = $now.AddSeconds(-$delay) + # exit if timestamp too young + if ( $filedate -gt $earlier ) { exit } +} +# create new timestamp file +New-Item $timestamp -type file -force | Out-Null + +# calculate unix timestamp +$epoch=[int][double]::Parse($(Get-Date -date (Get-Date).ToUniversalTime()-uformat %s)) + +$(Foreach ($mailbox in Get-Recipient -ResultSize Unlimited -RecipientType UserMailbox){ +$Stat = $mailbox | Get-MailboxStatistics | Select TotalItemSize + New-Object PSObject -Property @{ + PrimarySmtpAddress = $mailbox.PrimarySmtpAddress + TotalItemSize = $Stat.TotalItemSize.value.ToMB() + } +}) | Select PrimarySmtpAddress,TotalItemSize | +Export-CSV C:\CMK-MailboxReport.csv -NoTypeInformation + +(Get-Content C:\CMK-MailboxReport.csv) | Foreach-Object {$_ -replace '"', ''} | Foreach-Object {$_ -replace ',', ' '} | select -Skip 1 | Set-Content C:\CMK-MailboxReport.csv diff --git a/check_mk-exch-mbox/checkman/exchange_user_mbx_size b/check_mk-exch-mbox/checkman/exchange_user_mbx_size new file mode 100644 index 0000000..70c56f3 --- /dev/null +++ b/check_mk-exch-mbox/checkman/exchange_user_mbx_size @@ -0,0 +1,22 @@ +title: Check for users Exchange Mailbox size +agents: windows +catalog: os/windows +license: GPL +distribution: +description: + This check checks for individual exchange mailbox sizes. + You need to install the plugin {SPH-Exchange-MailboxSize.ps1} + into the {plugins} directory of your windows agent. + This check was tested with Exchange 2010 and must have PowerShell + installed. + + The check gets critical if there mailbox is over 2000 MB and warning + if over 1500MB. Both are definable in Wato under "Parameters for + Inventorized Checks", "Applications, Processes & Services". + +inventory: + One service will be created for each user mailbox where the + {SPH-Exchange-MailboxSize.ps1} plugin produces a non-empty output. + +perfdata: + One variable: {size}: the current size of the mailbox in MB. diff --git a/check_mk-exch-mbox/checks/exchange_user_mbx_size b/check_mk-exch-mbox/checks/exchange_user_mbx_size new file mode 100644 index 0000000..46754cb --- /dev/null +++ b/check_mk-exch-mbox/checks/exchange_user_mbx_size @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# Author: Marius Pana +# EXAMPLE DATA FROM: +# fomat: emailaddress size_in_MB +#<<>> +#marius.pana@sphs.ro 177 +#mpana@sphs.ro 81 + +factory_settings["exchange_user_mbx_size_default_values"] = { + "levels" : (1500, 2000), +} + +def inventory_exchange_user_mbx_size(info): + inventory = [] + for line in info: + useremail = line[0] + mailboxsize = line[1] + inventory.append((useremail, {} )) + return inventory + +def check_exchange_user_mbx_size(item, params, info): + if type(params) != dict: + params = { "levels" : params } + #unpack check params + warn, crit = params["levels"] + for line in info: + if line[0] == item: + mailboxsize = int(line[1]) + perfdata = [ ( "size", str(mailboxsize), warn, crit ) ] + if mailboxsize > crit: + return (2, "Mailbox size is %dMB" % mailboxsize, perfdata) + elif mailboxsize > warn: + return (1, "Mailbox size is %dMB" % mailboxsize, perfdata) + else: + return (0, "Mailbox size is %dMB" % mailboxsize, perfdata) + return(3, "Mailbox %s not found in agent output" % item) + +check_info["exchange_user_mbx_size"] = { + 'check_function': check_exchange_user_mbx_size, + 'inventory_function': inventory_exchange_user_mbx_size, + 'service_description': '%s Mailbox size', + 'default_levels_variable': 'exchange_user_mbx_size_default_values', + 'has_perfdata': True, + 'group': 'exchange_user_mbx_size', +} diff --git a/check_mk-exch-mbox/exchange_mbx_size-1.0.mkp b/check_mk-exch-mbox/exchange_mbx_size-1.0.mkp new file mode 100644 index 0000000..0409423 Binary files /dev/null and b/check_mk-exch-mbox/exchange_mbx_size-1.0.mkp differ diff --git a/check_mk-exch-mbox/info b/check_mk-exch-mbox/info new file mode 100644 index 0000000..43b65d1 --- /dev/null +++ b/check_mk-exch-mbox/info @@ -0,0 +1,17 @@ +{'author': 'Marius Pana', + 'description': 'Check_mk check for individual exchange mailbox sizes.', + 'download_url': 'https://github.com/spearheadsys/check_mk-exch-mbox', + 'files': {'agents': ['plugins/SPH-Exchange-MailboxSize.ps1'], + 'checkman': ['exchange_user_mbx_size'], + 'checks': ['exchange_user_mbx_size'], + 'doc': [], + 'inventory': [], + 'notifications': [], + 'pnp-templates': ['check_mk-exchange_user_mbx_size.php'], + 'web': ['plugins/perfometer/exchange_mbx_size_perfometer.py', + 'plugins/wato/exchange_mbx_size_check_parameters.py']}, + 'name': 'exchange_usr_mbox_size', + 'title': 'exchange_usr_mbox_size', + 'version': '1.0', + 'version.min_required': '1.2.6b1', + 'version.packaged': '1.2.6b1'} diff --git a/check_mk-exch-mbox/pnp-templates/check_mk-exchange_user_mbx_size.php b/check_mk-exch-mbox/pnp-templates/check_mk-exchange_user_mbx_size.php new file mode 100644 index 0000000..f8868bf --- /dev/null +++ b/check_mk-exch-mbox/pnp-templates/check_mk-exchange_user_mbx_size.php @@ -0,0 +1,14 @@ + diff --git a/check_mk-exch-mbox/web/plugins/perfometer/exchange_mbx_size_perfometer.py b/check_mk-exch-mbox/web/plugins/perfometer/exchange_mbx_size_perfometer.py new file mode 100644 index 0000000..7a00122 --- /dev/null +++ b/check_mk-exch-mbox/web/plugins/perfometer/exchange_mbx_size_perfometer.py @@ -0,0 +1,13 @@ +def perfometer_check_mk_exchange_user_mbx_size(row, check_command, perf_data): + #return 'Hello World! :-)', '' \ + # + perfometer_td(20, '#fff') \ + # + perfometer_td(80, '#ff0000') \ + # + '
' + size = float(perf_data[0][1]) + #return repr(size), '' + color = { 0: "#68f", 1: "#ff2", 2: "#f22", 3: "#fa2" }[row["service_state"]] + #size = perf_data[1] + #print(size) + return "%.0f" % size, perfometer_logarithmic(size, 1024, 2, color) + +perfometers['check_mk-exchange_user_mbx_size'] = perfometer_check_mk_exchange_user_mbx_size diff --git a/check_mk-exch-mbox/web/plugins/wato/exchange_mbx_size_check_parameters.py b/check_mk-exch-mbox/web/plugins/wato/exchange_mbx_size_check_parameters.py new file mode 100644 index 0000000..ccbc843 --- /dev/null +++ b/check_mk-exch-mbox/web/plugins/wato/exchange_mbx_size_check_parameters.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# 2014 Marius Pana mp@sphs.ro + +register_check_parameters( + subgroup_applications, + "exchange_user_mbx_size", + _("MS Exchange User Mailbox Size"), + Dictionary( + elements = [ + ("levels", # Name of your parameters + Tuple( + title = "Levels for mailboxes", # Specify a title for this parameters + elements = [ + Integer( + title = _("Warning if above"), + unit = _("MB"), + default_value = 1500 + ), + Integer( + title = _("Critical if above"), + unit = _("MB"), + default_value = 2000 + ), + ] + ) + ), + ], + optional_keys = None, # Always show this subgroup + ), + TextAscii( title = "Name of mailbox"), + "dict" +) diff --git a/check_mk-exchange-database-size/LICENSE b/check_mk-exchange-database-size/LICENSE new file mode 100644 index 0000000..d6a9326 --- /dev/null +++ b/check_mk-exchange-database-size/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/check_mk-exchange-database-size/README.md b/check_mk-exchange-database-size/README.md new file mode 100644 index 0000000..aa62c7b --- /dev/null +++ b/check_mk-exchange-database-size/README.md @@ -0,0 +1,8 @@ +check_mk-exchange-database-size +=============================== + +checks size of the mounted databases + + +TODO +- add available space (whitespace) to check, graphs and configure alerts based on this metric diff --git a/check_mk-exchange-database-size/agents/plugins/sph-exchange-database-size.ps1 b/check_mk-exchange-database-size/agents/plugins/sph-exchange-database-size.ps1 new file mode 100644 index 0000000..fcac32e --- /dev/null +++ b/check_mk-exchange-database-size/agents/plugins/sph-exchange-database-size.ps1 @@ -0,0 +1,19 @@ +#[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 +#write-output "" # workaround to prevent the byte order mark to be at the +# beginning of the first section +############################################################################## +# Exchange 2010 : mail database size +# Author: Marius Pana +# Company: Spearhead Systems +# Date 12/30/14 +############################################################################## + +add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 + +$dbs = Get-MailboxDatabase -Status | ? {$_.Mounted -eq $True} | Sort Name +ForEach ($db in $dbs) { + $DBsize = $db.DatabaseSize.ToMB() + $DBfreeSpace = $db.AvailableNewMailboxSpace.ToMB() + Write-Host "<<>>" + Write-Host "$($db.Name) $DBsize $DBfreeSpace" +} diff --git a/check_mk-exchange-database-size/checkman/exchange_db_size b/check_mk-exchange-database-size/checkman/exchange_db_size new file mode 100644 index 0000000..906faf1 --- /dev/null +++ b/check_mk-exchange-database-size/checkman/exchange_db_size @@ -0,0 +1,22 @@ +title: Check for Exchange Database size +agents: windows +catalog: os/windows +license: GPL +distribution: +description: + This check checks for individual exchange database sizes. + You need to install the plugin {sph-exchange-database-size.ps1} + into the {plugins} directory of your windows agent. + This check was tested with Exchange 2010 and must have PowerShell + installed. + + The check gets critical if there mailbox is over 20000 MB and warning + if over 2500MB. Both are definable in Wato under "Parameters for + Inventorized Checks", "Applications, Processes & Services". + +inventory: + One service will be created for each database where the + {sph-exchange-database-size.ps1} plugin produces a non-empty output. + +perfdata: + One variable: {size}: the current size of the database in MB. diff --git a/check_mk-exchange-database-size/checks/exchange_db_size b/check_mk-exchange-database-size/checks/exchange_db_size new file mode 100644 index 0000000..5f08159 --- /dev/null +++ b/check_mk-exchange-database-size/checks/exchange_db_size @@ -0,0 +1,51 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# Author: Marius Pana +# EXAMPLE DATA FROM: +# format: datbase size_in_MB free_MB_available +#<<>> +#RomaniaEXC 177 +#ExchangeDB_Size 81 + +factory_settings["exchange_db_size_default_values"] = { + "levels" : (20000, 25000), +} + +exchange_db_size_default_values = (20000, 25000) + +def inventory_exchange_db_size(info): + inventory = [] + for line in info: + database = line[0] + inventory.append((database, "exchange_db_size_default_values")) + return inventory + +def check_exchange_db_size(item, params, info): + if type(params) != dict: + params = { "levels" : params } + #unpack check params + warn, crit = params["levels"] + for line in info: + if line[0] == item: + dbsize = int(line[1]) + #dbavail = int(line[2]) + perfdata = [ + ( "size", str(dbsize), warn, crit ), + #( "avail", str(dbavail), warn, crit ), + ] + if dbsize > crit: + return (2, "Database size is %dMB" % dbsize, perfdata) + elif dbsize > warn: + return (1, "Database size is %dMB" % dbsize, perfdata) + else: + return (0, "Database size is %dMB" % dbsize, perfdata) + return(3, "Database %s not found in agent output" % item) + +check_info["exchange_db_size"] = { + 'check_function': check_exchange_db_size, + 'inventory_function': inventory_exchange_db_size, + 'service_description': '%s Database size', + 'default_levels_variable': 'exchange_user_mbx_size_default_values', + 'has_perfdata': True, + 'group': 'exchange_db_size', +} diff --git a/check_mk-exchange-database-size/exchange_db_size-1.1.mkp b/check_mk-exchange-database-size/exchange_db_size-1.1.mkp new file mode 100644 index 0000000..84afd16 Binary files /dev/null and b/check_mk-exchange-database-size/exchange_db_size-1.1.mkp differ diff --git a/check_mk-exchange-database-size/info b/check_mk-exchange-database-size/info new file mode 100644 index 0000000..c491ef5 --- /dev/null +++ b/check_mk-exchange-database-size/info @@ -0,0 +1,18 @@ +{'author': 'Marius Pana', + 'description': 'Check exchange database size', + 'download_url': 'https://github.com/spearheadsys/check_mk-exchange-database-size', + 'files': {'agents': ['plugins/sph-exchange-database-size.ps1'], + 'checkman': ['exchange_db_size'], + 'checks': ['exchange_db_size'], + 'doc': [], + 'inventory': [], + 'notifications': [], + 'pnp-templates': ['check_mk-exchange_db_size.php'], + 'web': ['plugins/perfometer/exchange_db_size_perfometer.py', + 'plugins/wato/exchange_db_size_check_parameters.py']}, + 'name': 'exchange_db_size', + 'num_files': 6, + 'title': 'exchange_db_size', + 'version': '1.1', + 'version.min_required': '1.2.6b1', + 'version.packaged': '1.2.6b1'} \ No newline at end of file diff --git a/check_mk-exchange-database-size/pnp-templates/check_mk-exchange_db_size.php b/check_mk-exchange-database-size/pnp-templates/check_mk-exchange_db_size.php new file mode 100644 index 0000000..6e5ea86 --- /dev/null +++ b/check_mk-exchange-database-size/pnp-templates/check_mk-exchange_db_size.php @@ -0,0 +1,13 @@ + diff --git a/check_mk-exchange-database-size/web/plugins/perfometer/exchange_db_size_perfometer.py b/check_mk-exchange-database-size/web/plugins/perfometer/exchange_db_size_perfometer.py new file mode 100644 index 0000000..38e728b --- /dev/null +++ b/check_mk-exchange-database-size/web/plugins/perfometer/exchange_db_size_perfometer.py @@ -0,0 +1,13 @@ +def perfometer_check_mk_exchange_db_size(row, check_command, perf_data): + #return 'Hello World! :-)', '' \ + # + perfometer_td(20, '#fff') \ + # + perfometer_td(80, '#ff0000') \ + # + '
' + size = float(perf_data[0][1]) + #return repr(size), '' + color = { 0: "#68f", 1: "#ff2", 2: "#f22", 3: "#fa2" }[row["service_state"]] + #size = perf_data[1] + #print(size) + return "%.0f" % size, perfometer_logarithmic(size, 1024, 2, color) + +perfometers['check_mk-exchange_db_size'] = perfometer_check_mk_exchange_db_size diff --git a/check_mk-exchange-database-size/web/plugins/wato/exchange_db_size_check_parameters.py b/check_mk-exchange-database-size/web/plugins/wato/exchange_db_size_check_parameters.py new file mode 100644 index 0000000..e565248 --- /dev/null +++ b/check_mk-exchange-database-size/web/plugins/wato/exchange_db_size_check_parameters.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# 2014 Marius Pana mp@sphs.ro + +register_check_parameters( + subgroup_applications, + "exchange_db_size", + _("MS Exchange Database Size"), + Dictionary( + elements = [ + ("levels", # Name of your parameters + Tuple( + title = "Levels for database", # Specify a title for this parameters + elements = [ + Integer( + title = _("Warning if above"), + unit = _("MB"), + default_value = 20000 + ), + Integer( + title = _("Critical if above"), + unit = _("MB"), + default_value = 25000 + ), + ] + ) + ), + ], + optional_keys = None, # Always show this subgroup + ), + TextAscii( title = "Name of database"), + "dict" +) diff --git a/check_mk-mysql_open_files/LICENSE b/check_mk-mysql_open_files/LICENSE new file mode 100644 index 0000000..d6a9326 --- /dev/null +++ b/check_mk-mysql_open_files/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/check_mk-mysql_open_files/README.md b/check_mk-mysql_open_files/README.md new file mode 100644 index 0000000..95ad4c6 --- /dev/null +++ b/check_mk-mysql_open_files/README.md @@ -0,0 +1,13 @@ +# check_mk-mysql_open_files + +This check will monitor mysql open_files value raported to +setted open_files_limit value. The plugin must be copied +into /usr/lib/check_mk_agent/plugins folder and the +executable bit must be set for this file. + +The check will return current open_files_limit and open_files +values. The check gets critical at 90 percent of +open_files_limit and warning at 80. + +Both limits are definable in Wato under "Parameters for +Inventorized Checks", "Applications, Processes & Services". diff --git a/check_mk-mysql_open_files/agents/plugins/mysql_open_files b/check_mk-mysql_open_files/agents/plugins/mysql_open_files new file mode 100644 index 0000000..36aa239 --- /dev/null +++ b/check_mk-mysql_open_files/agents/plugins/mysql_open_files @@ -0,0 +1,16 @@ +#!/bin/bash +# SpearHead Systems george.mocanu@sphs.ro 2015 +# Check_MK plugin for monitoring mysql open_files + +# Get mysqld pid number +mysqlPid=`pidof mysqld` + +# Count files currently opened by mysql +mysqlOpenFiles=`ls -las /proc/$mysqlPid/fd/ | wc -l` + +# Get current open_files_limit value +mysqlOpenFilesLimit=`cat /proc/$mysqlPid/limits | grep 'Max\ open\ files' | awk '{print $4}'` + +# Check output +echo '<<>>' +echo 'open_files ' $mysqlOpenFilesLimit ' ' $mysqlOpenFiles diff --git a/check_mk-mysql_open_files/checkman/mysql_open_files b/check_mk-mysql_open_files/checkman/mysql_open_files new file mode 100644 index 0000000..a82c650 --- /dev/null +++ b/check_mk-mysql_open_files/checkman/mysql_open_files @@ -0,0 +1,21 @@ +title: Check for monitor mysql open_files +agents: linux +catalog: os/linux +license: GPL +distribution: +description: + This check will monitor mysql open_files raported to + setted open_files_limit value. The plugin must be copied + into /usr/lib/check_mk_agent/plugins folder and the + executable bit mus be set for this file. + Will return current open_files_limit and open_files + values. The check gets critical at 90 percent of + open_files_limit and warning at 80. + Both limits are definable in Wato under "Parameters for + Inventorized Checks", "Applications, Processes & Services". + +inventory: + One service will be created for each host running the plugin. + +perfdata: + Percent usage of open_files_limit value. diff --git a/check_mk-mysql_open_files/checks/mysql_open_files b/check_mk-mysql_open_files/checks/mysql_open_files new file mode 100644 index 0000000..073ad44 --- /dev/null +++ b/check_mk-mysql_open_files/checks/mysql_open_files @@ -0,0 +1,47 @@ +#!/usr/bin/python +# SpearHead Systems george.mocanu@sphs.ro 2015 + +# EXAMPLE DATA FROM: +# fomat: "open_files" current_setted_value_of_open_files_limit current_value_of_open_files +# +#<<>> +#open_files 3000 2305 + +factory_settings["mysql_open_files_default_values"] = { + "levels": (80, 90), +} + +def inventory_mysql_open_files(info): + inventory = [] + for line in info: + checkName = line[0] + inventory.append( (checkName, {} ) ) + return inventory + + +def check_mysql_open_files(item, params, info): + if type(params) != dict: + params = { "levels": params } + warn, crit = params["levels"] + for line in info: + if line[0] == item: + open_files_limit = int(line[1]) + open_files = int(line[2]) + openPerc = int(((open_files*100)/open_files_limit)) + perfdata = [ ( "open_files", openPerc, warn, crit ) ] + if openPerc > crit: + return (2, "Open files use level: %d percents. %d files opened out of maximum %d cconfigured." %(openPerc, open_files, open_files_limit), perfdata) + elif openPerc > warn: + return (1, "Open files use level: %d percents. %d files opened out of maximum %d cconfigured." %(openPerc, open_files, open_files_limit), perfdata) + else: + return (0, "Open files use level: %d percents. %d files opened out of maximum %d cconfigured." %(openPerc, open_files, open_files_limit), perfdata) + return(3, "Plugin not running on host") + +check_info["mysql_open_files"] = { + "check_function" :check_mysql_open_files, + "inventory_function" :inventory_mysql_open_files, + "service_description" :"%s", + "default_levels_variable" :"mysql_open_files_default_values", + "has_perfdata" :True, + "group" :"mysql_open_files", +} diff --git a/check_mk-mysql_open_files/info b/check_mk-mysql_open_files/info new file mode 100644 index 0000000..263ea79 --- /dev/null +++ b/check_mk-mysql_open_files/info @@ -0,0 +1,17 @@ +{'author': 'george.mocanu@sphs.ro', + 'description': 'Monitor mysql open_files', + 'download_url': 'https://github.com/spearheadsys/check_mk-mysql_open_files', + 'files': {'agents': ['plugins/mysql_open_files'], + 'checkman': ['mysql_open_files'], + 'checks': ['mysql_open_files'], + 'doc': [], + 'inventory': [], + 'notifications': [], + 'pnp-templates': [], + 'web': ['plugins/wato/mysql_open_files.py']}, + 'name': 'mysql_open_files', + 'num_files': 4, + 'title': 'Check for mysql open_files', + 'version': '1.0', + 'version.min_required': '1.2.6b5', + 'version.packaged': '1.2.6b5'} \ No newline at end of file diff --git a/check_mk-mysql_open_files/mysql_open_files-1.0.mkp b/check_mk-mysql_open_files/mysql_open_files-1.0.mkp new file mode 100644 index 0000000..857ece5 Binary files /dev/null and b/check_mk-mysql_open_files/mysql_open_files-1.0.mkp differ diff --git a/check_mk-mysql_open_files/web/plugins/wato/mysql_open_files.py b/check_mk-mysql_open_files/web/plugins/wato/mysql_open_files.py new file mode 100644 index 0000000..0ca9ae1 --- /dev/null +++ b/check_mk-mysql_open_files/web/plugins/wato/mysql_open_files.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +# SpearHead Syste george.mocanu@sphs.ro 2015 + +register_check_parameters( + subgroup_applications, + "mysql_open_files", + _("Mysql Open Files Usage Status"), + Dictionary( + elements = [ + ("levels", # Name of your parameters + Tuple( + title = "Levels for Mysql Open Files Usage check", # Specify a title for this parameters + elements = [ + Integer( + title = _("Warning if above"), + unit = _("Percent"), + default_value = 80 + ), + Integer( + title = _("Critical if above"), + unit = _("Percent"), + default_value = 90 + ), + ] + ) + ), + ], + optional_keys = None, # Always show this subgroup + ), + TextAscii( title = "Service name"), + "dict" +) diff --git a/check_mk-pending_reboot/LICENSE b/check_mk-pending_reboot/LICENSE new file mode 100644 index 0000000..d6a9326 --- /dev/null +++ b/check_mk-pending_reboot/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/check_mk-pending_reboot/README.md b/check_mk-pending_reboot/README.md new file mode 100644 index 0000000..8d88428 --- /dev/null +++ b/check_mk-pending_reboot/README.md @@ -0,0 +1,2 @@ +# check_mk-pending_reboot +Monitor pending reboot status for Windows Host diff --git a/check_mk-pending_reboot/agents/windows/plugins/pending_reboot.ps1 b/check_mk-pending_reboot/agents/windows/plugins/pending_reboot.ps1 new file mode 100644 index 0000000..7f11804 Binary files /dev/null and b/check_mk-pending_reboot/agents/windows/plugins/pending_reboot.ps1 differ diff --git a/check_mk-pending_reboot/checkman/pending_reboot b/check_mk-pending_reboot/checkman/pending_reboot new file mode 100644 index 0000000..b66e270 --- /dev/null +++ b/check_mk-pending_reboot/checkman/pending_reboot @@ -0,0 +1,25 @@ +title: Check for pending reboot state of Windows machines +agents: windows +catalog: os/windows +license: GPL +distribution: +description: + This check checks for machines in pending reboot. + You need to install the plugin {pending_reboot.ps1} + into the {plugins} directory of your windows agent. + This check was tested with Windows 2008 Server and Windows 7 + and must have PowerShell installed. On Windows x64 is + recommended to use x64 agent. As always you must set + "set-executionpolicy remotesigned" on monitored host. + + The check gets critical if the pending reboot status have 24 + hours age and warning if the pending reboot status has more + than 12 hour age. + Both limits are definable in Wato under "Parameters for + Inventorized Checks", "Applications, Processes & Services". + +inventory: + One service will be created for each host running the plugin. + +perfdata: + None. diff --git a/check_mk-pending_reboot/checks/pending_reboot b/check_mk-pending_reboot/checks/pending_reboot new file mode 100644 index 0000000..e44a23e --- /dev/null +++ b/check_mk-pending_reboot/checks/pending_reboot @@ -0,0 +1,48 @@ +#!/usr/bin/python +# Author: George Mocanu + +# EXAMPLE DATA FROM: +# fomat: pendingReboot 0 8 +# +#<<>> +#pendingReboot 0 8 + +factory_settings["pending_reboot_default_values"] = { + "levels": (12, 24), +} + +def inventory_pending_reboot(info): + inventory = [] + for line in info: + checkName = line[0] + inventory.append( (checkName, {} ) ) + return inventory + + +def check_pending_reboot(item, params, info): + if type(params) != dict: + params = { "levels": params } + warn, crit = params["levels"] + for line in info: + if line[0] == item: + status = int(line[1]) + status_time = int(line[2]) + if status == 1: + if status_time > crit: + return (2, "Computer in pending reboot for %d Hours" %status_time) + elif status_time > warn: + return (1, "Computer in pending reboot for %d Hours" %status_time) + else: + return (0, "Computer in pending reboot for %d Hours" %status_time) + else: + return (0, "Computer not expecting reboot") + return(3, "Plugin not running on host") + +check_info["pending_reboot"] = { + "check_function" :check_pending_reboot, + "inventory_function" :inventory_pending_reboot, + "service_description" :"%s", + "default_levels_variable" :"pending_reboot_default_values", + "has_perfdata" :False, + "group" :"pending_reboot", +} diff --git a/check_mk-pending_reboot/info b/check_mk-pending_reboot/info new file mode 100644 index 0000000..e753f18 --- /dev/null +++ b/check_mk-pending_reboot/info @@ -0,0 +1,17 @@ +{'author': 'SpearHead Systems george.mocanu@sphs.ro', + 'description': 'Pending reboot status check', + 'download_url': 'https://github.com/spearheadsys/check_mk-pending_reboot', + 'files': {'agents': ['windows/plugins/pending_reboot.ps1'], + 'checkman': ['pending_reboot'], + 'checks': ['pending_reboot'], + 'doc': [], + 'inventory': [], + 'notifications': [], + 'pnp-templates': [], + 'web': ['plugins/wato/pending_reboot.py']}, + 'name': 'pending_reboot', + 'num_files': 4, + 'title': 'Package of pending_reboot check', + 'version': '1.1', + 'version.min_required': '1.2.6b5', + 'version.packaged': '1.2.6b5'} diff --git a/check_mk-pending_reboot/pending_reboot-1.1.mkp b/check_mk-pending_reboot/pending_reboot-1.1.mkp new file mode 100644 index 0000000..d06a582 Binary files /dev/null and b/check_mk-pending_reboot/pending_reboot-1.1.mkp differ diff --git a/check_mk-pending_reboot/web/plugins/wato/pending_reboot.py b/check_mk-pending_reboot/web/plugins/wato/pending_reboot.py new file mode 100644 index 0000000..aed530b --- /dev/null +++ b/check_mk-pending_reboot/web/plugins/wato/pending_reboot.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +# 2015 george.mocanu@sphs.ro + +register_check_parameters( + subgroup_applications, + "pending_reboot", + _("Windows Pending Reboot Status"), + Dictionary( + elements = [ + ("levels", # Name of your parameters + Tuple( + title = "Levels for pending reboot check", # Specify a title for this parameters + elements = [ + Integer( + title = _("Warning if above"), + unit = _("Hours"), + default_value = 10 + ), + Integer( + title = _("Critical if above"), + unit = _("Hours"), + default_value = 20 + ), + ] + ) + ), + ], + optional_keys = None, # Always show this subgroup + ), + TextAscii( title = "Service name"), + "dict" +) diff --git a/check_mk-rds_licenses/LICENSE b/check_mk-rds_licenses/LICENSE new file mode 100644 index 0000000..d6a9326 --- /dev/null +++ b/check_mk-rds_licenses/LICENSE @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/check_mk-rds_licenses/README.md b/check_mk-rds_licenses/README.md new file mode 100644 index 0000000..48aca27 --- /dev/null +++ b/check_mk-rds_licenses/README.md @@ -0,0 +1,17 @@ +# check_mk-rds_licenses +Monitor per user RDS licenses usage. + +The check for rds licenses usage is based on folowing plugins: + - rds_licenses_2008.ps1 + - rds_licenses_2012.ps1 + - elevate_shell.ps1 +If the Windows Server is 64 bit version the agent for x64 must be installed. + +Install procedure: + On Windows 2008 Server: copy the rds_licenses_2008.ps1 file in plugins +directory of check_mk agent folder. + On Windows 2012 Server: copy the elevate_shell.ps1 into plugins directory +of check_mk agent folder and the rds_licenses_2012.ps1 into check_mk agent folder. +The elevate_shell.ps1 will elevate de privileges for running rds_licences_2012.ps1 +and the user which run check_mk agent must have the rights to "run as +administrator". diff --git a/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/elevated_shell.ps1 b/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/elevated_shell.ps1 new file mode 100644 index 0000000..3b377ed --- /dev/null +++ b/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/elevated_shell.ps1 @@ -0,0 +1,42 @@ +# This code was published by Benjamin Armstrong on blogs.msdn.com +# This script will open an elevated powershell terminal and will run the specified script +# The script(s) that must be run with elevated privileges must be configured on the last lines + +# Get the ID and security principal of the current user account +$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent() +$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID) + +# Get the security principal for the Administrator role +$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator + +# Check to see if we are currently running "as Administrator" +if ($myWindowsPrincipal.IsInRole($adminRole)) + { + # We are running "as Administrator" - so change the title and background color to indicate this + $Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)" + $Host.UI.RawUI.BackgroundColor = "DarkBlue" + clear-host + } +else + { + # We are not running "as Administrator" - so relaunch as administrator + + # Create a new process object that starts PowerShell + $newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell"; + + # Specify the current script path and name as a parameter + $newProcess.Arguments = $myInvocation.MyCommand.Definition; + + # Indicate that the process should be elevated + $newProcess.Verb = "runas"; + + # Start the new process + [System.Diagnostics.Process]::Start($newProcess); + + # Exit from the current, unelevated, process + exit + } + +# Run your code that needs to be elevated here +# Will run rds_licenses script from check_mk directory +& "C:\Program Files (x86)\check_mk\rds_licenses_2012.ps1" diff --git a/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/install.txt b/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/install.txt new file mode 100644 index 0000000..068d616 --- /dev/null +++ b/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/install.txt @@ -0,0 +1,14 @@ +The check for rds licenses usage is based on folowing plugins: + - rds_licenses_2008.ps1 + - rds_licenses_2012.ps1 + - elevate_shell.ps1 +If the Windows Server is 64 bit version the agent for x64 must be installed. + +Install procedure: + On Windows 2008 Server: copy the rds_licenses_2008.ps1 file in plugins +directory of check_mk agent folder. + On Windows 2012 Server: copy the elevate_shell.ps1 into plugins directory +of check_mk agent folder and the rds_licenses_2012.ps1 into check_mk agent folder. +The elevate_shell.ps1 will elevate de privileges for running rds_licences_2012.ps1 +and the user which run check_mk agent must ghave the rights to "run as +administrator". diff --git a/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/rds_licenses_2008.ps1 b/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/rds_licenses_2008.ps1 new file mode 100644 index 0000000..1e62e5b --- /dev/null +++ b/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/rds_licenses_2008.ps1 @@ -0,0 +1,20 @@ +# SpearHead Systems george.mocanu@sphs.ro + +Import-Module RemoteDesktopServices +(cd RDS:\LicenseServer\IssuedLicenses\PerUserLicenseReports) | out-null + +# Remove all old reports +Remove-Item * -Recurse + +# Generate a new report +(New-Item -Name 'check' -Scope DOM) | out-null + +# Total installed licenses +$total = (Get-Item .\*\W*\InstalledCount).CurrentValue + +# Total used licenses +$used = (Get-Item .\*\W*\IssuedCount).CurrentValue + +# check_mk output +Write-Host "<<>>" +Write-Host "PerUserLicenses " $total " " $used diff --git a/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/rds_licenses_2012.ps1 b/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/rds_licenses_2012.ps1 new file mode 100644 index 0000000..15977d1 --- /dev/null +++ b/check_mk-rds_licenses/agents/windows/plugins/rds_licenses/rds_licenses_2012.ps1 @@ -0,0 +1,17 @@ +# SpearHead Systems george.mocanu@sphs.ro +# Check for Windows 2012 Server + +Import-Module RemoteDesktopServices + +$path = "RDS:\LicenseServer\LicenseKeyPacks\" + +Write-Host "<<>>" +foreach($pack in Get-ChildItem $path) + { + $checkName = $pack.Name -replace '\s','' + $newPath = Join-Path $path $pack + $total = (Get-Item $newPath\TotalLicenses).CurrentValue + $usage = (Get-Item $newPath\IssuedLicensesCount).CurrentValue + Write-Host $checkName " " $total " " $usage + } +exit diff --git a/check_mk-rds_licenses/checkman/rds_licenses b/check_mk-rds_licenses/checkman/rds_licenses new file mode 100644 index 0000000..510bb33 --- /dev/null +++ b/check_mk-rds_licenses/checkman/rds_licenses @@ -0,0 +1,30 @@ +title: Check for RDS licenses usage state +agents: windows +catalog: os/windows +license: GPL +distribution: +description: + This check return usage of RDS licenses. + You need to install the plugin {rds_licenses_2008.ps1} + into the {plugins} directory of your windows agent in + case of Win 2008 Server. In case of Win 2012 Server + in plugin directory must be copied elevate_shell.ps1 + and the rds_licenses_2008.ps1 must be copied into + check_mk agent folder and the user which run the check_mk + service must be allowed to elevate privileges. + This check was tested with Windows 2008 Server + and must have PowerShell installed. On Windows x64 is + recommended to use x64 agent. As always you must set + "set-executionpolicy remotesigned" on monitored host. + + The check gets critical if the usage percentage is above + 95 percents and warning if the usage percentage is above + 90 percents. + Both limits are definable in Wato under "Parameters for + Inventorized Checks", "Applications, Processes & Services". + +inventory: + One service will be created for each host running the plugin. + +perfdata: + Licenses usage. diff --git a/check_mk-rds_licenses/checks/rds_licenses b/check_mk-rds_licenses/checks/rds_licenses new file mode 100644 index 0000000..0248e80 --- /dev/null +++ b/check_mk-rds_licenses/checks/rds_licenses @@ -0,0 +1,57 @@ +#!/usr/bin/python +# Author: George Mocanu +# SpearHead Systems + +# EXAMPLE DATA FROM: +# fomat: Win2k8_Pack_Name No_of_Installed_Licenses No_of_Used_Licenses +# +#<<>> +#Win2k8_Pack_Name 20 15 + +factory_settings["rds_licenses_default_values"] = { + "levels": (80, 90), +} + +def inventory_rds_licenses(info): + inventory = [] + for line in info: + checkName = line[0] + inventory.append( (checkName, {} ) ) + return inventory + + +def check_rds_licenses(item, params, info): + if type(params) != dict: + params = { "levels": params } + warn, crit = params["levels"] + for line in info: + if line[0] == item: + total = int(line[1]) + used = int(line[2]) + if total != 0: + usedPerc = int(((used*100)/total)) + else: + usedPerc = int(((used*100)/1)) + perfdata = [ ( "usage", usedPerc, warn, crit ) ] + if total != 0: + if usedPerc > crit: + return (2, "License use level: %d percents. %d licenses used out of %d installed." %(usedPerc, used, total), perfdata) + elif usedPerc > warn: + return (1, "License use level: %d percents. %d licenses used out of %d installed." %(usedPerc, used, total), perfdata) + else: + return (0, "License use level: %d percents. %d licenses used out of %d installed." %(usedPerc, used, total), perfdata) + else: + if used == 0: + return (0, "No licenses installed, none used", perfdata) + else: + return (2, "No licenses installed, %d licenses used" %used, perfdata) + return(3, "Plugin not running on host") + +check_info["rds_licenses"] = { + "check_function" :check_rds_licenses, + "inventory_function" :inventory_rds_licenses, + "service_description" :"%s", + "default_levels_variable" :"rds_licenses_default_values", + "has_perfdata" :True, + "group" :"rds_licenses", +} diff --git a/check_mk-rds_licenses/info b/check_mk-rds_licenses/info new file mode 100644 index 0000000..f328401 --- /dev/null +++ b/check_mk-rds_licenses/info @@ -0,0 +1,17 @@ +{'author': 'SpearHead Systems george.mocanu@sphs.ro', + 'description': 'Check for RDS licenses usage', + 'download_url': 'https://github.com/spearheadsys/check_mk-rds_licenses/', + 'files': {'agents': ['windows/plugins/rds_licenses.ps1'], + 'checkman': ['rds_licenses'], + 'checks': ['rds_licenses'], + 'doc': [], + 'inventory': [], + 'notifications': [], + 'pnp-templates': [], + 'web': ['plugins/wato/rds_licenses.py']}, + 'name': 'rds_licenses', + 'num_files': 4, + 'title': 'rds_licenses', + 'version': '1.0', + 'version.min_required': '1.2.6b5', + 'version.packaged': '1.2.6b5'} \ No newline at end of file diff --git a/check_mk-rds_licenses/rds_licenses-1.1.mkp b/check_mk-rds_licenses/rds_licenses-1.1.mkp new file mode 100644 index 0000000..671fc78 Binary files /dev/null and b/check_mk-rds_licenses/rds_licenses-1.1.mkp differ diff --git a/check_mk-rds_licenses/web/plugins/wato/rds_licenses.py b/check_mk-rds_licenses/web/plugins/wato/rds_licenses.py new file mode 100644 index 0000000..27861fa --- /dev/null +++ b/check_mk-rds_licenses/web/plugins/wato/rds_licenses.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# 2015 george.mocanu@sphs.ro +# SpearHead Systems + +register_check_parameters( + subgroup_applications, + "rds_licenses", + _("RDS Licenses Usage Status"), + Dictionary( + elements = [ + ("levels", # Name of your parameters + Tuple( + title = "Levels for RDS Licenses Usage check", # Specify a title for this parameters + elements = [ + Integer( + title = _("Warning if above"), + unit = _("Percent"), + default_value = 80 + ), + Integer( + title = _("Critical if above"), + unit = _("Percent"), + default_value = 90 + ), + ] + ) + ), + ], + optional_keys = None, # Always show this subgroup + ), + TextAscii( title = "Service name"), + "dict" +) diff --git a/check_mk-vmware_orphaned_files/README.md b/check_mk-vmware_orphaned_files/README.md new file mode 100644 index 0000000..bac474b --- /dev/null +++ b/check_mk-vmware_orphaned_files/README.md @@ -0,0 +1 @@ +# check_mk-vmware_orphaned_files diff --git a/check_mk-vmware_orphaned_files/agents/windows/agents/find_orphaned_vmdk.ps1 b/check_mk-vmware_orphaned_files/agents/windows/agents/find_orphaned_vmdk.ps1 new file mode 100644 index 0000000..732fb9b --- /dev/null +++ b/check_mk-vmware_orphaned_files/agents/windows/agents/find_orphaned_vmdk.ps1 @@ -0,0 +1,103 @@ +# Purpose : This check verify if exists orphaned files on the datastores +# If there are orphaned files the output will be in the following format: +# [datastore_name] File_Path/file Size Last_Modified_Time +# Modify $usr,$pwd to match your vmware infrastructure; +# Modify $delay in order to run the script at specified interval. Default is one day + +Set-PSDebug -Strict + +#Main +#Configure user and password and delay(in seconds) +[string]$usr = "username" +[string]$pwd = "password" +$delay = 86400 + + +#Initialize the VIToolkit: +add-pssnapin VMware.VimAutomation.Core +[Reflection.Assembly]::LoadWithPartialName("VMware.Vim") + +# filename for timestamp +$remote_host = $env:REMOTE_HOST +$agent_dir = $env:MK_CONFDIR +$timestamp = $agent_dir + "\timestamp."+ $remote_host + +#Initialize variables +[string]$strVC = "127.0.0.1" +[string]$logfile = "C:\Orphaned_VMDK.log" +[string]$logdata = "" + + +# execute agent only every $delay seconds +# does $timestamp exist? +If (Test-Path $timestamp){ + # cat existing output + Get-Content C:\Orphaned_VMDK.log + $filedate = (ls $timestamp).LastWriteTime + $now = Get-Date + $earlier = $now.AddSeconds(-$delay) + # exit if timestamp too young + if ( $filedate -gt $earlier ) { exit } +} +# create new timestamp file +New-Item $timestamp -type file -force | Out-Null +# calculate unix timestamp +$epoch=[int][double]::Parse($(Get-Date -date (Get-Date).ToUniversalTime()-uformat %s)) + +[int]$countOrphaned = 0 +[int64]$orphanSize = 0 + +# vmWare Datastore Browser query parameters +# See http://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.host.DatastoreBrowser.SearchSpec.html +$fileQueryFlags = New-Object VMware.Vim.FileQueryFlags +$fileQueryFlags.FileSize = $true +$fileQueryFlags.FileType = $true +$fileQueryFlags.Modification = $true +$searchSpec = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec +$searchSpec.details = $fileQueryFlags +#The .query property is used to scope the query to only active vmdk files (excluding snaps and change block tracking). +$searchSpec.Query = (New-Object VMware.Vim.VmDiskFileQuery) +#$searchSpec.matchPattern = "*.vmdk" # Alternative VMDK match method. +$searchSpec.sortFoldersFirst = $true + +if ([System.IO.File]::Exists($logfile)) { + Remove-Item $logfile +} + +#Time stamp the log file +"<<>>" | Tee-Object -Variable logdata +$logdata | Out-File -FilePath $logfile -Append + +#Connect to vCenter Server +Connect-VIServer $strVC -Protocol https -User $usr -Password $pwd +#Collect array of all VMDK hard disk files in use: +[array]$UsedDisks = Get-View -ViewType VirtualMachine | % {$_.Layout} | % {$_.Disk} | % {$_.DiskFile} + + +#Collect array of all Datastores: +[array]$allDS = Get-Datastore | select -property name,Id | ? {$_.name -notmatch "LOG-"} | ? {$_.name -notmatch "_repository"} | Sort-Object -Property Name +[array]$orphans = @() +Foreach ($ds in $allDS) { + $dsView = Get-View $ds.Id + $dsBrowser = Get-View $dsView.browser + $rootPath = "["+$dsView.summary.Name+"]" + $searchResult = $dsBrowser.SearchDatastoreSubFolders($rootPath, $searchSpec) + foreach ($folder in $searchResult) { + foreach ($fileResult in $folder.File) { + if ($UsedDisks -notcontains ($folder.FolderPath + $fileResult.Path) -and ($fileResult.Path.length -gt 0)) { + $orphan = New-Object System.Object + ($folder.FolderPath + $fileResult.Path) | Tee-Object -Variable orphan + $orphans += $orphan + ([Math]::Round($fileResult.FileSize/1gb,2)) | Tee-Object -Variable orphan + $orphans += $orphan + ([string]$fileResult.Modification.year + "-" + [string]$fileResult.Modification.month + "-" + [string]$fileResult.Modification.day) + (echo "`r`n") | Tee-Object -Variable orphan + $orphans += $orphan + Remove-Variable orphan + } + } + } +} + +[array]$orphans | Tee-Object -Variable logdata +$logdata | Out-File -FilePath $logfile -Append +Disconnect-VIServer -Confirm:$False diff --git a/check_mk-vmware_orphaned_files/checkman/vmware_orphaned_files b/check_mk-vmware_orphaned_files/checkman/vmware_orphaned_files new file mode 100644 index 0000000..ecd2774 --- /dev/null +++ b/check_mk-vmware_orphaned_files/checkman/vmware_orphaned_files @@ -0,0 +1,20 @@ +title: Check for VMware Orphaned Files +agents: windows +catalog: os/windows +license: GPL +distribution: +description: + This check checks for VMware orpahned files. For more details + view the following VMware KB Article ID 1005049 + You need to install the plugin {find_vmdk_orphaned_files.ps1} + into the {plugins} directory of your windows agent. + + The check goes to warning if there any orphaned files. + The check will output a list of Datastore / Path / Size / LastModified files. + +inventory: + One service will be created indiferrently of the existence + of an orphaned file or not. + +perfdata: + None diff --git a/check_mk-vmware_orphaned_files/checks/vmware_orphaned_files b/check_mk-vmware_orphaned_files/checks/vmware_orphaned_files new file mode 100644 index 0000000..9e86ad7 --- /dev/null +++ b/check_mk-vmware_orphaned_files/checks/vmware_orphaned_files @@ -0,0 +1,41 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# Author: Marius Pana +# EXAMPLE DATA FROM: +# format: [datastore] [path] [size] [last mod date] +#<<>> +# [EUFRLHODS01] EUFRLHOAPP30/EUFRLHOAPP30-000002.vmdk 0.02 2015-1-29 +# [EUFRLHODS01] EUFRLHOAPP30/EUFRLHOAPP30_1-000002.vmdk 0.02 2015-1-29 +# [EUFRLHODS01] EUFRLHOAPP30/EUFRLHOAPP30_2-000002.vmdk 0.02 2015-1-29 + +def inventory_vmware_orphaned_files(info): + if len(info) >= 1 and len(info[0]) >= 1: + return [ (None, None) ] + else: + return [ (None, None) ] +# return [('No VMware orphan files detected', None)] + +def check_vmware_orphaned_files(item, params, info): + #if not item: + # return (0, "No VIMII orphan files found.") + if len(info) >= 1 and len(info[0]) >= 1: + total = len(info) + extended_info="" + for line in info: + if not line[0].startswith("["): + return (3, "There is a problem running the plugin. Please verify server") + else: + datastore = line[0] + path = line[1] + whichorphs = datastore + " " + path + extended_info += ' '.join(map(str,line)) + "
" + return (1, "WARN - VMware Orphan Files Detected: There are %d orphan files: %s" % (total, extended_info), [ ("vmware_orphaned_files", total) ]) + else: + return (0, "OK - No VMware Orphan Files Detected") + +check_info["vmware_orphaned_files"] = { + 'check_function': check_vmware_orphaned_files, + 'inventory_function': inventory_vmware_orphaned_files, + 'service_description': 'VMware Orphaned Files', + 'group': 'vmware_orphaned_files', +} diff --git a/check_mk-vmware_orphaned_files/info b/check_mk-vmware_orphaned_files/info new file mode 100644 index 0000000..a16e8be --- /dev/null +++ b/check_mk-vmware_orphaned_files/info @@ -0,0 +1,16 @@ +{'author': 'Marius Pana', + 'description': 'Check_mk check for VMware orphaned files.', + 'download_url': 'https://github.com/spearheadsys/check_mk-vmware_orphaned_files', + 'files': {'agents': [''], + 'checkman': ['vmware_orphaned_files'], + 'checks': ['vmware_orphaned_files'], + 'doc': [], + 'inventory': [], + 'notifications': [], + 'pnp-templates': [], + 'web': []}, + 'name': 'vmware_orphaned_files', + 'title': 'vmware_orphaned_files', + 'version': '1.0', + 'version.min_required': '1.2.6b1', + 'version.packaged': '1.2.6b1'} \ No newline at end of file diff --git a/check_mk-vmware_orphaned_files/vmware_orphaned_files-1.0.mkp b/check_mk-vmware_orphaned_files/vmware_orphaned_files-1.0.mkp new file mode 100644 index 0000000..0abe717 Binary files /dev/null and b/check_mk-vmware_orphaned_files/vmware_orphaned_files-1.0.mkp differ diff --git a/cmk_nsx/Check_NSX-1.4.mkp b/cmk_nsx/Check_NSX-1.4.mkp new file mode 100644 index 0000000..cc1d149 Binary files /dev/null and b/cmk_nsx/Check_NSX-1.4.mkp differ diff --git a/cmk_nsx/README.md b/cmk_nsx/README.md new file mode 100644 index 0000000..e0fb1d0 --- /dev/null +++ b/cmk_nsx/README.md @@ -0,0 +1,3 @@ +# cmk_nsx + +vmware NSX related checks \ No newline at end of file diff --git a/cmk_nsx/SRM-1.0.mkp b/cmk_nsx/SRM-1.0.mkp new file mode 100644 index 0000000..804c32b Binary files /dev/null and b/cmk_nsx/SRM-1.0.mkp differ diff --git a/cmk_nsx/local/share/check_mk/agents/special/agent_nsx b/cmk_nsx/local/share/check_mk/agents/special/agent_nsx new file mode 100644 index 0000000..5be13dc --- /dev/null +++ b/cmk_nsx/local/share/check_mk/agents/special/agent_nsx @@ -0,0 +1,1440 @@ +#!/usr/bin/env python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2018 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +import re +import sys, getopt +import requests +import xml.etree.ElementTree as ET +from requests.packages.urllib3.exceptions import InsecureRequestWarning # pylint: disable=import-error + +def usage(): + sys.stderr.write("""Check_MK VMWare NSX + +USAGE: agent_nsx [OPTIONS] HOST + +OPTIONS: + -h, --help Show this help message and exit + --address Host address + --user Username + --password Password + --no-cert-check Disable certificate check + --nsx_resource List of nsx resources +""") + sys.exit(1) + +short_options = "h" +long_options = ["help", "username=", "password=", "address=", "demo", "no-cert-check" , "nsx_resource="] + +try: + opts, args = getopt.getopt(sys.argv[1:], short_options, long_options) +except getopt.GetoptError, err: + sys.stderr.write("%s\n" % err) + sys.exit(1) + + +opt_demo = False +opt_cert = True +args_dict = {} +resources = [] + +for o,a in opts: + if o in [ "--address" ]: + args_dict["address"] = a + elif o in [ "--username" ]: + args_dict["username"] = a + elif o in [ "--password" ]: + args_dict["password"] = a + elif o in [ "--demo" ]: + opt_demo = True + elif o in [ "--no-cert-check" ]: + opt_cert = False + elif o in [ "--nsx_resource"]: + resources.append(a) + elif o in [ "-h", "--help" ]: + usage() + +def query(url): + if opt_cert == False: + requests.packages.urllib3.disable_warnings(InsecureRequestWarning) # pylint: disable=no-member + response = requests.get(url, verify=opt_cert, auth=(args_dict["username"], args_dict["password"]), headers={'Accept':'application/xml'}) + raw_xml = response.text + # Remove namespace nonsense + if "uptime" in str(url): + return raw_xml + else: + raw_xml = re.sub(' xml="[^"]+"', '', raw_xml, count=1) + xml_instance = ET.fromstring(raw_xml) + return xml_instance + +output_lines = [] +def output(line): + output_lines.append(line) + +def process_edge_info(): + output("<<>>") + xml_instance = query_edges() + if xml_instance.iter('edgeSummary'): + tbody = xml_instance.iter('edgeSummary') + for child in tbody: + name=child.find('name').text + edgeid=child.find('id').text + edgestatus=child.find('edgeStatus').text + edgestate=child.find('state').text + edgetype=child.find('edgeType').text + output("%s\t%s\t%s\t%s\t%s" % (name, edgeid, edgestatus, edgestate, edgetype)) + +def process_controller_info(): + output("<<>>") + xml_instance = query_controllers() + if xml_instance.iter('controller'): + tbody = xml_instance.iter('controller') + for child in tbody: + name=child.find('name').text + controllerid=child.find('id').text + controllerstatus=child.find('status').text + output("%s\t%s\t%s" % (name, controllerid, controllerstatus)) + +def process_nsx_components_info(): + output("<<>>") + xml_instance = query_nsx_components() + if xml_instance.iter('component'): + tbody = xml_instance.iter('component') + for child in tbody: + component_name=child.find('name').text + component_id=child.find('componentId').text + component_status=child.find('status').text + output("%s\t%s\t%s" % (component_name, component_id, component_status)) + +def process_nsx_backup_info(): + output("<<>>") + xml_instance = query_nsx_backup() + if xml_instance.iter('backupFileProperties'): + tbody = xml_instance.iter('backupFileProperties') + for child in tbody: + backup_file = child.find('fileName').text + backup_size = child.find('fileSize').text + backup_creationtime=child.find('creationTime').text + output("%s\t%s\t%s" % (backup_file, backup_size, backup_creationtime)) + +def process_nsx_cpu(): + output("<<>>") + xml_instance = query_nsx_cpu() + if xml_instance.iter('cpuinfo'): + tbody = xml_instance.iter('cpuInfo') + for child in tbody: + totalNoOfCPUs = child.find('totalNoOfCPUs').text + capacity = child.find('capacity').text + usedCapacity=child.find('usedCapacity').text + freeCapacity = child.find('freeCapacity').text + usedPercentage = child.find('usedPercentage').text + output("totalNoOfCPUs %s\ncapacity %s\nusedCapacity %s\nfreeCapacity %s\nusedPercentage %s" % (totalNoOfCPUs, capacity, usedCapacity, usedCapacity, usedPercentage )) + +def process_nsx_memory(): + output("<<>>") + xml_instance = query_nsx_memory() + if xml_instance.iter('memInfo'): + tbody = xml_instance.iter('memInfo') + for child in tbody: + totalMemory = child.find('totalMemory').text + usedMemory = child.find('usedMemory').text + freeMemory=child.find('freeMemory').text + usedPercentage = child.find('usedPercentage').text + output("TotalMem %s\nUsedMemory %s\nFreeMemory %s\nUsedPercentage %s" % (totalMemory, usedMemory, freeMemory, usedPercentage)) + +def process_nsx_uptime(): + output("<<>>") + seconds = 0 + uptime=query_nsx_uptime() + raw_text=uptime.split() + uptime=[] + for word in raw_text: + element = re.sub(',','',word,count =1) + uptime.append(element) + if "year" in uptime: + seconds = int(31536000) * int(uptime[int(uptime.index("year"))-1]) + if "days" in uptime: + seconds += int(86400) * int(uptime[int(uptime.index("days"))-1]) + if "hours" in uptime: + seconds += int(3600) * int(uptime[int(uptime.index("hours"))-1]) + if "minutes" in uptime: + seconds += int(60) * int(uptime[int(uptime.index("minutes"))-1]) + output(str(seconds)) + +def process_nsx_vcenter_connection(): + output("<<>>") + xml_instance = query_nsx_vcenter_connection() + if xml_instance.iter('vcConfigStatus'): + tbody = xml_instance.iter('vcConfigStatus') + for child in tbody: + connected = child.find('connected').text + output("vCenterConnection %s" % (connected)) + +def process_nsx_storage_info(): + output("<<>>") + xml_instance = query_nsx_storage_info() + if xml_instance.iter('storageInfo'): + tbody = xml_instance.iter('storageInfo') + for child in tbody: + totalStorage = child.find('totalStorage').text + usedStorage = child.find('usedStorage').text + freeStorage=child.find('freeStorage').text + usedPercentage = child.find('usedPercentage').text + output("TotalStorage %s\nUsedStorage %s\nFreeStorage %s\nUsedPercentage %s" % (totalStorage, usedStorage, freeStorage, usedPercentage)) + +def process_nsx_resource_info(): + output("<<>>") + for i in range(len(resources)): + xml_instance = query_nsx_resources(resources[i]) + if xml_instance.iter('resourceStatuses'): + tbody = xml_instance.iter('resourceStatus') + for child in tbody: + hostRebootRequired = child.find('hostRebootRequired').text + output("%s\thostRebootRequired\t%s" % ( resources[i], hostRebootRequired) ) + feature_statuses = child.iter('nwFabricFeatureStatus') + for feature in feature_statuses: + featureId = feature.find('featureId').text + featurestatus = feature.find('status').text + output("%s\t%s\t%s" % (resources[i], featureId, featurestatus)) + +def query_edges(): + if opt_demo: + raw_xml = re.sub(' xml="[^"]+"', '', edge_status, count=1) + return ET.fromstring(edge_status) + url = "https://%(address)s/api/4.0/edges" % args_dict + return query(url) + +def query_controllers(): + if opt_demo: + raw_xml = re.sub(' xml="[^"]+"', '', controllers, count=1) + return ET.fromstring(controllers) + url = "https://%(address)s/api/2.0/vdn/controller" % args_dict + return query(url) + +def query_nsx_components(): + if opt_demo: + raw_xml = re.sub(' xml="[^"]+"', '', nsx_components, count=1) + return ET.fromstring(nsx_components) + url = "https://%(address)s/api/1.0/appliance-management/summary/components" % args_dict + return query(url) + +def query_nsx_backup(): + if opt_demo: + raw_xml = re.sub(' xml="[^"]+"', '', backup, count=1) + return ET.fromstring(backup) + url = "https://%(address)s/api/1.0/appliance-management/backuprestore/backups" % args_dict + return query(url) + +def query_nsx_memory(): + if opt_demo: + raw_xml = re.sub(' xml="[^"]+"', '', nsx_memory, count=1) + return ET.fromstring(nsx_memory) + url = "https://%(address)s/api/1.0/appliance-management/system/meminfo" % args_dict + return query(url) + +def query_nsx_cpu(): + if opt_demo: + raw_xml = re.sub(' xml="[^"]+"', '', nsx_cpu, count=1) + return ET.fromstring(nsx_cpu) + url = "https://%(address)s/api/1.0/appliance-management/system/cpuinfo" % args_dict + return query(url) + +def query_nsx_uptime(): + if opt_demo: + return nsx_uptime + url = "https://%(address)s/api/1.0/appliance-management/system/uptime" % args_dict + return query(url) + +def query_nsx_vcenter_connection(): + if opt_demo: + raw_xml = re.sub(' xml="[^"]+"', '', nsx_vcenter_connection, count=1) + return ET.fromstring(nsx_vcenter_connection) + url = "https://%(address)s/api/2.0/services/vcconfig/status" % args_dict + return query(url) + +def query_nsx_storage_info(): + if opt_demo: + raw_xml = re.sub(' xml="[^"]+"', '', nsx_storage_info, count=1) + return ET.fromstring(nsx_storage_info) + url = "https://%(address)s/api/1.0/appliance-management/system/storageinfo" % args_dict + return query(url) + +def query_nsx_resources(resource): + if opt_demo: + raw_xml = re.sub(' xml="[^"]+"', '', nsx_resource_domain_c7, count=1) + return ET.fromstring(nsx_resource_domain_c7) + uri = "api/2.0/nwfabric/status?resource=%s" % resource + url_1 = "https://%(address)s/" % args_dict + url = "%s%s" % (url_1, uri) + return query(url) + +def main(): + try: + # Get edges info + process_edge_info() + # Get Controllers info + process_controller_info() + # Get NSX Components + process_nsx_components_info() + # Get NSX Backup + process_nsx_backup_info() + # Get NSX Memory Usage + process_nsx_memory() + # Get NSX CPU Usage + process_nsx_cpu() + # Get Uptime + process_nsx_uptime() + # Get vCenter Conneciton + process_nsx_vcenter_connection() + # Get Storage info + process_nsx_storage_info() + # get Resources info + process_nsx_resource_info() + sys.stdout.write("\n".join(output_lines) + "\n") + except Exception, e: + sys.stderr.write("Connection error: %s" % e) + sys.exit(1) + +edge_status = \ +""" + + + + 256 + 0 + 5 + true + id + + + edge-1 + Edge + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 17 + + Edge + + clj01psc01 + + + false + 0 + false + edge-1 + deployed + gatewayServices + datacenter-2 + clj01-m01dc + default + 4.0 + GREEN + 1 + + 6.3.4 + 6.3.4-6795877 + large + clj01psc01.test + 2 + 0 + vm-42 + clj01psc01-0 + host-21 + clj01m01esx03.test + resgroup-8 + Resources + datastore-12 + clj01-m01-ds01 + 1528198369821 + msgbus-msgbus + false + + false + + Change Log Level + Add Edge Appliance + Delete Edge Appliance + Edit Edge Appliance + Edit CLI Credentials + Change FIPS mode + Change edge appliance size + Force Sync + Redeploy Edge + Change Edge Appliance Core Dump Configuration + Enable hypervisorAssist + Edit Highavailability + Edit Dns + Edit Syslog + Edit Automatic Rule Generation Settings + Disable SSH + Download Edge TechSupport Logs + + + + edge-70c025e2-aae0-4801-b0dd-27c07cb6d9ae + Edge + 42220EB5-0574-A0A4-031B-1DA658998F9E + 8a3ecfae-a3dd-4558-91b6-7430419e174b + 8 + + Edge + + uni01w01dlrbuc01-X_DMZA + + + true + 0 + false + edge-70c025e2-aae0-4801-b0dd-27c07cb6d9ae + active + distributedRouter + default + 4.0 + + jobdata-63834 + SUCCESS + + GREY + 2 + + 6.3.4 + compact + NSX-edge-70c025e2-aae0-4801-b0dd-27c07cb6d9ae + 0 + true + + + + edge-2 + Edge + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 21 + + Edge + + clj01m01esg01 + + + false + 0 + false + edge-2 + deployed + gatewayServices + datacenter-2 + clj01-m01dc + default + 4.0 + GREEN + 3 + + 6.3.4 + 6.3.4-6795877 + large + clj01m01esg01.test + 1 + 0 + vm-46 + clj01m01esg01-0 + host-10 + clj01m01esx01.test + resgroup-8 + Resources + datastore-12 + clj01-m01-ds01 + 1528198355972 + msgbus + false + + false + + Change Log Level + Add Edge Appliance + Delete Edge Appliance + Edit Edge Appliance + Edit CLI Credentials + Change FIPS mode + Change edge appliance size + Force Sync + Redeploy Edge + Change Edge Appliance Core Dump Configuration + Enable hypervisorAssist + Edit Highavailability + Edit Dns + Edit Syslog + Edit Automatic Rule Generation Settings + Disable SSH + Download Edge TechSupport Logs + + + + edge-3 + Edge + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 15 + + Edge + + clj01m01esg02 + + + false + 0 + false + edge-3 + deployed + gatewayServices + datacenter-2 + clj01-m01dc + default + 4.0 + GREEN + 3 + + 6.3.4 + 6.3.4-6795877 + large + clj01m01esg02.test + 1 + 0 + vm-47 + clj01m01esg02-0 + host-20 + clj01m01esx02.test + resgroup-8 + Resources + datastore-12 + clj01-m01-ds01 + 1528198356967 + msgbus + false + + false + + Change Log Level + Add Edge Appliance + Delete Edge Appliance + Edit Edge Appliance + Edit CLI Credentials + Change FIPS mode + Change edge appliance size + Force Sync + Redeploy Edge + Change Edge Appliance Core Dump Configuration + Enable hypervisorAssist + Edit Highavailability + Edit Dns + Edit Syslog + Edit Automatic Rule Generation Settings + Disable SSH + Download Edge TechSupport Logs + + + + edge-4 + Edge + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 21 + + Edge + + clj01m01lb01 + + + false + 0 + false + edge-4 + deployed + gatewayServices + datacenter-2 + clj01-m01dc + default + 4.0 + + jobdata-25970 + SUCCESS + + GREEN + 2 + + 6.3.4 + 6.3.4-6795877 + large + clj01m01lb01.test + 2 + 1 + vm-68 + clj01m01lb01-1 + host-20 + clj01m01esx02.test + resgroup-8 + Resources + datastore-11 + clj01-m01-ds03 + 1528198325165 + msgbus-msgbus + false + + false + + Change Log Level + Add Edge Appliance + Delete Edge Appliance + Edit Edge Appliance + Edit CLI Credentials + Change FIPS mode + Change edge appliance size + Force Sync + Redeploy Edge + Change Edge Appliance Core Dump Configuration + Enable hypervisorAssist + Edit Highavailability + Edit Dns + Edit Syslog + Edit Automatic Rule Generation Settings + Disable SSH + Download Edge TechSupport Logs + + + + edge-2c8970e8-14f4-40f1-a684-9971976b730e + Edge + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 13 + + Edge + + buc01m01udlr01 + + + true + 0 + false + edge-2c8970e8-14f4-40f1-a684-9971976b730e + deployed + distributedRouter + default + 4.0 + + jobdata-25968 + SUCCESS + + GREEN + 4 + + 6.3.4 + 6.3.4-6795877 + compact + NSX-edge-2c8970e8-14f4-40f1-a684-9971976b730e + 2 + 0 + vm-303 + edge-2c8970e8-14f4-40f1-a684-9971976b730e-0-buc01m01udlr01 + host-21 + clj01m01esx03.test + resgroup-8 + Resources + datastore-12 + clj01-m01-ds01 + 1528198329144 + msgbus-msgbus + false + + false + + Change Log Level + Add Edge Appliance + Delete Edge Appliance + Edit Edge Appliance + Edit CLI Credentials + Change FIPS mode + Force Sync + Redeploy Edge + Change Edge Appliance Core Dump Configuration + Edit Highavailability + Edit Dns + Edit Syslog + Disable SSH + Download Edge TechSupport Logs + + 30000 + default+edge-2c8970e8-14f4-40f1-a684-9971976b730e + ffcbdd18-6397-489c-a94f-19761b811d81 + + + TransportZone + universalvdnscope + + + + +""" + + +controllers = \ +""" + + + Controller + 0 + clj01m01nsxc01 + clj01m01nsxc01 + + false + 0 + controller-47 + 172.19.133.51 + RUNNING + NOT_STARTED + 6.3.7087288 + true + + vm-301 + VirtualMachine + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 7 + + VirtualMachine + + NSX_Controller_70ef8503-f49b-478f-96bb-08cd01bd3558 + + domain-c7 + ClusterComputeResource + clj01-m01-mgmt01 + + + + false + 0 + + + host-21 + HostSystem + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 3016 + + HostSystem + + clj01m01esx03.test + + domain-c7 + ClusterComputeResource + clj01-m01-mgmt01 + + + + false + 0 + + + resgroup-8 + ResourcePool + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 153 + + ResourcePool + + Resources + + domain-c7 + ClusterComputeResource + clj01-m01-mgmt01 + + + + false + 0 + + + domain-c7 + ClusterComputeResource + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 9 + + ClusterComputeResource + + clj01-m01-mgmt01 + + datacenter-2 + Datacenter + clj01-m01dc + + + + false + 0 + + 42224242-869B-7AA0-5855-FD2C6ADF7451 + false + + datastore-12 + Datastore + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 2 + + Datastore + + clj01-m01-ds01 + + + false + 0 + + + + controller-47 + 172.19.133.51 + 172.19.133.52 + true + SUCCESS + 1528198790434 + + + FALSE + POWERED_ON + + + Controller + 0 + clj01m01nsxc01 + clj01m01nsxc01 + + false + 0 + controller-48 + 172.19.133.52 + RUNNING + NOT_STARTED + 6.3.7087288 + true + + vm-302 + VirtualMachine + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 7 + + VirtualMachine + + NSX_Controller_cdecc3f5-11c5-461f-b6a8-e980dcc83cc4 + + domain-c7 + ClusterComputeResource + clj01-m01-mgmt01 + + + + false + 0 + + + host-21 + HostSystem + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 3016 + + HostSystem + + clj01m01esx03.test + + domain-c7 + ClusterComputeResource + clj01-m01-mgmt01 + + + + false + 0 + + + resgroup-8 + ResourcePool + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 153 + + ResourcePool + + Resources + + domain-c7 + ClusterComputeResource + clj01-m01-mgmt01 + + + + false + 0 + + + domain-c7 + ClusterComputeResource + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 9 + + ClusterComputeResource + + clj01-m01-mgmt01 + + datacenter-2 + Datacenter + clj01-m01dc + + + + false + 0 + + 42224242-869B-7AA0-5855-FD2C6ADF7451 + false + + datastore-12 + Datastore + 42224242-869B-7AA0-5855-FD2C6ADF7451 + feec058e-c396-4c37-96d2-a7169e92622a + 2 + + Datastore + + clj01-m01-ds01 + + + false + 0 + + + + controller-48 + 172.19.133.52 + 172.19.133.51 + true + SUCCESS + 1528198790484 + + + FALSE + POWERED_ON + +""" + +nsx_components = \ +""" + + + + COMMON + + + VPOSTGRES + vPostgres + vPostgres - Database service + RUNNING + true + false + + NSX + + COMMON + + + RABBITMQ + RabbitMQ + RabbitMQ - Messaging service + RUNNING + true + false + + NSX + + COMMON + + + + + NSXGRP + + + NSXREPLICATOR + NSX Replicator + NSX Replicator + RUNNING + true + false + + NSX + + + NSXGRP + + + NSX + NSX Manager + NSX Manager + RUNNING + true + true + + VPOSTGRES + RABBITMQ + + + NSXREPLICATOR + + NSXGRP + + 6 + 3 + 4 + 7087695 + + + + + + SYSTEM + + + SSH + SSH Service + Secure Shell + RUNNING + true + false + + SYSTEM + + + + +""" + + +backup = \ +""" + + + clj01m01nsx01_00_00_00_Tue05Jun2018 + 3614752 + 1528156800000 + + + clj01m01nsx01_00_00_00_Sun03Jun2018 + 3553312 + 1527984000000 + + + clj01m01nsx01_00_00_00_Sat02Jun2018 + 3532832 + 1527897600000 + + + clj01m01nsx01_00_00_00_Thu31May2018 + 3491872 + 1527724800000 + + + clj01m01nsx01_00_00_00_Wed30May2018 + 3471392 + 1527638400000 + + + clj01m01nsx01_00_00_00_Tue29May2018 + 3450912 + 1527552000000 + + + clj01m01nsx01_00_00_00_Mon28May2018 + 3430432 + 1527465600000 + + + clj01m01nsx01_00_00_00_Sun27May2018 + 3420192 + 1527379200000 + + + clj01m01nsx01_00_00_00_Sat26May2018 + 3399712 + 1527292800000 + + + clj01m01nsx01_00_00_00_Fri25May2018 + 3389472 + 1527206400000 + + + clj01m01nsx01_00_00_00_Thu24May2018 + 3328032 + 1527120000000 + + + clj01m01nsx01_00_00_00_Tue22May2018 + 3266592 + 1526947200000 + + + clj01m01nsx01_00_00_00_Mon21May2018 + 3246112 + 1526860800000 + + + clj01m01nsx01_00_00_00_Sun20May2018 + 3225632 + 1526774400000 + + + clj01m01nsx01_00_00_00_Sat19May2018 + 3205152 + 1526688000000 + + + clj01m01nsx01_00_00_00_Fri30Mar2018 + 2109472 + 1522368000000 + + + clj01m01nsx01_00_00_00_Fri18May2018 + 3184672 + 1526601600000 + + + clj01m01nsx01_00_00_00_Thu29Mar2018 + 2088992 + 1522281600000 + + + clj01m01nsx01_00_00_00_Thu17May2018 + 3153952 + 1526515200000 + + + clj01m01nsx01_00_00_00_Wed28Mar2018 + 2058272 + 1522195200000 + + + clj01m01nsx01_00_00_00_Wed16May2018 + 3143712 + 1526428800000 + + + clj01m01nsx01_00_00_00_Tue27Mar2018 + 2037792 + 1522108800000 + + + clj01m01nsx01_23_59_58_Mon14May2018 + 3143712 + 1526342398000 + + + clj01m01nsx01_00_00_00_Mon26Mar2018 + 2017312 + 1522022400000 + + + clj01m01nsx01_00_00_00_Mon14May2018 + 3143712 + 1526256000000 + + + clj01m01nsx01_00_00_00_Sun25Mar2018 + 1996832 + 1521936000000 + + + clj01m01nsx01_00_00_00_Sun13May2018 + 3112992 + 1526169600000 + + + clj01m01nsx01_00_00_00_Sat24Mar2018 + 1976352 + 1521849600000 + + + clj01m01nsx01_00_00_00_Sat12May2018 + 3133472 + 1526083200000 + + + clj01m01nsx01_00_00_00_Fri23Mar2018 + 1996832 + 1521763200000 + + + clj01m01nsx01_00_00_00_Thu22Mar2018 + 1914912 + 1521676800000 + + + clj01m01nsx01_00_00_00_Thu10May2018 + 3072032 + 1525910400000 + + + clj01m01nsx01_00_00_00_Wed21Mar2018 + 1822752 + 1521590400000 + + + clj01m01nsx01_00_00_00_Wed09May2018 + 3051552 + 1525824000000 + + + clj01m01nsx01_00_00_00_Tue20Mar2018 + 1740832 + 1521504000000 + + + clj01m01nsx01_00_00_00_Tue08May2018 + 2990112 + 1525737600000 + + + clj01m01nsx01_00_00_00_Mon19Mar2018 + 1658912 + 1521417600000 + + + clj01m01nsx01_00_00_00_Mon07May2018 + 2928672 + 1525651200000 + + + clj01m01nsx01_00_00_00_Sun18Mar2018 + 1576992 + 1521331200000 + + + clj01m01nsx01_00_00_00_Sun06May2018 + 2908192 + 1525564800000 + + + clj01m01nsx01_00_00_00_Sat17Mar2018 + 1495072 + 1521244800000 + + + clj01m01nsx01_00_00_00_Sat05May2018 + 2887712 + 1525478400000 + + + clj01m01nsx01_00_00_00_Fri16Mar2018 + 1402912 + 1521158400000 + + + clj01m01nsx01_00_00_00_Fri04May2018 + 2867232 + 1525392000000 + + + clj01m01nsx01_00_00_00_Thu15Mar2018 + 1320992 + 1521072000000 + + + clj01m01nsx01_00_00_00_Wed14Mar2018 + 1228832 + 1520985600000 + + + clj01m01nsx01_00_00_00_Tue13Mar2018 + 1146912 + 1520899200000 + + + clj01m01nsx01_00_00_00_Mon12Mar2018 + 1064992 + 1520812800000 + + + clj01m01nsx01_00_00_00_Sun11Mar2018 + 993312 + 1520726400000 + + + clj01m01nsx01_23_59_58_Fri09Mar2018 + 911392 + 1520639998000 + + + clj01m01nsx01_23_59_58_Thu08Mar2018 + 778272 + 1520553598000 + + + clj01m01nsx01_00_00_00_Thu08Mar2018 + 665632 + 1520467200000 + + + clj01m01nsx01_08_21_01_Wed07Mar2018 + 532512 + 1520410861000 + + + clj01m01nsx01_00_00_00_Mon04Jun2018 + 3573792 + 1528070400000 + + + clj01m01nsx01_00_00_00_Fri01Jun2018 + 3512352 + 1527811200000 + +""" + +nsx_memory = \ +""" + + 16025 MB + 5233 MB + 10792 MB + 33 +""" + +nsx_cpu = \ +""" + + 4 + 2196 MHZ + 17 MHZ + 2179 MHZ + 1 +""" + +nsx_vcenter_connection = \ +""" + + true + 1528202184756 +""" + + +nsx_storage_info = \ +""" + + 81G + 4.1G + 77G + 5 +""" + + +nsx_uptime = "7 days, 7 minutes" + +nsx_resource_domain_c7 = \ +""" + + + + domain-c7 + ClusterComputeResource + 4220F930-D7C1-D623-88EC-FB40297018CF + b473ae67-65db-48cb-ac8d-069e43df1c52 + 12 + + ClusterComputeResource + + buc01-m01-mgmt01 + + datacenter-2 + Datacenter + buc01-m01dc + + + + false + 0 + + false + + com.vmware.vshield.vsm.nwfabric.hostPrep + 6.3.4.7087695 + false + GREEN + true + true + false + + + com.vmware.vshield.vsm.vdr_mon + 5.5 + false + UNKNOWN + false + true + false + + + com.vmware.vshield.vsm.vxlan + 5.5 + false + GREEN + true + true + false + + + com.vmware.vshield.vsm.messagingInfra + false + GREEN + true + true + false + + + com.vmware.vshield.firewall + 5.5 + false + GREEN + + true + true + false + + +""" + +if __name__ == "__main__": + main() + diff --git a/cmk_nsx/local/share/check_mk/agents/special/agent_srm b/cmk_nsx/local/share/check_mk/agents/special/agent_srm new file mode 100644 index 0000000..054be00 --- /dev/null +++ b/cmk_nsx/local/share/check_mk/agents/special/agent_srm @@ -0,0 +1,173 @@ +#!/usr/bin/env python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2018 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +import re +import sys, getopt +import requests +from requests.packages.urllib3.exceptions import InsecureRequestWarning # pylint: disable=import-error +from HTMLParser import HTMLParser + +def usage(): + sys.stderr.write("""Check_MK VMWare SRM + +USAGE: agent_srm [OPTIONS] HOST + +OPTIONS: + -h, --help Show this help message and exit + --address Host address + --no-cert-check Disable certificate check +""") + sys.exit(1) + +short_options = "h" +long_options = ["help", "address=", "demo", "no-cert-check"] + +try: + opts, args = getopt.getopt(sys.argv[1:], short_options, long_options) +except getopt.GetoptError, err: + sys.stderr.write("%s\n" % err) + sys.exit(1) + + +opt_demo = False +opt_cert = True +args_dict = {} +resources = [] + +for o,a in opts: + if o in [ "--address" ]: + args_dict["address"] = a + elif o in [ "--demo" ]: + opt_demo = True + elif o in [ "--no-cert-check" ]: + opt_cert = False + elif o in [ "-h", "--help" ]: + usage() + +class HTMLTableParser(HTMLParser): + def __init__( + self, + decode_html_entities=False, + data_separator=' ', + ): + + HTMLParser.__init__(self) + + self._parse_html_entities = decode_html_entities + self._data_separator = data_separator + + self._in_td = False + self._in_th = False + self._current_table = [] + self._current_row = [] + self._current_cell = [] + self.tables = [] + + def handle_starttag(self, tag, attrs): + if tag == 'td': + self._in_td = True + if tag == 'th': + self._in_th = True + + def handle_data(self, data): + if self._in_td or self._in_th: + self._current_cell.append(data.strip()) + + def handle_charref(self, name): + + if self._parse_html_entities: + self.handle_data(self.unescape('&#{};'.format(name))) + + def handle_endtag(self, tag): + if tag == 'td': + self._in_td = False + elif tag == 'th': + self._in_th = False + + if tag in ['td', 'th']: + final_cell = self._data_separator.join(self._current_cell).strip() + self._current_row.append(final_cell) + self._current_cell = [] + elif tag == 'tr': + self._current_table.append(self._current_row) + self._current_row = [] + elif tag == 'table': + self.tables.append(self._current_table) + self._current_table = [] + +parser=HTMLTableParser() + +def query(url): + if opt_cert == False: + requests.packages.urllib3.disable_warnings(InsecureRequestWarning) # pylint: disable=no-member + response = requests.get(url, verify=opt_cert) + raw_html = response.text + return raw_html +output_lines = [] +def output(line): + output_lines.append(line) + +def query_srm(): + if opt_demo: + return parser.feed(srm_status) + url = "https://%(address)s:9086/" % args_dict + return parser.feed(query(url)) + +def process_srm_info(): + output("<<>>") + query_srm() + local_connection = parser.tables[0] + remote_connection = parser.tables[1] + i=2 + for row in local_connection: + if str(row[0]) == "Service": + output("LocalConnection %s\t%s\t%s" % (row[1],local_connection[i][1],local_connection[i+2][1])) + i+=5 + + i=2 + for row in remote_connection: + if str(row[0]) == "Service": + output("RemoteConnection %s\t%s\t%s" % (row[1],local_connection[i][1],remote_connection[i+2][1])) + i+=5 + +def main(): + try: + process_srm_info() + sys.stdout.write("\n".join(output_lines) + "\n") + except Exception, e: + sys.stderr.write("Connection error: %s" % e) + sys.exit(1) + + +srm_status = \ +""" + + +

VMware vCenter Site Recovery Manager 6.5.1.6014840

Name: buc01m01vc01.test, UUID: d8fd8aea-a3ed-46e9-857e-509b80784c53, Extension key: com.vmware.vcDr

VMware vCenter Server 6.5.0 build-7515524


Supported VMODL versions

Inherent VMODL version


Local Connections

----------------------------------------------------------------------------------------------------
Servicecom.vmware.cis.vcenterserver
URLhttps://buc01m01vc01.test:443/sdk
Thumbprintunknown
StatusConnected
----------------------------------------------------------------------------------------------------
Servicecom.vmware.cis.cs.inventory
URLhttps://buc01m01vc01.test:443/invsvc/vmomi/sdk
Thumbprintunknown
StatusConnected
----------------------------------------------------------------------------------------------------
Servicecom.vmware.cis.cs.lookup
URLhttps://buc01psc01.test:443/lookupservice/sdk
Thumbprintunknown
StatusConnected
----------------------------------------------------------------------------------------------------
Servicecom.vmware.cis.cs.identity
URLhttps://buc01psc01.test/sso-adminserver/sdk/vsphere.local
Thumbprintunknown
StatusConnected
----------------------------------------------------------------------------------------------------
Servicecom.vmware.cis.cs.authorization
URLhttps://buc01m01vc01.test:443/invsvc/vmomi/sdk
Thumbprintunknown
StatusConnected
----------------------------------------------------------------------------------------------------
Servicecom.vmware.cis.cs.license
URLhttps://buc01psc01.test:443/ls/sdk
Thumbprintunknown
StatusConnected
----------------------------------------------------------------------------------------------------

Paired with remote SRM with name 'clj01m01vc01.test' and uuid 'acf7df22-01bb-439a-b27e-9f8b83e23233'

Remote Connections

----------------------------------------------------------------------------------------------------
Servicecom.vmware.cis.vcenterserver
URLhttps://clj01m01vc01.test:443/sdk
Thumbprintunknown
StatusConnected
----------------------------------------------------------------------------------------------------
Servicecom.vmware.dr.vcDr
URLhttps://clj01m01srm01.test:9086/vcdr/vmomi/sdk
Thumbprintunknown
StatusConnected
----------------------------------------------------------------------------------------------------
Servicecom.vmware.cis.cs.lookup
URLhttps://clj01psc01.test:443/lookupservice/sdk
Thumbprintunknown
StatusConnected
----------------------------------------------------------------------------------------------------
Servicecom.vmware.cis.cs.identity
URLhttps://clj01psc01.test/sso-adminserver/sdk/vsphere.local
Thumbprintunknown
StatusConnected
----------------------------------------------------------------------------------------------------
""" + +if __name__ == "__main__": + main() + diff --git a/cmk_nsx/local/share/check_mk/checkman/nsx_backup b/cmk_nsx/local/share/check_mk/checkman/nsx_backup new file mode 100644 index 0000000..8c4dfdc --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checkman/nsx_backup @@ -0,0 +1,14 @@ +title: VMWare NSX: Backup time +agents: agent_nsx +catalog: Miscellaneous +license: GPL +distribution: check_mk +description: + This check monitors the date of last backup. +item: + Backup service. + +perfdata: + none +inventory: + One service called "NSX Backups". diff --git a/cmk_nsx/local/share/check_mk/checkman/nsx_components b/cmk_nsx/local/share/check_mk/checkman/nsx_components new file mode 100644 index 0000000..6232707 --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checkman/nsx_components @@ -0,0 +1,15 @@ +title: VMWare NSX: Components status +agents: agent_nsx +catalog: Miscellaneous +license: GPL +distribution: check_mk +description: + This check monitors the status of VMWare NSX Components +item: + The item is composed from the Component Type. + +perfdata: + none +inventory: + All NSX Components defined will be inventorized. + diff --git a/cmk_nsx/local/share/check_mk/checkman/nsx_controllers b/cmk_nsx/local/share/check_mk/checkman/nsx_controllers new file mode 100644 index 0000000..78bb4fe --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checkman/nsx_controllers @@ -0,0 +1,19 @@ +title: VMWare NSX: Controllers status +agents: agent_nsx +catalog: Miscellaneous +license: GPL +distribution: check_mk +description: + This check monitors the status of VMWare NSX Constrollers +• Deploying - controller is being deployed and the procedure has not completed yet. +• Removing - controller is being removed and the procedure has not completed yet. +• Running - controller has been deployed and can respond to API invocation. +• Unknown - controller has been deployed but fails to respond to API invocation. +item: + The item is composed from the Controller-id. + +perfdata: + none +inventory: + All NSX Controllers defined will be inventorized. + diff --git a/cmk_nsx/local/share/check_mk/checkman/nsx_cpu b/cmk_nsx/local/share/check_mk/checkman/nsx_cpu new file mode 100644 index 0000000..bdbc6ff --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checkman/nsx_cpu @@ -0,0 +1,15 @@ +title: VMWare NSX: CPU usage of NSX +agents: agent_nsx +catalog: Miscellaneous +license: GPL +distribution: check_mk +description: + This check monitors the CPU usage. +item: + Memory used + +perfdata: + One graph for CPU used in percentage +inventory: + One service called "CPU Utilization". + diff --git a/cmk_nsx/local/share/check_mk/checkman/nsx_edges b/cmk_nsx/local/share/check_mk/checkman/nsx_edges new file mode 100644 index 0000000..1a3caff --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checkman/nsx_edges @@ -0,0 +1,15 @@ +title: VMWare NSX: Edges status +agents: agent_nsx +catalog: Miscellaneous +license: GPL +distribution: check_mk +description: + This check monitors the status of VMWare NSX Edges +item: + The item is composed from the edge-id. + +perfdata: + none +inventory: + All NSX edges defined will be inventorized. + diff --git a/cmk_nsx/local/share/check_mk/checkman/nsx_mem b/cmk_nsx/local/share/check_mk/checkman/nsx_mem new file mode 100644 index 0000000..33f64c2 --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checkman/nsx_mem @@ -0,0 +1,15 @@ +title: VMWare NSX: Memory usage of NSX +agents: agent_nsx +catalog: Miscellaneous +license: GPL +distribution: check_mk +description: + This check monitors the memory usage. +item: + Memory used + +perfdata: + Two graphs for memory used and all memory +inventory: + One service called "Memory Usage". + diff --git a/cmk_nsx/local/share/check_mk/checkman/nsx_memory b/cmk_nsx/local/share/check_mk/checkman/nsx_memory new file mode 100644 index 0000000..e785410 --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checkman/nsx_memory @@ -0,0 +1,14 @@ +title: VMWare NSX: Memory usage of NSX +agents: agent_nsx +catalog: Miscellaneous +license: GPL +distribution: check_mk +description: + This check monitors the memory usage. +item: + Memory used + +perfdata: + Two graphs for memory used and all memory +inventory: + One service called "Memory Usage". diff --git a/cmk_nsx/local/share/check_mk/checkman/nsx_storage b/cmk_nsx/local/share/check_mk/checkman/nsx_storage new file mode 100644 index 0000000..ffec152 --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checkman/nsx_storage @@ -0,0 +1,15 @@ +title: VMWare NSX: Storage usage of NSX +agents: agent_nsx +catalog: Miscellaneous +license: GPL +distribution: check_mk +description: + This check monitors the storage usage. +item: + Memory used + +perfdata: + One graph for storage used in bytes, autoscaled +inventory: + One service called "Storage used". + diff --git a/cmk_nsx/local/share/check_mk/checkman/nsx_vcenter_connection b/cmk_nsx/local/share/check_mk/checkman/nsx_vcenter_connection new file mode 100644 index 0000000..752bd82 --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checkman/nsx_vcenter_connection @@ -0,0 +1,14 @@ +title: VMWare NSX: vCenter Connection +agents: agent_nsx +catalog: Miscellaneous +license: GPL +distribution: check_mk +description: + This check monitors the state of vCenter Connection. +item: + vCenter Connection + +perfdata: + none +inventory: + One service called "vCenter Connection". diff --git a/cmk_nsx/local/share/check_mk/checks/agent_nsx b/cmk_nsx/local/share/check_mk/checks/agent_nsx new file mode 100644 index 0000000..1f6bbf6 --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checks/agent_nsx @@ -0,0 +1,41 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2017 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +def agent_nsx_arguments(params, hostname, ipaddress): + args = '' + args += "--address=%s " % hostname + args += "--user=%s " % params["user"] + args += "--password=%s " % params["password"] + + if "nsx_resource" in params: + for domain in params["nsx_resource"]: + args += "--nsx_resource=%s " % domain + if "cert" in params and params["cert"] == False: + args += "--no-cert-check " + return args + +special_agent_info['nsx'] = agent_nsx_arguments + diff --git a/cmk_nsx/local/share/check_mk/checks/agent_srm b/cmk_nsx/local/share/check_mk/checks/agent_srm new file mode 100644 index 0000000..21c5ce0 --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checks/agent_srm @@ -0,0 +1,36 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2017 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +def agent_srm_arguments(params, hostname, ipaddress): + args = '' + args += "--address=%s " % hostname + + if "cert" in params and params["cert"] == False: + args += "--no-cert-check " + return args + +special_agent_info['srm'] = agent_srm_arguments + diff --git a/cmk_nsx/local/share/check_mk/checks/check_nsx b/cmk_nsx/local/share/check_mk/checks/check_nsx new file mode 100644 index 0000000..e7a155c --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checks/check_nsx @@ -0,0 +1,431 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2018 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +import datetime + +def inventory_edges_status(info): + for name, edgeid, edgestatus, edgestate, edgetype in info: + yield ("Edge %s" % \ + (edgeid), {}) + + +def check_edges_status(item, params, info): + for line in info: + edge = "Edge" + " " + line[1] + if edge==item: + edgename = line[0] + edgestatus = line[2] + edgestate = line[3] + edgetype = line[4] + if edgetype == "distributedRouter": + if edgestate != "active": + return 2, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus ) + elif edgestatus == "GREEN": + return 0, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus ) + elif edgestatus == "GREY": + return 0, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus ) + elif edgestatus == "YELLOW": + return 1, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus ) + elif edgestatus == "RED": + return 2, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus ) + return 3, "Edge %s state is %s and status %s" % (edgename, edgestate, edgestatus ) + else: + if edgestatus == "GREEN": + return 0, "Edge %s is %s" % (edgename, edgestatus) + elif edgestatus == "YELLOW": + return 1, "Edge %s is %s" % (edgename, edgestatus) + elif edgestatus == "RED": + return 2, "Edge %s is %s" % (edgename, edgestatus) + return 3, "Edge %s is %s" % (edgename, edgestatus) + + +check_info['nsx_edges'] = { + 'inventory_function' : inventory_edges_status, + 'check_function' : check_edges_status, + 'service_description' : '%s', + 'has_perfdata' : False, +} + +#. +# .--Controller Status---------------------------------------------------. +# | ____ _ _ _ | +# | / ___|___ _ __ | |_ _ __ ___ | | | ___ _ __ | +# | | | / _ \| '_ \| __| '__/ _ \| | |/ _ \ '__| | +# | | |__| (_) | | | | |_| | | (_) | | | __/ | | +# | \____\___/|_| |_|\__|_| \___/|_|_|\___|_| | +# | | +# | ____ _ _ | +# | / ___|| |_ __ _| |_ _ _ ___ | +# | \___ \| __/ _` | __| | | / __| | +# | ___) | || (_| | |_| |_| \__ \ | +# | |____/ \__\__,_|\__|\__,_|___/ | +# | | +# +----------------------------------------------------------------------+ +# | | +# '----------------------------------------------------------------------' + +def inventory_controller_status(info): + for name, id, status in info: + yield ("Controller %s" % \ + (id), {}) + + +def check_controller_status(item, params, info): + for line in info: + controller = "Controller" + " " + line[1] + if controller==item: + controllername = line[0] + controllerstatus = line[2] + if controllerstatus == "RUNNING": + return 0, "Controller %s is %s" % (controllername, controllerstatus) + elif controllerstatus == "DEPLOYING": + return 1, "Controller %s is %s" % (controllername, controllerstatus) + elif controllerstatus == "REMOVING": + return 1, "Controller %s is %s" % (controllername, controllerstatus) + elif controllerstatus == "UNKNOWN": + return 2, "Controller %s is %s" % (controllername, controllerstatus) + +check_info['nsx_controller'] = { + 'inventory_function' : inventory_controller_status, + 'check_function' : check_controller_status, + 'service_description' : '%s', + 'has_perfdata' : False, +} + + + +#. +# .--NSX Components------------------------------------------------------. +# | _ _ ______ __ | +# | | \ | / ___\ \/ / | +# | | \| \___ \\ / | +# | | |\ |___) / \ | +# | |_| \_|____/_/\_\ | +# | | +# | ____ _ | +# | / ___|___ _ __ ___ _ __ ___ _ __ ___ _ __ | |_ ___ | +# | | | / _ \| '_ ` _ \| '_ \ / _ \| '_ \ / _ \ '_ \| __/ __| | +# | | |__| (_) | | | | | | |_) | (_) | | | | __/ | | | |_\__ \ | +# | \____\___/|_| |_| |_| .__/ \___/|_| |_|\___|_| |_|\__|___/ | +# | |_| | +# +----------------------------------------------------------------------+ +# | | +# '----------------------------------------------------------------------' +def inventory_nsx_components(info): + for name, id, status in info: + yield ("Component %s" % \ + (id), {}) + + +def check_nsx_components(item, params, info): + for line in info: + component = "Component" + " " + line[1] + if component==item: + component_name = line[0] + component_status = line[2] + if component_status == "RUNNING": + return 0, "Component %s is %s" % (component_name, component_status) + else: + return 2, "Component %s is %s" % (component_name, component_status) + +check_info['nsx_components'] = { + 'inventory_function' : inventory_nsx_components, + 'check_function' : check_nsx_components, + 'service_description' : '%s', + 'has_perfdata' : False, +} + +#. +# .--NSX Backup----------------------------------------------------------. +# | _ _ ______ __ ____ _ | +# | | \ | / ___\ \/ / | __ ) __ _ ___| | ___ _ _ __ | +# | | \| \___ \\ / | _ \ / _` |/ __| |/ / | | | '_ \ | +# | | |\ |___) / \ | |_) | (_| | (__| <| |_| | |_) | | +# | |_| \_|____/_/\_\ |____/ \__,_|\___|_|\_\\__,_| .__/ | +# | |_| | +# +----------------------------------------------------------------------+ +# | | +# '----------------------------------------------------------------------' +def inventory_nsx_backups(info): + return [(None, {})] + + +def check_nsx_backup(item, params, info): + warn, crit = params + if info: + last_backup = sorted(info, key=lambda tup: tup[2])[-1] + last_backup_size = last_backup[1] + last_backup_time = datetime.datetime.fromtimestamp(float(last_backup[2])/1000) + elapsed = datetime.datetime.now() - last_backup_time + if elapsed >= datetime.timedelta(days=crit): + return 2, "Last backup was taken more than %s days ago. Last backup date is %s " \ + % (crit, last_backup_time) + elif elapsed >= datetime.timedelta(days=warn): + return 1, "Last backup was taken more than %s days ago. Last backup date is %s " \ + % (warn, last_backup_time) + else: + return 0, "Date of last backup is %s" % last_backup_time + else: + return 3, "Backup not available" + +check_info['nsx_backup'] = { + 'inventory_function' : inventory_nsx_backups, + 'check_function' : check_nsx_backup, + 'service_description' : 'NSX Backups', + 'has_perfdata' : False, + 'group' : "backups", +} + +#. +# .--Memory--------------------------------------------------------------. +# | __ __ | +# | | \/ | ___ _ __ ___ ___ _ __ _ _ | +# | | |\/| |/ _ \ '_ ` _ \ / _ \| '__| | | | | +# | | | | | __/ | | | | | (_) | | | |_| | | +# | |_| |_|\___|_| |_| |_|\___/|_| \__, | | +# | |___/ | +# +----------------------------------------------------------------------+ +nsx_memory_default_levels = ( 80.0, 90.0 ) + +def nsx_convert(info): + data = {} + for line in info: + data[line[0]] = line[1:] + return data + +def inventory_nsx_mem(info): + data = nsx_convert(info) + return [(None, 'nsx_mem_default_levels')] + +def check_nsx_mem(item, params, info): + data = nsx_convert(info) + warn, crit = params + memory_usage = savefloat(data['UsedMemory'][0]) * 1024 * 1024 + memory_size = savefloat(data['TotalMem'][0]) * 1024 * 1024 + level = savefloat(data['UsedPercentage'][0]) + state = 0 + label = '' + if level >= crit: + state = 2 + label = " (Levels at %d%%/%d%%)" % (warn, crit) + elif level >= warn: + state = 1 + label = " (Levels at %d%%/%d%%)" % (warn, crit) + message = "%d%%%s used - %s/%s" % \ + (level, label, get_bytes_human_readable(memory_usage), get_bytes_human_readable(memory_size)) + perf = [("mem_used", memory_usage, warn * memory_size / 100, crit * memory_size / 100, 0, memory_size), + ("mem_total", memory_size)] + return(state, message, perf) + + +check_info['nsx_memory'] = { + "inventory_function" : inventory_nsx_mem, + "check_function" : check_nsx_mem, + "service_description" : "Memory used", + "group" : "nsx_memory", + "has_perfdata" : True, + "default_levels_variable" : "nsx_mem_default_levels" +} + +#. +# .--CPU-----------------------------------------------------------------. +# | ____ ____ _ _ | +# | / ___| _ \| | | | | +# | | | | |_) | | | | | +# | | |___| __/| |_| | | +# | \____|_| \___/ | +# | | +# +----------------------------------------------------------------------+ + +nsx_host_cpu_default_levels = {} + +def inventory_nsx_cpu(info): + data = nsx_convert(info).keys() + if 'usedPercentage' in data \ + and 'totalNoOfCPUs' in data\ + and 'capacity' in data: + return [(None, {})] + +def check_nsx_cpu(item, params, info): + data = nsx_convert(info) + + if "usedPercentage" not in data: + return + #Asuming that there are 1 thread per core and one core per socket + #Asuming that capacity represents total capacity + + num_cpu = int(data['totalNoOfCPUs'][0]) + total_capacity = int(data['capacity'][0]) + used_capacity = float(data['usedCapacity'][0]) + mhz_per_core = float(data['capacity'][0]) / num_cpu + + + usage = used_capacity / total_capacity * 100 + per_core = num_cpu / 100.0 + + infotext = "%.1f%%" % usage + + # Convert legacy parameters + this_time = time.time() + state, infotext, perfdata = check_cpu_util(usage, params).next() + + infotext += ", %.2fGHz/%.2fGHz" % (used_capacity / 1000.0, total_capacity / 1000.0) + infotext += ", %d sockets, %d cores/socket, %d threads" % ( + num_cpu, 1 , 1) + return (state, infotext, perfdata) + + +check_info['nsx_cpu'] = { + "inventory_function" : inventory_nsx_cpu, + "check_function" : check_nsx_cpu, + "service_description" : "CPU utilization", + "group" : "cpu_utilization_os", + "has_perfdata" : True, + "default_levels_variable" : "nsx_host_cpu_default_levels", + "includes" : [ "cpu_util.include" ], +} + +#. +# .--NSX vCenter Connection----------------------------------------------. +# | _ _ ______ __ ____ _ | +# | | \ | / ___\ \/ / __ __/ ___|___ _ __ | |_ ___ _ __ | +# | | \| \___ \\ / \ \ / / | / _ \ '_ \| __/ _ \ '__| | +# | | |\ |___) / \ \ V /| |__| __/ | | | || __/ | | +# | |_| \_|____/_/\_\ \_/ \____\___|_| |_|\__\___|_| | +# | | +# | ____ _ _ | +# | / ___|___ _ __ _ __ ___ ___| |_(_) ___ _ __ | +# | | | / _ \| '_ \| '_ \ / _ \/ __| __| |/ _ \| '_ \ | +# | | |__| (_) | | | | | | | __/ (__| |_| | (_) | | | | | +# | \____\___/|_| |_|_| |_|\___|\___|\__|_|\___/|_| |_| | +# | | +# +----------------------------------------------------------------------+ +# | | +# '----------------------------------------------------------------------' +def inventory_nsx_vcenter_connection(info): + return [(None, {})] + + +def check_nsx_vcenter_connection(item, params, info): + if "true" in info[0]: + return 0, "vCenterConnection is true" + elif "false" in info[0]: + return 2, "vCenterConnection is false" + +check_info['nsx_vcenter_connection'] = { + 'inventory_function' : inventory_nsx_vcenter_connection, + 'check_function' : check_nsx_vcenter_connection, + 'service_description' : 'vCenter Connection', + 'has_perfdata' : False, +} + + +#. +# .--NSX Storage Info----------------------------------------------------. +# | _ _ ______ __ ____ _ | +# | | \ | / ___\ \/ / / ___|| |_ ___ _ __ __ _ __ _ ___ | +# | | \| \___ \\ / \___ \| __/ _ \| '__/ _` |/ _` |/ _ \ | +# | | |\ |___) / \ ___) | || (_) | | | (_| | (_| | __/ | +# | |_| \_|____/_/\_\ |____/ \__\___/|_| \__,_|\__, |\___| | +# | |___/ | +# | ___ __ | +# | |_ _|_ __ / _| ___ | +# | | || '_ \| |_ / _ \ | +# | | || | | | _| (_) | | +# | |___|_| |_|_| \___/ | +# | | +# +----------------------------------------------------------------------+ +# | | +# '----------------------------------------------------------------------' +nsx_storage_default_levels = ( 70.0, 80.0 ) + +def inventory_nsx_storage(info): + data = nsx_convert(info) + return [(None, 'nsx_storage_default_levels')] + +def check_nsx_storage(item, params, info): + warn,crit = params + data = nsx_convert(info) + used_storage = float(re.sub('G','', data['UsedStorage'][0],count =1)) + total_storage = float(re.sub('G','', data['TotalStorage'][0],count =1)) + free_storage = float(re.sub('G','', data['FreeStorage'][0],count =1)) + used_percentage = float(re.sub('G','', data['UsedPercentage'][0],count =1)) + perf = [("storage_used", used_storage * 1024 * 1024 * 1024, \ + warn * total_storage * 1024 * 1024 * 1024 / 100 , \ + crit * total_storage * 1024 * 1024 * 1024 / 100 , 0, total_storage * 1024 * 1024 * 1024)] + if used_percentage >= crit: + return 2, "Storage used is %sGB out of %sGB" % (used_storage, total_storage) , perf + elif used_percentage >= warn: + return 1, "Storage used is %sGB out of %sGB" % (used_storage, total_storage) , perf + else: + return 0, "Storage used is %sGB out of %sGB" % (used_storage, total_storage) , perf + +check_info['nsx_storage_info'] = { + "inventory_function" : inventory_nsx_storage, + "check_function" : check_nsx_storage, + "service_description" : "Storage used", + "group" : "nsx_storage", + "has_perfdata" : True, + "default_levels_variable" : "nsx_storage_default_levels", + +} + + + +####NSX_RESOURCES +def inventory_nsx_resources(info): + for domain_name, component, status in info: + component_sn = component.split(".")[-1] + yield ("%s %s" % \ + (domain_name, component_sn), {}) + + +def check_nsx_resources(item, params, info): + for line in info: + component = line[0] + " " + line[1].split(".")[-1] + if component==item: + domain_name = line[0] + component_name = line[1].split(".")[-1] + component_status = line[2] + if component_name == "hostRebootRequired": + if component_status == "false": + return 0, "Host reboot is not required. " + else: + return 1, "Host needs a reboot" + + if component_status == "GREEN": + return 0, "Component %s is %s" % (component_name, component_status) + elif component_status =="UNKNOWN": + return 3, "Status is unknown" + else: + return 2, "Component %s is %s" % (component_name, component_status) + +check_info['nsx_resources'] = { + 'inventory_function' : inventory_nsx_resources, + 'check_function' : check_nsx_resources, + 'service_description' : '%s', + 'has_perfdata' : False, +} diff --git a/cmk_nsx/local/share/check_mk/checks/check_srm b/cmk_nsx/local/share/check_mk/checks/check_srm new file mode 100644 index 0000000..429269a --- /dev/null +++ b/cmk_nsx/local/share/check_mk/checks/check_srm @@ -0,0 +1,59 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2018 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +#<<>> +#LocalConnection com.vmware.cis.vcenterserver https://buc01m01vc01.test:443/sdk Connected +#LocalConnection com.vmware.cis.cs.inventory https://buc01m01vc01.test:443/invsvc/vmomi/sdk Connected +#LocalConnection com.vmware.cis.cs.lookup https://buc01psc01.test:443/lookupservice/sdk Connected +#LocalConnection com.vmware.cis.cs.identity https://buc01psc01.test/sso-adminserver/sdk/vsphere.local Connected +#LocalConnection com.vmware.cis.cs.authorization https://buc01m01vc01.test:443/invsvc/vmomi/sdk Connected +#LocalConnection com.vmware.cis.cs.license https://buc01psc01.test:443/ls/sdk Connected +#RemoteConnection com.vmware.cis.vcenterserver https://buc01m01vc01.test:443/sdk Connected +#RemoteConnection com.vmware.dr.vcDr https://buc01m01vc01.test:443/invsvc/vmomi/sdk Connected +#RemoteConnection com.vmware.cis.cs.lookup https://buc01psc01.test:443/lookupservice/sdk Connected +#RemoteConnection com.vmware.cis.cs.identity https://buc01psc01.test/sso-adminserver/sdk/vsphere.locaConnected + +import datetime + +def inventory_srm_status(info): + for servicename, url, state in info: + yield ("%s" % (servicename), {}) + + +def check_srm_status(item, params, info): + for line in info: + if line[0]==item: + if line[2]=="Connected": + return 0, "OK, %s is %s; %s" % (item,line[2],line[1]) + else: + return 1, "CRIT, %s is %s; %s" % (item,line[2],line[1]) + +check_info['vcenter_srm'] = { + 'inventory_function' : inventory_srm_status, + 'check_function' : check_srm_status, + 'service_description' : '%s', + 'has_perfdata' : False, +}