diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..74f09f3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,270 @@ +Essential Kaos Open Source License + +Version: 1.0 — May 10, 2013. + +Please read this License Agreement carefully before downloading this software. +By downloading or using this software, you are agreeing to be bound by the +terms of this License. If you do not or cannot agree to the terms of this +License, please do not download or use the software. + +This License Agreement (hereinafter — the "License") defines the terms and +conditions of use of the Source and Object forms of the products produced by +the Essential Kaos Ltd. Company that are publicly available to any third +parties. + +This license extends and is applicable to any Source and Object form of the +product of the Essential Kaos Ltd. Company (hereinafter — the "Licensor"), +which are publicly available (open source) for download by any third party +(hereinafter — the "Licensee") by the decision of the Licensor. + +1. TERMS USED IN THE LICENSE + +For the purposes of this License the following terms are used in the following +meaning: + +1.1 Product — any result of intellectual activity, produced by the +implementation of the Source and/or Object form, in particular, but not +limited to, software (computer programs), audio and video records, images, +texts, etc. + +1.2 Source form of the product — the form, preferred for making modifications +to the Product, including, but not limited to, source code, source file +documentation, configuration and installation files, etc., initially provided +by the Licensor. + +1.3 Object form of the product — the result of automatic (computer, hardware +and technical) transformation or translation of the Source form of the Product, +including but not limited to, source code compiled into object code, generated +documentation, and other kinds of media files (resources), initially provided +by the Licensor. + +1.4 Licensor — the Essential Kaos company, holding the exclusive (property) +rights to collectively all Source and/or Object forms of products, published +on the official website of Licensor, and to each of them individually. + +1.5 Licensee — any individual, sole proprietorship, legal entity or other +entity legally capable in accordance with the provisions of the applicable +law, who downloads and uses the Source and/or Object form of the product. + +1.6 Official Website of the Licensor — web site located on the Internet under +the essentialkaos.com domain name (domain address). + +1.7 Modification of the Source or Object form of the Product — any addition, +deletion, alteration of Source or Object form of the Product, the combination +of source code with any other elements, etc. + +The License may use terms not defined in this section. In these cases, the +terms shall be interpreted in accordance with the text and the context of this +License. In the absence of a clear interpretation of the term in the text of +the License, the parties shall rely upon, firstly, the interpretations used +on the Official Website of the Licensor, and secondly, the provisions of +applicable law. + +2. VALIDITY OF THE LICENSE + +2.1 Full awareness of the conditions and provisions of this License is an +indispensable condition for downloading and using the Source and/or Object +form of the Product. + +2.2 The download of the Source and/or Object form of the Product by the +Licensee to its software and hardware device (with or without the use of +their software and hardware devices) means the Licensee is fully aware of, +accepts and agrees to, obligations to comply with and carry out the terms and +conditions of this License. In case of disagreement with certain terms and +conditions herein and/or inability to carry them out the Licensee must +withdraw from the download and use of the Source and/or Object form of the +Products. + +2.3 This License is effective upon posting on the Official Website of the +Licensor, subject to paragraph 1.4. of this License. + +2.4 This License applies to Source and/or Object form of the Products, +downloaded by the Licensee prior to publication of the License on the +Official Website of the Licensor. + +2.5 This License is valid for an indefinite period of time and shall cease +to be valid on its annulment by the Licensor. + +2.6 The Licensor has the right to change the text of the License at his sole +discretion. In case of such changes to the License text, they come into force +from the moment of publication of the new edition of the Lcense on the official +Website of the Licensor, unless otherwise defined at the publication. + +2.7 The Licensee undertakes to monitor the changes in the provisions of this +License, and bears the responsibility and risk of the potential negative +consequences resulting from non-compliance with this obligation. + +2.8 If the Licensee does not agree with the changes in the text of the License +and/or fails to carry out the terms of the new License edition, the Licensee +must withdraw from downloading and stop using the Source and/or Object form of +the Product. Otherwise, the Licensee’s continued use of the Source and/or +Object form of the Product means the Licensee agrees to the terms of the new +License edition and is capable of fully complying with them. + +2.9 The Licensor shall have the right at any time to unilaterally terminate +this License. Upon termination of this License, the Licensee is obliged to +cease all use of the Source and/or Object form of the Product. + +2.10 The current version of the License can be permanently found on the +official Website of the Licensor at: http://essentialkaos.com/ekol. + +3. PERMITTED USE + +The basic principle of download and use of the Source and/or Object form of the +Product is the use of the Source and/or Object form of the Product exclusively +for personal (internal, intra-corporate) purposes. + +The Licensor hereby gives any Licensee, regardless of location and country of +residence the right to download at no charge (for free) the Source and/or +Object form of the Product and use it under a simple (non-exclusive) license +in the following ways, and in the following amounts: + +3.1 Use of the Source and/or Object form of the Product by any means and for +any purposes (both non-commercial and commercial), not prohibited by applicable +law, solely for the personal benefit, subject to the limitations set out in +this License, including but not limited to, reproduction demonstration, +implementation of the Source and/or Object form of the Product. + +3.2 The modification of the Source and/or Object form of the Product and the +use of modified Source and/or Object form solely for the Licensee’s personal +(commercial or non-commercial) purposes. In the event that the modification of +the Source and/or Object form of the Product requires the consent of a third +party (including the cases of using the objects of the person in question for +modifying the Source and/or Object form of the Product), the Licensee must +independently obtain such consent from the party. + +3.3 The inclusion (incorporation) of the Source and/or Object form of the +Product into a larger product, preserving the validity of terms of this +License with respect to the Source and/or Object form of the Product, +incorporated in the larger product. The Licensee shall ensure that this +License is enclosed to each of the Source and/or Object form of the Product +that is included in the larger product with the obligatory indication of the +name of Licensor - Essential Kaos Ltd. Company. The Licensor shall also ensure +the binding power of this License in the larger product, into which the Source +and/or Object form of the Product is included. + +3.4 The right to distribute to third parties the Source and/or Object forms of +the Product on a non-profit (free, no-charge) basis. + +This License does not grant Licensee any rights in any part to use the +trademarks, logos, commercial symbols, service marks owned by the Licensor on +legal grounds and in accordance with the provisions of applicable law, except +when otherwise stipulated by the Licensor. + +4. RESTRICTIONS AND LIMITATIONS + +The licensor is constantly striving to improve and enhance the quality of the +Source and Object forms for their most optimal and productive use by the +Licensee. + +In connection with the aforesaid, in order to maintain the quality of the +Source and Object forms of the product and to prevent it from decreasing the +following requirements and restrictions are applied when downloading and using +the Source and Object forms of the product: + +4.1 It is prohibited to distribute to third parties the modified Source and/or +Object forms of the product in any ways and in any volume, including both on +commercial (paid, reimbursable) and non-commercial (free, no-charge) basis. In +some cases, determined at the discretion and by the decision of the Licensor, +the Licensee shall be entitled to distribute the Source and/or Object forms of +the products, but only with the Licensor’s written permission. + +4.2 It is prohibited to distribute to third parties the Source and/or Object +forms of the product on a commercial (paid, reimbursable) basis. + +5. WARRANTY DISCLAIMER + +5.1 The Licensor is committed to providing the highest quality of the Source +and Object forms of product, constantly improving them, and to the possible +extent eliminating various errors, malfunctions and defects that occur when +downloading and using the Source and Object forms of the Product. + +5.2 The Source and Object forms of the product are available to Licensee on an +"as is" basis, without any guarantees of suitability of the Source or Object +form for a particular purpose, or for the general use of the Source or Object +form of the product. + +5.3 The Licensor disclaims all warranties and obligations to ensure the +absence of any errors, faults, defects, etc., arising when downloading and +using the Source and Object forms of the product, as well as modifications of +the Source and Object forms of the product and/or using the modified Source +and Object forms of the product. + +5.4 Nothing in this License shall act as a guarantee or obligation of the +Licensor to ensure uninterrupted or error-free operation of the Source and/or +Object forms of the product. In connection therewith, the Licensor shall be +exempt from any liability for any errors, malfunctions, defects, etc., +occurring during the download and use of the Source and Object forms of +product, as well as modifications of the Source and Object forms of product +and/or the use of the modified Source and Object forms of the product. + +5.5 The Licensor does not assume any obligation to eliminate errors, +malfunctions and defects, identified by the Licensee when downloading and using +the Source and Object forms of the product, as well as modifications of the +Source and Object forms of the product and/or using the modified Source and +Object forms of the product. + +5.6 Source and/or Object forms of the product are available for download from +the official Website of the Licensor in the condition, in which they are at +present. + +5.7 The Licensee hereby confirms that he understands and accepts all risks and +adverse consequences associated with downloading and using the Source and/or +Object forms of the product, as well as modifying the Source and/or Object +forms of the product and/or using the modified Source and/or Object forms of +the product, including, but not limited to, the loss of any data, any +malfunction or damage to the software and hardware of the Licensee. + +6. LIMITATION OF LIABILITY + +6.1 The Licensor shall not be liable for incidental, direct or consequential +loss (damage, lost profits, etc.) incurred by third parties as a result of the +implementation and execution of this License. + +6.2 The Licensor shall not be liable for any failure or temporary +unavailability of the download and use of the Object or Source form of the +product. +6.3 The Licensor shall not be liable for any tort of Licensee, the Licensee's +breach of warranty and violation of civil and constitutional rights of third +parties. + +6.4 In any case, if the applicable law defines the necessity for the Licensor +to bear responsibility for the Licensee under this License, the Licensor's +liability is limited to the amount of 100 USD. + +7. INTELLECTUAL PROPERTY RIGHTS TO THE SOURCE AND OBJECT FORMS OF THE PRODUCT + +The Source and Object forms of the product have the potential and real value +for the implementation of activities by individuals and legal entities. + +7.1 The Licensor hereby confirms that he has the exclusive (property) rights to +collectively all Source and/or Object forms of the product, available for +download on the official Website of the Licensor, and to each of them +individually. + +7.2 The Licensor acknowledges that the placement of the Source and Object forms +of the product on the website for download and use does not infringe the +intellectual property rights of third parties. The exclusive rights of the +Licensor to the Source and/or Object forms of the product are supported by the +relevant permissions and consents of, or written agreements with, authors of +the Source and Object forms of the product. + +7.3 This License does not mean alienation to any third party, including the +Licensee, of the exclusive (property) rights of the Licensor to the Source or +Object forms of the product. The exclusive (property) rights to the Source or +Object forms of the product are fully retained by the Licensor. + +8. DISPUTE RESOLUTION + +8.1 Any disputes arising from the execution of this License and downloading and +using the Source and Object forms of the product, as well as modifying the +Source and Object forms of the product and/or using the modified Source and +Object forms of the product, shall be settled in the court at the Licensor’s +location. + +8.2 If the court recognizes any provision of this License as invalid, the rest +of this License shall remain unchanged, and the invalid provision shall be +amended in accordance with applicable law. + +8.3 Conditions not covered by this License shall be settled in accordance with +the law, applicable in the country of the Licensor’s registration. \ No newline at end of file diff --git a/common/redis-cli-monitor.spec b/common/redis-cli-monitor.spec index bdfeae4..b06de86 100644 --- a/common/redis-cli-monitor.spec +++ b/common/redis-cli-monitor.spec @@ -8,13 +8,13 @@ ############################################################################### -Summary: Tiny redis client for renamed MONITOR commands +Summary: Tiny Redis client for renamed MONITOR commands Name: redis-cli-monitor -Version: 1.3.0 +Version: 1.4.0 Release: 0%{?dist} Group: Applications/System License: EKOL -URL: http://essentialkaos.com +URL: https://github.com/essentialkaos/redis-cli-monitor Source0: https://source.kaos.io/%{name}/%{name}-%{version}.tar.bz2 @@ -27,7 +27,7 @@ Provides: %{name} = %{version}-%{release} ############################################################################### %description -Tiny redis client for renamed MONITOR commands. +Tiny Redis client for renamed MONITOR commands. ############################################################################### @@ -57,6 +57,9 @@ rm -rf %{buildroot} ############################################################################### %changelog +* Wed Jun 07 2017 Anton Novojilov - 1.4.0-0 +- Minor improvements + * Fri May 26 2017 Anton Novojilov - 1.3.0-0 - ek package updated to v9 diff --git a/readme.md b/readme.md index b2d1485..f0549ea 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ -## Redis CLI Monitor [![Build Status](https://travis-ci.org/essentialkaos/redis-cli-monitor.svg?branch=master)](https://travis-ci.org/essentialkaos/redis-cli-monitor) [![License](https://gh.kaos.io/ekol.svg)](https://essentialkaos.com/ekol) +## Redis CLI Monitor [![Build Status](https://travis-ci.org/essentialkaos/redis-cli-monitor.svg?branch=master)](https://travis-ci.org/essentialkaos/redis-cli-monitor) [![Go Report Card](https://goreportcard.com/badge/github.com/essentialkaos/redis-cli-monitor)](https://goreportcard.com/report/github.com/essentialkaos/redis-cli-monitor) [![License](https://gh.kaos.io/ekol.svg)](https://essentialkaos.com/ekol) -Tiny redis client for renamed MONITOR commands. +Tiny Redis client for renamed MONITOR commands. ### Installation @@ -24,6 +24,20 @@ If you want to update `redis-cli-monitor` to latest stable release, do: go get -u github.com/essentialkaos/redis-cli-monitor ``` +#### From ESSENTIAL KAOS Public repo for RHEL6/CentOS6 + +```bash +[sudo] yum install -y https://yum.kaos.io/6/release/x86_64/kaos-repo-8.0-0.el6.noarch.rpm +[sudo] yum install redis-cli-monitor +``` + +#### From ESSENTIAL KAOS Public repo for RHEL7/CentOS7 + +```bash +[sudo] yum install -y https://yum.kaos.io/7/release/x86_64/kaos-repo-8.0-0.el7.noarch.rpm +[sudo] yum install redis-cli-monitor +``` + #### Prebuilt binaries You can download prebuilt binaries for Linux and OS X from [EK Apps Repository](https://apps.kaos.io/redis-cli-monitor/latest). @@ -35,19 +49,20 @@ Usage: redis-cli-monitor {options} command-name Options - --host, -H ip/host Server hostname - --port, -p port Server port + --host, -H ip/host Server hostname (127.0.0.1 by default) + --port, -P port Server port (6379 by default) --password, -a password Password to use when connecting to the server - --timeout, -t 1-300 Connection timeout in seconds + --timeout, -t 1-300 Connection timeout in seconds (3 by default) + --no-color, -nc Disable colors in output --help, -h Show this help message --version, -v Show version Examples - redis-cli-monitor -h 192.168.0.123 -p 6821 -t 15 RENAMED_MONITOR + redis-cli-monitor --host 192.168.0.123 --password 6821 --timeout 15 RENAMED_MONITOR Execute "RENAMED_MONITOR" command on 192.168.0.123:6821 with 15 sec timeout - redis-cli-monitor -p 12345 -a MySuppaPassword1234 RENAMED_MONITOR + redis-cli-monitor -P 12345 -a MySuppaPassword1234 RENAMED_MONITOR Execute "RENAMED_MONITOR" command on 127.0.0.1:12345 with password "MySuppaPassword1234" ``` diff --git a/redis-cli-monitor.go b/redis-cli-monitor.go index 3fa4a7a..9230d2d 100644 --- a/redis-cli-monitor.go +++ b/redis-cli-monitor.go @@ -14,6 +14,7 @@ import ( "os" "time" + "pkg.re/essentialkaos/ek.v9/fmtc" "pkg.re/essentialkaos/ek.v9/options" "pkg.re/essentialkaos/ek.v9/usage" ) @@ -22,28 +23,30 @@ import ( const ( APP = "Redis CLI Monitor" - VER = "1.3.0" - DESC = "Tiny redis client for renamed MONITOR commands" + VER = "1.4.0" + DESC = "Tiny Redis client for renamed MONITOR commands" ) const ( - OPT_HOST = "H:host" - OPT_PORT = "p:port" - OPT_AUTH = "a:password" - OPT_TIMEOUT = "t:timeout" - OPT_HELP = "h:help" - OPT_VER = "v:version" + OPT_HOST = "H:host" + OPT_PORT = "P:port" + OPT_AUTH = "a:password" + OPT_TIMEOUT = "t:timeout" + OPT_NO_COLOR = "nc:no-color" + OPT_HELP = "h:help" + OPT_VER = "v:version" ) // ////////////////////////////////////////////////////////////////////////////////// // var optMap = options.Map{ - OPT_HOST: {Value: "127.0.0.1"}, - OPT_PORT: {Value: "6379"}, - OPT_TIMEOUT: {Type: options.INT, Value: 3, Min: 1, Max: 300}, - OPT_AUTH: {}, - OPT_HELP: {Type: options.BOOL, Alias: "u:usage"}, - OPT_VER: {Type: options.BOOL, Alias: "ver"}, + OPT_HOST: {Value: "127.0.0.1"}, + OPT_PORT: {Value: "6379"}, + OPT_TIMEOUT: {Type: options.INT, Value: 3, Min: 1, Max: 300}, + OPT_AUTH: {}, + OPT_NO_COLOR: {Type: options.BOOL}, + OPT_HELP: {Type: options.BOOL, Alias: "u:usage"}, + OPT_VER: {Type: options.BOOL, Alias: "ver"}, } // ////////////////////////////////////////////////////////////////////////////////// // @@ -54,18 +57,22 @@ func main() { if len(errs) != 0 { for _, err := range errs { - fmt.Println(err.Error()) + printError(err.Error()) } os.Exit(1) } - if options.GetB(OPT_VER) == true { + if options.GetB(OPT_NO_COLOR) { + fmtc.DisableColors = true + } + + if options.GetB(OPT_VER) { showAbout() return } - if options.GetB(OPT_HELP) == true || len(args) == 0 { + if options.GetB(OPT_HELP) || len(args) == 0 { showUsage() return } @@ -81,7 +88,7 @@ func connect(cmd string) { conn, err := net.DialTimeout("tcp", host, timeout) if err != nil { - fmt.Println(err.Error()) + printError(err.Error()) os.Exit(1) } @@ -96,6 +103,7 @@ func connect(cmd string) { for { str, err := connbuf.ReadString('\n') + if len(str) > 0 { if str == "+OK\r\n" { continue @@ -103,33 +111,40 @@ func connect(cmd string) { fmt.Printf("%s", str[1:]) } + if err != nil { - fmt.Println(err.Error()) + printError(err.Error()) os.Exit(1) } } } +// printError prints error message to console +func printError(f string, a ...interface{}) { + fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...) +} + // ////////////////////////////////////////////////////////////////////////////////// // // showUsage print usage info func showUsage() { info := usage.NewInfo("", "command-name") - info.AddOption(OPT_HOST, "Server hostname", "ip/host") - info.AddOption(OPT_PORT, "Server port", "port") + info.AddOption(OPT_HOST, "Server hostname {s-}(127.0.0.1 by default){!}", "ip/host") + info.AddOption(OPT_PORT, "Server port {s-}(6379 by default){!}", "port") info.AddOption(OPT_AUTH, "Password to use when connecting to the server", "password") - info.AddOption(OPT_TIMEOUT, "Connection timeout in seconds", "1-300") + info.AddOption(OPT_TIMEOUT, "Connection timeout in seconds {s-}(3 by default){!}", "1-300") + info.AddOption(OPT_NO_COLOR, "Disable colors in output") info.AddOption(OPT_HELP, "Show this help message") info.AddOption(OPT_VER, "Show version") info.AddExample( - "-h 192.168.0.123 -p 6821 -t 15 RENAMED_MONITOR", + "--host 192.168.0.123 --password 6821 --timeout 15 RENAMED_MONITOR", "Execute \"RENAMED_MONITOR\" command on 192.168.0.123:6821 with 15 sec timeout", ) info.AddExample( - "-p 12345 -a MySuppaPassword1234 RENAMED_MONITOR", + "-P 12345 -a MySuppaPassword1234 RENAMED_MONITOR", "Execute \"RENAMED_MONITOR\" command on 127.0.0.1:12345 with password \"MySuppaPassword1234\"", )