Module: check_mk
Branch: master
Commit: 8ab1c0413c1af037379832d0842f2d24e96306d5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8ab1c0413c1af0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Apr 14 15:36:41 2014 +0200
New option for writing all messages into a syslog-like logfile
The new Event Console global option <i>Syslog-like message logging</i> will enable
logging of <b>all</b> incoming events into logfiles that have syslog format.
These files will be stored below <tt>var/check_mk/mkeventd/messages</tt> and will
be named with the same scheme as the history logfiles. They will adopt the same
rotation principle as the history files.
If you are using Check_MK in a non-OMD environment and enable this option then
please make sure that you have some logrotate configuration or similar for
deleting outdated files.
If you are using OMD then consider enabling the global <i>Diskspace Cleanup</i>.
---
.werks/885 | 18 ++++++++++++++++++
ChangeLog | 3 +++
mkeventd/bin/mkeventd | 27 ++++++++++++++++++++++++---
mkeventd/web/plugins/wato/mkeventd.py | 13 +++++++++++++
web/plugins/wato/backup_domains.py | 2 ++
5 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/.werks/885 b/.werks/885
new file mode 100644
index 0000000..3cbae30
--- /dev/null
+++ b/.werks/885
@@ -0,0 +1,18 @@
+Title: New option for writing all messages into a syslog-like logfile
+Level: 1
+Component: ec
+Version: 1.2.5i3
+Date: 1397482457
+Class: feature
+
+The new Event Console global option <i>Syslog-like message logging</i> will enable
+logging of <b>all</b> incoming events into logfiles that have syslog format.
+These files will be stored below <tt>var/check_mk/mkeventd/messages</tt> and will
+be named with the same scheme as the history logfiles. They will adopt the same
+rotation principle as the history files.
+
+If you are using Check_MK in a non-OMD environment and enable this option then
+please make sure that you have some logrotate configuration or similar for
+deleting outdated files.
+
+If you are using OMD then consider enabling the global <i>Diskspace Cleanup</i>.
diff --git a/ChangeLog b/ChangeLog
index 7510b61..afeded1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -57,6 +57,9 @@
Reporting & Availability:
* 0756 Allow availability of multisite BI aggregates at once...
+ Event Console:
+ * 0885 New option for writing all messages into a syslog-like logfile...
+
Livestatus:
* 0747 FIX: livestatus table hostsbygroup: fixed bug with group_authorization strict...
diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index 66ced83..463c7ef 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -407,7 +407,7 @@ def log_event_history(event, what, who="", addinfo=""):
columns += [ quote_tab(event.get(colname[6:], defval)) # drop "event_"
for colname, defval in event_columns ]
- get_logfile().write("\t".join(map(to_utf8, columns)) + "\n")
+ get_logfile("history").write("\t".join(map(to_utf8, columns)) + "\n")
def to_utf8(x):
if type(x) == unicode:
@@ -429,9 +429,9 @@ active_history_period = None
# Get file object to current log file, handle also
# history and lifetime limit.
-def get_logfile():
+def get_logfile(basename):
global active_history_period
- log_dir = g_state_dir + "/history"
+ log_dir = g_state_dir + "/" + basename
make_parentdirs(log_dir + "/foo")
# Log into file starting at current history period,
@@ -732,6 +732,7 @@ class EventServer:
self.open_syslog()
self.open_syslog_tcp()
self.open_snmptrap()
+
self._rules = []
self._hash_stats = []
for facility in range(32):
@@ -1483,6 +1484,10 @@ class EventServer:
self.process_event(self.parse_event(line, address))
def process_event(self, event):
+ # Log all incoming messages into a syslog-like text file if that is enabled
+ if g_config["log_messages"]:
+ self.log_message(event)
+
# Rule optimizer
if g_config["rule_optimizer"]:
self._hash_stats[event["facility"]][event["priority"]] += 1
@@ -1900,6 +1905,21 @@ class EventServer:
return event
+ def log_message(self, event):
+ try:
+ get_logfile("messages").write("%s %s %s%s: %s\n" % (
+ time.strftime("%b %d %H:%M:%S", time.localtime(event["time"])),
+ event["host"],
+ event["application"],
+ event["pid"] and ("[%s]" % event["pid"]) or "",
+ event["text"]))
+ except Exception, e:
+ if opt_debug:
+ raise
+ # Better silently ignore errors. We could have run out of
+ # diskspace and make things worse by logging that we could
+ # not log.
+
#.
@@ -2993,6 +3013,7 @@ def load_configuration():
"debug_rules" : False,
"rule_optimizer" : True,
"log_rulehits" : False,
+ "log_messages" : False,
"retention_interval" : 60,
"housekeeping_interval" : 60,
"statistics_interval" : 5,
diff --git a/mkeventd/web/plugins/wato/mkeventd.py b/mkeventd/web/plugins/wato/mkeventd.py
index 65cf707..0366a9e 100644
--- a/mkeventd/web/plugins/wato/mkeventd.py
+++ b/mkeventd/web/plugins/wato/mkeventd.py
@@ -1649,6 +1649,19 @@ if mkeventd_enabled:
)
register_configvar(group,
+ "log_messages",
+ Checkbox(title = _("Syslog-like message logging"),
+ label = _("Log all messages into syslog-like logfiles"),
+ help = _("When this option is enabled, then <b>every</b> incoming message is being "
+ "logged into the directory <tt>messages</tt> in the Event Consoles state "
+ "directory. The logfile rotation is analog to that of the history logfiles. "
+ "Please note that if you have lots of incoming messages then these "
+ "files can get very large."),
+ default_value = False),
+ domain = "mkeventd",
+ )
+
+ register_configvar(group,
"rule_optimizer",
Checkbox(title = _("Optimize rule execution"),
label = _("enable optimized rule execution"),
diff --git a/web/plugins/wato/backup_domains.py b/web/plugins/wato/backup_domains.py
index e036a6f..14d7c6c 100644
--- a/web/plugins/wato/backup_domains.py
+++ b/web/plugins/wato/backup_domains.py
@@ -180,6 +180,8 @@ else:
"paths" : [
("dir", "var/mkeventd/history"),
("file", "var/mkeventd/status"),
+ ("file", "var/mkeventd/messages"),
+ ("dir", "var/mkeventd/messages-history"),
],
},
"dokuwiki": {
Module: check_mk
Branch: master
Commit: b7bd87d4dae634668594db08792852275afa1320
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b7bd87d4dae634…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Mon Apr 14 11:33:11 2014 +0200
FIX apache_status: now also sends an accept header to make it work with mod_security enables servers
---
.werks/606 | 8 ++++++++
ChangeLog | 1 +
agents/plugins/apache_status | 3 ++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/.werks/606 b/.werks/606
new file mode 100644
index 0000000..442d91f
--- /dev/null
+++ b/.werks/606
@@ -0,0 +1,8 @@
+Title: apache_status: now also sends an accept header to make it work with mod_security enables servers
+Level: 1
+Component: checks
+Version: 1.2.5i3
+Date: 1397467941
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 3d936f0..6360411 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,6 +37,7 @@
* 0605 FIX: enterasys_cpu_util enterasys_lsnat: syntax fixes
* 0889 FIX: logwatch: fix case where rule wouldn't be applied...
* 0882 FIX: check_bi_local.py: fix crash in case of non-ascii characters...
+ * 0606 FIX: apache_status: now also sends an accept header to make it work with mod_security enables servers
Multisite:
* 0779 Hostgroups (Summary): Empty hostgroups are no longer shown (can be re-enabled by filter)
diff --git a/agents/plugins/apache_status b/agents/plugins/apache_status
index f2bd8fa..0b91371 100755
--- a/agents/plugins/apache_status
+++ b/agents/plugins/apache_status
@@ -103,7 +103,8 @@ for server in servers:
url = '%s://%s:%s/%s?auto' % (proto, address, port, page)
# Try to fetch the status page for each server
try:
- fd = urllib2.urlopen(url)
+ request = urllib2.Request(url, headers={"Accept" : "text/plain"})
+ fd = urllib2.urlopen(request)
except urllib2.URLError, e:
if 'SSL23_GET_SERVER_HELLO:unknown protocol' in str(e):
# HACK: workaround misconfigurations where port 443 is used for
Module: check_mk
Branch: master
Commit: bdf710a7c789ddc2fd74701c98e609aae8ec67ad
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bdf710a7c789dd…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Apr 14 10:08:12 2014 +0200
New options --oid and --extraoid for cmk --snmpwalk
It is now possible to specify alternative or additional OIDs to fetch
from a host when using <tt>cmk --snmpwalk</tt>. Please always specify
numeric OIDs. Example:
C+:
OM:cmk --extraoid .1.3.6.1.4.1.8072 --snmpwalk switch4712
C-:
---
.werks/884 | 14 ++++++++++++++
ChangeLog | 1 +
modules/check_mk.py | 30 +++++++++++++++++++++++++-----
modules/check_mk_base.py | 2 ++
4 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/.werks/884 b/.werks/884
new file mode 100644
index 0000000..903692a
--- /dev/null
+++ b/.werks/884
@@ -0,0 +1,14 @@
+Title: New options --oid and --extraoid for cmk --snmpwalk
+Level: 2
+Component: core
+Version: 1.2.5i3
+Date: 1397462765
+Class: feature
+
+It is now possible to specify alternative or additional OIDs to fetch
+from a host when using <tt>cmk --snmpwalk</tt>. Please always specify
+numeric OIDs. Example:
+
+C+:
+OM:cmk --extraoid .1.3.6.1.4.1.8072 --snmpwalk switch4712
+C-:
diff --git a/ChangeLog b/ChangeLog
index 4835d69..7510b61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
1.2.5i3:
Core & Setup:
+ * 0884 New options --oid and --extraoid for cmk --snmpwalk...
* 0785 FIX: Availability: fixed memory leak in table statehist...
Checks & Agents:
diff --git a/modules/check_mk.py b/modules/check_mk.py
index fffad57..0439188 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -4367,6 +4367,9 @@ def do_snmptranslate(walk):
sys.stdout.write(format_string % (translation, line))
def do_snmpwalk(hostnames):
+ if opt_oids and opt_extra_oids:
+ raise MKGeneralException("You cannot specify --oid and --extraoid at the same time.")
+
if len(hostnames) == 0:
sys.stderr.write("Please specify host names to walk on.\n")
return
@@ -4386,10 +4389,14 @@ def do_snmpwalk_on(hostname, filename):
ip = lookup_ipaddress(hostname)
out = file(filename, "w")
- for oid in [
+ oids_to_walk = opt_oids
+ if not opt_oids:
+ oids_to_walk = [
".1.3.6.1.2.1", # SNMPv2-SMI::mib-2
".1.3.6.1.4.1" # SNMPv2-SMI::enterprises
- ]:
+ ] + opt_extra_oids
+
+ for oid in oids_to_walk:
if opt_verbose:
sys.stdout.write("Walk on \"%s\"..." % oid)
sys.stdout.flush()
@@ -4673,7 +4680,7 @@ def usage():
cmk --restore BACKUPFILE.tar.gz restore configuration and data
cmk --flush [HOST1 HOST2...] flush all data of some or all hosts
cmk --donate Email data of configured hosts to MK
- cmk --snmpwalk HOST1 HOST2 ... Do snmpwalk on host
+ cmk --snmpwalk HOST1 HOST2 ... Do snmpwalk on one or more hosts
cmk --snmptranslate HOST Do snmptranslate on walk
cmk --snmpget OID HOST1 HOST2 ... Fetch single OIDs and output them
cmk --scan-parents [HOST1 HOST2...] autoscan parents, create conf.d/parents.mk
@@ -4705,6 +4712,10 @@ OPTIONS:
--keepalive used by Check_MK Mirco Core: run check and --notify in continous
mode. Read data from stdin and von from cmd line and environment
--cmc-file=X relative filename for CMC config file (used by -B/-U)
+ --extraoid A Do --snmpwalk also on this OID, in addition to mib-2 and enterprises.
+ You can specify this option multiple times.
+ --oid A Do --snmpwalk on this OID instead of mib-2 and enterprises.
+ You can specify this option multiple times.
NOTES:
-I can be restricted to certain check types. Write '--checks df -I' if you
@@ -4773,7 +4784,11 @@ NOTES:
--snmpwalk does a complete snmpwalk for the specified hosts both
on the standard MIB and the enterprises MIB and stores the
- result in the directory %s.
+ result in the directory %s. Use the option --oid one or several
+ times in order to specify alternative OIDs to walk. You need to
+ specify numeric OIDs. If you want to keep the two standard OIDS
+ .1.3.6.1.2.1 and .1.3.6.1.4.1 then use --extraoid for just adding
+ additional OIDs to walk.
--snmptranslate does not contact the host again, but reuses the hosts
walk from the directory %s.%s
@@ -5807,7 +5822,8 @@ if __name__ == "__main__":
short_options = 'SHVLCURODMmd:Ic:nhvpXPNBil'
long_options = [ "help", "version", "verbose", "compile", "debug",
"list-checks", "list-hosts", "list-tag", "no-tcp", "cache",
- "flush", "package", "localize", "donate", "snmpwalk", "snmptranslate",
+ "flush", "package", "localize", "donate", "snmpwalk", "oid=", "extraoid=",
+ "snmptranslate",
"usewalk", "scan-parents", "procs=", "automation=", "notify",
"snmpget=", "profile", "keepalive", "keepalive-fd=", "create-rrd",
"no-cache", "update", "restart", "reload", "dump", "fake-dns=",
@@ -5860,6 +5876,10 @@ if __name__ == "__main__":
opt_keepalive_fd = int(a)
elif o == '--usewalk':
opt_use_snmp_walk = True
+ elif o == '--oid':
+ opt_oids.append(a)
+ elif o == '--extraoid':
+ opt_extra_oids.append(a)
elif o == '--procs':
max_num_processes = int(a)
elif o == '--nowiki':
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index cc3dffc..3af4219 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -106,6 +106,8 @@ fake_dns = False
opt_keepalive = False
opt_cmc_relfilename = "config"
opt_keepalive_fd = None
+opt_oids = []
+opt_extra_oids = []
# register SIGINT handler for consistenct CTRL+C handling
def interrupt_handler(signum, frame):
Module: check_mk
Branch: master
Commit: 8ced5eedb2ca4732c361100ce3ff2ce9700f9d8a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8ced5eedb2ca47…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Fri Apr 11 19:10:30 2014 +0200
more general scan function for TP-Link Switches
---
checks/rmon_stats | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/checks/rmon_stats b/checks/rmon_stats
index f779be1..8c5169c 100644
--- a/checks/rmon_stats
+++ b/checks/rmon_stats
@@ -74,6 +74,6 @@ check_info["rmon_stats"] = {
# for the scan we need to check for any single object in the RMON tree,
# we choose netDefaultGateway in the hope that it will always be present
'snmp_scan_function' : lambda oid: ( oid(".1.3.6.1.2.1.1.1.0").lower().startswith("cisco") \
- or oid(".1.3.6.1.2.1.1.1.0").startswith("10G Managed Switch") ) \
- and oid(".1.3.6.1.2.1.16.19.12.0") != None,
+ or oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.11863.1.1.3" \
+ ) and oid(".1.3.6.1.2.1.16.19.12.0") != None,
}