initial import

This commit is contained in:
Marius Pana 2019-08-12 11:59:29 +03:00
commit d4d4074b1b
113 changed files with 6385 additions and 0 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
This is a repo containing all (hopefully) of our check_mk plugins.

View File

@ -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 ...

View File

@ -0,0 +1,7 @@
---
# file: bootstrap.yml
- hosts: all
#vars:
vars_files: [roles/common/vars/usersandpsks.yml, roles/omd/vars/main.yml]
roles:
- common

View File

@ -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

View File

@ -0,0 +1,7 @@
---
# file: loadbalancers.yml
- hosts: loadbalancers
vars_files: [roles/common/vars/usersandpsks.yml, roles/omd/vars/main.yml]
roles:
- common
- loadbalancers

7
ansible-check_mk/omd.yml Normal file
View File

@ -0,0 +1,7 @@
---
# file: omd.yml
- hosts: omd
#vars:
#vars_files:
roles:
- omd

View File

@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/asZXkhLJVGIcPQGUxZDLl/yMwslgn6GyJd6QGKUmR+Snr1hMz01y7WEWPvfXXUqNym6rMU5fAMUr+alcyzMGZYKyymTLfjgp0SUuWG3TGpl3EPxnfGwNcXOvuJE9cnY0q3nhZgQjvn6EdEFDKAmLG1WXlKYjbQUUrHp0wFvEx3TNIXMVJqHxbKi8Uwyvn5EB1emdeJkaAaXJbk1TxALu400Ts0KYJUUyMn5njJjVELwtPVsnb0skmKSXd4dgBLN+wo94YQLpdfCnmho0uPhZfTHHi0+jtJNtUSycOSuOr/TxYGirxOYcb5FoOvzg9L0RyQAj6O+Hzs3RkHB+qast mariusp@marduk.local

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,8 @@
---
usersAdd:
- mariusp
usersDel:
- none
usersPSK:
- name: mariusp
psk: ["../files/ssh_keys/mariusp.pub"]

View File

@ -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 "<<<up_scale>>>"
echo "up_scale 1000"
echo "<<<down_scale>>>"
echo "down_scale 1000"
else
let "CONNPERSRV=$CONN/$SRVS"
echo "<<<up_scale>>>"
echo "up_scale $CONNPERSRV"
if [ $SRVS -le 2 ]; then
echo "<<<down_scale>>>"
echo "down_scale 16"
else
echo "<<<down_scale>>>"
echo "down_scale $CONNPERSRV"
fi
fi

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

View File

@ -0,0 +1,6 @@
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 10.88.88.150 127.0.0.1 ::1
</Location>

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,16 @@
<html>
<head>
<title>Welcome to the 2ND Check_MK Conference!</title>
</head>
<body>
<img src="konf.jpg" />
<br />
<br />
<strong>Welcome to the 2ND Check_MK Conference!</strong>
<br />
<p><h3>Im running on {{ inventory_hostname }}.</h3><p>
<p>Running on {{ ansible_os_family }} ;-}</p>
</body>
</html>

View File

@ -0,0 +1,5 @@
---
- include: bootstrap.yml
- include: webservers.yml
- include: loadbalancers.yml
- include: omd.yml

View File

@ -0,0 +1,7 @@
---
# file: webservers.yml
- hosts: webservers
vars_files: [roles/common/vars/usersandpsks.yml, roles/omd/vars/main.yml]
roles:
- common
- webservers

1
check_ibm_flex/README.MD Normal file
View File

@ -0,0 +1 @@
# check_ibm_flex repository

Binary file not shown.

View File

@ -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,
}

View File

@ -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 <lm@mathias-kettner.de>
# 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,
}

View File

@ -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,
}

View File

@ -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,
}

View File

@ -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,
}

View File

@ -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,
}

1
check_mk-check-nfsiostat/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.vscode

View File

@ -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", ],
}

View File

@ -0,0 +1,6 @@
#!/bin/bash
if command nfsiostat > /dev/null ; then
echo '<<<nfsiostat>>>'
nfsiostat | paste -sd " " - | tr -s ' '
fi

View File

@ -0,0 +1,16 @@
title: Check NFS IO Stats
agents: linux
catalog: os/storage
distribution:
author: Marius Pana <mp@spearhead.systems>
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).

View File

@ -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,
}

View File

@ -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'}

Binary file not shown.

View File

@ -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',
}

