lists.checkmk.com
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
List overview
Download
Checkmk git commits
November 2015
----- 2024 -----
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
checkmk-commits@lists.checkmk.com
8 participants
303 discussions
Start a n
N
ew thread
#2846 FIX View refresh could reset checkboxes on views where "
by Lars Michelsen
always show checkboxes" is enabled Message-ID: <56533717.MourHTa9UdwiJsxG%lm(a)mathias-kettner.de> User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Module: check_mk Branch: master Commit: 3a096a8cd7660ee9d39a33dbea09b10a0cf7ce8e URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3a096a8cd7660e…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Nov 23 16:55:53 2015 +0100 #2846 FIX View refresh could reset checkboxes on views where "always show checkboxes" is enabled --- .werks/2846 | 10 ++++++++++ ChangeLog | 1 + web/htdocs/js/checkmk.js | 3 +++ web/htdocs/views.py | 4 ++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.werks/2846 b/.werks/2846 new file mode 100644 index 0000000..83f0440 --- /dev/null +++ b/.werks/2846 @@ -0,0 +1,10 @@ +Title: View refresh could reset checkboxes on views where "always show checkboxes" is enabled +Level: 1 +Component: multisite +Class: fix +Compatible: compat +State: unknown +Version: 1.2.7i4 +Date: 1448294124 + + diff --git a/ChangeLog b/ChangeLog index 532814a..44c8f85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -120,6 +120,7 @@ * 2758 FIX: Fixed processing of metrics containing varnames with quotes and/or spaces * 2762 FIX: Fixed formating of check_http when using "clickable URL" option * 2772 FIX: Fixed possible exception in icon column when showing some actions in the column... + * 2846 FIX: View refresh could reset checkboxes on views where "always show checkboxes" is enabled WATO: * 2442 WATO remove host: improved cleanup of obsolete host files... diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js index 8b0bcab..dd931c3 100644 --- a/web/htdocs/js/checkmk.js +++ b/web/htdocs/js/checkmk.js @@ -1097,6 +1097,9 @@ function do_reload(url) if (window.location.href.indexOf("dashboard_dashlet.py") != -1) params["_reload"] = "1"; + if (g_selection_enabled) + params["selection"] = g_selection; + call_ajax(makeuri(params), { response_handler : handle_content_reload, error_handler : handle_content_reload_error, diff --git a/web/htdocs/views.py b/web/htdocs/views.py index fe3c695..c132678 100644 --- a/web/htdocs/views.py +++ b/web/htdocs/views.py @@ -1521,12 +1521,12 @@ def show_context_links(thisview, show_filters, display_options, hidden = not enable_commands) togglebutton_off("commands", "commands", hidden = enable_commands) - selection_enabled = enable_commands and enable_checkboxes + selection_enabled = (enable_commands and enable_checkboxes) or thisview.get("force_checkboxes") if not thisview.get("force_checkboxes"): toggler("checkbox", "checkbox", _("Enable/Disable checkboxes for selecting rows for commands"), "location.href='%s';" % html.makeuri([('show_checkboxes', show_checkboxes and '0' or '1')]), show_checkboxes, hidden = True) # not selection_enabled) - togglebutton_off("checkbox", "checkbox", hidden = selection_enabled) + togglebutton_off("checkbox", "checkbox", hidden = not thisview.get("force_checkboxes")) html.javascript('g_selection_enabled = %s;' % (selection_enabled and 'true' or 'false')) if 'O' in display_options:
8 years, 10 months
1
0
0
0
Add icon for a button to a view
by Mathias Kettner
Module: check_mk Branch: master Commit: a9d14ee934d5ed4d8a26e7598cbf6e14e417fe20 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a9d14ee934d5ed…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Mon Nov 23 16:55:08 2015 +0100 Add icon for a button to a view --- web/htdocs/images/button_view.png | Bin 0 -> 2203 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/web/htdocs/images/button_view.png b/web/htdocs/images/button_view.png new file mode 100644 index 0000000..36927aa Binary files /dev/null and b/web/htdocs/images/button_view.png differ
8 years, 10 months
1
0
0
0
Add link to agent bakery in rulesets of monitoring agents
by Mathias Kettner
Module: check_mk Branch: master Commit: 65201cc81713370c8607f81c09767588ffa4543b URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=65201cc8171337…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Mon Nov 23 16:55:21 2015 +0100 Add link to agent bakery in rulesets of monitoring agents --- web/htdocs/wato.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py index 894db11..273c357 100644 --- a/web/htdocs/wato.py +++ b/web/htdocs/wato.py @@ -14997,6 +14997,8 @@ def mode_rulesets(phase, group=None): html.context_button(_("All Rulesets"), make_link([("mode", "ruleeditor")]), "back") if config.may("wato.hosts") or config.may("wato.seeall"): html.context_button(_("Folder"), make_link([("mode", "folder")]), "folder") + if group == "agents": + html.context_button(_("Agent Bakery"), make_link([("mode", "agents")]), "agents") return elif phase == "action":
8 years, 10 months
1
0
0
0
Fixed duplicate html input fields for filled_in, buttons
by Lars Michelsen
Module: check_mk Branch: master Commit: 10d817c51f50fdbdae15d0bfb3370e46d81196bc URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=10d817c51f50fd…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Nov 23 15:01:53 2015 +0100 Fixed duplicate html input fields for filled_in, buttons --- web/htdocs/htmllib.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py index dedb631..9be6bfd 100644 --- a/web/htdocs/htmllib.py +++ b/web/htdocs/htmllib.py @@ -237,7 +237,7 @@ class html: self.write('<form id="form_%s" name="%s" class="%s" action="%s" method="%s"%s%s>\n' % (enc_name, enc_name, enc_name, self.attrencode(action), self.attrencode(method), enctype, onsubmit)) - self.hidden_field("filled_in", name) + self.hidden_field("filled_in", name, add_var=True) if add_transid: self.hidden_field("_transid", str(self.get_transid())) self.hidden_fields(self.global_vars) @@ -342,11 +342,13 @@ class html: def button(self, *args): self.image_button(*args) + def raw_button(self, varname, title, cssclass=""): self.write("<input onfocus=\"if (this.blur) this.blur();\" " "type=\"submit\" name=\"%s\" id=\"%s\" value=\"%s\" " "class=\"%s\" />\n" % \ - ( varname, varname, title, cssclass)) + (varname, varname, title, cssclass)) + self.add_form_var(varname) def buttonlink(self, href, text, add_transid=False, obj_id='', style='', title='', disabled=''):
8 years, 10 months
1
0
0
0
some cleanup and fixes in the modernized perfcounter code and added a small test application
by Sebastian Herbord
Module: check_mk Branch: master Commit: 2f0d9872ab8232ab6e0c1a92a6a2c7f2cfe961ec URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2f0d9872ab8232…
Author: Sebastian Herbord <sh(a)mathias-kettner.de> Date: Mon Nov 23 16:24:04 2015 +0100 some cleanup and fixes in the modernized perfcounter code and added a small test application --- agents/windows/Configuration.cc | 68 +------------- agents/windows/PerfCounter.cc | 106 +++++++++++++++++++++- agents/windows/PerfCounter.h | 7 ++ agents/windows/build_version | 2 +- agents/windows/check_mk_agent-64.exe | Bin 5813995 -> 5881061 bytes agents/windows/check_mk_agent-64.unversioned.exe | Bin 5813995 -> 5881061 bytes agents/windows/check_mk_agent.cc | 9 -- agents/windows/check_mk_agent.exe | Bin 4603891 -> 4657243 bytes agents/windows/check_mk_agent.msi | Bin 10747904 -> 10869248 bytes agents/windows/check_mk_agent.unversioned.exe | Bin 4603891 -> 4657243 bytes agents/windows/install_agent-64.exe | Bin 1378209 -> 1390774 bytes agents/windows/install_agent.exe | Bin 1255524 -> 1265926 bytes agents/windows/perftest.cc | 81 +++++++++++++++++ agents/windows/stringutil.h | 18 ++++ agents/windows/types.h | 9 ++ agents/windows/wmiHelper.cc | 4 + agents/windows/wmitest.cc | 21 +---- 17 files changed, 227 insertions(+), 98 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=2f0d9872ab…
8 years, 10 months
1
0
0
0
#2799 FIX check_mail_loop: "Use TLS over SMTP" option did not work
by Andreas Boesl
Module: check_mk Branch: master Commit: 2c1bd62dcf2af895dda09b18f5efcac5dbaa8ba2 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2c1bd62dcf2af8…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Mon Nov 23 14:37:48 2015 +0100 #2799 FIX check_mail_loop: "Use TLS over SMTP" option did not work --- .werks/2799 | 10 ++++++++++ ChangeLog | 1 + checks/check_mail_loop | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.werks/2799 b/.werks/2799 new file mode 100644 index 0000000..1e8a907 --- /dev/null +++ b/.werks/2799 @@ -0,0 +1,10 @@ +Title: check_mail_loop: "Use TLS over SMTP" option did not work +Level: 1 +Component: checks +Class: fix +Compatible: compat +State: unknown +Version: 1.2.7i4 +Date: 1448285828 + + diff --git a/ChangeLog b/ChangeLog index 3975ea1..532814a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -95,6 +95,7 @@ * 2837 FIX: hitachi_hnas_temp: fixed ascii decode error, handles degree celsius now correct * 2844 FIX: heartbeat_crm: Fixed problem processing the state of clone set resources * 2798 FIX: netapp_api_cpu: fixed incorrect scaling of CPU data in NetApp Clustermode... + * 2799 FIX: check_mail_loop: "Use TLS over SMTP" option did not work Multisite: * 2684 Added icons for downloading agent data / walks of hosts... diff --git a/checks/check_mail_loop b/checks/check_mail_loop index 2842217..5bdedd3 100644 --- a/checks/check_mail_loop +++ b/checks/check_mail_loop @@ -33,7 +33,7 @@ def check_mail_loop_arguments(params): args += ' --smtp-server=$HOSTADDRESS$' if 'smtp_tls' in params: - args == ' --smtp-tls' + args += ' --smtp-tls' if 'smtp_port' in params: args += ' --smtp-port=%d' % params['smtp_port']
8 years, 10 months
1
0
0
0
windows agent: factored out performance counter access code
by Sebastian Herbord
Module: check_mk Branch: master Commit: d316d052c466b465770cf99964a7ab5fc80f39c0 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d316d052c466b4…
Author: Sebastian Herbord <sh(a)mathias-kettner.de> Date: Mon Nov 23 11:48:50 2015 +0100 windows agent: factored out performance counter access code --- agents/windows/Makefile | 4 +- agents/windows/PerfCounter.cc | 264 +++++++++++++++ agents/windows/PerfCounter.h | 89 ++++++ agents/windows/build_version | 2 +- agents/windows/check_mk_agent-64.exe | Bin 5397569 -> 5813995 bytes agents/windows/check_mk_agent-64.unversioned.exe | Bin 5397569 -> 5813995 bytes agents/windows/check_mk_agent.cc | 370 +++------------------- agents/windows/check_mk_agent.exe | Bin 4257835 -> 4603891 bytes agents/windows/check_mk_agent.msi | Bin 9979904 -> 10747904 bytes agents/windows/check_mk_agent.unversioned.exe | Bin 4257835 -> 4603891 bytes agents/windows/install_agent-64.exe | Bin 1288918 -> 1378209 bytes agents/windows/install_agent.exe | Bin 1169708 -> 1255524 bytes 12 files changed, 403 insertions(+), 326 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=d316d052c4…
8 years, 10 months
1
0
0
0
#2798 FIX netapp_api_cpu: fixed incorrect scaling of CPU data in NetApp Clustermode
by Andreas Boesl
Module: check_mk Branch: master Commit: 48117acfccd168c72d09f437aba33ae47a03adcc URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=48117acfccd168…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Mon Nov 23 11:09:55 2015 +0100 #2798 FIX netapp_api_cpu: fixed incorrect scaling of CPU data in NetApp Clustermode The value was off by factor 100. --- .werks/2798 | 9 +++++++++ ChangeLog | 1 + agents/special/agent_netapp | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.werks/2798 b/.werks/2798 new file mode 100644 index 0000000..dc77c04 --- /dev/null +++ b/.werks/2798 @@ -0,0 +1,9 @@ +Title: netapp_api_cpu: fixed incorrect scaling of CPU data in NetApp Clustermode +Level: 1 +Component: checks +Compatible: compat +Version: 1.2.7i4 +Date: 1448273327 +Class: fix + +The value was off by factor 100. diff --git a/ChangeLog b/ChangeLog index bfa1da5..3975ea1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -94,6 +94,7 @@ * 2796 FIX: apc_symetra_ext_temp: now supports temperatures measured in fahrenheit * 2837 FIX: hitachi_hnas_temp: fixed ascii decode error, handles degree celsius now correct * 2844 FIX: heartbeat_crm: Fixed problem processing the state of clone set resources + * 2798 FIX: netapp_api_cpu: fixed incorrect scaling of CPU data in NetApp Clustermode... Multisite: * 2684 Added icons for downloading agent data / walks of hosts... diff --git a/agents/special/agent_netapp b/agents/special/agent_netapp index 7e189b7c..fc2b14a 100755 --- a/agents/special/agent_netapp +++ b/agents/special/agent_netapp @@ -467,7 +467,7 @@ if netapp_mode == "clustermode": print "<<<netapp_api_cpu:sep(9)>>>" print format_config(node_info, "cpu-info", "system-name", config_report = ["number-of-processors"], config_rename = {"number-of-processors": "num_processors"}) - print format_config(system_info, "cpu-info", "node", config_scale = {"cpu-busytime": 10000}, + print format_config(system_info, "cpu-info", "node", config_scale = {"cpu-busytime": 1000000}, config_report = ["cpu-busytime", "nvram-battery-status"], config_rename = {"cpu-busytime": "cpu_busy"})
8 years, 10 months
1
0
0
0
Bookmark lists of other users can now be edited by admins
by Lars Michelsen
Module: check_mk Branch: master Commit: 9a501e1ce44ba53988665204efee304b5f5b1f0d URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9a501e1ce44ba5…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Nov 23 11:06:13 2015 +0100 Bookmark lists of other users can now be edited by admins --- web/htdocs/pagetypes.py | 64 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/web/htdocs/pagetypes.py b/web/htdocs/pagetypes.py index 86745b8..3a52777 100644 --- a/web/htdocs/pagetypes.py +++ b/web/htdocs/pagetypes.py @@ -425,8 +425,19 @@ class Overridable: else: return config.may('general.delete_foreign_%s' % self.type_name()) + + def may_edit(self): + if self.is_builtin(): + return False + elif self.is_mine(): + return True + else: + return config.may('general.edit_foreign_%s' % self.type_name()) + + def edit_url(self): - return "edit_%s.py?load_name=%s" % (self.type_name(), self.name()) + owner = not self.is_mine() and ("&owner=%s" % self.owner()) or "" + return "edit_%s.py?load_name=%s%s" % (self.type_name(), self.name(), owner) def clone_url(self): backurl = html.urlencode(html.makeuri([])) @@ -477,6 +488,11 @@ class Overridable: _("Make own published %s override builtin %s for all users.") % (self.phrase("title_plural"), self.phrase("title_plural")), [ "admin" ]) + config.declare_permission("general.edit_foreign_" + self.type_name(), + _("Edit foreign %s") % self.phrase("title_plural"), + _("Allows to edit %s created by other users.") % self.phrase("title_plural"), + [ "admin" ]) + config.declare_permission("general.delete_foreign_" + self.type_name(), _("Delete foreign %s") % self.phrase("title_plural"), _("Allows to delete %s created by other users.") % self.phrase("title_plural"), @@ -567,6 +583,13 @@ class Overridable: return page @classmethod + def find_foreign_page(self, owner, name): + try: + return self.instance((owner, name)) + except KeyError: + return None + + @classmethod def builtin_pages(self): return {} @@ -712,7 +735,8 @@ class Overridable: builtin_instances.append(instance) elif instance.is_mine(): my_instances.append(instance) - elif instance.is_public(): + elif instance.is_public() \ + or instance.may_delete() or instance.may_edit(): foreign_instances.append(instance) for title, instances in [ @@ -732,6 +756,10 @@ class Overridable: # Actions table.cell(_('Actions'), css = 'buttons visuals') + # Edit + if instance.may_edit(): + html.icon_button(instance.edit_url(), _("Edit"), "edit") + # Clone / Customize buttontext = _("Create a customized copy of this") html.icon_button(instance.clone_url(), buttontext, "new_" + self.type_name()) @@ -740,12 +768,6 @@ class Overridable: if instance.may_delete(): html.icon_button(instance.delete_url(), _("Delete!"), "delete") - # Edit - # TODO: Reihenfolge der Aktionen. Ist nicht delete immer nach edit? Sollte - # nicht clone und edit am gleichen Platz sein? - if instance.is_mine(): - html.icon_button(instance.edit_url(), _("Edit"), "edit") - ### # Custom buttons - visual specific ### if render_custom_buttons: ### render_custom_buttons(visual_name, visual) @@ -815,13 +837,21 @@ class Overridable: page_name = html.var("load_name") if mode == "edit": title = self.phrase("edit") - page = self.find_my_page(page_name) + + owner_user_id = html.var("owner", config.user_id) + if owner_user_id == config.user_id: + page = self.find_my_page(page_name) + else: + page = self.find_foreign_page(owner_user_id, page_name) + if page == None: raise MKUserError(None, _("The requested %s does not exist") % self.phrase("title")) - self.remove_instance((config.user_id, page_name)) # will be added later again + + # TODO FIXME: Looks like a hack + self.remove_instance((owner_user_id, page_name)) # will be added later again else: # clone title = self.phrase("clone") - load_user = html.var("load_user") + load_user = html.var("load_user") # FIXME: Change varname to "owner" page = self.instance((load_user, page_name)) page_dict = page.internal_representation() @@ -840,12 +870,18 @@ class Overridable: ) def validate(page_dict): - if self.find_my_page(page_dict["name"]): + owner_user_id = html.var("owner", config.user_id) + if owner_user_id == config.user_id: + page = self.find_my_page(page_name) + else: + page = self.find_foreign_page(owner_user_id, page_name) + if page: raise MKUserError("_p_name", _("You already have an with the ID <b>%s</b>") % page_dict["name"]) new_page_dict = forms.edit_valuespec(vs, page_dict, validate=validate) if new_page_dict != None: - new_page_dict["owner"] = config.user_id + owner = html.var("owner", config.user_id) + new_page_dict["owner"] = owner new_page = self(new_page_dict) if mode in ("edit", "clone"): @@ -855,7 +891,7 @@ class Overridable: new_page_dict[key] = page_dict[key] self.add_page(new_page) - self.save_user_instances() + self.save_user_instances(owner) html.immediate_browser_redirect(1, back_url) html.message(_('Your changes haven been saved.')) # Reload sidebar.TODO: This code logically belongs to PageRenderer. How
8 years, 10 months
1
0
0
0
Cleaned up waitmax. Clang-formatted, iwyu'd, cppchecked.
by Sven Panne
Module: check_mk Branch: master Commit: df3a7be41c2017fd5a6ecf2b62a56183bb877d35 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=df3a7be41c2017…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Mon Nov 23 10:37:01 2015 +0100 Cleaned up waitmax. Clang-formatted, iwyu'd, cppchecked. --- agents/waitmax | Bin 9956 -> 13224 bytes agents/waitmax.c | 204 ++++++++++++++++++++++++++---------------------------- 2 files changed, 97 insertions(+), 107 deletions(-) diff --git a/agents/waitmax b/agents/waitmax index cb77121..b956084 100755 Binary files a/agents/waitmax and b/agents/waitmax differ diff --git a/agents/waitmax.c b/agents/waitmax.c index de09216..54d71be 100644 --- a/agents/waitmax.c +++ b/agents/waitmax.c @@ -22,136 +22,126 @@ // to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA. -#include <stdio.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/errno.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> #include <errno.h> -#include <signal.h> #include <getopt.h> +#include <signal.h> +#include <stddef.h> +#include <stdlib.h> +#include <string.h> +#include <sys/wait.h> +#include <unistd.h> -/* macros for using write(2) instead of fprintf(stderr, ) */ -#define out(text) write(2, text, strlen(text)); +void out(const char *buf) +{ + size_t bytes_to_write = strlen(buf); + while (bytes_to_write > 0) { + ssize_t written = write(STDERR_FILENO, buf, bytes_to_write); + if (written == -1) { + if (errno == EINTR) continue; + return; + } + buf += written; + bytes_to_write -= written; + } +} int g_pid; int g_timeout = 0; int g_signum = 15; -struct option long_options[] = { - { "version" , no_argument, 0, 'V' }, - { "help" , no_argument, 0, 'h' }, - { "signal" , required_argument, 0, 's' }, - { 0, 0, 0, 0 } }; +struct option long_options[] = {{"version", no_argument, 0, 'V'}, + {"help", no_argument, 0, 'h'}, + {"signal", required_argument, 0, 's'}, + {0, 0, 0, 0}}; void version() { - out("waitmax version 1.1\n" - "Copyright Mathias Kettner 2008\n" - "This is free software; see the source for copying conditions. There is NO\n" - "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"); - exit(0); + out( + "waitmax version 1.1\n" + "Copyright Mathias Kettner 2008\n" + "This is free software; see the source for copying conditions. " + "There is NO\n" + "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR " + "PURPOSE.\n"); + exit(0); } - void usage() { - out("Usage: waitmax [-s SIGNUM] MAXTIME PROGRAM [ARGS...]\n" - "\n" - "Execute PROGRAM as a subprocess. If PROGRAM does not exit before MAXTIME\n" - "seconds, it will be killed with SIGTERM or an alternative signal.\n" - "\n" - " -s, --signal SIGNUM kill with SIGNUM on timeout\n" - " -h, --help this help\n" - " -V, --version show version an exit\n\n"); - exit(1); + out( + "Usage: waitmax [-s SIGNUM] MAXTIME PROGRAM [ARGS...]\n" + "\n" + "Execute PROGRAM as a subprocess. If PROGRAM does not exit before " + "MAXTIME\n" + "seconds, it will be killed with SIGTERM or an alternative signal.\n" + "\n" + " -s, --signal SIGNUM kill with SIGNUM on timeout\n" + " -h, --help this help\n" + " -V, --version show version an exit\n\n"); + exit(1); } - -void signalhandler(int signum) +void signalhandler(int signum __attribute__((__unused__))) { - if (0 == kill(g_pid, g_signum)) - g_timeout = 1; + if (kill(g_pid, g_signum) == 0) g_timeout = 1; } - int main(int argc, char **argv) { - int indexptr=0; - int ret; - setenv("POSIXLY_CORRECT", "true", 0); - while (0 <= (ret = getopt_long(argc, argv, "Vhs:", long_options, &indexptr))) { - switch (ret) - { - case 'V': - version(); - - case 'h': - usage(); - - case 's': - g_signum = strtoul(optarg, 0, 10); - if (g_signum < 1 || g_signum > 32) { - out("Signalnumber must be between 1 and 32.\n"); - exit(1); - } - break; - - default: - usage(argv[0]); - exit(1); - break; - } - } - - if (optind + 1 >= argc) usage(); - - int maxtime = atoi(argv[optind]); - if (maxtime <= 0) usage(); - - g_pid = fork(); - if (g_pid == 0) { + int indexptr = 0; + int ret; + setenv("POSIXLY_CORRECT", "true", 0); + while (0 <= + (ret = getopt_long(argc, argv, "Vhs:", long_options, &indexptr))) { + switch (ret) { + case 'V': version(); + + case 'h': usage(); + + case 's': + g_signum = strtoul(optarg, 0, 10); + if (g_signum < 1 || g_signum > 32) { + out("Signalnumber must be between 1 and 32.\n"); + exit(1); + } + break; + + default: usage(); exit(1); + } + } + + if (optind + 1 >= argc) usage(); + + int maxtime = atoi(argv[optind]); + if (maxtime <= 0) usage(); + + g_pid = fork(); + if (g_pid == 0) { + signal(SIGALRM, signalhandler); + execvp(argv[optind + 1], argv + optind + 1); + out("Cannot execute "); + out(argv[optind + 1]); + out(": "); + out(strerror(errno)); + out("\n"); + exit(253); + } + signal(SIGALRM, signalhandler); - execvp(argv[optind + 1], argv + optind + 1); - out("Cannot execute "); - out(argv[optind + 1]); - out(": "); - out(strerror(errno)); - out("\n"); - exit(253); - } - - signal(SIGALRM, signalhandler); - alarm(maxtime); - int status; - while (1) { - int pid = waitpid(g_pid, &status, 0); - if (pid <= 0) { - if (errno == EINTR) continue; // interuppted by alarm - else - out("Strange: waitpid() fails: "); - out(strerror(errno)); - out("\n"); - exit(1); - } - else break; - } - - if (WIFEXITED(status)) { - int exitcode = WEXITSTATUS(status); - return exitcode; - } - else if (WIFSIGNALED(status)) { - int signum = WTERMSIG(status); - if (g_timeout) - return 255; - else - return 128 + signum; - } - else { + alarm(maxtime); + + int status; + while (waitpid(g_pid, &status, 0) == -1) { + if (errno != EINTR) { + out("Strange: waitpid() fails: "); + out(strerror(errno)); + out("\n"); + exit(1); + } + } + + if (WIFEXITED(status)) return WEXITSTATUS(status); + if (WIFSIGNALED(status)) return g_timeout ? 255 : 128 + WTERMSIG(status); out("Strange: program did neither exit nor was signalled.\n"); return 254; - } }
8 years, 10 months
1
0
0
0
← Newer
1
...
4
5
6
7
8
9
10
...
31
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Results per page:
10
25
50
100
200