├── .github └── workflows │ └── Check pull request source branch.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── archive ├── rtrmon-1.0.sh ├── rtrmon-1.01.sh ├── rtrmon-1.02.sh ├── rtrmon-1.03.sh ├── rtrmon-1.04.sh ├── rtrmon-1.05.sh ├── rtrmon-1.06b1.sh ├── rtrmon-1.0RC1.sh ├── rtrmon-1.1.sh ├── rtrmon-1.11.sh ├── rtrmon-1.12.sh ├── rtrmon-1.14.sh ├── rtrmon-1.15.sh ├── rtrmon-1.17.sh ├── rtrmon-1.19.sh ├── rtrmon-1.1b1.sh ├── rtrmon-1.20.sh ├── rtrmon-1.21b1.sh ├── rtrmon-1.21b2.sh ├── rtrmon-1.21b3.sh ├── rtrmon-1.21b4.sh ├── rtrmon-1.21b5.sh ├── rtrmon-1.22.sh ├── rtrmon-1.23.sh ├── rtrmon-1.24.sh ├── rtrmon-1.30.sh ├── rtrmon-1.31.sh ├── rtrmon-1.32.sh ├── rtrmon-1.32b1.sh ├── rtrmon-1.33b2.sh ├── rtrmon-1.33b3.sh ├── rtrmon-1.33b4.sh ├── rtrmon-1.33b5.sh ├── rtrmon-1.33b6.sh ├── rtrmon-1.33b7.sh ├── rtrmon-1.33b8.sh ├── rtrmon-1.40.sh ├── rtrmon-1.41.sh ├── rtrmon-1.45.sh ├── rtrmon-1.46.sh ├── rtrmon-1.49.sh ├── rtrmon-1.50.sh ├── rtrmon-1.51.sh ├── rtrmon-1.54.sh ├── rtrmon-1.55.sh ├── rtrmon-1.56.sh ├── rtrmon-1.57.sh ├── rtrmon-1.58.sh ├── rtrmon-1.6.2.sh ├── rtrmon-1.6.4.sh ├── rtrmon-1.6.7.sh ├── rtrmon-1.6.8.sh ├── rtrmon-1.6.9.sh ├── rtrmon-2.0.12b2.sh ├── rtrmon-2.0.15RC.sh ├── rtrmon-2.0.16.sh ├── rtrmon-2.0.17.sh ├── rtrmon-2.0.8b1.sh ├── rtrmon-2.1.0.sh ├── rtrmon-2.1.3.sh ├── rtrmon-2.1.4.sh ├── rtrmon-2.1.5.sh ├── rtrmon-2.1.6.sh ├── rtrmon-2.1.6b1.sh └── rtrmon-2.2.0.sh ├── changelog.txt ├── enhancements.txt ├── rtrmon-2.2.1.sh ├── rtrmon.sh └── version.txt /.github/workflows/Check pull request source branch.yml: -------------------------------------------------------------------------------- 1 | name: Check pull request source branch 2 | on: 3 | pull_request_target: 4 | types: 5 | - opened 6 | - reopened 7 | - synchronize 8 | - edited 9 | jobs: 10 | check-branches: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Check branches 14 | run: | 15 | if [ ${{ github.head_ref }} != "develop" ] && [ ${{ github.base_ref }} == "main" ]; then 16 | echo "Merge requests to main branch are only allowed from dev branch." 17 | exit 1 18 | fi 19 | 20 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to RTRMON 2 | 3 | We're thrilled that you're interested in contributing to RTRMON! This document provides a set of guidelines for contributing to RTRMON. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. 4 | 5 | RTRMON is licensed under the Unlicense, a license with no conditions whatsoever which dedicates works to the public domain. 6 | 7 | ****How Can I Contribute?**** 8 | For those wishing to contribute to RTRMON, please make your mods to the **"rtrmon.sh"** file under the "develop" branch. For more info, please see below: 9 | 10 | ------ 11 | 12 | **Reporting Bugs** 13 | * Use a clear and descriptive title for the issue to identify the problem. 14 | * Describe the exact steps which reproduce the problem in as much detail as possible. 15 | * Provide specific examples screenshots or logs to demonstrate the steps 16 | 17 | **Suggesting Enhancements** 18 | * Use a clear and descriptive title for the issue to identify the suggestion. 19 | * Provide a step-by-step description of the suggested enhancement in as much detail as possible. 20 | 21 | **Your First Code Contribution** 22 | * Pull requests are the method for submitting changes. Here's the general process: 23 | * Fork the repository. 24 | * Create a new branch in your fork (git checkout -b feature/my-new-feature). 25 | * Make your changes. 26 | * Commit your changes (git commit -am 'Add some feature'). 27 | * Push to the branch (git push origin feature/my-new-feature). 28 | * Create a new Pull Request. 29 | 30 | **Pull Request Guidelines** 31 | * Write clear and concise commit messages. 32 | * Include links to existing BUGS or REQs when possible. 33 | * Include screenshots and logs whenever possible. 34 | * End all files with a newline. 35 | 36 | **Documentation Styleguide** 37 | * Keep language simple and clear. 38 | 39 | **More Questions?** 40 | * Feel free to ask for help if you need it, either via issues or through the provided contact owner @VictorJp 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RTRMON v2.2.2 2 | Asus-Merlin Router Monitor by Viktor Jaep, 2022-2025 3 | 4 | Updated on 2025-Oct-21 5 | 6 | --- 7 | 8 | image 9 | 10 | --- 11 | 12 | RTRMON is a shell script that provides near-realtime stats about your Asus-Merlin firmware router. Instead of having to find this information on various different screens or apps, this tool was built to bring all this info together in one stat dashboard. Having a 'system' dashboard showing current CPU, Memory, Disk and Network stats would compiment other dashboard-like scripts greatly (like RTRMON), sitting side-by-side in their own SSH windows to give you everything you need to know that's happening on your network with a glance at your screen. Capabilities have been added to give a full view of your router's CPU, Memory, Disk, NVRAM, Swap file, WAN, LAN, Wi-FI, IP4/6 addresses, CPU/Antenna Temps, in addition to having incorporated the Ookla Speedtest Binaries for you to run an on-demand Speedtest with the press of a button. New supported models are continually being added as @RMerlin adds support for them with his own firmware. 13 | 14 | Full thread/community here: https://www.snbforums.com/threads/rtrmon-v2-1-6-jul-5-2025-monitor-your-routers-health-new-amtm-network-conn-bandwidth-diag-port-scanner-speedtest-wireguard-v2-2-04-beta.90292/ 15 | -------------------------------------------------------------------------------- /archive/rtrmon-1.0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # RTRMON v1.0 - Asus-Merlin Router Monitor 4 | # RTRMON is a shell script that provides near-realtime stats about your Asus-Merlin firmware router. Instead of having to 5 | # find this information on various different screens or apps, this tool was built to bring all this info together in one 6 | # stat dashboard. Having a 'system' dashboard showing current CPU, Memory, Disk and Network stats would compiment other 7 | # dashboard-like scripts greatly (like RTRMON), sitting side-by-side in their own SSH windows to give you everything 8 | # you need to know with a glance at your screen. 9 | # 10 | # Please use the 'rtrmon.sh -setup' to configure the necessary parameters that match your environment the best! 11 | # 12 | # ------------------------------------------------------------------------------------------------------------------------- 13 | # System Variables (Do not change beyond this point or this may change the programs ability to function correctly) 14 | # ------------------------------------------------------------------------------------------------------------------------- 15 | Version="1.0" 16 | Beta=0 17 | LOGFILE="/jffs/addons/rtrmon.d/rtrmon.log" # Logfile path/name that captures important date/time events - change 18 | APPPATH="/jffs/scripts/rtrmon.sh" # Path to the location of rtrmon.sh 19 | CFGPATH="/jffs/addons/rtrmon.d/rtrmon.cfg" # Path to the location of rtrmon.cfg 20 | DLVERPATH="/jffs/addons/rtrmon.d/version.txt" # Path to downloaded version from the source repository 21 | 22 | FromUI=0 23 | NextPage=1 24 | memused1=0 25 | memfree1=0 26 | memshrd1=0 27 | membuff1=0 28 | memcach1=0 29 | memused2=0 30 | memfree2=0 31 | memshrd2=0 32 | membuff2=0 33 | memcach2=0 34 | cpuusr1=0 35 | cpusys1=0 36 | cpunice1=0 37 | cpuidle1=0 38 | displaycpuusr1=0 39 | displaycpusys1=0 40 | displaycpunice1=0 41 | displaycpuidle1=0 42 | 43 | # Color variables 44 | CBlack="\e[1;30m" 45 | InvBlack="\e[1;40m" 46 | CRed="\e[1;31m" 47 | InvRed="\e[1;41m" 48 | CGreen="\e[1;32m" 49 | InvGreen="\e[1;42m" 50 | InvDkGray="\e[1;100m" 51 | InvLtGray="\e[1;47m" 52 | CYellow="\e[1;33m" 53 | InvYellow="\e[1;43m" 54 | CBlue="\e[1;34m" 55 | InvBlue="\e[1;44m" 56 | CMagenta="\e[1;35m" 57 | CCyan="\e[1;36m" 58 | InvCyan="\e[1;46m" 59 | CWhite="\e[1;37m" 60 | InvWhite="\e[1;107m" 61 | CClear="\e[0m" 62 | 63 | # ------------------------------------------------------------------------------------------------------------------------- 64 | # Functions 65 | # ------------------------------------------------------------------------------------------------------------------------- 66 | 67 | # Logo is a function that displays the RTRMON script name in a cool ASCII font 68 | logo () { 69 | echo -e "${CYellow} ____ __________ __ _______ _ __" 70 | echo -e " / __ \/_ __/ __ \/ |/ / __ \/ | / / ${CGreen}v$Version${CYellow}" 71 | echo -e " / /_/ / / / / /_/ / /|_/ / / / / |/ / ${CRed}(S)${CGreen}etup${CYellow}" 72 | echo -e " / _, _/ / / / _, _/ / / / /_/ / /| / ${CRed}(N)${CGreen}ext Page ($NextPage/2)${CYellow}" 73 | echo -e " /_/ |_| /_/ /_/ |_/_/ /_/\____/_/ |_/ ${CRed}(E)${CGreen}xit${CClear}" 74 | } 75 | 76 | # ------------------------------------------------------------------------------------------------------------------------- 77 | 78 | # LogoNM is a function that displays the RTRMON script name in a cool ASCII font without menu options 79 | logoNM () { 80 | echo -e "${CYellow} ____ __________ __ _______ _ __" 81 | echo -e " / __ \/_ __/ __ \/ |/ / __ \/ | / / ${CGreen}v$Version${CYellow}" 82 | echo -e " / /_/ / / / / /_/ / /|_/ / / / / |/ /" 83 | echo -e " / _, _/ / / / _, _/ / / / /_/ / /| /" 84 | echo -e " /_/ |_| /_/ /_/ |_/_/ /_/\____/_/ |_/${CClear}" 85 | } 86 | 87 | # ------------------------------------------------------------------------------------------------------------------------- 88 | 89 | # promptyn takes input for Y/N questions 90 | promptyn () { # No defaults, just y or n 91 | while true; do 92 | read -p "[y/n]? " -n 1 -r yn 93 | case "${yn}" in 94 | [Yy]* ) return 0 ;; 95 | [Nn]* ) return 1 ;; 96 | * ) echo -e "\nPlease answer y or n.";; 97 | esac 98 | done 99 | } 100 | 101 | # ------------------------------------------------------------------------------------------------------------------------- 102 | 103 | # Preparebar and Progressbar is a script that provides a nice progressbar to show script activity 104 | preparebar() { 105 | # $1 - bar length 106 | # $2 - bar char 107 | #printf "\n" 108 | barlen=$1 109 | barspaces=$(printf "%*s" "$1") 110 | barchars=$(printf "%*s" "$1" | tr ' ' "$2") 111 | } 112 | 113 | # Had to make some mods to the variables being passed, and created an inverse colored progress bar 114 | progressbar() { 115 | # $1 - number (-1 for clearing the bar) 116 | # $2 - max number 117 | # $3 - system name 118 | # $4 - measurement 119 | # $5 - standard/reverse progressbar 120 | insertspc=" " 121 | 122 | if [ $1 -eq -1 ]; then 123 | printf "\r $barspaces\r" 124 | else 125 | barch=$(($1*barlen/$2)) 126 | barsp=$((barlen-barch)) 127 | progr=$((100*$1/$2)) 128 | 129 | if [ ! -z $6 ]; then AltNum=$6; else AltNum=$1; fi 130 | 131 | if [ "$5" == "Standard" ]; then 132 | if [ $progr -lt 60 ]; then 133 | printf "${InvGreen}${CWhite}$insertspc${CClear}${CGreen}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 134 | elif [ $progr -gt 59 ] && [ $progr -lt 85 ]; then 135 | printf "${InvYellow}${CBlack}$insertspc${CClear}${CYellow}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 136 | else 137 | printf "${InvRed}${CWhite}$insertspc${CClear}${CRed}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 138 | fi 139 | elif [ "$5" == "Reverse" ]; then 140 | if [ $progr -lt 35 ]; then 141 | printf "${InvRed}${CWhite}$insertspc${CClear}${CRed}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 142 | elif [ $progr -gt 35 ] && [ $progr -lt 85 ]; then 143 | printf "${InvYellow}${CBlack}$insertspc${CClear}${CYellow}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 144 | else 145 | printf "${InvGreen}${CWhite}$insertspc${CClear}${CGreen}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 146 | fi 147 | fi 148 | fi 149 | } 150 | 151 | # ------------------------------------------------------------------------------------------------------------------------- 152 | 153 | # converttemps is a function that converts temp readouts from C to F or K 154 | converttemps () { 155 | # $1 is the incoming C Temp 156 | 157 | if [ "$TempUnits" == "F" ]; then 158 | currenttemp=$(awk -v v1=$1 'BEGIN{printf "%0.2f\n", (v1*9)/5+32}' | cut -d . -f 1) 159 | currentrange=266 160 | elif [ "$TempUnits" == "K" ]; then 161 | currenttemp=$(awk -v v1=$1 'BEGIN{printf "%0.2f\n", v1+273}' | cut -d . -f 1) 162 | currentrange=403 163 | elif [ "$TempUnits" == "C" ]; then 164 | currenttemp=$1 165 | currentrange=130 166 | fi 167 | 168 | } 169 | 170 | # ------------------------------------------------------------------------------------------------------------------------- 171 | 172 | # updatecheck is a function that downloads the latest update version file, and compares it with what's currently installed 173 | updatecheck () { 174 | 175 | # Download the latest version file from the source repository 176 | curl --silent --retry 3 "https://raw.githubusercontent.com/ViktorJp/RTRMON/master/version.txt" -o "/jffs/addons/rtrmon.d/version.txt" 177 | 178 | if [ -f $DLVERPATH ] 179 | then 180 | # Read in its contents for the current version file 181 | DLVersion=$(cat $DLVERPATH) 182 | 183 | # Compare the new version with the old version and log it 184 | if [ "$Beta" == "1" ]; then # Check if Dev/Beta Mode is enabled and disable notification message 185 | UpdateNotify=0 186 | elif [ "$DLVersion" != "$Version" ]; then 187 | UpdateNotify="Update available: v$Version -> v$DLVersion" 188 | echo -e "$(date) - RTRMON - A new update (v$DLVersion) is available to download" >> $LOGFILE 189 | else 190 | UpdateNotify=0 191 | fi 192 | fi 193 | } 194 | 195 | # ------------------------------------------------------------------------------------------------------------------------- 196 | 197 | # vlogs is a function that calls the nano text editor to view the RTRMON log file 198 | vlogs() { 199 | 200 | export TERM=linux 201 | nano $LOGFILE 202 | 203 | } 204 | 205 | # ------------------------------------------------------------------------------------------------------------------------- 206 | 207 | # vconfig is a function that guides you through the various configuration options for RTRMON 208 | vconfig () { 209 | 210 | if [ -f $CFGPATH ]; then #Making sure file exists before proceeding 211 | source $CFGPATH 212 | 213 | while true; do 214 | clear 215 | logoNM 216 | echo "" 217 | echo -e "${CGreen}RTRMON Configuration Utility${CClear}" # Provide main setup menu 218 | echo "" 219 | echo -e "${CGreen}----------------------------------------------------------------" 220 | echo -e "${CGreen}Options" 221 | echo -e "${CGreen}----------------------------------------------------------------" 222 | echo -e "${InvDkGray}${CWhite} 1 ${CClear}${CCyan}: Timer Interval (seconds) :"${CGreen}$Interval 223 | echo -e "${InvDkGray}${CWhite} 2 ${CClear}${CCyan}: Max Internet Speed (Mbps) :"${CGreen}$MaxSpeedInet 224 | echo -e "${InvDkGray}${CWhite} 3 ${CClear}${CCyan}: Max LAN Speed (Mbps) :"${CGreen}$MaxSpeedLAN 225 | echo -e "${InvDkGray}${CWhite} 4 ${CClear}${CCyan}: Max 2.4Ghz Speed (Mbps) :"${CGreen}$MaxSpeed24Ghz 226 | echo -e "${InvDkGray}${CWhite} 5 ${CClear}${CCyan}: Max 5Ghz Speed (Mbps) :"${CGreen}$MaxSpeed5Ghz 227 | echo -e "${InvDkGray}${CWhite} 6 ${CClear}${CCyan}: Temperature Units (C/F/K) :"${CGreen}$TempUnits 228 | echo -e "${InvDkGray}${CWhite} s ${CClear}${CCyan}: Save & Exit" 229 | echo -e "${InvDkGray}${CWhite} e ${CClear}${CCyan}: Exit & Discard Changes" 230 | echo -e "${CGreen}----------------------------------------------------------------" 231 | echo "" 232 | printf "Selection: " 233 | read -r ConfigSelection 234 | 235 | # Execute chosen selections 236 | case "$ConfigSelection" in 237 | 238 | 1) # ----------------------------------------------------------------------------------------- 239 | echo "" 240 | echo -e "${CCyan}1. How many seconds would you like to use to refresh your stats?" 241 | echo -e "${CYellow}(Default = 10)${CClear}" 242 | read -p 'Interval (seconds): ' Interval1 243 | Interval=$Interval1 244 | ;; 245 | 246 | 2) # ----------------------------------------------------------------------------------------- 247 | echo "" 248 | echo -e "${CCyan}2. What is your maximum internet bandwidth/speed in Mbps?" 249 | echo -e "${CYellow}(Default = 1000)${CClear}" 250 | read -p 'Max Internet Speed (Mbps): ' MaxSpeedInet1 251 | MaxSpeedInet=$MaxSpeedInet1 252 | ;; 253 | 254 | 3) # ----------------------------------------------------------------------------------------- 255 | echo "" 256 | echo -e "${CCyan}3. What is your maximum LAN switch bandwidth/speed in Mbps?" 257 | echo -e "${CYellow}(Default = 1000)${CClear}" 258 | read -p 'Max LAN Speed (Mbps): ' MaxSpeedLAN1 259 | MaxSpeedLAN=$MaxSpeedLAN1 260 | ;; 261 | 262 | 4) # ----------------------------------------------------------------------------------------- 263 | echo "" 264 | echo -e "${CCyan}4. What is your maximum realistic 2.4Ghz speed in Mbps?" 265 | echo -e "${CYellow}(Default = 450)${CClear}" 266 | read -p 'Max 2.4Ghz Speed (Mbps): ' MaxSpeed24Ghz1 267 | MaxSpeed24Ghz=$MaxSpeed24Ghz1 268 | ;; 269 | 270 | 5) # ----------------------------------------------------------------------------------------- 271 | echo "" 272 | echo -e "${CCyan}5. What is your maximum realistic 5Ghz speed in Mbps?" 273 | echo -e "${CYellow}(Default = 780)${CClear}" 274 | read -p 'Max 5Ghz Speed (Mbps): ' MaxSpeed5Ghz1 275 | MaxSpeed5Ghz=$MaxSpeed5Ghz1 276 | ;; 277 | 278 | 6) # ----------------------------------------------------------------------------------------- 279 | echo "" 280 | echo -e "${CCyan}6. Which Temperature Units would you prefer? (C)elcius," 281 | echo -e "${CCyan}(Fahrenheit) or (K)elvin?" 282 | echo -e "${CYellow}(Default = C)${CClear}" 283 | read -p 'Temp Units (C/F/K): ' TempUnits1 284 | TempUnits=$(echo $TempUnits1 | tr '[a-z]' '[A-Z]') 285 | ;; 286 | 287 | s) # ----------------------------------------------------------------------------------------- 288 | echo "" 289 | { echo 'Interval='$Interval 290 | echo 'MaxSpeedInet='$MaxSpeedInet 291 | echo 'MaxSpeedLAN='$MaxSpeedLAN 292 | echo 'MaxSpeed24Ghz='$MaxSpeed24Ghz 293 | echo 'MaxSpeed5Ghz='$MaxSpeed5Ghz 294 | echo 'TempUnits="'"$TempUnits"'"' 295 | } > $CFGPATH 296 | echo "" 297 | echo -e "${CGreen}Please restart RTRMON to apply your changes..." 298 | echo -e "$(date) - RTRMON - Successfully wrote a new config file" >> $LOGFILE 299 | sleep 3 300 | return 301 | ;; 302 | 303 | e) # ----------------------------------------------------------------------------------------- 304 | return 305 | ;; 306 | 307 | esac 308 | done 309 | 310 | else 311 | #Create a new config file with default values to get it to a basic running state 312 | { echo 'Interval=10' 313 | echo 'MaxSpeedInet=1000' 314 | echo 'MaxSpeedLAN=1000' 315 | echo 'MaxSpeed24Ghz=450' 316 | echo 'MaxSpeed5Ghz=780' 317 | echo 'TempUnits="C"' 318 | } > $CFGPATH 319 | 320 | #Re-run rtrmon -config to restart setup process 321 | vconfig 322 | 323 | fi 324 | 325 | } 326 | 327 | # ------------------------------------------------------------------------------------------------------------------------- 328 | 329 | # vuninstall is a function that uninstalls and removes all traces of RTRMON from your router... 330 | vuninstall () { 331 | clear 332 | logoNM 333 | echo "" 334 | echo -e "${CGreen}RTRMON Uninstall Utility${CClear}" 335 | echo "" 336 | echo -e "${CCyan}You are about to uninstall RTRMON! This action is irreversible." 337 | echo -e "${CCyan}Do you wish to proceed?${CClear}" 338 | if promptyn "(y/n): "; then 339 | echo "" 340 | echo -e "\n${CCyan}Are you sure? Please type 'Y' to validate you want to proceed.${CClear}" 341 | if promptyn "(y/n): "; then 342 | clear 343 | rm -r /jffs/addons/rtrmon.d 344 | rm /jffs/scripts/rtrmon.sh 345 | echo "" 346 | echo -e "\n${CGreen}RTRMON has been uninstalled...${CClear}" 347 | echo "" 348 | exit 0 349 | else 350 | echo "" 351 | echo -e "\n${CGreen}Exiting Uninstall Utility...${CClear}" 352 | sleep 1 353 | return 354 | fi 355 | else 356 | echo "" 357 | echo -e "\n${CGreen}Exiting Uninstall Utility...${CClear}" 358 | sleep 1 359 | return 360 | fi 361 | } 362 | 363 | 364 | # ------------------------------------------------------------------------------------------------------------------------- 365 | 366 | # vupdate is a function that provides a UI to check for script updates and allows you to install the latest version... 367 | vupdate () { 368 | updatecheck # Check for the latest version from source repository 369 | clear 370 | logoNM 371 | echo "" 372 | echo -e "${CGreen}RTRMON Update Utility${CClear}" 373 | echo "" 374 | echo -e "${CCyan}Current Version: ${CYellow}$Version${CClear}" 375 | echo -e "${CCyan}Updated Version: ${CYellow}$DLVersion${CClear}" 376 | echo "" 377 | if [ "$Version" == "$DLVersion" ] 378 | then 379 | echo -e "${CGreen}No update available. You are on the latest version!${CClear}" 380 | echo "" 381 | read -rsp $'Press any key to continue...\n' -n1 key 382 | return 383 | else 384 | echo -e "${CCyan}Would you like to update to the latest version?${CClear}" 385 | if promptyn "(y/n): "; then 386 | echo "" 387 | echo -e "${CCyan}Updating RTRMON to ${CYellow}v$DLVersion${CClear}" 388 | curl --silent --retry 3 "https://raw.githubusercontent.com/ViktorJp/RTRMON/master/rtrmon-$DLVersion.sh" -o "/jffs/scripts/rtrmon.sh" && chmod a+rx "/jffs/scripts/rtrmon.sh" 389 | echo "" 390 | echo -e "${CCyan}Update successful!${CClear}" 391 | echo -e "$(date) - RTRMON - Successfully updated RTRMON from v$Version to v$DLVersion" >> $LOGFILE 392 | echo "" 393 | echo -e "${CYellow}Please exit, restart and configure new options using: 'rtrmon.sh -config'.${CClear}" 394 | echo -e "${CYellow}NOTE: New features may have been added that require your input to take${CClear}" 395 | echo -e "${CYellow}advantage of its full functionality.${CClear}" 396 | echo "" 397 | read -rsp $'Press any key to continue...\n' -n1 key 398 | return 399 | else 400 | echo "" 401 | echo "" 402 | echo -e "${CGreen}Exiting Update Utility...${CClear}" 403 | sleep 1 404 | return 405 | fi 406 | fi 407 | } 408 | 409 | # ------------------------------------------------------------------------------------------------------------------------- 410 | 411 | # vsetup is a function that sets up, confiures and allows you to launch RTRMON on your router... 412 | vsetup () { 413 | 414 | # Check for and add an alias for RTRMON 415 | if ! grep -F "sh /jffs/scripts/rtrmon.sh" /jffs/configs/profile.add; then 416 | echo "alias rtrmon=\"sh /jffs/scripts/rtrmon.sh\" # RTRMON" >> /jffs/configs/profile.add 417 | fi 418 | 419 | while true; do 420 | clear 421 | logoNM 422 | echo "" 423 | echo -e "${CGreen}RTRMON Setup Utility${CClear}" # Provide main setup menu 424 | echo "" 425 | echo -e "${CGreen}----------------------------------------------------------------" 426 | echo -e "${CGreen}Operations" 427 | echo -e "${CGreen}----------------------------------------------------------------" 428 | echo -e "${InvDkGray}${CWhite} sc ${CClear}${CCyan}: Setup and Configure RTRMON" 429 | echo -e "${InvDkGray}${CWhite} fr ${CClear}${CCyan}: Force Re-install Entware Dependencies" 430 | echo -e "${InvDkGray}${CWhite} up ${CClear}${CCyan}: Check for latest updates" 431 | echo -e "${InvDkGray}${CWhite} vl ${CClear}${CCyan}: View logs" 432 | echo -e "${InvDkGray}${CWhite} un ${CClear}${CCyan}: Uninstall" 433 | echo -e "${InvDkGray}${CWhite} e ${CClear}${CCyan}: Exit" 434 | echo -e "${CGreen}----------------------------------------------------------------" 435 | if [ "$FromUI" == "0" ]; then 436 | echo -e "${CGreen}Launch" 437 | echo -e "${CGreen}----------------------------------------------------------------" 438 | echo -e "${InvDkGray}${CWhite} m1 ${CClear}${CCyan}: Launch RTRMON into Normal Monitoring Mode" 439 | echo -e "${InvDkGray}${CWhite} m2 ${CClear}${CCyan}: Launch RTRMON into Normal Monitoring Mode w/ Screen" 440 | echo -e "${CGreen}----------------------------------------------------------------" 441 | fi 442 | echo "" 443 | printf "Selection: " 444 | read -r InstallSelection 445 | 446 | # Execute chosen selections 447 | case "$InstallSelection" in 448 | 449 | sc) # Check for existence of entware, and if so proceed and install the timeout package, then run RTRMON -config 450 | clear 451 | if [ -f "/opt/bin/timeout" ] && [ -f "/opt/sbin/screen" ]; then 452 | vconfig 453 | else 454 | logoNM 455 | echo -e "${CYellow}Installing RTRMON...${CClear}" 456 | echo "" 457 | echo -e "${CCyan}Would you like to optionally install the CoreUtils-Timeout${CClear}" 458 | echo -e "${CCyan}and Screen utility? These utilities require you to have Entware${CClear}" 459 | echo -e "${CCyan}already installed using the AMTM tool. If Entware is present, the ${CClear}" 460 | echo -e "${CCyan}Timeout and Screen utilities will be downloaded and installed during${CClear}" 461 | echo -e "${CCyan}this setup process, and used by RTRMON.${CClear}" 462 | echo "" 463 | echo -e "${CGreen}CoreUtils-Timeout${CCyan} is a utility that provides more stability for${CClear}" 464 | echo -e "${CCyan}certain routers (like the RT-AC86U) which has a tendency to randomly${CClear}" 465 | echo -e "${CCyan}hang scripts running on this router model.${CClear}" 466 | echo "" 467 | echo -e "${CGreen}Screen${CCyan} is a utility that allows you to run SSH scripts in a standalone" 468 | echo -e "${CCyan}environment directly on the router itself, instead of running your" 469 | echo -e "${CCyan}commands or a script from a network-attached SSH client. This can" 470 | echo -e "${CCyan}provide greater stability due to it running from the router itself." 471 | echo "" 472 | [ -z "$(nvram get odmpid)" ] && RouterModel="$(nvram get productid)" || RouterModel="$(nvram get odmpid)" # Thanks @thelonelycoder for this logic 473 | echo -e "${CCyan}Your router model is: ${CYellow}$RouterModel" 474 | echo "" 475 | echo -e "${CCyan}Install?${CClear}" 476 | if promptyn "(y/n): " 477 | then 478 | if [ -d "/opt" ]; then # Does entware exist? If yes proceed, if no error out. 479 | echo "" 480 | echo -e "\n${CGreen}Updating Entware Packages...${CClear}" 481 | echo "" 482 | opkg update 483 | echo "" 484 | echo -e "${CGreen}Installing Entware CoreUtils-Timeout Package...${CClear}" 485 | echo "" 486 | opkg install coreutils-timeout 487 | echo -e "${CGreen}Installing Entware Screen Package...${CClear}" 488 | echo "" 489 | opkg install screen 490 | echo "" 491 | sleep 1 492 | echo -e "${CGreen}Executing RTRMON Configuration Utility...${CClear}" 493 | sleep 2 494 | vconfig 495 | else 496 | clear 497 | echo -e "${CGreen}ERROR: Entware was not found on this router...${CClear}" 498 | echo -e "${CGreen}Please install Entware using the AMTM utility before proceeding...${CClear}" 499 | echo "" 500 | sleep 3 501 | fi 502 | else 503 | echo "" 504 | echo -e "\n${CGreen}Executing RTRMON Configuration Utility...${CClear}" 505 | sleep 2 506 | vconfig 507 | fi 508 | fi 509 | ;; 510 | 511 | 512 | fr) # Force re-install the CoreUtils timeout/screen package 513 | clear 514 | logoNM 515 | echo "" 516 | echo -e "${CYellow}Force Re-installing CoreUtils-Timeout/Screen Packages...${CClear}" 517 | echo "" 518 | echo -e "${CCyan}Would you like to optionally re-install the CoreUtils-Timeout${CClear}" 519 | echo -e "${CCyan}and Screen utility? These utilities require you to have Entware${CClear}" 520 | echo -e "${CCyan}already installed using the AMTM tool. If Entware is present, the ${CClear}" 521 | echo -e "${CCyan}Timeout and Screen utilities will be downloaded and installed during${CClear}" 522 | echo -e "${CCyan}this setup process, and used by RTRMON.${CClear}" 523 | echo "" 524 | echo -e "${CGreen}CoreUtils-Timeout${CCyan} is a utility that provides more stability for${CClear}" 525 | echo -e "${CCyan}certain routers (like the RT-AC86U) which has a tendency to randomly${CClear}" 526 | echo -e "${CCyan}hang scripts running on this router model.${CClear}" 527 | echo "" 528 | echo -e "${CGreen}Screen${CCyan} is a utility that allows you to run SSH scripts in a standalone" 529 | echo -e "${CCyan}environment directly on the router itself, instead of running your" 530 | echo -e "${CCyan}commands or a script from a network-attached SSH client. This can" 531 | echo -e "${CCyan}provide greater stability due to it running from the router itself." 532 | echo "" 533 | [ -z "$(nvram get odmpid)" ] && RouterModel="$(nvram get productid)" || RouterModel="$(nvram get odmpid)" # Thanks @thelonelycoder for this logic 534 | echo -e "${CCyan}Your router model is: ${CYellow}$RouterModel" 535 | echo "" 536 | echo -e "${CCyan}Force Re-install?${CClear}" 537 | if promptyn "(y/n): " 538 | then 539 | if [ -d "/opt" ]; then # Does entware exist? If yes proceed, if no error out. 540 | echo "" 541 | echo -e "\n${CGreen}Updating Entware Packages...${CClear}" 542 | echo "" 543 | opkg update 544 | echo "" 545 | echo -e "${CGreen}Force Re-installing Entware CoreUtils-Timeout Package...${CClear}" 546 | echo "" 547 | opkg install --force-reinstall coreutils-timeout 548 | echo -e "${CGreen}Force Re-installing Entware Screen Package...${CClear}" 549 | echo "" 550 | opkg install --force-reinstall screen 551 | echo "" 552 | echo -e "${CGreen}Re-install completed...${CClear}" 553 | sleep 2 554 | else 555 | clear 556 | echo -e "${CGreen}ERROR: Entware was not found on this router...${CClear}" 557 | echo -e "${CGreen}Please install Entware using the AMTM utility before proceeding...${CClear}" 558 | echo "" 559 | sleep 3 560 | fi 561 | fi 562 | ;; 563 | 564 | up) 565 | echo "" 566 | vupdate 567 | ;; 568 | 569 | m1) 570 | echo "" 571 | echo -e "\n${CGreen}Launching RTRMON into Monitor Mode...${CClear}" 572 | sleep 2 573 | sh $APPPATH -monitor 574 | ;; 575 | 576 | m2) 577 | echo "" 578 | echo -e "\n${CGreen}Launching RTRMON into Monitor Mode with Screen Utility...${CClear}" 579 | sleep 2 580 | sh $APPPATH -screen 581 | ;; 582 | 583 | vl) 584 | echo "" 585 | vlogs 586 | ;; 587 | 588 | un) 589 | echo "" 590 | vuninstall 591 | ;; 592 | 593 | e) 594 | echo -e "${CClear}" 595 | exit 0 596 | ;; 597 | 598 | *) 599 | echo "" 600 | echo -e "${CRed}Invalid choice - Please enter a valid option...${CClear}" 601 | echo "" 602 | sleep 2 603 | ;; 604 | 605 | esac 606 | done 607 | } 608 | 609 | # ------------------------------------------------------------------------------------------------------------------------- 610 | 611 | # get_wan_setting was "borrowed" graciously from @dave14305 from his FlexQoS script to determine the active WAN connection. 612 | # Thanks much for your troubleshooting help as we tackled how to best derive the active WAN interface, Dave! 613 | get_wan_setting() { 614 | local varname varval 615 | varname="${1}" 616 | prefixes="wan0_ wan1_" 617 | 618 | if [ "$($timeoutcmd$timeoutsec nvram get wans_mode)" = "lb" ] ; then 619 | for prefix in $prefixes; do 620 | state="$($timeoutcmd$timeoutsec nvram get "${prefix}"state_t)" 621 | sbstate="$($timeoutcmd$timeoutsec nvram get "${prefix}"sbstate_t)" 622 | auxstate="$($timeoutcmd$timeoutsec nvram get "${prefix}"auxstate_t)" 623 | 624 | # is_wan_connect() 625 | [ "${state}" = "2" ] || continue 626 | [ "${sbstate}" = "0" ] || continue 627 | [ "${auxstate}" = "0" ] || [ "${auxstate}" = "2" ] || continue 628 | 629 | # get_wan_ifname() 630 | proto="$($timeoutcmd$timeoutsec nvram get "${prefix}"proto)" 631 | if [ "${proto}" = "pppoe" ] || [ "${proto}" = "pptp" ] || [ "${proto}" = "l2tp" ] ; then 632 | varval="$($timeoutcmd$timeoutsec nvram get "${prefix}"pppoe_"${varname}")" 633 | else 634 | varval="$($timeoutcmd$timeoutsec nvram get "${prefix}""${varname}")" 635 | fi 636 | done 637 | else 638 | for prefix in $prefixes; do 639 | primary="$($timeoutcmd$timeoutsec nvram get "${prefix}"primary)" 640 | [ "${primary}" = "1" ] && break 641 | done 642 | 643 | proto="$($timeoutcmd$timeoutsec nvram get "${prefix}"proto)" 644 | if [ "${proto}" = "pppoe" ] || [ "${proto}" = "pptp" ] || [ "${proto}" = "l2tp" ] ; then 645 | varval="$($timeoutcmd$timeoutsec nvram get "${prefix}"pppoe_"${varname}")" 646 | else 647 | varval="$($timeoutcmd$timeoutsec nvram get "${prefix}""${varname}")" 648 | fi 649 | fi 650 | printf "%s" "${varval}" 651 | } # get_wan_setting 652 | 653 | # ------------------------------------------------------------------------------------------------------------------------- 654 | 655 | # gettopstats gathers the majority of cpu and memory related stats directly from the TOP utility 656 | gettopstats () { 657 | 658 | TotalMem=$(top -n 1 | awk 'NR==1 {print $2, $4, $6, $8, $10} NR==2 {print $2, $4, $6, $8} NR==3 {print $3, $4, $5}' 2>/dev/null) 659 | 660 | memused="$(echo $TotalMem | awk '{print $1}' | sed 's/K$//')" 661 | memfree="$(echo $TotalMem | awk '{print $2}' | sed 's/K$//')" 662 | memshrd="$(echo $TotalMem | awk '{print $3}' | sed 's/K$//')" 663 | membuff="$(echo $TotalMem | awk '{print $4}' | sed 's/K$//')" 664 | memcach="$(echo $TotalMem | awk '{print $5}' | sed 's/K$//')" 665 | cpuusr="$(echo $TotalMem | awk '{print $6}' | sed 's/%$//' | cut -d . -f 1)" 666 | cpusys="$(echo $TotalMem | awk '{print $7}' | sed 's/%$//' | cut -d . -f 1)" 667 | cpunice="$(echo $TotalMem | awk '{print $8}' | sed 's/%$//' | cut -d . -f 1)" 668 | cpuidle="$(echo $TotalMem | awk '{print $9}' | sed 's/%$//' | cut -d . -f 1)" 669 | displaycpuusr="$(echo $TotalMem | awk '{print $6}' | sed 's/%$//')" 670 | displaycpusys="$(echo $TotalMem | awk '{print $7}' | sed 's/%$//')" 671 | displaycpunice="$(echo $TotalMem | awk '{print $8}' | sed 's/%$//')" 672 | displaycpuidle="$(echo $TotalMem | awk '{print $9}' | sed 's/%$//')" 673 | cpuload1m="$(echo $TotalMem | awk '{print $10}')" 674 | cpuload5m="$(echo $TotalMem | awk '{print $11}')" 675 | cpuload15m="$(echo $TotalMem | awk '{print $12}')" 676 | 677 | memused1=$(($memused1 + $memused)) 678 | memfree1=$(($memfree1 + $memfree)) 679 | memshrd1=$(($memshrd1 + $memshrd)) 680 | membuff1=$(($membuff1 + $membuff)) 681 | memcach1=$(($memcach1 + $memcach)) 682 | cpuusr1=$(($cpuusr1 + $cpuusr)) 683 | cpusys1=$(($cpusys1 + $cpusys)) 684 | cpunice1=$(($cpunice1 + $cpunice)) 685 | cpuidle1=$(($cpuidle1 + $cpuidle)) 686 | displaycpuusr1=$(awk -v v1=$displaycpuusr1 -v v2=$displaycpuusr 'BEGIN{printf "%0.2f\n", v1+v2}') 687 | displaycpusys1=$(awk -v v1=$displaycpusys1 -v v2=$displaycpusys 'BEGIN{printf "%0.2f\n", v1+v2}') 688 | displaycpunice1=$(awk -v v1=$displaycpunice1 -v v2=$displaycpunice 'BEGIN{printf "%0.2f\n", v1+v2}') 689 | displaycpuidle1=$(awk -v v1=$displaycpuidle1 -v v2=$displaycpuidle 'BEGIN{printf "%0.2f\n", v1+v2}') 690 | 691 | # Borrowed this wonderful keypress capturing mechanism from @Eibgrad... thank you! :) 692 | key_press=''; read -rsn1 -t 1 key_press < "$(tty 0>&2)" 693 | 694 | if [ $key_press ]; then 695 | case $key_press in 696 | [Ss]) FromUI=1; (vsetup); echo -e "${CGreen} [Returning to the Main UI momentarily] "; FromUI=0;; 697 | [Nn]) if [ "$NextPage" == "1" ]; then NextPage=2; clear; DisplayPage2; echo -e "\n"; elif [ "$NextPage" == "2" ]; then NextPage=1; clear; DisplayPage1; echo -e "\n"; fi;; 698 | [Ee]) echo -e "${CClear}"; exit 0;; 699 | esac 700 | fi 701 | 702 | } 703 | 704 | # ------------------------------------------------------------------------------------------------------------------------- 705 | 706 | # oldstats holds the old (current) stats that are being used to display stats on-screen 707 | oldstats () { 708 | 709 | oldcpuusr1=$cpuusr1 710 | oldcpusys1=$cpusys1 711 | oldcpunice1=$cpunice1 712 | oldcpuidle1=$cpuidle1 713 | olddisplaycpuusr1=$displaycpuusr1 714 | olddisplaycpusys1=$displaycpusys1 715 | olddisplaycpunice1=$displaycpunice1 716 | olddisplaycpuidle1=$displaycpuidle1 717 | oldF_cputemp=$F_cputemp 718 | oldmemused2=$memused2 719 | oldmemfree2=$memfree2 720 | oldmemshrd2=$memshrd2 721 | oldmembuff2=$membuff2 722 | oldmemcach2=$memcach2 723 | oldtotalmemory=$totalmemory 724 | oldnvramfree=$nvramfree 725 | oldnvramused=$nvramused 726 | oldtotalnvram=$totalnvram 727 | oldjffstotal=$jffstotal 728 | oldjffsused=$jffsused 729 | oldswaptotal=$swaptotal 730 | oldswapused=$swapused 731 | oldwanrxmbrate=$wanrxmbrate 732 | oldwantxmbrate=$wantxmbrate 733 | oldw24rxmbrate=$w24rxmbrate 734 | oldw24txmbrate=$w24txmbrate 735 | oldw5rxmbrate=$w5rxmbrate 736 | oldw5txmbrate=$w5txmbrate 737 | oldw0temp=$w0temp 738 | oldw1temp=$w1temp 739 | oldlanrxmbrate=$lanrxmbrate 740 | oldlantxmbrate=$lantxmbrate 741 | 742 | } 743 | 744 | # ------------------------------------------------------------------------------------------------------------------------- 745 | 746 | # calculatestats calculates, well, all the current stats ;) 747 | calculatestats () { 748 | 749 | RM_END_TIME=$(date +%s) 750 | RM_ELAPSED_TIME=$(( RM_END_TIME - RM_START_TIME )) 751 | 752 | # CPU - Usage 753 | if [ ! -z $cpuusr1 ]; then cpuusr1=$(($cpuusr1 / $Interval)); else cpuusr1=0; fi 754 | if [ ! -z $cpusys1 ]; then cpusys1=$(($cpusys1 / $Interval)); else cpusys1=0; fi 755 | if [ ! -z $cpunice1 ]; then cpunice1=$(($cpunice1 / $Interval)); else cpunice1=0; fi 756 | if [ ! -z $cpuidle1 ]; then cpuidle1=$(($cpuidle1 / $Interval)); else cpuidle1=0; fi 757 | if [ ! -z $displaycpuusr1 ]; then displaycpuusr1=$(awk -v rb=$displaycpuusr1 -v intv=$Interval 'BEGIN{printf "%0.2f\n", rb/intv}'); else displaycpuusr1=0; fi 758 | if [ ! -z $displaycpusys1 ]; then displaycpusys1=$(awk -v rb=$displaycpusys1 -v intv=$Interval 'BEGIN{printf "%0.2f\n", rb/intv}'); else displaycpusys1=0; fi 759 | if [ ! -z $displaycpunice1 ]; then displaycpunice1=$(awk -v rb=$displaycpunice1 -v intv=$Interval 'BEGIN{printf "%0.2f\n", rb/intv}'); else displaycpunice1=0; fi 760 | if [ ! -z $displaycpuidle1 ]; then displaycpuidle1=$(awk -v rb=$displaycpuidle1 -v intv=$Interval 'BEGIN{printf "%0.2f\n", rb/intv}'); else displaycpuidle1=0; fi 761 | 762 | # CPU - Temp - borrowed from @Maverickcdn - thank you! 763 | F_cputemp=$($timeoutcmd$timeoutsec cat /sys/class/thermal/thermal_zone0/temp | cut -c -2) 764 | 765 | # Memory - Usage 766 | if [ ! -z $memused1 ]; then memused1=$(($memused1 / $Interval)); else memused1=0; fi 767 | if [ ! -z $memfree1 ]; then memfree1=$(($memfree1 / $Interval)); else memfree1=0; fi 768 | if [ ! -z $memshrd1 ]; then memshrd1=$(($memshrd1 / $Interval)); else memshrd1=0; fi 769 | if [ ! -z $membuff1 ]; then membuff1=$(($membuff1 / $Interval)); else membuff1=0; fi 770 | if [ ! -z $memcach1 ]; then memcach1=$(($memcach1 / $Interval)); else memcach1=0; fi 771 | 772 | memused2=$(($memused1 / 1024 )) 773 | memfree2=$(($memfree1 / 1024 )) 774 | memshrd2=$(($memshrd1 / 1024 )) 775 | membuff2=$(($membuff1 / 1024 )) 776 | memcach2=$(($memcach1 / 1024 )) 777 | totalmemory=$((($memused1 + $memfree1) / 1024 )) 778 | 779 | # Memory - NVRAM -- Many thanks to @RMerlin, @SomewhereOverTheRainbow and @Ranger802004 for your help finding NVRAM stats 780 | $($timeoutcmd$timeoutsec nvram show >/tmp/output.txt 2> /tmp/size.txt) 781 | chmod 755 /tmp/size.txt 782 | nvramtotals=$(awk '{print $2, $4}' /tmp/size.txt 2>/dev/null) 783 | nvramused="$(echo $nvramtotals | awk '{print $1}')" 784 | nvramfree="$(echo $nvramtotals | awk '{print $2}' | sed 's/[)(]//g')" 785 | totalnvram=$(($nvramused + $nvramfree)) 786 | 787 | # Disk - JFFS 788 | disk_use=$(df -P | grep /dev | grep -v -E '(tmp|boot)' | awk '{print $2, $3}') 789 | jffstotal="$(echo $disk_use | awk '{print $1}')" 790 | jffsused="$(echo $disk_use | awk '{print $2}')" 791 | jffstotal="$(($jffstotal / 1024))" 792 | jffsused="$(($jffsused / 1024))" 793 | 794 | # Disk - Swap file 795 | swap_use=$(free | awk 'NR==4 {print $2, $3}' 2>/dev/null) 796 | swaptotal="$(echo $swap_use | awk '{print $1}')" 797 | swapused="$(echo $swap_use | awk '{print $2}')" 798 | swaptotal="$(($swaptotal / 1024))" 799 | swapused="$(($swapused / 1024))" 800 | 801 | # Network - Wifi - Temp 802 | ifname24=$($timeoutcmd$timeoutsec nvram get wl0_ifname) 803 | ifname5=$($timeoutcmd$timeoutsec nvram get wl1_ifname) 804 | w0tempraw=$($timeoutcmd$timeoutsec wl -i $ifname24 phy_tempsense | awk '{print $1}' ) 805 | w1tempraw=$($timeoutcmd$timeoutsec wl -i $ifname5 phy_tempsense | awk '{print $1}' ) 806 | if [ -z $w0tempraw ] || [ $w0tempraw -eq 0 ]; then w0tempraw=4; fi #in case it does not return a valid number 807 | if [ -z $w1tempraw ] || [ $w1tempraw -eq 0 ]; then w1tempraw=4; fi 808 | w0temp=$(awk -v v1=$w0tempraw 'BEGIN{printf "\n" (v1/2)+20}' | cut -d . -f 1) 809 | w1temp=$(awk -v v1=$w1tempraw 'BEGIN{printf "\n" (v1/2)+20}' | cut -d . -f 1) 810 | 811 | # Network - Wifi - Traffic 812 | ifname24=$($timeoutcmd$timeoutsec nvram get wl0_ifname) 813 | ifname5=$($timeoutcmd$timeoutsec nvram get wl1_ifname) 814 | new24rxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$ifname24/statistics/rx_bytes)" 815 | new24txbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$ifname24/statistics/tx_bytes)" 816 | new5rxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$ifname5/statistics/rx_bytes)" 817 | new5txbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$ifname5/statistics/tx_bytes)" 818 | 819 | # Network - LAN - Traffic 820 | newlanrxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/br0/statistics/rx_bytes)" 821 | newlantxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/br0/statistics/tx_bytes)" 822 | 823 | # Network - WAN - Traffic 824 | WANIFNAME=$(get_wan_setting ifname) 825 | newwanrxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$WANIFNAME/statistics/rx_bytes)" 826 | newwantxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$WANIFNAME/statistics/tx_bytes)" 827 | 828 | # Network - Traffic - Calculations to find the difference between old and new total bytes send/received and divided to give Megabits 829 | diffwanrxbytes=$(awk -v new=$newwanrxbytes -v old=$oldwanrxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 830 | diffwantxbytes=$(awk -v new=$newwantxbytes -v old=$oldwantxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 831 | diff24rxbytes=$(awk -v new=$new24rxbytes -v old=$old24rxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 832 | diff24txbytes=$(awk -v new=$new24txbytes -v old=$old24txbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 833 | diff5rxbytes=$(awk -v new=$new5rxbytes -v old=$old5rxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 834 | diff5txbytes=$(awk -v new=$new5txbytes -v old=$old5txbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 835 | difflanrxbytes=$(awk -v new=$newlanrxbytes -v old=$oldlanrxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 836 | difflantxbytes=$(awk -v new=$newlantxbytes -v old=$oldlantxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 837 | 838 | # Network - Traffic - Results are further divided by the timer/interval to give Megabits/sec 839 | wanrxmbrate=$(awk -v rb=$diffwanrxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", rb/intv}' | cut -d . -f 1) 840 | wantxmbrate=$(awk -v tb=$diffwantxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", tb/intv}' | cut -d . -f 1) 841 | w24rxmbrate=$(awk -v rb=$diff24rxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", rb/intv}' | cut -d . -f 1) 842 | w24txmbrate=$(awk -v tb=$diff24txbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", tb/intv}' | cut -d . -f 1) 843 | w5rxmbrate=$(awk -v rb=$diff5rxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", rb/intv}' | cut -d . -f 1) 844 | w5txmbrate=$(awk -v tb=$diff5txbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", tb/intv}' | cut -d . -f 1) 845 | lanrxmbrate=$(awk -v rb=$difflanrxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", rb/intv}' | cut -d . -f 1) 846 | lantxmbrate=$(awk -v tb=$difflantxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", tb/intv}' | cut -d . -f 1) 847 | 848 | # Uptime calc 849 | uptime=$(awk '{printf("%03dd %02dh %02dm %02ds\n",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}' /proc/uptime) 850 | } 851 | 852 | # ------------------------------------------------------------------------------------------------------------------------- 853 | 854 | # This function displays the stats UI for page 1 855 | DisplayPage1 () { 856 | logo 857 | if [ "$UpdateNotify" != "0" ]; then 858 | echo -e "${CRed} $UpdateNotify${CClear}" 859 | echo -e "${CGreen} ___${CClear}" 860 | else 861 | echo -e "${CGreen} ___${CClear}" 862 | fi 863 | echo -e "${CGreen}/${CRed}CPU${CClear}${CGreen}\_____________________________________________________________${CClear}" 864 | echo "" 865 | echo -e " ${CCyan}Uptime ${CGreen}[ ${CCyan}$uptime${CGreen} ]${CClear}" 866 | echo -e " ${CCyan}CPU Load ${CGreen}[ 1m: ${CCyan}$cpuload1m ${CGreen}5m: ${CCyan}$cpuload5m ${CGreen}15m: ${CCyan}$cpuload15m${CGreen} ]" 867 | preparebar 35 "|" 868 | progressbar $oldcpuusr1 100 " CPU User " "%%" "Standard" $olddisplaycpuusr1 869 | echo "" 870 | preparebar 35 "|" 871 | progressbar $oldcpusys1 100 " CPU System" "%%" "Standard" $olddisplaycpusys1 872 | echo "" 873 | preparebar 35 "|" 874 | progressbar $oldcpunice1 100 " CPU Nice " "%%" "Standard" $olddisplaycpunice1 875 | echo "" 876 | preparebar 35 "|" 877 | progressbar $oldcpuidle1 100 " CPU Idle " "%%" "Reverse" $olddisplaycpuidle1 878 | echo "" 879 | preparebar 35 "|" 880 | converttemps $oldF_cputemp 881 | progressbar $currenttemp $currentrange " CPU Temp " $TempUnits "Standard" 882 | echo "" 883 | echo -e "${CGreen} ______" 884 | echo -e "${CGreen}/${CRed}Memory${CClear}${CGreen}\__________________________________________________________${CClear}" 885 | echo "" 886 | preparebar 35 "|" 887 | progressbar $oldmemused2 $oldtotalmemory " Mem Used " "MB" "Standard" 888 | echo "" 889 | preparebar 35 "|" 890 | progressbar $oldmemfree2 $oldtotalmemory " Mem Free " "MB" "Standard" 891 | echo "" 892 | preparebar 35 "|" 893 | progressbar $oldmemshrd2 $oldtotalmemory " Mem Shared" "MB" "Standard" 894 | echo "" 895 | preparebar 35 "|" 896 | progressbar $oldmembuff2 $oldtotalmemory " Mem Buffer" "MB" "Standard" 897 | echo "" 898 | preparebar 35 "|" 899 | progressbar $oldmemcach2 $oldtotalmemory " Mem Cache " "MB" "Standard" 900 | echo "" 901 | preparebar 35 "|" 902 | progressbar $oldnvramused $oldtotalnvram " NVRAM Used" "B" "Standard" 903 | echo "" 904 | echo -e "${CGreen} ____" 905 | echo -e "${CGreen}/${CRed}Disk${CClear}${CGreen}\____________________________________________________________${CClear}" 906 | echo "" 907 | preparebar 35 "|" 908 | progressbar $oldjffsused $oldjffstotal " JFFS Used " "MB" "Standard" 909 | echo "" 910 | preparebar 35 "|" 911 | progressbar $oldswapused $oldswaptotal " Swap Used " "MB" "Standard" 912 | } 913 | 914 | # ------------------------------------------------------------------------------------------------------------------------- 915 | 916 | # This function displays the stats UI for page 2 917 | DisplayPage2 () { 918 | logo 919 | if [ "$UpdateNotify" != "0" ]; then 920 | echo -e "${CRed} $UpdateNotify${CClear}" 921 | echo -e "${CGreen} ___${CClear}" 922 | else 923 | echo -e "${CGreen} ___${CClear}" 924 | fi 925 | echo -e "${CGreen}/${CRed}WAN${CClear}${CGreen}\_____________________________________________________________${CClear}" 926 | echo "" 927 | preparebar 35 "|" 928 | progressbar $oldwanrxmbrate $MaxSpeedInet " Avg WAN RX" "Mbps" "Standard" 929 | echo "" 930 | preparebar 35 "|" 931 | progressbar $oldwantxmbrate $MaxSpeedInet " Avg WAN TX" "Mbps" "Standard" 932 | echo "" 933 | echo -e "${CGreen} ___" 934 | echo -e "${CGreen}/${CRed}LAN${CClear}${CGreen}\_____________________________________________________________${CClear}" 935 | echo "" 936 | preparebar 35 "|" 937 | progressbar $oldlanrxmbrate $MaxSpeedLAN " Avg LAN RX" "Mbps" "Standard" 938 | echo "" 939 | preparebar 35 "|" 940 | progressbar $oldlantxmbrate $MaxSpeedLAN " Avg LAN TX" "Mbps" "Standard" 941 | echo "" 942 | echo -e "${CGreen} ____" 943 | echo -e "${CGreen}/${CRed}WiFi${CClear}${CGreen}\____________________________________________________________${CClear}" 944 | echo "" 945 | if [ "$MaxSpeed24Ghz" != "0" ]; then 946 | preparebar 35 "|" 947 | progressbar $oldw24rxmbrate $MaxSpeed24Ghz " Avg 24G RX" "Mbps" "Standard" 948 | echo "" 949 | preparebar 35 "|" 950 | progressbar $oldw24txmbrate $MaxSpeed24Ghz " Avg 24G TX" "Mbps" "Standard" 951 | echo "" 952 | preparebar 35 "|" 953 | converttemps $oldw0temp 954 | progressbar $currenttemp $currentrange " 2.4G Temp " $TempUnits "Standard" 955 | echo "" 956 | echo "" 957 | else 958 | echo -e "${InvCyan} ${CClear}${CCyan} W0 Disabled" 959 | echo "" 960 | fi 961 | if [ "$MaxSpeed5Ghz" != "0" ]; then 962 | preparebar 35 "|" 963 | progressbar $oldw5rxmbrate $MaxSpeed5Ghz " Avg 50G RX" "Mbps" "Standard" 964 | echo "" 965 | preparebar 35 "|" 966 | progressbar $oldw5txmbrate $MaxSpeed5Ghz " Avg 50G TX" "Mbps" "Standard" 967 | echo "" 968 | preparebar 35 "|" 969 | converttemps $oldw1temp 970 | progressbar $currenttemp $currentrange " 5.0G Temp " $TempUnits "Standard" 971 | else 972 | echo -e "${InvCyan} ${CClear}${CCyan} W1 Disabled" 973 | fi 974 | } 975 | 976 | # ------------------------------------------------------------------------------------------------------------------------- 977 | # Begin Commandline Argument Gatekeeper and Configuration Utility Functionality 978 | # ------------------------------------------------------------------------------------------------------------------------- 979 | 980 | #DEBUG=; set -x # uncomment/comment to enable/disable debug mode 981 | #{ # uncomment/comment to enable/disable debug mode 982 | 983 | # Create the necessary folder/file structure for RTRMON under /jffs/addons 984 | if [ ! -d "/jffs/addons/rtrmon.d" ]; then 985 | mkdir -p "/jffs/addons/rtrmon.d" 986 | fi 987 | 988 | # Check for Updates 989 | updatecheck 990 | 991 | # Check and see if any commandline option is being used 992 | if [ $# -eq 0 ] 993 | then 994 | clear 995 | echo "" 996 | echo "RTRMON v$Version" 997 | echo "" 998 | echo "Exiting due to missing commandline options!" 999 | echo "(run 'rtrmon.sh -h' for help)" 1000 | echo "" 1001 | echo -e "${CClear}" 1002 | exit 0 1003 | fi 1004 | 1005 | # Check and see if an invalid commandline option is being used 1006 | if [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$1" == "-config" ] || [ "$1" == "-monitor" ] || [ "$1" == "-log" ] || [ "$1" == "-update" ] || [ "$1" == "-setup" ] || [ "$1" == "-uninstall" ] || [ "$1" == "-screen" ] || [ "$1" == "-reset" ] 1007 | then 1008 | clear 1009 | else 1010 | clear 1011 | echo "" 1012 | echo "RTRMON v$Version" 1013 | echo "" 1014 | echo "Exiting due to invalid commandline options!" 1015 | echo "(run 'rtrmon.sh -h' for help)" 1016 | echo "" 1017 | echo -e "${CClear}" 1018 | exit 0 1019 | fi 1020 | 1021 | # Check to see if the help option is being called 1022 | if [ "$1" == "-h" ] || [ "$1" == "-help" ] 1023 | then 1024 | clear 1025 | echo "" 1026 | echo "RTRMON v$Version Commandline Option Usage:" 1027 | echo "" 1028 | echo "rtrmon.sh -h | -help" 1029 | echo "rtrmon.sh -log" 1030 | echo "rtrmon.sh -config" 1031 | echo "rtrmon.sh -update" 1032 | echo "rtrmon.sh -setup" 1033 | echo "rtrmon.sh -uninstall" 1034 | echo "rtrmon.sh -screen" 1035 | echo "rtrmon.sh -monitor" 1036 | echo "" 1037 | echo " -h | -help (this output)" 1038 | echo " -log (display the current log contents)" 1039 | echo " -config (configuration/setup utility)" 1040 | echo " -update (script update utility)" 1041 | echo " -setup (setup/dependencies utility)" 1042 | echo " -uninstall (uninstall utility)" 1043 | echo " -screen (normal router monitoring using the screen utility)" 1044 | echo " -monitor (normal router monitoring operations)" 1045 | echo "" 1046 | echo -e "${CClear}" 1047 | exit 0 1048 | fi 1049 | 1050 | # Check to see if the log option is being called, and display through nano 1051 | if [ "$1" == "-log" ] 1052 | then 1053 | vlogs 1054 | exit 0 1055 | fi 1056 | 1057 | # Check to see if the configuration option is being called, and run through setup utility 1058 | if [ "$1" == "-config" ] 1059 | then 1060 | vconfig 1061 | echo -e "${CClear}" 1062 | exit 0 1063 | fi 1064 | 1065 | # Check to see if the update option is being called 1066 | if [ "$1" == "-update" ] 1067 | then 1068 | vupdate 1069 | echo -e "${CClear}" 1070 | exit 0 1071 | fi 1072 | 1073 | # Check to see if the install option is being called 1074 | if [ "$1" == "-setup" ] 1075 | then 1076 | vsetup 1077 | fi 1078 | 1079 | # Check to see if the uninstall option is being called 1080 | if [ "$1" == "-uninstall" ] 1081 | then 1082 | vuninstall 1083 | echo -e "${CClear}" 1084 | exit 0 1085 | fi 1086 | 1087 | # Check to see if the screen option is being called and run operations normally using the screen utility 1088 | if [ "$1" == "-screen" ] 1089 | then 1090 | ScreenSess=$(screen -ls | grep "rtrmon" | awk '{print $1}' | cut -d . -f 1) 1091 | if [ -z $ScreenSess ]; then 1092 | clear 1093 | echo -e "${CGreen}Executing RTRMON using the SCREEN utility...${CClear}" 1094 | echo "" 1095 | echo -e "${CGreen}Reconnect at any time using the command 'screen -r rtrmon'${CClear}" 1096 | echo -e "${CGreen}To exit the SCREEN session, type: CTRL-A + D${CClear}" 1097 | echo "" 1098 | screen -dmS "rtrmon" $APPPATH -monitor 1099 | sleep 2 1100 | read -rsp $'Press any key to continue...\n' -n1 key 1101 | echo -e "${CClear}" 1102 | exit 0 1103 | else 1104 | clear 1105 | echo -e "${CGreen}Another RTRMON Screen session is already running...${CClear}" 1106 | echo -e "${CGreen}Would you like to attach to this session?${CClear}" 1107 | if promptyn "(y/n): "; then 1108 | screen -dr $ScreenSess 1109 | sleep 2 1110 | echo -e "${CClear}" 1111 | exit 0 1112 | else 1113 | echo "" 1114 | echo -e "\n${CGreen}Exiting...${CClear}" 1115 | sleep 1 1116 | return 1117 | fi 1118 | fi 1119 | fi 1120 | 1121 | # Check to see if the monitor option is being called and run operations normally 1122 | if [ "$1" == "-monitor" ] 1123 | then 1124 | clear 1125 | if [ -f $CFGPATH ]; then 1126 | source $CFGPATH 1127 | 1128 | if [ -f "/opt/bin/timeout" ] # If the timeout utility is available then use it and assign variables 1129 | then 1130 | timeoutcmd="timeout " 1131 | timeoutsec="10" 1132 | timeoutlng="60" 1133 | else 1134 | timeoutcmd="" 1135 | timeoutsec="" 1136 | timeoutlng="" 1137 | fi 1138 | 1139 | if [ "$DelayStartup" != "0" ] 1140 | then 1141 | SPIN=$DelayStartup 1142 | echo -e "${CGreen}Delaying RTRMON start-up for $DelayStartup seconds..." 1143 | spinner 1144 | fi 1145 | 1146 | else 1147 | echo -e "${CRed}Error: RTRMON is not configured. Please run 'rtrmon.sh -setup' to complete setup${CClear}" 1148 | echo "" 1149 | echo -e "$(date) - RTRMON ----------> ERROR: rtrmon.cfg was not found. Please run the setup tool." >> $LOGFILE 1150 | kill 0 1151 | fi 1152 | fi 1153 | 1154 | # ------------------------------------------------------------------------------------------------------------------------- 1155 | # Main RTRMON program initialization 1156 | # ------------------------------------------------------------------------------------------------------------------------- 1157 | 1158 | # Display the logo and indicator that stats are being gathered. 1159 | clear 1160 | logoNM 1161 | echo "" 1162 | echo -e " ${CGreen}[Initiating Boot Sequence - Gathering Initial Stats...]" 1163 | echo "" 1164 | 1165 | # Capture Traffic and store current WAN/WiFi bytes stats 1166 | WANIFNAME=$(get_wan_setting ifname) 1167 | oldwanrxbytes="$(cat /sys/class/net/$WANIFNAME/statistics/rx_bytes)" 1168 | oldwantxbytes="$(cat /sys/class/net/$WANIFNAME/statistics/tx_bytes)" 1169 | 1170 | ifname24=$($timeoutcmd$timeoutsec nvram get wl0_ifname) 1171 | ifname5=$($timeoutcmd$timeoutsec nvram get wl1_ifname) 1172 | old24rxbytes="$(cat /sys/class/net/$ifname24/statistics/rx_bytes)" 1173 | old24txbytes="$(cat /sys/class/net/$ifname24/statistics/tx_bytes)" 1174 | old5rxbytes="$(cat /sys/class/net/$ifname5/statistics/rx_bytes)" 1175 | old5txbytes="$(cat /sys/class/net/$ifname5/statistics/tx_bytes)" 1176 | 1177 | oldlanrxbytes="$(cat /sys/class/net/br0/statistics/rx_bytes)" 1178 | oldlantxbytes="$(cat /sys/class/net/br0/statistics/tx_bytes)" 1179 | 1180 | # Get initial TOP stats to average across the interval period 1181 | 1182 | RM_ELAPSED_TIME=0 1183 | RM_START_TIME=$(date +%s) 1184 | i=0 1185 | while [ $i -ne $Interval ] 1186 | do 1187 | i=$(($i+1)) 1188 | gettopstats $i 1189 | preparebar 53 "|" 1190 | progressbar $i $Interval "" "s" "Standard" 1191 | done 1192 | 1193 | calculatestats 1194 | oldstats 1195 | clear 1196 | 1197 | # ------------------------------------------------------------------------------------------------------------------------- 1198 | # Main loop that calls functions to perform all necessary calculations across the interval period 1199 | # ------------------------------------------------------------------------------------------------------------------------- 1200 | 1201 | while true; do 1202 | 1203 | if [ "$NextPage" == "1" ]; then 1204 | clear 1205 | DisplayPage1 1206 | echo "" 1207 | elif [ "$NextPage" == "2" ]; then 1208 | clear 1209 | DisplayPage2 1210 | echo "" 1211 | fi 1212 | 1213 | # Reset stats after the UI has finished drawing 1214 | memused1=0 1215 | memfree1=0 1216 | memshrd1=0 1217 | membuff1=0 1218 | memcach1=0 1219 | memused2=0 1220 | memfree2=0 1221 | memshrd2=0 1222 | membuff2=0 1223 | memcach2=0 1224 | cpuusr1=0 1225 | cpusys1=0 1226 | cpunice1=0 1227 | cpuidle1=0 1228 | displaycpuusr1=0 1229 | displaycpusys1=0 1230 | displaycpunice1=0 1231 | displaycpuidle1=0 1232 | 1233 | # Get fresh WAN stats 1234 | oldwanrxbytes="$(cat /sys/class/net/$WANIFNAME/statistics/rx_bytes)" 1235 | oldwantxbytes="$(cat /sys/class/net/$WANIFNAME/statistics/tx_bytes)" 1236 | old24rxbytes="$(cat /sys/class/net/$ifname24/statistics/rx_bytes)" 1237 | old24txbytes="$(cat /sys/class/net/$ifname24/statistics/tx_bytes)" 1238 | old5rxbytes="$(cat /sys/class/net/$ifname5/statistics/rx_bytes)" 1239 | old5txbytes="$(cat /sys/class/net/$ifname5/statistics/tx_bytes)" 1240 | oldlanrxbytes="$(cat /sys/class/net/br0/statistics/rx_bytes)" 1241 | oldlantxbytes="$(cat /sys/class/net/br0/statistics/tx_bytes)" 1242 | 1243 | # Run through the stats gathering loop based on the current interval 1244 | echo "" 1245 | RM_ELAPSED_TIME=0 1246 | RM_START_TIME=$(date +%s) 1247 | i=0 1248 | while [ $i -ne $Interval ] 1249 | do 1250 | i=$(($i+1)) 1251 | gettopstats $i 1252 | preparebar 46 "|" 1253 | progressbar $i $Interval "" "s" "Standard" 1254 | done 1255 | 1256 | # Do a fresh round of stats and save them to the old stats for display purposes 1257 | calculatestats 1258 | oldstats 1259 | clear 1260 | 1261 | done 1262 | 1263 | exit 0 1264 | 1265 | #} #2>&1 | tee $LOG | logger -t $(basename $0)[$$] # uncomment/comment to enable/disable debug mode 1266 | -------------------------------------------------------------------------------- /archive/rtrmon-1.0RC1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # RTRMON v1.0RC1 - Asus-Merlin Router Monitor 4 | # RTRMON is a shell script that provides near-realtime stats about your Asus-Merlin firmware router. Instead of having to 5 | # find this information on various different screens or apps, this tool was built to bring all this info together in one 6 | # stat dashboard. Having a 'system' dashboard showing current CPU, Memory, Disk and Network stats would compiment other 7 | # dashboard-like scripts greatly (like RTRMON), sitting side-by-side in their own SSH windows to give you everything 8 | # you need to know with a glance at your screen. 9 | # 10 | # Please use the 'rtrmon.sh -setup' to configure the necessary parameters that match your environment the best! 11 | # 12 | # ------------------------------------------------------------------------------------------------------------------------- 13 | # System Variables (Do not change beyond this point or this may change the programs ability to function correctly) 14 | # ------------------------------------------------------------------------------------------------------------------------- 15 | Version="1.0RC1" 16 | Beta=0 17 | LOGFILE="/jffs/addons/rtrmon.d/rtrmon.log" # Logfile path/name that captures important date/time events - change 18 | APPPATH="/jffs/scripts/rtrmon.sh" # Path to the location of rtrmon.sh 19 | CFGPATH="/jffs/addons/rtrmon.d/rtrmon.cfg" # Path to the location of rtrmon.cfg 20 | DLVERPATH="/jffs/addons/rtrmon.d/version.txt" # Path to downloaded version from the source repository 21 | 22 | FromUI=0 23 | NextPage=1 24 | memused1=0 25 | memfree1=0 26 | memshrd1=0 27 | membuff1=0 28 | memcach1=0 29 | memused2=0 30 | memfree2=0 31 | memshrd2=0 32 | membuff2=0 33 | memcach2=0 34 | cpuusr1=0 35 | cpusys1=0 36 | cpunice1=0 37 | cpuidle1=0 38 | displaycpuusr1=0 39 | displaycpusys1=0 40 | displaycpunice1=0 41 | displaycpuidle1=0 42 | 43 | # Color variables 44 | CBlack="\e[1;30m" 45 | InvBlack="\e[1;40m" 46 | CRed="\e[1;31m" 47 | InvRed="\e[1;41m" 48 | CGreen="\e[1;32m" 49 | InvGreen="\e[1;42m" 50 | InvDkGray="\e[1;100m" 51 | InvLtGray="\e[1;47m" 52 | CYellow="\e[1;33m" 53 | InvYellow="\e[1;43m" 54 | CBlue="\e[1;34m" 55 | InvBlue="\e[1;44m" 56 | CMagenta="\e[1;35m" 57 | CCyan="\e[1;36m" 58 | InvCyan="\e[1;46m" 59 | CWhite="\e[1;37m" 60 | InvWhite="\e[1;107m" 61 | CClear="\e[0m" 62 | 63 | # ------------------------------------------------------------------------------------------------------------------------- 64 | # Functions 65 | # ------------------------------------------------------------------------------------------------------------------------- 66 | 67 | # Logo is a function that displays the RTRMON script name in a cool ASCII font 68 | logo () { 69 | echo -e "${CYellow} ____ __________ __ _______ _ __" 70 | echo -e " / __ \/_ __/ __ \/ |/ / __ \/ | / / ${CGreen}v$Version${CYellow}" 71 | echo -e " / /_/ / / / / /_/ / /|_/ / / / / |/ / ${CRed}(S)${CGreen}etup${CYellow}" 72 | echo -e " / _, _/ / / / _, _/ / / / /_/ / /| / ${CRed}(N)${CGreen}ext Page ($NextPage/2)${CYellow}" 73 | echo -e " /_/ |_| /_/ /_/ |_/_/ /_/\____/_/ |_/ ${CRed}(E)${CGreen}xit${CClear}" 74 | } 75 | 76 | # ------------------------------------------------------------------------------------------------------------------------- 77 | 78 | # LogoNM is a function that displays the RTRMON script name in a cool ASCII font without menu options 79 | logoNM () { 80 | echo -e "${CYellow} ____ __________ __ _______ _ __" 81 | echo -e " / __ \/_ __/ __ \/ |/ / __ \/ | / / ${CGreen}v$Version${CYellow}" 82 | echo -e " / /_/ / / / / /_/ / /|_/ / / / / |/ /" 83 | echo -e " / _, _/ / / / _, _/ / / / /_/ / /| /" 84 | echo -e " /_/ |_| /_/ /_/ |_/_/ /_/\____/_/ |_/${CClear}" 85 | } 86 | 87 | # ------------------------------------------------------------------------------------------------------------------------- 88 | 89 | # promptyn takes input for Y/N questions 90 | promptyn () { # No defaults, just y or n 91 | while true; do 92 | read -p "[y/n]? " -n 1 -r yn 93 | case "${yn}" in 94 | [Yy]* ) return 0 ;; 95 | [Nn]* ) return 1 ;; 96 | * ) echo -e "\nPlease answer y or n.";; 97 | esac 98 | done 99 | } 100 | 101 | # ------------------------------------------------------------------------------------------------------------------------- 102 | 103 | # Preparebar and Progressbar is a script that provides a nice progressbar to show script activity 104 | preparebar() { 105 | # $1 - bar length 106 | # $2 - bar char 107 | #printf "\n" 108 | barlen=$1 109 | barspaces=$(printf "%*s" "$1") 110 | barchars=$(printf "%*s" "$1" | tr ' ' "$2") 111 | } 112 | 113 | # Had to make some mods to the variables being passed, and created an inverse colored progress bar 114 | progressbar() { 115 | # $1 - number (-1 for clearing the bar) 116 | # $2 - max number 117 | # $3 - system name 118 | # $4 - measurement 119 | # $5 - standard/reverse progressbar 120 | insertspc=" " 121 | 122 | if [ $1 -eq -1 ]; then 123 | printf "\r $barspaces\r" 124 | else 125 | barch=$(($1*barlen/$2)) 126 | barsp=$((barlen-barch)) 127 | progr=$((100*$1/$2)) 128 | 129 | if [ ! -z $6 ]; then AltNum=$6; else AltNum=$1; fi 130 | 131 | if [ "$5" == "Standard" ]; then 132 | if [ $progr -lt 60 ]; then 133 | printf "${InvGreen}${CWhite}$insertspc${CClear}${CGreen}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 134 | elif [ $progr -gt 59 ] && [ $progr -lt 85 ]; then 135 | printf "${InvYellow}${CBlack}$insertspc${CClear}${CYellow}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 136 | else 137 | printf "${InvRed}${CWhite}$insertspc${CClear}${CRed}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 138 | fi 139 | elif [ "$5" == "Reverse" ]; then 140 | if [ $progr -lt 35 ]; then 141 | printf "${InvRed}${CWhite}$insertspc${CClear}${CRed}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 142 | elif [ $progr -gt 35 ] && [ $progr -lt 85 ]; then 143 | printf "${InvYellow}${CBlack}$insertspc${CClear}${CYellow}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 144 | else 145 | printf "${InvGreen}${CWhite}$insertspc${CClear}${CGreen}${3} [%.${barch}s%.${barsp}s]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces" 146 | fi 147 | fi 148 | fi 149 | } 150 | 151 | # ------------------------------------------------------------------------------------------------------------------------- 152 | 153 | # converttemps is a function that converts temp readouts from C to F or K 154 | converttemps () { 155 | # $1 is the incoming C Temp 156 | 157 | if [ "$TempUnits" == "F" ]; then 158 | currenttemp=$(awk -v v1=$1 'BEGIN{printf "%0.2f\n", (v1*9)/5+32}' | cut -d . -f 1) 159 | currentrange=266 160 | elif [ "$TempUnits" == "K" ]; then 161 | currenttemp=$(awk -v v1=$1 'BEGIN{printf "%0.2f\n", v1+273}' | cut -d . -f 1) 162 | currentrange=403 163 | elif [ "$TempUnits" == "C" ]; then 164 | currenttemp=$1 165 | currentrange=130 166 | fi 167 | 168 | } 169 | 170 | # ------------------------------------------------------------------------------------------------------------------------- 171 | 172 | # updatecheck is a function that downloads the latest update version file, and compares it with what's currently installed 173 | updatecheck () { 174 | 175 | # Download the latest version file from the source repository 176 | curl --silent --retry 3 "https://raw.githubusercontent.com/ViktorJp/RTRMON/master/version.txt" -o "/jffs/addons/rtrmon.d/version.txt" 177 | 178 | if [ -f $DLVERPATH ] 179 | then 180 | # Read in its contents for the current version file 181 | DLVersion=$(cat $DLVERPATH) 182 | 183 | # Compare the new version with the old version and log it 184 | if [ "$Beta" == "1" ]; then # Check if Dev/Beta Mode is enabled and disable notification message 185 | UpdateNotify=0 186 | elif [ "$DLVersion" != "$Version" ]; then 187 | UpdateNotify="Update available: v$Version -> v$DLVersion" 188 | echo -e "$(date) - RTRMON - A new update (v$DLVersion) is available to download" >> $LOGFILE 189 | else 190 | UpdateNotify=0 191 | fi 192 | fi 193 | } 194 | 195 | # ------------------------------------------------------------------------------------------------------------------------- 196 | 197 | # vlogs is a function that calls the nano text editor to view the RTRMON log file 198 | vlogs() { 199 | 200 | export TERM=linux 201 | nano $LOGFILE 202 | 203 | } 204 | 205 | # ------------------------------------------------------------------------------------------------------------------------- 206 | 207 | # vconfig is a function that guides you through the various configuration options for RTRMON 208 | vconfig () { 209 | 210 | if [ -f $CFGPATH ]; then #Making sure file exists before proceeding 211 | source $CFGPATH 212 | 213 | while true; do 214 | clear 215 | logoNM 216 | echo "" 217 | echo -e "${CGreen}RTRMON Configuration Utility${CClear}" # Provide main setup menu 218 | echo "" 219 | echo -e "${CGreen}----------------------------------------------------------------" 220 | echo -e "${CGreen}Options" 221 | echo -e "${CGreen}----------------------------------------------------------------" 222 | echo -e "${InvDkGray}${CWhite} 1 ${CClear}${CCyan}: Timer Interval (seconds) :"${CGreen}$Interval 223 | echo -e "${InvDkGray}${CWhite} 2 ${CClear}${CCyan}: Max Internet Speed (Mbps) :"${CGreen}$MaxSpeedInet 224 | echo -e "${InvDkGray}${CWhite} 3 ${CClear}${CCyan}: Max LAN Speed (Mbps) :"${CGreen}$MaxSpeedLAN 225 | echo -e "${InvDkGray}${CWhite} 4 ${CClear}${CCyan}: Max 2.4Ghz Speed (Mbps) :"${CGreen}$MaxSpeed24Ghz 226 | echo -e "${InvDkGray}${CWhite} 5 ${CClear}${CCyan}: Max 5Ghz Speed (Mbps) :"${CGreen}$MaxSpeed5Ghz 227 | echo -e "${InvDkGray}${CWhite} 6 ${CClear}${CCyan}: Temperature Units (C/F/K) :"${CGreen}$TempUnits 228 | echo -e "${InvDkGray}${CWhite} s ${CClear}${CCyan}: Save & Exit" 229 | echo -e "${InvDkGray}${CWhite} e ${CClear}${CCyan}: Exit & Discard Changes" 230 | echo -e "${CGreen}----------------------------------------------------------------" 231 | echo "" 232 | printf "Selection: " 233 | read -r ConfigSelection 234 | 235 | # Execute chosen selections 236 | case "$ConfigSelection" in 237 | 238 | 1) # ----------------------------------------------------------------------------------------- 239 | echo "" 240 | echo -e "${CCyan}1. How many seconds would you like to use to refresh your stats?" 241 | echo -e "${CYellow}(Default = 10)${CClear}" 242 | read -p 'Interval (seconds): ' Interval1 243 | Interval=$Interval1 244 | ;; 245 | 246 | 2) # ----------------------------------------------------------------------------------------- 247 | echo "" 248 | echo -e "${CCyan}2. What is your maximum internet bandwidth/speed in Mbps?" 249 | echo -e "${CYellow}(Default = 1000)${CClear}" 250 | read -p 'Max Internet Speed (Mbps): ' MaxSpeedInet1 251 | MaxSpeedInet=$MaxSpeedInet1 252 | ;; 253 | 254 | 3) # ----------------------------------------------------------------------------------------- 255 | echo "" 256 | echo -e "${CCyan}3. What is your maximum LAN switch bandwidth/speed in Mbps?" 257 | echo -e "${CYellow}(Default = 1000)${CClear}" 258 | read -p 'Max LAN Speed (Mbps): ' MaxSpeedLAN1 259 | MaxSpeedLAN=$MaxSpeedLAN1 260 | ;; 261 | 262 | 4) # ----------------------------------------------------------------------------------------- 263 | echo "" 264 | echo -e "${CCyan}4. What is your maximum realistic 2.4Ghz speed in Mbps?" 265 | echo -e "${CYellow}(Default = 450)${CClear}" 266 | read -p 'Max 2.4Ghz Speed (Mbps): ' MaxSpeed24Ghz1 267 | MaxSpeed24Ghz=$MaxSpeed24Ghz1 268 | ;; 269 | 270 | 5) # ----------------------------------------------------------------------------------------- 271 | echo "" 272 | echo -e "${CCyan}5. What is your maximum realistic 5Ghz speed in Mbps?" 273 | echo -e "${CYellow}(Default = 780)${CClear}" 274 | read -p 'Max 5Ghz Speed (Mbps): ' MaxSpeed5Ghz1 275 | MaxSpeed5Ghz=$MaxSpeed5Ghz1 276 | ;; 277 | 278 | 6) # ----------------------------------------------------------------------------------------- 279 | echo "" 280 | echo -e "${CCyan}6. Which Temperature Units would you prefer? (C)elcius," 281 | echo -e "${CCyan}(Fahrenheit) or (K)elvin?" 282 | echo -e "${CYellow}(Default = C)${CClear}" 283 | read -p 'Temp Units (C/F/K): ' TempUnits1 284 | TempUnits=$TempUnits1 285 | ;; 286 | 287 | s) # ----------------------------------------------------------------------------------------- 288 | echo "" 289 | { echo 'Interval='$Interval 290 | echo 'MaxSpeedInet='$MaxSpeedInet 291 | echo 'MaxSpeedLAN='$MaxSpeedLAN 292 | echo 'MaxSpeed24Ghz='$MaxSpeed24Ghz 293 | echo 'MaxSpeed5Ghz='$MaxSpeed5Ghz 294 | echo 'TempUnits="'"$TempUnits"'"' 295 | } > $CFGPATH 296 | echo "" 297 | echo -e "$(date) - RTRMON - Successfully wrote a new config file" >> $LOGFILE 298 | return 299 | ;; 300 | 301 | e) # ----------------------------------------------------------------------------------------- 302 | return 303 | ;; 304 | 305 | esac 306 | done 307 | 308 | else 309 | #Create a new config file with default values to get it to a basic running state 310 | { echo 'Interval=10' 311 | echo 'MaxSpeedInet=1000' 312 | echo 'MaxSpeedLAN=1000' 313 | echo 'MaxSpeed24Ghz=450' 314 | echo 'MaxSpeed5Ghz=780' 315 | echo 'TempUnits="C"' 316 | } > $CFGPATH 317 | 318 | #Re-run rtrmon -config to restart setup process 319 | vconfig 320 | 321 | fi 322 | 323 | } 324 | 325 | # ------------------------------------------------------------------------------------------------------------------------- 326 | 327 | # vuninstall is a function that uninstalls and removes all traces of RTRMON from your router... 328 | vuninstall () { 329 | clear 330 | logoNM 331 | echo "" 332 | echo -e "${CGreen}RTRMON Uninstall Utility${CClear}" 333 | echo "" 334 | echo -e "${CCyan}You are about to uninstall RTRMON! This action is irreversible." 335 | echo -e "${CCyan}Do you wish to proceed?${CClear}" 336 | if promptyn "(y/n): "; then 337 | echo "" 338 | echo -e "\n${CCyan}Are you sure? Please type 'Y' to validate you want to proceed.${CClear}" 339 | if promptyn "(y/n): "; then 340 | clear 341 | rm -r /jffs/addons/rtrmon.d 342 | rm /jffs/scripts/rtrmon.sh 343 | echo "" 344 | echo -e "\n${CGreen}RTRMON has been uninstalled...${CClear}" 345 | echo "" 346 | exit 0 347 | else 348 | echo "" 349 | echo -e "\n${CGreen}Exiting Uninstall Utility...${CClear}" 350 | sleep 1 351 | return 352 | fi 353 | else 354 | echo "" 355 | echo -e "\n${CGreen}Exiting Uninstall Utility...${CClear}" 356 | sleep 1 357 | return 358 | fi 359 | } 360 | 361 | 362 | # ------------------------------------------------------------------------------------------------------------------------- 363 | 364 | # vupdate is a function that provides a UI to check for script updates and allows you to install the latest version... 365 | vupdate () { 366 | updatecheck # Check for the latest version from source repository 367 | clear 368 | logoNM 369 | echo "" 370 | echo -e "${CGreen}RTRMON Update Utility${CClear}" 371 | echo "" 372 | echo -e "${CCyan}Current Version: ${CYellow}$Version${CClear}" 373 | echo -e "${CCyan}Updated Version: ${CYellow}$DLVersion${CClear}" 374 | echo "" 375 | if [ "$Version" == "$DLVersion" ] 376 | then 377 | echo -e "${CGreen}No update available. You are on the latest version!${CClear}" 378 | echo "" 379 | read -rsp $'Press any key to continue...\n' -n1 key 380 | return 381 | else 382 | echo -e "${CCyan}Would you like to update to the latest version?${CClear}" 383 | if promptyn "(y/n): "; then 384 | echo "" 385 | echo -e "${CCyan}Updating RTRMON to ${CYellow}v$DLVersion${CClear}" 386 | curl --silent --retry 3 "https://raw.githubusercontent.com/ViktorJp/RTRMON/master/rtrmon-$DLVersion.sh" -o "/jffs/scripts/rtrmon.sh" && chmod a+rx "/jffs/scripts/rtrmon.sh" 387 | echo "" 388 | echo -e "${CCyan}Update successful!${CClear}" 389 | echo -e "$(date) - RTRMON - Successfully updated RTRMON from v$Version to v$DLVersion" >> $LOGFILE 390 | echo "" 391 | echo -e "${CYellow}Please exit, restart and configure new options using: 'rtrmon.sh -config'.${CClear}" 392 | echo -e "${CYellow}NOTE: New features may have been added that require your input to take${CClear}" 393 | echo -e "${CYellow}advantage of its full functionality.${CClear}" 394 | echo "" 395 | read -rsp $'Press any key to continue...\n' -n1 key 396 | return 397 | else 398 | echo "" 399 | echo "" 400 | echo -e "${CGreen}Exiting Update Utility...${CClear}" 401 | sleep 1 402 | return 403 | fi 404 | fi 405 | } 406 | 407 | # ------------------------------------------------------------------------------------------------------------------------- 408 | 409 | # vsetup is a function that sets up, confiures and allows you to launch RTRMON on your router... 410 | vsetup () { 411 | 412 | # Check for and add an alias for RTRMON 413 | if ! grep -F "sh /jffs/scripts/rtrmon.sh" /jffs/configs/profile.add; then 414 | echo "alias rtrmon=\"sh /jffs/scripts/rtrmon.sh\" # RTRMON" >> /jffs/configs/profile.add 415 | fi 416 | 417 | while true; do 418 | clear 419 | logoNM 420 | echo "" 421 | echo -e "${CGreen}RTRMON Setup Utility${CClear}" # Provide main setup menu 422 | echo "" 423 | echo -e "${CGreen}----------------------------------------------------------------" 424 | echo -e "${CGreen}Operations" 425 | echo -e "${CGreen}----------------------------------------------------------------" 426 | echo -e "${InvDkGray}${CWhite} sc ${CClear}${CCyan}: Setup and Configure RTRMON" 427 | echo -e "${InvDkGray}${CWhite} fr ${CClear}${CCyan}: Force Re-install Entware Dependencies" 428 | echo -e "${InvDkGray}${CWhite} up ${CClear}${CCyan}: Check for latest updates" 429 | echo -e "${InvDkGray}${CWhite} vl ${CClear}${CCyan}: View logs" 430 | echo -e "${InvDkGray}${CWhite} un ${CClear}${CCyan}: Uninstall" 431 | echo -e "${InvDkGray}${CWhite} e ${CClear}${CCyan}: Exit" 432 | echo -e "${CGreen}----------------------------------------------------------------" 433 | if [ "$FromUI" == "0" ]; then 434 | echo -e "${CGreen}Launch" 435 | echo -e "${CGreen}----------------------------------------------------------------" 436 | echo -e "${InvDkGray}${CWhite} m1 ${CClear}${CCyan}: Launch RTRMON into Normal Monitoring Mode" 437 | echo -e "${InvDkGray}${CWhite} m2 ${CClear}${CCyan}: Launch RTRMON into Normal Monitoring Mode w/ Screen" 438 | echo -e "${CGreen}----------------------------------------------------------------" 439 | fi 440 | echo "" 441 | printf "Selection: " 442 | read -r InstallSelection 443 | 444 | # Execute chosen selections 445 | case "$InstallSelection" in 446 | 447 | sc) # Check for existence of entware, and if so proceed and install the timeout package, then run RTRMON -config 448 | clear 449 | if [ -f "/opt/bin/timeout" ] && [ -f "/opt/sbin/screen" ]; then 450 | vconfig 451 | else 452 | logoNM 453 | echo -e "${CYellow}Installing RTRMON...${CClear}" 454 | echo "" 455 | echo -e "${CCyan}Would you like to optionally install the CoreUtils-Timeout${CClear}" 456 | echo -e "${CCyan}and Screen utility? These utilities require you to have Entware${CClear}" 457 | echo -e "${CCyan}already installed using the AMTM tool. If Entware is present, the ${CClear}" 458 | echo -e "${CCyan}Timeout and Screen utilities will be downloaded and installed during${CClear}" 459 | echo -e "${CCyan}this setup process, and used by RTRMON.${CClear}" 460 | echo "" 461 | echo -e "${CGreen}CoreUtils-Timeout${CCyan} is a utility that provides more stability for${CClear}" 462 | echo -e "${CCyan}certain routers (like the RT-AC86U) which has a tendency to randomly${CClear}" 463 | echo -e "${CCyan}hang scripts running on this router model.${CClear}" 464 | echo "" 465 | echo -e "${CGreen}Screen${CCyan} is a utility that allows you to run SSH scripts in a standalone" 466 | echo -e "${CCyan}environment directly on the router itself, instead of running your" 467 | echo -e "${CCyan}commands or a script from a network-attached SSH client. This can" 468 | echo -e "${CCyan}provide greater stability due to it running from the router itself." 469 | echo "" 470 | [ -z "$(nvram get odmpid)" ] && RouterModel="$(nvram get productid)" || RouterModel="$(nvram get odmpid)" # Thanks @thelonelycoder for this logic 471 | echo -e "${CCyan}Your router model is: ${CYellow}$RouterModel" 472 | echo "" 473 | echo -e "${CCyan}Install?${CClear}" 474 | if promptyn "(y/n): " 475 | then 476 | if [ -d "/opt" ]; then # Does entware exist? If yes proceed, if no error out. 477 | echo "" 478 | echo -e "\n${CGreen}Updating Entware Packages...${CClear}" 479 | echo "" 480 | opkg update 481 | echo "" 482 | echo -e "${CGreen}Installing Entware CoreUtils-Timeout Package...${CClear}" 483 | echo "" 484 | opkg install coreutils-timeout 485 | echo -e "${CGreen}Installing Entware Screen Package...${CClear}" 486 | echo "" 487 | opkg install screen 488 | echo "" 489 | sleep 1 490 | echo -e "${CGreen}Executing RTRMON Configuration Utility...${CClear}" 491 | sleep 2 492 | vconfig 493 | else 494 | clear 495 | echo -e "${CGreen}ERROR: Entware was not found on this router...${CClear}" 496 | echo -e "${CGreen}Please install Entware using the AMTM utility before proceeding...${CClear}" 497 | echo "" 498 | sleep 3 499 | fi 500 | else 501 | echo "" 502 | echo -e "\n${CGreen}Executing RTRMON Configuration Utility...${CClear}" 503 | sleep 2 504 | vconfig 505 | fi 506 | fi 507 | ;; 508 | 509 | 510 | fr) # Force re-install the CoreUtils timeout/screen package 511 | clear 512 | logoNM 513 | echo "" 514 | echo -e "${CYellow}Force Re-installing CoreUtils-Timeout/Screen Packages...${CClear}" 515 | echo "" 516 | echo -e "${CCyan}Would you like to optionally re-install the CoreUtils-Timeout${CClear}" 517 | echo -e "${CCyan}and Screen utility? These utilities require you to have Entware${CClear}" 518 | echo -e "${CCyan}already installed using the AMTM tool. If Entware is present, the ${CClear}" 519 | echo -e "${CCyan}Timeout and Screen utilities will be downloaded and installed during${CClear}" 520 | echo -e "${CCyan}this setup process, and used by RTRMON.${CClear}" 521 | echo "" 522 | echo -e "${CGreen}CoreUtils-Timeout${CCyan} is a utility that provides more stability for${CClear}" 523 | echo -e "${CCyan}certain routers (like the RT-AC86U) which has a tendency to randomly${CClear}" 524 | echo -e "${CCyan}hang scripts running on this router model.${CClear}" 525 | echo "" 526 | echo -e "${CGreen}Screen${CCyan} is a utility that allows you to run SSH scripts in a standalone" 527 | echo -e "${CCyan}environment directly on the router itself, instead of running your" 528 | echo -e "${CCyan}commands or a script from a network-attached SSH client. This can" 529 | echo -e "${CCyan}provide greater stability due to it running from the router itself." 530 | echo "" 531 | [ -z "$(nvram get odmpid)" ] && RouterModel="$(nvram get productid)" || RouterModel="$(nvram get odmpid)" # Thanks @thelonelycoder for this logic 532 | echo -e "${CCyan}Your router model is: ${CYellow}$RouterModel" 533 | echo "" 534 | echo -e "${CCyan}Force Re-install?${CClear}" 535 | if promptyn "(y/n): " 536 | then 537 | if [ -d "/opt" ]; then # Does entware exist? If yes proceed, if no error out. 538 | echo "" 539 | echo -e "\n${CGreen}Updating Entware Packages...${CClear}" 540 | echo "" 541 | opkg update 542 | echo "" 543 | echo -e "${CGreen}Force Re-installing Entware CoreUtils-Timeout Package...${CClear}" 544 | echo "" 545 | opkg install --force-reinstall coreutils-timeout 546 | echo -e "${CGreen}Force Re-installing Entware Screen Package...${CClear}" 547 | echo "" 548 | opkg install --force-reinstall screen 549 | echo "" 550 | echo -e "${CGreen}Re-install completed...${CClear}" 551 | sleep 2 552 | else 553 | clear 554 | echo -e "${CGreen}ERROR: Entware was not found on this router...${CClear}" 555 | echo -e "${CGreen}Please install Entware using the AMTM utility before proceeding...${CClear}" 556 | echo "" 557 | sleep 3 558 | fi 559 | fi 560 | ;; 561 | 562 | up) 563 | echo "" 564 | vupdate 565 | ;; 566 | 567 | m1) 568 | echo "" 569 | echo -e "\n${CGreen}Launching RTRMON into Monitor Mode...${CClear}" 570 | sleep 2 571 | sh $APPPATH -monitor 572 | ;; 573 | 574 | m2) 575 | echo "" 576 | echo -e "\n${CGreen}Launching RTRMON into Monitor Mode with Screen Utility...${CClear}" 577 | sleep 2 578 | sh $APPPATH -screen 579 | ;; 580 | 581 | vl) 582 | echo "" 583 | vlogs 584 | ;; 585 | 586 | un) 587 | echo "" 588 | vuninstall 589 | ;; 590 | 591 | e) 592 | echo -e "${CClear}" 593 | exit 0 594 | ;; 595 | 596 | *) 597 | echo "" 598 | echo -e "${CRed}Invalid choice - Please enter a valid option...${CClear}" 599 | echo "" 600 | sleep 2 601 | ;; 602 | 603 | esac 604 | done 605 | } 606 | 607 | # ------------------------------------------------------------------------------------------------------------------------- 608 | 609 | # get_wan_setting was "borrowed" graciously from @dave14305 from his FlexQoS script to determine the active WAN connection. 610 | # Thanks much for your troubleshooting help as we tackled how to best derive the active WAN interface, Dave! 611 | get_wan_setting() { 612 | local varname varval 613 | varname="${1}" 614 | prefixes="wan0_ wan1_" 615 | 616 | if [ "$($timeoutcmd$timeoutsec nvram get wans_mode)" = "lb" ] ; then 617 | for prefix in $prefixes; do 618 | state="$($timeoutcmd$timeoutsec nvram get "${prefix}"state_t)" 619 | sbstate="$($timeoutcmd$timeoutsec nvram get "${prefix}"sbstate_t)" 620 | auxstate="$($timeoutcmd$timeoutsec nvram get "${prefix}"auxstate_t)" 621 | 622 | # is_wan_connect() 623 | [ "${state}" = "2" ] || continue 624 | [ "${sbstate}" = "0" ] || continue 625 | [ "${auxstate}" = "0" ] || [ "${auxstate}" = "2" ] || continue 626 | 627 | # get_wan_ifname() 628 | proto="$($timeoutcmd$timeoutsec nvram get "${prefix}"proto)" 629 | if [ "${proto}" = "pppoe" ] || [ "${proto}" = "pptp" ] || [ "${proto}" = "l2tp" ] ; then 630 | varval="$($timeoutcmd$timeoutsec nvram get "${prefix}"pppoe_"${varname}")" 631 | else 632 | varval="$($timeoutcmd$timeoutsec nvram get "${prefix}""${varname}")" 633 | fi 634 | done 635 | else 636 | for prefix in $prefixes; do 637 | primary="$($timeoutcmd$timeoutsec nvram get "${prefix}"primary)" 638 | [ "${primary}" = "1" ] && break 639 | done 640 | 641 | proto="$($timeoutcmd$timeoutsec nvram get "${prefix}"proto)" 642 | if [ "${proto}" = "pppoe" ] || [ "${proto}" = "pptp" ] || [ "${proto}" = "l2tp" ] ; then 643 | varval="$($timeoutcmd$timeoutsec nvram get "${prefix}"pppoe_"${varname}")" 644 | else 645 | varval="$($timeoutcmd$timeoutsec nvram get "${prefix}""${varname}")" 646 | fi 647 | fi 648 | printf "%s" "${varval}" 649 | } # get_wan_setting 650 | 651 | # ------------------------------------------------------------------------------------------------------------------------- 652 | 653 | # gettopstats gathers the majority of cpu and memory related stats directly from the TOP utility 654 | gettopstats () { 655 | 656 | TotalMem=$(top -n 1 | awk 'NR==1 {print $2, $4, $6, $8, $10} NR==2 {print $2, $4, $6, $8} NR==3 {print $3, $4, $5}' 2>/dev/null) 657 | 658 | memused="$(echo $TotalMem | awk '{print $1}' | sed 's/K$//')" 659 | memfree="$(echo $TotalMem | awk '{print $2}' | sed 's/K$//')" 660 | memshrd="$(echo $TotalMem | awk '{print $3}' | sed 's/K$//')" 661 | membuff="$(echo $TotalMem | awk '{print $4}' | sed 's/K$//')" 662 | memcach="$(echo $TotalMem | awk '{print $5}' | sed 's/K$//')" 663 | cpuusr="$(echo $TotalMem | awk '{print $6}' | sed 's/%$//' | cut -d . -f 1)" 664 | cpusys="$(echo $TotalMem | awk '{print $7}' | sed 's/%$//' | cut -d . -f 1)" 665 | cpunice="$(echo $TotalMem | awk '{print $8}' | sed 's/%$//' | cut -d . -f 1)" 666 | cpuidle="$(echo $TotalMem | awk '{print $9}' | sed 's/%$//' | cut -d . -f 1)" 667 | displaycpuusr="$(echo $TotalMem | awk '{print $6}' | sed 's/%$//')" 668 | displaycpusys="$(echo $TotalMem | awk '{print $7}' | sed 's/%$//')" 669 | displaycpunice="$(echo $TotalMem | awk '{print $8}' | sed 's/%$//')" 670 | displaycpuidle="$(echo $TotalMem | awk '{print $9}' | sed 's/%$//')" 671 | cpuload1m="$(echo $TotalMem | awk '{print $10}')" 672 | cpuload5m="$(echo $TotalMem | awk '{print $11}')" 673 | cpuload15m="$(echo $TotalMem | awk '{print $12}')" 674 | 675 | memused1=$(($memused1 + $memused)) 676 | memfree1=$(($memfree1 + $memfree)) 677 | memshrd1=$(($memshrd1 + $memshrd)) 678 | membuff1=$(($membuff1 + $membuff)) 679 | memcach1=$(($memcach1 + $memcach)) 680 | cpuusr1=$(($cpuusr1 + $cpuusr)) 681 | cpusys1=$(($cpusys1 + $cpusys)) 682 | cpunice1=$(($cpunice1 + $cpunice)) 683 | cpuidle1=$(($cpuidle1 + $cpuidle)) 684 | displaycpuusr1=$(awk -v v1=$displaycpuusr1 -v v2=$displaycpuusr 'BEGIN{printf "%0.2f\n", v1+v2}') 685 | displaycpusys1=$(awk -v v1=$displaycpusys1 -v v2=$displaycpusys 'BEGIN{printf "%0.2f\n", v1+v2}') 686 | displaycpunice1=$(awk -v v1=$displaycpunice1 -v v2=$displaycpunice 'BEGIN{printf "%0.2f\n", v1+v2}') 687 | displaycpuidle1=$(awk -v v1=$displaycpuidle1 -v v2=$displaycpuidle 'BEGIN{printf "%0.2f\n", v1+v2}') 688 | 689 | # Borrowed this wonderful keypress capturing mechanism from @Eibgrad... thank you! :) 690 | key_press=''; read -rsn1 -t 1 key_press < "$(tty 0>&2)" 691 | 692 | if [ $key_press ]; then 693 | case $key_press in 694 | [Ss]) FromUI=1; (vsetup); echo -e "${CGreen} [Returning to the Main UI momentarily] "; FromUI=0;; 695 | [Nn]) if [ "$NextPage" == "1" ]; then NextPage=2; clear; DisplayPage2; echo -e "\n"; elif [ "$NextPage" == "2" ]; then NextPage=1; clear; DisplayPage1; echo -e "\n"; fi;; 696 | [Ee]) echo -e "${CClear}"; exit 0;; 697 | esac 698 | fi 699 | 700 | } 701 | 702 | # ------------------------------------------------------------------------------------------------------------------------- 703 | 704 | # oldstats holds the old (current) stats that are being used to display stats on-screen 705 | oldstats () { 706 | 707 | oldcpuusr1=$cpuusr1 708 | oldcpusys1=$cpusys1 709 | oldcpunice1=$cpunice1 710 | oldcpuidle1=$cpuidle1 711 | olddisplaycpuusr1=$displaycpuusr1 712 | olddisplaycpusys1=$displaycpusys1 713 | olddisplaycpunice1=$displaycpunice1 714 | olddisplaycpuidle1=$displaycpuidle1 715 | oldF_cputemp=$F_cputemp 716 | oldmemused2=$memused2 717 | oldmemfree2=$memfree2 718 | oldmemshrd2=$memshrd2 719 | oldmembuff2=$membuff2 720 | oldmemcach2=$memcach2 721 | oldtotalmemory=$totalmemory 722 | oldnvramfree=$nvramfree 723 | oldnvramused=$nvramused 724 | oldtotalnvram=$totalnvram 725 | oldjffstotal=$jffstotal 726 | oldjffsused=$jffsused 727 | oldswaptotal=$swaptotal 728 | oldswapused=$swapused 729 | oldwanrxmbrate=$wanrxmbrate 730 | oldwantxmbrate=$wantxmbrate 731 | oldw24rxmbrate=$w24rxmbrate 732 | oldw24txmbrate=$w24txmbrate 733 | oldw5rxmbrate=$w5rxmbrate 734 | oldw5txmbrate=$w5txmbrate 735 | oldw0temp=$w0temp 736 | oldw1temp=$w1temp 737 | oldlanrxmbrate=$lanrxmbrate 738 | oldlantxmbrate=$lantxmbrate 739 | 740 | } 741 | 742 | # ------------------------------------------------------------------------------------------------------------------------- 743 | 744 | # calculatestats calculates, well, all the current stats ;) 745 | calculatestats () { 746 | 747 | RM_END_TIME=$(date +%s) 748 | RM_ELAPSED_TIME=$(( RM_END_TIME - RM_START_TIME )) 749 | 750 | # CPU - Usage 751 | if [ ! -z $cpuusr1 ]; then cpuusr1=$(($cpuusr1 / $Interval)); else cpuusr1=0; fi 752 | if [ ! -z $cpusys1 ]; then cpusys1=$(($cpusys1 / $Interval)); else cpusys1=0; fi 753 | if [ ! -z $cpunice1 ]; then cpunice1=$(($cpunice1 / $Interval)); else cpunice1=0; fi 754 | if [ ! -z $cpuidle1 ]; then cpuidle1=$(($cpuidle1 / $Interval)); else cpuidle1=0; fi 755 | if [ ! -z $displaycpuusr1 ]; then displaycpuusr1=$(awk -v rb=$displaycpuusr1 -v intv=$Interval 'BEGIN{printf "%0.2f\n", rb/intv}'); else displaycpuusr1=0; fi 756 | if [ ! -z $displaycpusys1 ]; then displaycpusys1=$(awk -v rb=$displaycpusys1 -v intv=$Interval 'BEGIN{printf "%0.2f\n", rb/intv}'); else displaycpusys1=0; fi 757 | if [ ! -z $displaycpunice1 ]; then displaycpunice1=$(awk -v rb=$displaycpunice1 -v intv=$Interval 'BEGIN{printf "%0.2f\n", rb/intv}'); else displaycpunice1=0; fi 758 | if [ ! -z $displaycpuidle1 ]; then displaycpuidle1=$(awk -v rb=$displaycpuidle1 -v intv=$Interval 'BEGIN{printf "%0.2f\n", rb/intv}'); else displaycpuidle1=0; fi 759 | 760 | # CPU - Temp - borrowed from @Maverickcdn - thank you! 761 | F_cputemp=$($timeoutcmd$timeoutsec cat /sys/class/thermal/thermal_zone0/temp | cut -c -2) 762 | 763 | # Memory - Usage 764 | if [ ! -z $memused1 ]; then memused1=$(($memused1 / $Interval)); else memused1=0; fi 765 | if [ ! -z $memfree1 ]; then memfree1=$(($memfree1 / $Interval)); else memfree1=0; fi 766 | if [ ! -z $memshrd1 ]; then memshrd1=$(($memshrd1 / $Interval)); else memshrd1=0; fi 767 | if [ ! -z $membuff1 ]; then membuff1=$(($membuff1 / $Interval)); else membuff1=0; fi 768 | if [ ! -z $memcach1 ]; then memcach1=$(($memcach1 / $Interval)); else memcach1=0; fi 769 | 770 | memused2=$(($memused1 / 1024 )) 771 | memfree2=$(($memfree1 / 1024 )) 772 | memshrd2=$(($memshrd1 / 1024 )) 773 | membuff2=$(($membuff1 / 1024 )) 774 | memcach2=$(($memcach1 / 1024 )) 775 | totalmemory=$((($memused1 + $memfree1) / 1024 )) 776 | 777 | # Memory - NVRAM -- Many thanks to @RMerlin, @SomewhereOverTheRainbow and @Ranger802004 for your help finding NVRAM stats 778 | $($timeoutcmd$timeoutsec nvram show >/tmp/output.txt 2> /tmp/size.txt) 779 | chmod 755 /tmp/size.txt 780 | nvramtotals=$(awk '{print $2, $4}' /tmp/size.txt 2>/dev/null) 781 | nvramused="$(echo $nvramtotals | awk '{print $1}')" 782 | nvramfree="$(echo $nvramtotals | awk '{print $2}' | sed 's/[)(]//g')" 783 | totalnvram=$(($nvramused + $nvramfree)) 784 | 785 | # Disk - JFFS 786 | disk_use=$(df -P | grep /dev | grep -v -E '(tmp|boot)' | awk '{print $2, $3}') 787 | jffstotal="$(echo $disk_use | awk '{print $1}')" 788 | jffsused="$(echo $disk_use | awk '{print $2}')" 789 | jffstotal="$(($jffstotal / 1024))" 790 | jffsused="$(($jffsused / 1024))" 791 | 792 | # Disk - Swap file 793 | swap_use=$(free | awk 'NR==4 {print $2, $3}' 2>/dev/null) 794 | swaptotal="$(echo $swap_use | awk '{print $1}')" 795 | swapused="$(echo $swap_use | awk '{print $2}')" 796 | swaptotal="$(($swaptotal / 1024))" 797 | swapused="$(($swapused / 1024))" 798 | 799 | # Network - Wifi - Temp 800 | ifname24=$($timeoutcmd$timeoutsec nvram get wl0_ifname) 801 | ifname5=$($timeoutcmd$timeoutsec nvram get wl1_ifname) 802 | w0tempraw=$($timeoutcmd$timeoutsec wl -i $ifname24 phy_tempsense | awk '{print $1}' ) 803 | w1tempraw=$($timeoutcmd$timeoutsec wl -i $ifname5 phy_tempsense | awk '{print $1}' ) 804 | if [ -z $w0tempraw ] || [ $w0tempraw -eq 0 ]; then w0tempraw=4; fi #in case it does not return a valid number 805 | if [ -z $w1tempraw ] || [ $w1tempraw -eq 0 ]; then w1tempraw=4; fi 806 | w0temp=$(awk -v v1=$w0tempraw 'BEGIN{printf "\n" (v1/2)+20}' | cut -d . -f 1) 807 | w1temp=$(awk -v v1=$w1tempraw 'BEGIN{printf "\n" (v1/2)+20}' | cut -d . -f 1) 808 | 809 | # Network - Wifi - Traffic 810 | ifname24=$($timeoutcmd$timeoutsec nvram get wl0_ifname) 811 | ifname5=$($timeoutcmd$timeoutsec nvram get wl1_ifname) 812 | new24rxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$ifname24/statistics/rx_bytes)" 813 | new24txbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$ifname24/statistics/tx_bytes)" 814 | new5rxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$ifname5/statistics/rx_bytes)" 815 | new5txbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$ifname5/statistics/tx_bytes)" 816 | 817 | # Network - LAN - Traffic 818 | newlanrxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/br0/statistics/rx_bytes)" 819 | newlantxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/br0/statistics/tx_bytes)" 820 | 821 | # Network - WAN - Traffic 822 | WANIFNAME=$(get_wan_setting ifname) 823 | newwanrxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$WANIFNAME/statistics/rx_bytes)" 824 | newwantxbytes="$($timeoutcmd$timeoutsec cat /sys/class/net/$WANIFNAME/statistics/tx_bytes)" 825 | 826 | # Network - Traffic - Calculations to find the difference between old and new total bytes send/received and divided to give Megabits 827 | diffwanrxbytes=$(awk -v new=$newwanrxbytes -v old=$oldwanrxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 828 | diffwantxbytes=$(awk -v new=$newwantxbytes -v old=$oldwantxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 829 | diff24rxbytes=$(awk -v new=$new24rxbytes -v old=$old24rxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 830 | diff24txbytes=$(awk -v new=$new24txbytes -v old=$old24txbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 831 | diff5rxbytes=$(awk -v new=$new5rxbytes -v old=$old5rxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 832 | diff5txbytes=$(awk -v new=$new5txbytes -v old=$old5txbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 833 | difflanrxbytes=$(awk -v new=$newlanrxbytes -v old=$oldlanrxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 834 | difflantxbytes=$(awk -v new=$newlantxbytes -v old=$oldlantxbytes -v mb=125000 'BEGIN{printf "%.4f\n", (new-old)/mb}') 835 | 836 | # Network - Traffic - Results are further divided by the timer/interval to give Megabits/sec 837 | wanrxmbrate=$(awk -v rb=$diffwanrxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", rb/intv}' | cut -d . -f 1) 838 | wantxmbrate=$(awk -v tb=$diffwantxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", tb/intv}' | cut -d . -f 1) 839 | w24rxmbrate=$(awk -v rb=$diff24rxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", rb/intv}' | cut -d . -f 1) 840 | w24txmbrate=$(awk -v tb=$diff24txbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", tb/intv}' | cut -d . -f 1) 841 | w5rxmbrate=$(awk -v rb=$diff5rxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", rb/intv}' | cut -d . -f 1) 842 | w5txmbrate=$(awk -v tb=$diff5txbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", tb/intv}' | cut -d . -f 1) 843 | lanrxmbrate=$(awk -v rb=$difflanrxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", rb/intv}' | cut -d . -f 1) 844 | lantxmbrate=$(awk -v tb=$difflantxbytes -v intv=$RM_ELAPSED_TIME 'BEGIN{printf "%0.2f\n", tb/intv}' | cut -d . -f 1) 845 | 846 | # Uptime calc 847 | uptime=$(awk '{printf("%03dd %02dh %02dm %02ds\n",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}' /proc/uptime) 848 | } 849 | 850 | # ------------------------------------------------------------------------------------------------------------------------- 851 | 852 | # This function displays the stats UI for page 1 853 | DisplayPage1 () { 854 | logo 855 | if [ "$UpdateNotify" != "0" ]; then 856 | echo -e "${CRed} $UpdateNotify${CClear}" 857 | echo -e "${CGreen} ___${CClear}" 858 | else 859 | echo -e "${CGreen} ___${CClear}" 860 | fi 861 | echo -e "${CGreen}/${CRed}CPU${CClear}${CGreen}\_____________________________________________________________${CClear}" 862 | echo "" 863 | echo -e " ${CCyan}Uptime ${CGreen}[ ${CCyan}$uptime${CGreen} ]${CClear}" 864 | echo -e " ${CCyan}CPU Load ${CGreen}[ 1m: ${CCyan}$cpuload1m ${CGreen}5m: ${CCyan}$cpuload5m ${CGreen}15m: ${CCyan}$cpuload15m${CGreen} ]" 865 | preparebar 35 "|" 866 | progressbar $oldcpuusr1 100 " CPU User " "%%" "Standard" $olddisplaycpuusr1 867 | echo "" 868 | preparebar 35 "|" 869 | progressbar $oldcpusys1 100 " CPU System" "%%" "Standard" $olddisplaycpusys1 870 | echo "" 871 | preparebar 35 "|" 872 | progressbar $oldcpunice1 100 " CPU Nice " "%%" "Standard" $olddisplaycpunice1 873 | echo "" 874 | preparebar 35 "|" 875 | progressbar $oldcpuidle1 100 " CPU Idle " "%%" "Reverse" $olddisplaycpuidle1 876 | echo "" 877 | preparebar 35 "|" 878 | converttemps $oldF_cputemp 879 | progressbar $currenttemp $currentrange " CPU Temp " $TempUnits "Standard" 880 | echo "" 881 | echo -e "${CGreen} ______" 882 | echo -e "${CGreen}/${CRed}Memory${CClear}${CGreen}\__________________________________________________________${CClear}" 883 | echo "" 884 | preparebar 35 "|" 885 | progressbar $oldmemused2 $oldtotalmemory " Mem Used " "MB" "Standard" 886 | echo "" 887 | preparebar 35 "|" 888 | progressbar $oldmemfree2 $oldtotalmemory " Mem Free " "MB" "Standard" 889 | echo "" 890 | preparebar 35 "|" 891 | progressbar $oldmemshrd2 $oldtotalmemory " Mem Shared" "MB" "Standard" 892 | echo "" 893 | preparebar 35 "|" 894 | progressbar $oldmembuff2 $oldtotalmemory " Mem Buffer" "MB" "Standard" 895 | echo "" 896 | preparebar 35 "|" 897 | progressbar $oldmemcach2 $oldtotalmemory " Mem Cache " "MB" "Standard" 898 | echo "" 899 | preparebar 35 "|" 900 | progressbar $oldnvramused $oldtotalnvram " NVRAM Used" "B" "Standard" 901 | echo "" 902 | echo -e "${CGreen} ____" 903 | echo -e "${CGreen}/${CRed}Disk${CClear}${CGreen}\____________________________________________________________${CClear}" 904 | echo "" 905 | preparebar 35 "|" 906 | progressbar $oldjffsused $oldjffstotal " JFFS Used " "MB" "Standard" 907 | echo "" 908 | preparebar 35 "|" 909 | progressbar $oldswapused $oldswaptotal " Swap Used " "MB" "Standard" 910 | } 911 | 912 | # ------------------------------------------------------------------------------------------------------------------------- 913 | 914 | # This function displays the stats UI for page 2 915 | DisplayPage2 () { 916 | logo 917 | if [ "$UpdateNotify" != "0" ]; then 918 | echo -e "${CRed} $UpdateNotify${CClear}" 919 | echo -e "${CGreen} ___${CClear}" 920 | else 921 | echo -e "${CGreen} ___${CClear}" 922 | fi 923 | echo -e "${CGreen}/${CRed}WAN${CClear}${CGreen}\_____________________________________________________________${CClear}" 924 | echo "" 925 | preparebar 35 "|" 926 | progressbar $oldwanrxmbrate $MaxSpeedInet " Avg WAN RX" "Mbps" "Standard" 927 | echo "" 928 | preparebar 35 "|" 929 | progressbar $oldwantxmbrate $MaxSpeedInet " Avg WAN TX" "Mbps" "Standard" 930 | echo "" 931 | echo -e "${CGreen} ___" 932 | echo -e "${CGreen}/${CRed}LAN${CClear}${CGreen}\_____________________________________________________________${CClear}" 933 | echo "" 934 | preparebar 35 "|" 935 | progressbar $oldlanrxmbrate $MaxSpeedLAN " Avg LAN RX" "Mbps" "Standard" 936 | echo "" 937 | preparebar 35 "|" 938 | progressbar $oldlantxmbrate $MaxSpeedLAN " Avg LAN TX" "Mbps" "Standard" 939 | echo "" 940 | echo -e "${CGreen} ____" 941 | echo -e "${CGreen}/${CRed}WiFi${CClear}${CGreen}\____________________________________________________________${CClear}" 942 | echo "" 943 | preparebar 35 "|" 944 | progressbar $oldw24rxmbrate $MaxSpeed24Ghz " Avg 24G RX" "Mbps" "Standard" 945 | echo "" 946 | preparebar 35 "|" 947 | progressbar $oldw24txmbrate $MaxSpeed24Ghz " Avg 24G TX" "Mbps" "Standard" 948 | echo "" 949 | preparebar 35 "|" 950 | converttemps $oldw0temp 951 | progressbar $currenttemp $currentrange " 2.4G Temp " $TempUnits "Standard" 952 | echo "" 953 | echo "" 954 | preparebar 35 "|" 955 | progressbar $oldw5rxmbrate $MaxSpeed5Ghz " Avg 50G RX" "Mbps" "Standard" 956 | echo "" 957 | preparebar 35 "|" 958 | progressbar $oldw5txmbrate $MaxSpeed5Ghz " Avg 50G TX" "Mbps" "Standard" 959 | echo "" 960 | preparebar 35 "|" 961 | converttemps $oldw1temp 962 | progressbar $currenttemp $currentrange " 5.0G Temp " $TempUnits "Standard" 963 | } 964 | 965 | # ------------------------------------------------------------------------------------------------------------------------- 966 | # Begin Commandline Argument Gatekeeper and Configuration Utility Functionality 967 | # ------------------------------------------------------------------------------------------------------------------------- 968 | 969 | #DEBUG=; set -x # uncomment/comment to enable/disable debug mode 970 | #{ # uncomment/comment to enable/disable debug mode 971 | 972 | # Create the necessary folder/file structure for RTRMON under /jffs/addons 973 | if [ ! -d "/jffs/addons/rtrmon.d" ]; then 974 | mkdir -p "/jffs/addons/rtrmon.d" 975 | fi 976 | 977 | # Check for Updates 978 | updatecheck 979 | 980 | # Check and see if any commandline option is being used 981 | if [ $# -eq 0 ] 982 | then 983 | clear 984 | echo "" 985 | echo "RTRMON v$Version" 986 | echo "" 987 | echo "Exiting due to missing commandline options!" 988 | echo "(run 'rtrmon.sh -h' for help)" 989 | echo "" 990 | echo -e "${CClear}" 991 | exit 0 992 | fi 993 | 994 | # Check and see if an invalid commandline option is being used 995 | if [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$1" == "-config" ] || [ "$1" == "-monitor" ] || [ "$1" == "-log" ] || [ "$1" == "-update" ] || [ "$1" == "-setup" ] || [ "$1" == "-uninstall" ] || [ "$1" == "-screen" ] || [ "$1" == "-reset" ] 996 | then 997 | clear 998 | else 999 | clear 1000 | echo "" 1001 | echo "RTRMON v$Version" 1002 | echo "" 1003 | echo "Exiting due to invalid commandline options!" 1004 | echo "(run 'rtrmon.sh -h' for help)" 1005 | echo "" 1006 | echo -e "${CClear}" 1007 | exit 0 1008 | fi 1009 | 1010 | # Check to see if the help option is being called 1011 | if [ "$1" == "-h" ] || [ "$1" == "-help" ] 1012 | then 1013 | clear 1014 | echo "" 1015 | echo "RTRMON v$Version Commandline Option Usage:" 1016 | echo "" 1017 | echo "rtrmon.sh -h | -help" 1018 | echo "rtrmon.sh -log" 1019 | echo "rtrmon.sh -config" 1020 | echo "rtrmon.sh -update" 1021 | echo "rtrmon.sh -setup" 1022 | echo "rtrmon.sh -uninstall" 1023 | echo "rtrmon.sh -screen" 1024 | echo "rtrmon.sh -monitor" 1025 | echo "" 1026 | echo " -h | -help (this output)" 1027 | echo " -log (display the current log contents)" 1028 | echo " -config (configuration/setup utility)" 1029 | echo " -update (script update utility)" 1030 | echo " -setup (setup/dependencies utility)" 1031 | echo " -uninstall (uninstall utility)" 1032 | echo " -screen (normal router monitoring using the screen utility)" 1033 | echo " -monitor (normal router monitoring operations)" 1034 | echo "" 1035 | echo -e "${CClear}" 1036 | exit 0 1037 | fi 1038 | 1039 | # Check to see if the log option is being called, and display through nano 1040 | if [ "$1" == "-log" ] 1041 | then 1042 | vlogs 1043 | exit 0 1044 | fi 1045 | 1046 | # Check to see if the configuration option is being called, and run through setup utility 1047 | if [ "$1" == "-config" ] 1048 | then 1049 | vconfig 1050 | echo -e "${CClear}" 1051 | exit 0 1052 | fi 1053 | 1054 | # Check to see if the update option is being called 1055 | if [ "$1" == "-update" ] 1056 | then 1057 | vupdate 1058 | echo -e "${CClear}" 1059 | exit 0 1060 | fi 1061 | 1062 | # Check to see if the install option is being called 1063 | if [ "$1" == "-setup" ] 1064 | then 1065 | vsetup 1066 | fi 1067 | 1068 | # Check to see if the uninstall option is being called 1069 | if [ "$1" == "-uninstall" ] 1070 | then 1071 | vuninstall 1072 | echo -e "${CClear}" 1073 | exit 0 1074 | fi 1075 | 1076 | # Check to see if the screen option is being called and run operations normally using the screen utility 1077 | if [ "$1" == "-screen" ] 1078 | then 1079 | ScreenSess=$(screen -ls | grep "rtrmon" | awk '{print $1}' | cut -d . -f 1) 1080 | if [ -z $ScreenSess ]; then 1081 | clear 1082 | echo -e "${CGreen}Executing RTRMON using the SCREEN utility...${CClear}" 1083 | echo "" 1084 | echo -e "${CGreen}Reconnect at any time using the command 'screen -r RTRMON'${CClear}" 1085 | echo -e "${CGreen}To exit the SCREEN session, type: CTRL-A + D${CClear}" 1086 | echo "" 1087 | screen -dmS "rtrmon" $APPPATH -monitor 1088 | sleep 2 1089 | read -rsp $'Press any key to continue...\n' -n1 key 1090 | echo -e "${CClear}" 1091 | exit 0 1092 | else 1093 | clear 1094 | echo -e "${CGreen}Another RTRMON Screen session is already running...${CClear}" 1095 | echo -e "${CGreen}Would you like to attach to this session?${CClear}" 1096 | if promptyn "(y/n): "; then 1097 | screen -dr $ScreenSess 1098 | sleep 2 1099 | echo -e "${CClear}" 1100 | exit 0 1101 | else 1102 | echo "" 1103 | echo -e "\n${CGreen}Exiting...${CClear}" 1104 | sleep 1 1105 | return 1106 | fi 1107 | fi 1108 | fi 1109 | 1110 | # Check to see if the monitor option is being called and run operations normally 1111 | if [ "$1" == "-monitor" ] 1112 | then 1113 | clear 1114 | if [ -f $CFGPATH ]; then 1115 | source $CFGPATH 1116 | 1117 | if [ -f "/opt/bin/timeout" ] # If the timeout utility is available then use it and assign variables 1118 | then 1119 | timeoutcmd="timeout " 1120 | timeoutsec="10" 1121 | timeoutlng="60" 1122 | else 1123 | timeoutcmd="" 1124 | timeoutsec="" 1125 | timeoutlng="" 1126 | fi 1127 | 1128 | if [ "$DelayStartup" != "0" ] 1129 | then 1130 | SPIN=$DelayStartup 1131 | echo -e "${CGreen}Delaying RTRMON start-up for $DelayStartup seconds..." 1132 | spinner 1133 | fi 1134 | 1135 | else 1136 | echo -e "${CRed}Error: RTRMON is not configured. Please run 'rtrmon.sh -setup' to complete setup${CClear}" 1137 | echo "" 1138 | echo -e "$(date) - RTRMON ----------> ERROR: rtrmon.cfg was not found. Please run the setup tool." >> $LOGFILE 1139 | kill 0 1140 | fi 1141 | fi 1142 | 1143 | # ------------------------------------------------------------------------------------------------------------------------- 1144 | # Main RTRMON program initialization 1145 | # ------------------------------------------------------------------------------------------------------------------------- 1146 | 1147 | # Display the logo and indicator that stats are being gathered. 1148 | clear 1149 | logoNM 1150 | echo "" 1151 | echo -e " ${CGreen}[Initiating Boot Sequence - Gathering Initial Stats...]" 1152 | echo "" 1153 | 1154 | # Capture Traffic and store current WAN/WiFi bytes stats 1155 | WANIFNAME=$(get_wan_setting ifname) 1156 | oldwanrxbytes="$(cat /sys/class/net/$WANIFNAME/statistics/rx_bytes)" 1157 | oldwantxbytes="$(cat /sys/class/net/$WANIFNAME/statistics/tx_bytes)" 1158 | 1159 | ifname24=$($timeoutcmd$timeoutsec nvram get wl0_ifname) 1160 | ifname5=$($timeoutcmd$timeoutsec nvram get wl1_ifname) 1161 | old24rxbytes="$(cat /sys/class/net/$ifname24/statistics/rx_bytes)" 1162 | old24txbytes="$(cat /sys/class/net/$ifname24/statistics/tx_bytes)" 1163 | old5rxbytes="$(cat /sys/class/net/$ifname5/statistics/rx_bytes)" 1164 | old5txbytes="$(cat /sys/class/net/$ifname5/statistics/tx_bytes)" 1165 | 1166 | oldlanrxbytes="$(cat /sys/class/net/br0/statistics/rx_bytes)" 1167 | oldlantxbytes="$(cat /sys/class/net/br0/statistics/tx_bytes)" 1168 | 1169 | # Get initial TOP stats to average across the interval period 1170 | 1171 | RM_ELAPSED_TIME=0 1172 | RM_START_TIME=$(date +%s) 1173 | i=0 1174 | while [ $i -ne $Interval ] 1175 | do 1176 | i=$(($i+1)) 1177 | gettopstats $i 1178 | preparebar 53 "|" 1179 | progressbar $i $Interval "" "s" "Standard" 1180 | done 1181 | 1182 | calculatestats 1183 | oldstats 1184 | clear 1185 | 1186 | # ------------------------------------------------------------------------------------------------------------------------- 1187 | # Main loop that calls functions to perform all necessary calculations across the interval period 1188 | # ------------------------------------------------------------------------------------------------------------------------- 1189 | 1190 | while true; do 1191 | 1192 | if [ "$NextPage" == "1" ]; then 1193 | clear 1194 | DisplayPage1 1195 | echo "" 1196 | elif [ "$NextPage" == "2" ]; then 1197 | clear 1198 | DisplayPage2 1199 | echo "" 1200 | fi 1201 | 1202 | # Reset stats after the UI has finished drawing 1203 | memused1=0 1204 | memfree1=0 1205 | memshrd1=0 1206 | membuff1=0 1207 | memcach1=0 1208 | memused2=0 1209 | memfree2=0 1210 | memshrd2=0 1211 | membuff2=0 1212 | memcach2=0 1213 | cpuusr1=0 1214 | cpusys1=0 1215 | cpunice1=0 1216 | cpuidle1=0 1217 | displaycpuusr1=0 1218 | displaycpusys1=0 1219 | displaycpunice1=0 1220 | displaycpuidle1=0 1221 | 1222 | # Get fresh WAN stats 1223 | oldwanrxbytes="$(cat /sys/class/net/$WANIFNAME/statistics/rx_bytes)" 1224 | oldwantxbytes="$(cat /sys/class/net/$WANIFNAME/statistics/tx_bytes)" 1225 | old24rxbytes="$(cat /sys/class/net/$ifname24/statistics/rx_bytes)" 1226 | old24txbytes="$(cat /sys/class/net/$ifname24/statistics/tx_bytes)" 1227 | old5rxbytes="$(cat /sys/class/net/$ifname5/statistics/rx_bytes)" 1228 | old5txbytes="$(cat /sys/class/net/$ifname5/statistics/tx_bytes)" 1229 | oldlanrxbytes="$(cat /sys/class/net/br0/statistics/rx_bytes)" 1230 | oldlantxbytes="$(cat /sys/class/net/br0/statistics/tx_bytes)" 1231 | 1232 | # Run through the stats gathering loop based on the current interval 1233 | echo "" 1234 | RM_ELAPSED_TIME=0 1235 | RM_START_TIME=$(date +%s) 1236 | i=0 1237 | while [ $i -ne $Interval ] 1238 | do 1239 | i=$(($i+1)) 1240 | gettopstats $i 1241 | preparebar 46 "|" 1242 | progressbar $i $Interval "" "s" "Standard" 1243 | done 1244 | 1245 | # Do a fresh round of stats and save them to the old stats for display purposes 1246 | calculatestats 1247 | oldstats 1248 | clear 1249 | 1250 | done 1251 | 1252 | exit 0 1253 | 1254 | #} #2>&1 | tee $LOG | logger -t $(basename $0)[$$] # uncomment/comment to enable/disable debug mode 1255 | -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | v2.2.2 - (October 21, 2025) 2 | - PATCH: Fixed some of the logic to cut down on the VPN/WG slot calls for external public IP 3 | address/city validation, and re-use those same values if they have not changed. This would help 4 | bring down the amount of regular network noise that the script generates while running. 5 | - PATCH: In the process of cutting down these IP address/location calls, a lot of duplicate code 6 | around these functions was cleaned up so that RTRMON runs faster and leaner, and provides 7 | slightly more accuracy around stats. 8 | - PATCH: Fixed the banner menu showing whether VPN or WG or both VPN/WG are available for speed 9 | tests on page #4 depending on what slots are active. 10 | - PATCH: Fixed OVPN1 stats not showing due to some incorrect variable naming. Thanks to 11 | @scootertramp for reporting! 12 | - PATCH: Fixed the timing issue around the iftop command on the Top 10 Network Connections and 13 | Bandwidth Stats page #6. What was happening was that iftop would be waiting for any kind of 14 | network traffic, and on a low or unused VPN/WG slot, would just sit there until something 15 | came through. Now, the timeout command will kill iftop after 15 seconds of use, while iftop 16 | is now given the command to do its thing within 10 seconds, which still gives you a decent 17 | snapshot of what kind of traffic is happening during that time. Thanks to @CaptainSTX for 18 | reporting this! 19 | 20 | v2.2.1 - (August 24, 2025) 21 | - PATCH: Added compatibility for the RT-BE92U line of routers 22 | - PATCH: Fixed Operations Menu display problem presented itself when no VPN slots were active, 23 | but WG slots are active. 24 | 25 | v2.2.0 - (August 3, 2025) 26 | - MINOR: This release adds compatibility with Wireguard connections! New functionality has been 27 | added under: Page 2 - Network connections, now adding any Wireguard connections to the bottom 28 | of the list. Page 4 - Speed Test, now allowing you to speed test your WAN, VPN and Wireguard 29 | connections. Page 6 - Top 10 Network/Bandwidth connections, now showing established connections 30 | running across your Wireguard tunnels. Operations Menu, now showing additional keyboard options 31 | to allow you to quickly jump to a Wireguard speed test. 32 | - PATCH: Many, many behind the scenes additions, optimizations and fixes, but could probably use 33 | a lot more! But hey it works! :) 34 | - PATCH: Minor fixes and adding some more dev/nulls around certain commands to keep occasional 35 | messages from popping up in the main UI. 36 | - PATCH: Added the rp_filter compatibility statements per @ZebMcKayhan for during use of the 37 | speedtest. Added additional ip rule filters to handle IPv6 as it the output was displaying 38 | errors and causing some display issues. Thanks so much for your help with this, Zeb! 39 | 40 | v2.1.6 - (July 5, 2025) 41 | - PATCH: Included a much needed "export PATH" statement to ensure the script knows where to look 42 | for commonly installed entware tools. Not having this could cause confusion, as the script might 43 | use a similar older or newer tool installed in a different location on the router. 44 | - PATCH: Included a check for the "column" entware tool. This tool is necessary for the display of 45 | data on page #7 (wireless/wired devices), and originally thought it was included with our FW by 46 | default. Apparently not the case, and will now get installed on a new RTRMON install, or will 47 | complain its missing and ask you to reinstall through the "Force Reinstall Entware Dependencies" 48 | menu item. 49 | - PATCH: General bugfixes and UI cleanup items. 50 | 51 | v2.1.5 - (April 12, 2025) 52 | - PATCH: Thanks to @ExtremeFiretop for providing a fix for the way RTRMON looks up client name 53 | based on the MAC address used for association, as it might not find the correct hostname if the 54 | DHCP lease is associated with the MLD MAC. This was based on RMerlin's note here: 55 | https://www.snbforums.com/threads/even-when-not-using-mlo-it-still-changes-some-stuff.94070/ 56 | 57 | v2.1.4 - (November 28, 2024) 58 | - PATCH: Modified code to ignore ALL character key presses during the initial "Boot Sequence" loop. 59 | - PATCH: Modified code to ignore all INVALID character key presses within the main loop. 60 | - PATCH: Added code to avoid updating the timer prematurely within the initial & main loops due to 61 | repeatedly fast key presses. 62 | - PATCH: Modified code to avoid redisplaying the top "Options Menu" unnecessarily too often and 63 | resetting the timer loop due to repeatedly fast key presses. 64 | - PATCH: Modified code to get elapsed time percentage values with 1 decimal place (e.g. 0.5%). This 65 | allows non-integer values to be displayed for percentages of the elapsed time. 66 | - PATCH: Modified the top "Operations Menu" section with the title for the "Setup Configuration Menu" 67 | to highlight "M" as the key press to launch the Setup Menu instead of the "S" key press which was 68 | in conflict with the "S" required to show the "Operations Menu" section. 69 | - PATCH: Fixed menu option to set "Timer Interval (seconds)" values because it was accepting any user 70 | input (e.g. "0", "X") with very little validation and there was no lower-bound & upper-bound value 71 | checking. For example, inputs like "0" && "X" were accepted leading to runtime errors being 72 | generated. 73 | - PATCH: Added a toggle switch to pause/resume the timer cycle within the main loop. Pressing the 74 | character 'X' key (upper-case X only) will toggle the timer to pause/resume. While in the paused 75 | state, all character key presses are ignored except for the toggle 'X' key to resume the timer. 76 | - PATCH: Various other coding improvements & fine-tuning. 77 | - HUGE thanks to @Martinski for helping improve RTRMON with all the above fixes!! :) 78 | 79 | v2.1.3 - (October 19, 2024) 80 | - PATCH: Minor spacing issues fixed for screen #6 (wired/wireless clients page) 81 | - PATCH: Fixed some logic due to the $VPNSite2Site variable not being considered, though it is set 82 | in the config. Thanks to @Visortgw for his sleuthing and seeing what worked for him, and implemented 83 | these changes across the script as it pertains to site-to-site VPN configurations. 84 | - PATCH: Fixed the Y/N prompts so they now require you to hit after typing either y or n. This 85 | changes its behavior from automatically moving on and possibly causing issues from people also using 86 | the enter key accidentally. 87 | 88 | v2.1.0 - (October 12, 2024) 89 | - MINOR: Based on some samples that @RMerlin provided @JGrana when looking at connected WiFi client 90 | connected time, it seemed like a great idea to provide a view of which connected clients are 91 | currently attached to your router, and on what interface. This new view (page #7) shows the client 92 | name, IP, MAC, Uptime, TX/RX Totals (in GB), TX/RX Speeds (in Mbps) for each wireless interface, and 93 | also shows the name, IP and MAC for everything else connected to the LAN (br0). Still a bit 94 | experimental as I'm refining this, and would definitely appreciate your feedback! 95 | - PATCH: Some further debugging to eliminate dupes caused by shoddy coding, and will now just display 96 | an "UNKNOWN" entry if a device shows up that is not defined using a custom name. 97 | - PATCH: Introduced the option to sort your connected client lists by Name, IP or MAC address! Columns 98 | will sort by alpha or numerical order... in the case of MAC, it seems to go alpha then numeric. Huge 99 | thanks to @visortgw for suggesting this feature! 100 | - PATCH: Some additional work was done on the connected clients to account for guest wi-fi clients per 101 | feedback by both @visortgw and @CaptainSTX. Thanks also to @ColinTaylor and @DJones for narrowing 102 | down what interface guest wi-fi clients reside on, and providing script samples of pulling legit 103 | guest wi-fi interface names. RTRMON will now display enabled guest wi-fi ranges along with their 104 | associated connections. 105 | - PATCH: Based on a suggestion from @DJones, the client signal strength value has been added to the 106 | column layout! 107 | - PATCH: After much back and forth with @visortgw, sleuthing through NVRAM, I have not been able to 108 | get past the VLAN brick wall, in order to show which devices are on which VLAN. So for the moment, 109 | until 3006 arrives for my router, I will need to put a pin in it, and will just combine LAN and VLAN 110 | devices under the same section. 111 | - PATCH: Added a blank IP for clients that come up as UNKNOWN to help with spacing. 112 | - PATCH: With many huge thanks to @ExtremeFiretop, he had some very productive time to help debug and 113 | develop some workarounds while testing it against his live GT-BE98U! He singlehandedly was able to 114 | figure out the methodology needed to report which clients fell into which VLANs, along with other 115 | great code optimization, including falling back to pulling device names from dnsmasq when the 116 | custom client name entry is non-existent in NVRAM! THANK YOU!:) 117 | - PATCH: @ExtremeFiretop and @visortgw have been busy working together in the background and putting 118 | the final finishing touches on the network client listing screen! Thanks so much for your help and 119 | expertise and putting a nice bow on top! :) 120 | 121 | v2.0.17 - (June 8, 2024) 122 | - PATCH: Fixed compatibility issues with the GT-AX11000_Pro. Apparently, I was searching for an 123 | incorrect model name... Thanks to @Kingp1n for noticing that his 2nd 5GHz band was not showing up. 124 | 125 | v2.0.16 - (June 3, 2024) 126 | - PATCH: Added some logic to the network connections/bandwidth test to try to exclude VPN connections 127 | that come up with a private IP address in the vpn_clientX_addr NVRAM field. In the process, added 128 | another option under the configuration menu (item #13) that asks whether or not the router is purely 129 | being used in a VPN site-to-site configuration, as that would have a bearing on how the "public- 130 | facing" IP ends up, and is most likely a private IP that will cause delays or no data during testing. 131 | 132 | v2.0.15 - (June 1, 2024) 133 | - RTRMON v2.0.15 is finally live... Enjoy! Thanks to everyone for all their input and testing throughout 134 | the development of this release! I hope you all enjoy it and find it useful as much as I do. :) 135 | 136 | v2.0.15RC - (TBA) 137 | - PATCH: After some debug/testing with @visorgtw, it was determined that a change to the ping command 138 | needed to be reverted due to site-to-site VPNs not returning pings as expected. Huge thanks for his 139 | great help testing this on his various pieces of router and iMesh-configured equipment! 140 | 141 | v2.0.14RC - (TBA) 142 | - PATCH: Implemented the -now switch functionality, giving you the ability to bypass the 5 second SCREEN 143 | utility instructions and timer. This functionality works inconjunction with being able to specify which 144 | page (1-6) you want to jump to. Examples: "rtrmon -screen -now", "rtrmon -screen 2 -now". The second 145 | example would jump to page 2 using screen with no wait. 146 | - PATCH: With many thanks to @nzwayne for allowing us some time to play with his GT-BE98_Pro, and making 147 | sure RTRMON is fully compatible with the new dual 6GHz bands, we have worked through all issues! Wanted 148 | to say how much I truly appreciate SNB Forum members like @nzwayne for jumping in, being willing to 149 | sacrifice his router and load the latest Merlin FW Alpha version on there to ensure compatibility. You 150 | rock! 151 | 152 | v2.0.12b2 - (TBA) 153 | - PATCH: After getting some nvram feedback from @visortgw and @dave14305, I've made more modifications on 154 | how to determine if a router is truly a router, not an AP/Repeater/iMesh Node. This version is now 155 | compliant in supporting routers in these particular configurations. 156 | - PATCH: Through testing with @visortgw, it was determined that the nslookup diag command does not work 157 | on iMesh nodes, and made a small modification to it so that it may hopefully pass this test. 158 | - PATCH: Now proudly includes compatibility for the newly announced supported Asus-Merlin FW routers: 159 | the GT-BE98_PRO, RT-BE96U and GT-BE98. The BE98_PRO is the first router that makes use of two distinct 160 | 6GHz ranges requiring new capabilities from RTRMON! Huge thanks to @nzwayne for installing the Alpha 161 | on his GT-BE98_PRO and making sure RTRMON worked flawlessly on it! Also, many thanks to @GNUton for 162 | his help determining Wifi interface ranges on the GT-BE98! 163 | - PATCH: Logging standards have been updated across the script, and open to suggestions for other log 164 | events that might be reported on. 165 | 166 | v2.0.8b1 - (TBA) 167 | - MAJOR: Brought RTRMON up to the new visual standards in use across VPNMON-R3, TAILMON and BACKUPMON. All 168 | screens have been resized for the more "wide-screen" look, allowing me to condense information, and make 169 | better use of screen space. This also includes an operations menu which you can show/hide in order to 170 | capitalize on even more screen space in much of the same way VPNMON-R3 functions. It just feels like a 171 | whole new script! ;) 172 | - PATCH: In previous versions, only 2 VPN slots would be presented with relevant info. In today's version, 173 | up to 5 different VPN slots are displayed depending on which ones are in use. 174 | - PATCH: In previous versions, you could only run a speedtest against your first VPN connection. In this 175 | release, you can indicate whether to run a speedtest against any of your up to 5 VPN slots. 176 | - PATCH: Previously, when WiFi interfaces turn on or shut off, they would not be represented in RTRMON as 177 | doing such, and would require a restart of RTRMON to see the current WiFi state. Now, the WiFi interfaces 178 | reflect reality in realtime. 179 | - PATCH: Prevously, the iftop network stats would only gather WAN, LAN and the first available VPN slot. 180 | Page 6 (network/bandwidth stats) now queries and displays all VPN connection info. 181 | - PATCH: Added some additional information on page 1: Total Available RAM, and Total Swap File Size. 182 | - PATCH: On the Network Diagnostics page, RTRMON is now showing a preview of the test command involved in 183 | determining if a function works or not. This gives more insight as to the command, IP or network address 184 | that the test is attempting to connect to. 185 | - PATCH: Added a new item (12) under the Configuration menu that allows you to specify whether the router 186 | that RTRMON is running on is an iMesh Node, AP, Repeater or Bridge. In these operating modes, the eth0 187 | interface is most likely not being used, and will no longer be reporting on or capturing any WAN0 traffic 188 | in the RTRMON UI. 189 | - PATCH: Added a new item (13) under the Configuration menu that allows you to specify how large you want 190 | your log file to reach. The default is currently 2000 rows, which would give you many months of log data. 191 | 192 | v1.6.9 - (May 3, 2024) 193 | - PATCH: After @bubba123 reported some display issues with his SDA devices, it was determined that the large 194 | size of his drive was creating some sort of math/integer problem, and was causing the division problem to 195 | equal zero, eventhough it should have amounted to 5544GB. I changed the way that RTRMON calculates these 196 | large drive space numbers using the awk tool, and implemented a fix. Thanks for the heads-up @bubba123! 197 | 198 | v1.6.8 - (March 17, 2024) 199 | - PATCH: After some back and forth on how to best handle the CPU temp range and colors, I'm going to settle on 200 | agreeing that the upper max range for the graph will be 100C. It's at this temperature that your router starts 201 | shutting down CPU cores to prevent damage, though it could probably get to 120C before it actually starts 202 | physically causing damage. I think if you're getting close to 100C, you should be getting concerned. So the 203 | bar chart will show green up to 80C, yellow from 80C-90C, and red from 90C-100C+. Thanks much to @Tech9, 204 | @L&LD and @visortgw for their valuable feedback on this! 205 | 206 | v1.6.7 - (March 16, 2024) 207 | - PATCH: Based on some great feedback from @adzie and @ExtremeFiretop, I've added stats for your attached USB 208 | storage. All /dev/sd* devices will now show up under the "Disk" section on page 1, showing % used and GB used. 209 | - PATCH: Thanks to the keen eye of @Tech9, the "mem used" counter being displayed on page 1 was displaying the 210 | color scheme wrong... (ie. low memory was marked green, but in this case, should be red). Fixed and reversed! 211 | - PATCH: Also thanks to @Tech9 for his feedback on this, the MAX range for all CPU temps has been dropped from 212 | 130C down to 100C, 212F and 373K, as noted that the router will start shutting down CPUs when it hits 100C to 213 | protect itself. 214 | 215 | v1.6.4 - (March 12, 2024) 216 | - PATCH: Fixed some minor spacing issues on the WiFi page that was covering some info if the 5GHz range is turned 217 | off. Also some minor fixes to the screen utility logic that was causing some visual unknown operand errors when 218 | starting RTRMON without a secondary commandline argument. 219 | - PATCH: Fixed some of the minor look & feel to bring it more in line with the latest "standards" I've implemented 220 | across some of my other scripts. 221 | 222 | v1.6.2 - (February 7, 2024) 223 | - PATCH: Changed the versioning logic to align with the general accepted way of versioning, using the notation: 224 | major.minor.patch ... finally, right? After seeing @thelonelycoder changing his ways, I figured it was probably 225 | time for me as well. All my scripts moving forward will go this route. Change log wording is now changed to 226 | conform to the major/minor/patch standards. So previously, FIXED now conforms to PATCH, ADDED conforms to MINOR, 227 | and MAJOR stays the same! 228 | - PATCH: Updated the NC statement that runs the SSL Handshake test under the Diagnostics menu. For some reason, 229 | something changed on possibly Google's end, yielding a failure each time. Now utilizing the same modified SSL 230 | Handshake statement carried over from VPNMON-R3 which is coming back successful. Thanks to @Makaveli for the 231 | heads-up! 232 | - MINOR: Added new functionality that allows you to start on a specific page. A very old request from @Stephen 233 | Harrington! Thank you! :) You can make use of this functionality by specifying a page number (1-6) after you 234 | execute RTRMON using the -monitor or -screen function switch. (Example: rtrmon -monitor 2) This would execute 235 | RTRMON, and will start on the 2nd page (network bandwidth/usage stats). Enjoy! 236 | 237 | v1.58 - (December 7, 2023) 238 | - FIXED: Issue where RTRMON would be returning invalid operand errors due to null vpnclient state entries in NVRAM. 239 | Used @Martinski's excellent function to catch for these now. 240 | 241 | v1.57 - (September 12, 2023) 242 | - FIXED: Issue where on certain routers, whether it was a new install, or perhaps openvpn was never configured, or 243 | perhaps only wireguard was being used, needless to say, the NVRAM variables for all 5 openvpn slots were returning 244 | null values, instead of an expected 0. Now assumes a zero if it returns null. 245 | 246 | v1.56 - (June 24, 2023) 247 | - FIXED: There were a few instances of "Ghz" wording on the setup screen that now have been corrected to GHz. Many 248 | thanks to @ColinTaylor for uncovering these unforgivable semantic errors. 249 | 250 | v1.55 - (May 13, 2023) 251 | - ADDED: Added functionality to the speedtest section to either test your WAN connection, or if one exists, your 252 | VPN connection! Thanks to @Shades for the suggestion/idea! :) 253 | 254 | v1.54 - (January 3, 2023) 255 | - ADDED: Now giving more visibility to the status of the Wi-Fi scheduler, and showing whether or not the Wi-Fi is 256 | up or down based on the scheduler. Please note, when the scheduler disables Wi-Fi for a certain time period, the 257 | Wi-Fi itself actually still shows as enabled. Thanks to @heysoundude for the suggestion, and to @ColinTaylor for 258 | sharing his wisdom on how to find these particular intriquite settings under NVRAM! 259 | - FIXED: Thanks to @jtp10181 for identifying an issue with the free command, and have inserted an explicit call to 260 | /usr/bin/free in case another version of free is present on the system returning invalid info. 261 | - FIXED: Regressed some changes back to v1.50 and implemented some different methods to achieve the same results, as 262 | the code I was using was causing some strange results. 263 | 264 | v1.51 - (December 31, 2022) 265 | - FIXED: Some logic was causing issues pulling up the NVRAM stats and causing a "malformed ?: operator" full-stop. I 266 | am guessing there was a difference between the way 386 reported these stats vs. 388. This fix should be backwards 267 | compatible, and was able to test that it continues to work on the old AC86U running 386.7_2. 268 | 269 | v1.50 - (December 7, 2022) HOTFIX 270 | - FIXED: Due to a variable name that was already being used, one of the UI figures was being misreported for the new 271 | speedtest results. Thanks much to @visortgw for catching this! 272 | 273 | v1.49 - (December 7, 2022) 274 | - CHANGED: Updated the script to point to the new Ookla Speedtest CLI version. Ookla updated the CLI (commandline- 275 | based speedtest executable) from v1.1.1 to v1.2.0. In order to update to the latest version, please visit the 276 | RTRMON config, disable/uninstall Speedtest, and re-enable/install it again. This will cause RTRMON to uninstall the 277 | old version, and download/install the new version. Thanks for the heads-up, @Matthew Patrick! 278 | - CHANGED: As as result of the new Speedtest CLI, page 4 has been significantly modified to show additional 279 | information as low/high idle, download and upload latencies as well as download and upload jitter, hopefully giving 280 | you a better idea on bufferbloat. 281 | - CHANGED: Modified the minimalist progress bar to show "[Selection? X]", indicating when it is acceptable to use a 282 | keypress, and added another banner indicating "[Refreshing Stats]". 283 | - ADDED: The version number now shows when RTRMON is kicked off with the -screen switch. 284 | - FIXED: The inputs on the config screen will now filter out any invalid characters, in the case someone uses decimals 285 | or accidentally adds letters. The temperature question will now also force input for C, K or F only now. Thanks to 286 | @ottofreud for working with me on this issue! 287 | 288 | v1.46 - (November 26, 2022) 289 | - HOTFIX: Added the requirement to check for the iftop binary, and if it's not installed, will prompt you through the 290 | setup menu to install/re-install entware dependencies. iftop is used to gather connections and bandwidth stats and 291 | give you the top 10 connections for WAN, LAN and VPN interfaces. 292 | 293 | v1.45 - (November 25, 2022) 294 | - MAJOR: Added a 6th page of statistics... this time borrowing a little magic from the iftop command, and giving you 295 | the top 10 network connections/bandwidth info currently taking place on your WAN, LAN and VPN connections! This info 296 | gives you a quick snapshot in time showing you current activity to satisfy any curiocity you may have on what servers 297 | or services your network clients are currently interacting with, or could be helpful determining bandwidth hogs, or 298 | tracking down curious outbound connections that require a bit more scrutiny and research. Happy Thanksgiving! 299 | 300 | v1.41 - (November 2, 2022) HOTFIX 1 301 | - CHANGED: Added a prerequisite check for the existence of JQ, which is now required when pulling info about your VPN 302 | connection. Thanks for the heads-up, @ugandy! 303 | 304 | v1.40 - (November 2, 2022) 305 | - ADDED: Borrowing a little something from VPNMON-R2, and are now showing VPN client statistics under page 2 of RTRMON. 306 | The VPN section shows current public VPN IP, VPN IP city location, current TUN (tunnel) slot and TX/RX stats of the 307 | current connection. Having this alongside your WAN and LAN stats, gives you a good perspective on what level of network 308 | traffic is truly happening on your router. This feature will now show up to 2 connected VPN clients that you may 309 | currently have connected due to screen space contraints. 310 | - ADDED: Now you are able to pick your own custom speedtest server ID to test against. This option is now available under 311 | the config menu. Please note, in order to find the ID, one method currently available is when using the browser and 312 | going to speedtest.net, when hoving your mouse over a specific test server, the digits on the end of the URL signify 313 | its ID. Enter these digits into the config menu item to always test against this preferred server. Leaving this field 314 | with a 0 entry will choose the closest/fastest test server to your WAN exit location. Look for item #10 under config. 315 | - ADDED: An option to choose a more minimalist progress bar. Thanks to @ugandy, you can specify if you want the standard 316 | or minimalist progress bar under the config menu, item #12. For those who found it annoying or distracting, enjoy! 317 | - ADDED: An auto-rotate option is now available by hitting the (R)otate pgs option from any of the currently 5 different 318 | stats screens. When doing so, RTRMON will automatically advance to the next page, and loop through each until you 319 | disable this feature by again hitting the (R)otate pgs key. Thanks for the suggestion, @Stephen Harrington! 320 | - ADDED: More log events have been added, namely when the script started up, results of speed tests, and when your VPN 321 | changes so that it lets you know that an API call was made to determine your public VPN IP and exit city location. 322 | - CHANGED: As with VPNMON-R2, now when you make changes to the config while running the program, upon return to the main 323 | UI, your changes will automatically be applied without needing to exit and restart. 324 | - CHANGED: Modified the update functionality to allow you to force-update your current RTRMON script with the current 325 | build available on github. 326 | - FIXED: Under heavy load, I noticed that the CPU percentages did not add up (close to) 100%, and realized that I left 327 | out a vital component, namely the IRQ stat. This item has now been added under the CPU stats, giving you a little more 328 | accuracy on current CPU activity. 329 | - FIXED: RTRMON is now able to recognize whether your VPN connection is using a public or private network, and will 330 | accommodate for each in the UI under page #2. Thanks to @visortgw for reporting this issue! 331 | - FIXED: The minimalist progress bar will now also be visible during the initial booth sequence... thanks for the 332 | suggestion, @visortgw 333 | 334 | v1.32 - (October 11, 2022) - HOTFIX 2 335 | - FIXED: Added some additional error checking on the network diag functions based on some output/screenshot received from 336 | @DJones. Thank you! NC errors should be suppressed from this point forward, allowing RTRMON to show a passed/failed 337 | message after the completion of each test. 338 | 339 | v1.31 - (October 7, 2022) - HOTFIX 340 | - FIXED: Ookla continues to surprise me with getting their licensing agreement in your face in places you don't expect it. 341 | In this case, it was interfering with the results file being saved, and causing malformed strings, gunking things up. 342 | The process has now changed a bit... On a new install, or when you select option 9 to enable the Ookla Speedtest, after 343 | the install completes, an initial speedtest is run where the license file is captured and saved to the /jffs/addons/ 344 | rtrmon.d folder. Each time RTRMON runs, it will check to see if that license file exists, if not, it will copy it over 345 | from the /root/.config/ookla folder, and vice versa... if the /root/.config/ookla folder is gone due to a router reboot, 346 | it will copy that license file back over, hopefully providing some stability. Thanks to @ugandy for reporting this 347 | issue! :) 348 | 349 | v1.30 - (October 7, 2022) 350 | - MAJOR: Added a 5th page of STATS! -- View Network Diagnostics and and Open TCP/UDP Port Scanner!! This page gives you the 351 | option of running a network diagnostics check, and will test the following: Local clock, network connectivity, network 352 | resolution, dig functionality, curl functionality, spider functionality and SSL Handshakes! It will furthermore run an 353 | nmap scan against your local BR0 LAN connection and your public WAN connection, giving you information about any open 354 | TCP or UDP ports it finds. You can switch back and forth between the TCP and UDP results by hitting (T) and (U) while 355 | on that page. Huge thanks to @SomeWhereOverTheRainbow for his inspiration and code for this functionality. This code was 356 | originally designed as a very efficient WAN check, it ended up getting converted into a slick network diag function. ;) 357 | - ADDED: Nmap is now part of the required Entware Dependencies for RTRMON to run and perform all of its intended functions. 358 | This can be added by going into the Setup menu, and choosing "sc" - Setup & Configure, or "fr" - Force Reinstall 359 | Dependencies. 360 | - FIXED: the -wipe SCREEN command is now being checked earlier before the script determines how it is going to initiate a 361 | SCREEN session. 362 | - FIXED: Looks like my 2.4GHz antenna temp sensor stopped working suddenly, and generating a weird message, so I built in 363 | some error checking to eliminate those messages from making it to the screen. 364 | 365 | v1.24 - (September 29, 2022) 366 | - MINOR: Small wording changes around the setup menu when it comes to installing Entware prerequisites. Added a check when the 367 | script starts up to ensure that all prerequisites are in place before running the script. 368 | - CHANGED: The behavior of the "rtrmon -screen" command, so that when you execute this commandline parameter, it first will 369 | look for orphaned screens and wipe them... then, it will launch RTRMON into a new screen environment, and connect to it. This 370 | skips the original behavior where it drops back to a command prompt, and asks the user to connect to the RTRMON screen by 371 | requiring the user to run the "screen -r rtrmon" command. If a screen session is already running, and you type: 372 | "rtrmon -screen", it will then connect to this screen session without requiring any user input. Thanks much to @TITAN for the 373 | great suggestion! 374 | 375 | v1.23 - (September 10, 2022) 376 | - ADDED: Compatibility added for the other Asus-Merlin-compatible routers: GT-AX11000, ZenWiFi_Pro_XT12, and ZenWIFI_AX are all 377 | tri-band routers. Please know, I'm just taking a wild stab at identifying these router "model names", which would get read 378 | from your NVRAM. If these are not correct, and you're not seeing 3 different WiFi bands under your page (3) WiFi tab, please 379 | let me know. 380 | - CHANGED: Minor fixes and enhancements 381 | 382 | v1.22 - (September 7, 2022) 383 | - ADDED: Based on excellent feedback from @ugandy, I have added compatibility for the more advanced GT-AXE11000 and the 384 | GT-AXE16000 routers with 3 or 4 different WiFi interfaces, 2.4Ghz, 2 x 5Ghz and 6Ghz transmitters. In doing so, the WiFi 385 | section has now been split off onto its own page (3) to handle up to 4 different wireless interface statistics. This version 386 | adds completely new logic to handle the weird interface assignment for the GT-AXE16000, the more standard 2.4/5/6GHz 387 | assignment for the GT-AXE11000, and the even more different 2.4/5-1/5-2GHz assignment for the GT-AX11000_PRO. I think I have 388 | a method now to easily add new models as they come up... the downside is that I have to define them to specify what kinds of 389 | assignments they "might" have. 390 | - ADDED: Included the interface names for all the Wireless transmitters to be included on top of the stats for each. 391 | - ADDED: A (P)revious page keypress function that allows you to now go back and forth between pages! Whoo! 392 | - CHANGED: Moved the (I)nitiate Speedtest menu item to the top of page (4) on the Speedtest page. 393 | 394 | v1.20 - (August 28, 2022) 395 | - CHANGED: Thanks to @Jack Yaz, always pushing me to do better, I have accepted the challenge, and created a numbered list of 396 | valid interfaces to choose from instead of typing in an interface name. It is completely understandable that relying on people 397 | to type in the correct interface name might cause you to lose faith in humanity, but I was trusting. ;) I think it took me 398 | longer to come up with a working method to validate input! LOL 399 | 400 | v1.19 - (August 28, 2022) 401 | - ADDED: Added another menu item that allows you to override the default interface assigned to WAN0. Thanks to @adahnert for the 402 | suggestion, and for @SomeWhereOverTheRainBow for helping shape this feature! :) This menu item will list the valid interfaces 403 | that are currently available on your router for you to pick from. Please note, correct spelling and case senstivity is very 404 | important when entering this value! 405 | - ADDED: The interface name is now visible on page (2) next to the WAN0/1 IP4 address field. This will give you a quick way to 406 | view what interface is currently selected to monitor your WAN stats. 407 | - FIXED: Fixed the other menu items so that if someone just hits enter while prompting for a value, that the default value gets 408 | added. This should help catch any accidental entries (or cats walking across your keyboard), and increases the chances for a 409 | valid entry to be registered. 410 | 411 | v1.17 - (August 24, 2022) 412 | - FIXED: Added a few more timeout commands to some recently imported NVRAM GET statements that were locking up my script 413 | again. Grr. 414 | - CHANGED: The way that the progress bar percentages work, and now allows them to display values > 100%. This was evident 415 | where indicated or measured speedtest bandwidth rates were being capped at the top of specified speeds, and would not show any 416 | values greater than what was specified in the config. So now, if you specified that you have a 1Gig pipe, and you're actually 417 | pulling down 1200Mbps, it will show your current bandwidth rate at 120%. This change has been made for any networking and 418 | temperature values. Thanks much to @visortgw for the suggestion! 419 | 420 | v1.15 - (August 17, 2022) 421 | - FIXED: Modified the df command which is used to assemble /jffs stats/information, and came across a weird situation that was 422 | breaking the command due to it referencing ubi:/jffs instead of dev:/jffs... Thanks for the find, @visortgw 423 | 424 | v1.14 - (August 17, 2022) 425 | - FIXED: Based on feedback from @adahnert running on stock Asus firmware, I have made some mods to certain NVRAM calls that don't 426 | seem to return any values when running on non-Merlin firmware. Happy to oblige, so now the cache total value defaults to 100 427 | if there is no cache configured (to avoid divide-by-zero errors and wonky progress bars), and the WAN interface name now 428 | defaults to "eth0" if this value is returned as a blank. 429 | - ADDED: The router model at the top of the page to easily identify what kind of device this is. 430 | 431 | v1.12 - (August 7, 2022) 432 | - FIXED: Prevented the hotkey menu from working during the initial boot process while it is capturing data for display purposes, 433 | and makes this menu active after the capture process. This helps prevent invalid results from being display and borking things 434 | up with error messages. ;) Thanks for the find, @Stephen Harrington! 435 | - FIXED: A couple of minor numbering typos for some setup menu entries. 436 | 437 | v1.11 - (August 6, 2022) 438 | - FIXED: A parsing issue was generating some weird results due to the formatting of some the test servers, and subsequently dropping 439 | the wrong data into the wrong fields. 440 | 441 | v1.1 - (August 5, 2022) 442 | - MAJOR: Added a major enhancement to RTRMON -- namely, the commandline Ookla Speedtest binary! Whoo! On the newly added Page 3 of 443 | the application, you can now initiate a manual speedtest! It will by default use your primary WAN connection and pick the closest 444 | server to you to run its test, and display these results on Page 3. These results are saved to a file, so next time you launch 445 | RTRMON, you will be able to see your last results. There are no fancy spdMerlin graphs or charts, but just good ol' plain data, 446 | and some progress indicators giving you a dashboard-like view of your actual vs max WAN up/down speeds. In the setup menu, you 447 | can now enable 'Ookla Speedtest', which will download and install the binaries. If you disable it, the setup menu will prompt you 448 | to uninstall these components for you. 449 | - ADDED: Another variable has been added to capture your WAN upload speed. I personally don't have symmetrical up/download speeds, 450 | and using this will only give you a better indicator what's happening on your network as it measures and displays these results. 451 | - ADDED: Additional stats on the networking page, including the WAN and LAN IP6 addresses. Though my alignment OCD will have to live 452 | with the fact that IP6 addresses are variable length and won't fit nicely between brackets. Thanks to @SomewhereOverTheRainbow for 453 | his assist in developing the code that pulls this info! RTRMON v1.06b1 additions have been absorbed under this major release. 454 | 455 | v1.05 - (July 22, 2022) 456 | - FIXED: Additional bug that @Stephen Harrington uncovered regarding the WAN DNS NVRAM variable being used, and was yielding some 457 | different results for him than it was for me. Changed it to look at a different variable, and built in some more logic that 458 | picks the DNS entries depending on which WAN connection is active. 459 | 460 | v1.04 - (July 22, 2022) 461 | - ADDED: Additional stats on the networking page, include WAN0, WAN1 and LAN IP addresses... as well as WAN DNS IP addresses! Whoo! 462 | - CHANGED: Increased the number of digits after the decimal for all networking traffic to show a little more precision. 463 | - CHANGED: All setup menu's look & feel now match that of VPNMON-R2! We have achieved congruency! :) 464 | 465 | v1.03 - (July 20, 2022) 466 | - FIXED - It looks like there was some inconsistency in the way the JFFS partition was being measured as well, and fixed that code to 467 | be a bit more compliant with returning the right values. 468 | 469 | v1.02 - (July 20, 2022) 470 | - FIXED - Apparently AC68U's have a different way of capturing the CPU temp, and am checking for this alternate way on any router that 471 | might use the same methods. So now there's two. ;) 472 | 473 | v1.01 - (July 18, 2022) 474 | - FIXED - Bug fix that was occasionally being caused by reading a blank NVRAM file causing an arithmetic error! 475 | - ADDED - capability of checking NVRAM to determine whether your wl0 or wl1 (wireless LANs) are turned on or not, and if not, it will 476 | show as disabled in the UI - Thanks @Stephen Harrington! 477 | - ADDED - if someone fat-fingers the temp units other than C, F or K, it will just default to C. 478 | 479 | v1.0 - (July 16, 2022) 480 | - FIXED - Now allows you to set your WiFi speeds to 0 if you effectively have them disabled (Thanks @Stephen Harrington) 481 | - FIXED - Changed temp units to force to uppercase during config, and made a small wording change (Thanks @Thirteen) 482 | 483 | v1.0RC1 - (July 15, 2022) 484 | - RELEASE - Release Candidate 1 (RC1) is officially out there! 485 | - ADDED - Added a setup, config, uninstall, and update menu, along with options to view logs, or launch RTRMON regularly in an SSH window, 486 | or using the screen utility. Many of these capabilities came over from VPNMON-R2. 487 | - ADDED - Using proper add-on guidelines, support files are now located under /jffs/addons/rtrmon.d, with the main rtrmon.sh located under 488 | the /jffs/scripts as usual. 489 | -------------------------------------------------------------------------------- /enhancements.txt: -------------------------------------------------------------------------------- 1 | Future Enhancements (Possible/Planned) 2 | ----------------------------- 3 | * AMTM Email notifications on certain events (like 80% disk usage) 4 | * Perhaps check the amount of uptime of the router, and if it's less than 5 minutes, send a notification that the router just rebooted 5 | 6 | Completed: 7 | ---------- 8 | * Fix VPN/WG Speedtest availability in UI if one or the other isn't being used 9 | * Include Wireguard Slots + Stats 10 | * opkg install column -- RTRMON! 11 | * FIX the VPN-site-to-site option and exclude any private VPNs from needing ping tests or city lookups. (visortgw) 12 | * 'update [y/n] not waiting for an enter keypress causing the Enter to go into the buffer and skipping the next prompt' 13 | * Sorting of attached clients, name/ip/mac, etc. 14 | * Find way to exclude VPN from Connection test due to private site-to-site private IPs causing delays (visortgw) 15 | * Implement -now switch 16 | * Instead of just showing up-to-2 VPN connections, show all of them 17 | * Startup on a certain page (Stephen Harrington) 18 | * Go direct to pages 1-5 (Stephen Harrington) 19 | * Implement the exec command to apply changes immediately per @thelonelycoder 20 | * Speedtest VPN connection in addition to WAN 21 | * Snapshot of top bandwidth usage on br0 and eth* and vpn* 22 | * Allow user to pick own custom speedtest server by ID 23 | * maybe an option to disable the countdown bar? i find it distracting (@ugandy) 24 | * config changes are applied upon exit & save 25 | * Autorotate through pages (Stephen Harrington) 26 | * Added CPU IRQ stats to the CPU stats 27 | * Show VPN traffic usage on WAN/LAN page 28 | * Add log events for boot, speedtest and vpn api calls 29 | * Force update (like in vpnmon-r2) 30 | * Add UDP open ports tab 31 | * WAN diagnostics/test page 32 | * Allow percentage results to indicate > 100% 33 | * Added compatiblity for the GT-AXE/AX line of routers 34 | 35 | Ideas or Discussion 36 | ------------------- 37 | If you have any ideas or requests, please don't hesitate to mention them here in the forums for further discussion: 38 | https://www.snbforums.com/threads/release-rtrmon-v1-15-aug-17-2022-monitor-your-routers-health-new-ookla-speedtest-geek-out-and-measure-your-cpu-temp-in-k.79738/ 39 | -------------------------------------------------------------------------------- /version.txt: -------------------------------------------------------------------------------- 1 | 2.2.2 2 | --------------------------------------------------------------------------------