View File

@ -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

View File

@ -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 <tt>mk_nfsiostat</tt> 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") ),
]
)
)

View File

@ -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",
)

340
check_mk-exch-mbox/LICENSE Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
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.

View File

@ -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

View File

@ -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 "<<<exchange_user_mbx_size>>>"
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

View File

@ -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.

View File

@ -0,0 +1,46 @@
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# Author: Marius Pana <mp@sphs.ro>
# EXAMPLE DATA FROM:
# fomat: emailaddress size_in_MB
#<<<exchange_user_mbx_size>>>
#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',
}

Binary file not shown.

17
check_mk-exch-mbox/info Normal file
View File

@ -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'}

View File

@ -0,0 +1,14 @@
<?php
#
# Copyright (c) 2006-2010 Joerg Linge (http://www.pnp4nagios.org)
# Plugin: check_load
#
$opt[1] = "--vertical-label \"Size in MB\" -X0 -b1024 -l0 --title \"Mailbox Size $servicedesc\" ";
$def[1] = "DEF:var1=$RRDFILE[1]:$DS[1]:MAX ";
if ($WARN[1] != "") {
$def[1] .= "HRULE:$WARN[1]#FFFF00:\"Warning\: $WARN[1]MB\" ";
$def[1] .= "HRULE:$CRIT[1]#FF0000:\"Critical\: $CRIT[1]MB\" ";
}
$def[1] .= rrd::area("var1", "#EACC00", "size ") ;
$def[1] .= rrd::gprint("var1", array("LAST", "AVERAGE", "MAX"), "%6.0lf MB");
?>

View File

@ -0,0 +1,13 @@
def perfometer_check_mk_exchange_user_mbx_size(row, check_command, perf_data):
#return 'Hello World! :-)', '<table><tr>' \
# + perfometer_td(20, '#fff') \
# + perfometer_td(80, '#ff0000') \
# + '</tr></table>'
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

View File

@ -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"
)

View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
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.

View File

@ -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

View File

@ -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 "<<<exchange_db_size>>>"
Write-Host "$($db.Name) $DBsize $DBfreeSpace"
}

View File

@ -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.

View File

@ -0,0 +1,51 @@
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# Author: Marius Pana <mp@sphs.ro>
# EXAMPLE DATA FROM:
# format: datbase size_in_MB free_MB_available
#<<<exchange_db_size>>>
#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',
}

View File

@ -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'}

View File

@ -0,0 +1,13 @@
<?php
#
# Plugin: check_mk-exchange_db_size
#
$opt[1] = "--vertical-label \"Size in MB\" -X0 -b1024 -l0 --title \"Mailbox Size $servicedesc\" ";
$def[1] = "DEF:size=$RRDFILE[1]:$DS[1]:MAX ";
if ($WARN[1] != "") {
$def[1] .= "HRULE:$WARN[1]#FFFF00:\"Warning\: $WARN[1]MB\" ";
$def[1] .= "HRULE:$CRIT[1]#FF0000:\"Critical\: $CRIT[1]MB\" ";
}
$def[1] .= rrd::area("size", "#EACC00", "size ") ;
$def[1] .= rrd::gprint("size", array("LAST", "AVERAGE", "MAX"), "%6.0lf MB");
?>

View File

@ -0,0 +1,13 @@
def perfometer_check_mk_exchange_db_size(row, check_command, perf_data):
#return 'Hello World! :-)', '<table><tr>' \
# + perfometer_td(20, '#fff') \
# + perfometer_td(80, '#ff0000') \
# + '</tr></table>'
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

View File

@ -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"
)

View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
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.

View File

@ -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".

View File

@ -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 '<<<mysql_open_files>>>'
echo 'open_files ' $mysqlOpenFilesLimit ' ' $mysqlOpenFiles

View File

@ -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.

View File

@ -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
#
#<<<mysql_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",
}

View File

@ -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'}

Binary file not shown.

View File

@ -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"
)

View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
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.

View File

@ -0,0 +1,2 @@
# check_mk-pending_reboot
Monitor pending reboot status for Windows Host

View File

@ -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.

View File

@ -0,0 +1,48 @@
#!/usr/bin/python
# Author: George Mocanu <george.mocanu@sphs.ro>
# EXAMPLE DATA FROM:
# fomat: pendingReboot 0 8
#
#<<<pending_reboot>>>
#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",
}

View File

@ -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'}

Binary file not shown.

View File

@ -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"
)

View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
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.

View File

@ -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".

View File

@ -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"

View File

@ -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".

View File

@ -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 "<<<rds_licenses>>>"
Write-Host "PerUserLicenses " $total " " $used

View File

@ -0,0 +1,17 @@
# SpearHead Systems george.mocanu@sphs.ro
# Check for Windows 2012 Server
Import-Module RemoteDesktopServices
$path = "RDS:\LicenseServer\LicenseKeyPacks\"
Write-Host "<<<rds_licenses>>>"
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

View File

@ -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.

View File

@ -0,0 +1,57 @@
#!/usr/bin/python
# Author: George Mocanu <george.mocanu@sphs.ro>
# SpearHead Systems
# EXAMPLE DATA FROM:
# fomat: Win2k8_Pack_Name No_of_Installed_Licenses No_of_Used_Licenses
#
#<<<rds_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",
}

View File

@ -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'}

Binary file not shown.

View File

@ -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"
)

View File

@ -0,0 +1 @@
# check_mk-vmware_orphaned_files

View File

@ -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
"<<<vmware_orphaned_files>>>" | 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

View File

@ -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

View File

@ -0,0 +1,41 @@
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# Author: Marius Pana <mp@sphs.ro>
# EXAMPLE DATA FROM:
# format: [datastore] [path] [size] [last mod date]
#<<<vmware_orphaned_files>>>
# [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)) + "<br>"
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',
}

View File

@ -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'}

BIN
cmk_nsx/Check_NSX-1.4.mkp Normal file

Binary file not shown.

3
cmk_nsx/README.md Normal file
View File

@ -0,0 +1,3 @@
# cmk_nsx
vmware NSX related checks

BIN
cmk_nsx/SRM-1.0.mkp Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -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("<<<vcenter_srm:sep(9)>>>")
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 = \
"""
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252"><style></style></head><body><h3>VMware vCenter Site Recovery Manager 6.5.1.6014840</h3><p>Name: <b>buc01m01vc01.test</b>, UUID: <b>d8fd8aea-a3ed-46e9-857e-509b80784c53</b>, Extension key: <b>com.vmware.vcDr</b></p><h4>VMware vCenter Server 6.5.0 build-7515524</h4><hr><p><a href="https://buc01m01srm01.test:9086/vcdr/vmomi/drserviceversions.xml">Supported VMODL versions</a></p><p><a href="https://buc01m01srm01.test:9086/vcdr/vmomi/drversion.xml">Inherent VMODL version</a></p><hr><h4>Local Connections</h4><table><tbody><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.vcenterserver</td></tr><tr><td>URL</td><td>https://buc01m01vc01.test:443/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.inventory</td></tr><tr><td>URL</td><td>https://buc01m01vc01.test:443/invsvc/vmomi/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.lookup</td></tr><tr><td>URL</td><td>https://buc01psc01.test:443/lookupservice/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.identity</td></tr><tr><td>URL</td><td>https://buc01psc01.test/sso-adminserver/sdk/vsphere.local</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.authorization</td></tr><tr><td>URL</td><td>https://buc01m01vc01.test:443/invsvc/vmomi/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.license</td></tr><tr><td>URL</td><td>https://buc01psc01.test:443/ls/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr></tbody></table><h4>Paired with remote SRM with name 'clj01m01vc01.test' and uuid 'acf7df22-01bb-439a-b27e-9f8b83e23233'</h4><h4>Remote Connections</h4><table><tbody><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.vcenterserver</td></tr><tr><td>URL</td><td>https://clj01m01vc01.test:443/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.dr.vcDr</td></tr><tr><td>URL</td><td>https://clj01m01srm01.test:9086/vcdr/vmomi/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.lookup</td></tr><tr><td>URL</td><td>https://clj01psc01.test:443/lookupservice/sdk</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr><tr><td>Service</td><td>com.vmware.cis.cs.identity</td></tr><tr><td>URL</td><td>https://clj01psc01.test/sso-adminserver/sdk/vsphere.local</td></tr><tr><td>Thumbprint</td><td>unknown</td></tr><tr><td>Status</td><td style="color:#080;">Connected</td></tr><tr><td>--------------------</td><td>--------------------------------------------------------------------------------</td></tr></tbody></table></body></html>"""
if __name__ == "__main__":
main()

Some files were not shown because too many files have changed in this diff Show More