What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

One error is if you delete only one line in a file. It is already fixed in my code.

Curious which you're referring to? I can go ahead and fix up my code for anyone interested in using it until you have the next release (unless that is happening imminently). I don't think you have public code repo, but if you do just point me there :)

thanks!
 
Curious which you're referring to? I can go ahead and fix up my code for anyone interested in using it until you have the next release (unless that is happening imminently). I don't think you have public code repo, but if you do just point me there :)

thanks!
The variable $delete_range_end can be a null or "" so I added a test for when you delete a single line.
This code may be differing from yours as I changed it to my way of coding.
Code:
delete_range_start=$(echo $deleteline | awk -F "-" '{print $1}')
delete_range_end=$(echo $deleteline | awk -F "-" '{print $2}')
[ "$delete_range_end" = "" ] && delete_range_end=$delete_range_start

if [ "$delete_range_end" -lt "$delete_range_start" ]; then
    printf "\\n upper range must be higher than lower range.\\n"
else
    if [ "$delete_range_end" = "$delete_range_start" ]; then
        delete_range_end=$delete_range_start
    elif [ "$delete_range_end" -gt "$lineNumbers" ]; then
        printf "\\n${RED_BG} Setting range to last entry${NC} (line: $lineNumbers)\\n"
    fi
    break
fi
 
The variable $delete_range_end can be a null or "" so I added a test for when you delete a single line.

This code may be differing from yours as I changed it to my way of coding.

Code:
...
[ "$delete_range_end" = "" ] && delete_range_end=$delete_range_start
...

It was that single line above, the rest of the code is identical to mine which means I did a pretty good job sticking to "your way of coding" ;)

I did have that working and tested, but then I realized that my behavior for breaking out/repeating for invalid input didn't match your convention so in cleaning up that block to be more efficient I somehow left that out and didn't bother to test it again since it was the "easy" test. I've got my code and links updated above so anyone getting it until the next release will have the fix.

thanks
 
It was that single line above, the rest of the code is identical to mine which means I did a pretty good job sticking to "your way of coding" ;)
You did, most of it. I strive for POSIX compliance and strictly no bashisms.
 
You did, most of it. I strive for POSIX compliance and strictly no bashisms.
At a previous job I was partly responsible for maintaining an installation script for a product that needed to run on every single unix/linux platform - so we had a similar POSIX compliance methodology. I learned most of what I know about shell coding from there...which still isn't much, but I'm pretty good at faking it.
 
At a previous job I was partly responsible for maintaining an installation script for a product that needed to run on every single unix/linux platform - so we had a similar POSIX compliance methodology. I learned most of what I know about shell coding from there...which still isn't much, but I'm pretty good at faking it.
The comment for the function says it all:
# aka THE MONSTER
edit_list(){

Since you understood the monster and were able to add working functionality to it without breaking it: thumbsup.jpg
 
I'm getting very high cpu usage and it seems to be coming from Diversion do you know what this process is doing?





*update*

I rebooted router and it was still high only way to get cpu usage back to normal was to kill the process in htop.
 
Last edited:
I'm getting very high cpu usage and it seems to be coming from Diversion do you know what this process is doing?





*update*

I rebooted router and it was still high only way to get cpu usage back to normal was to kill the process in htop.
Which model of router? No abnormal cpu usage on my AC86U
 
I'm getting very high cpu usage and it seems to be coming from Diversion do you know what this process is doing?





*update*

I rebooted router and it was still high only way to get cpu usage back to normal was to kill the process in htop.

I saw the exact same thing (and I think @skeal did too), but I wasn't aware it was (or could have been caused by...) Diversion. After two reboots it was gone (and for @skeal a power cycle). It makes more sense now, as I saw the same thing when I reverted to 384.6 and the same high CPU load showed up again. Should have checked htop to see which process caused it, so can't confirm whether it was Diversion in my case as well...
 
Last edited by a moderator:
I saw the exact same thing (and I think @skeal did too), but I wasn't aware it was Diversion. After two reboots it was gone (and for @skeal a power cycle). It makes more sense now, as I saw the same thing when I reverted to 384.6 and the same high CPU load showed up again. Should have checked htop to see which process caused it, so can't confirm whether it was Diversion in my case as well...
When it happened? Straight after reboot and loading diversion? How Long it last? What is the frequency of it having spike?
Mine is 384.7 alpha 1 and the cpu quite normal.
 
@Makaveli that's the ash history sorting and removing duplicates.
Open two shells one with htop and in the other enter
Code:
diversion ash_history
 
When it happened? Straight after reboot and loading diversion? How Long it last? What is the frequency of it having spike?
Mine is 384.7 alpha 1 and the cpu quite normal.
After uploading firmware, initializing, rebooting twice to make sure /jffs was populated and writable, installing Diversion, amtm, and from amtm creating a swapfile and Skynet. I've seen it on 384.6, 384.7 alpha 1 and 2. High cpu load occured after rebooting, with (very much) similar behaviour as in @Makaveli's screenshot lasted continuously and I needed to reboot twice to bring back the CPU load to nearly idle. I haven't measured frequency, didn't think of that. At first I thought it were just background processes running after uploading new firmware, but now @Makaveli has the same kind of issue (and I know @skeal had them too - see the 384.7 alpha thread) I'm starting to wonder whether it can be caused by something else. Not blaming Diversion, but the behaviour seems identical to what others have observed.
 
After uploading firmware, initializing, rebooting twice to make sure /jffs was populated and writable, installing Diversion, amtm, and from amtm creating a swapfile and Skynet. I've seen it on 384.6, 384.7 alpha 1 and 2. High cpu load occured after rebooting, with (very much) similar behaviour as in @Makaveli's screenshot lasted continuously and I needed to reboot twice to bring back the CPU load to nearly idle. I haven't measured frequency, didn't think of that. At first I thought it were just background processes running after uploading new firmware, but now @Makaveli has the same kind of issue (and I know @skeal had them too - see the 384.7 alpha thread) I'm starting to wonder whether it can be caused by something else. Not blaming Diversion, but the behaviour seems identical to what others have observed.
The symptoms may be the same but without top/htop output it is all speculation, and could be completely unrelated to Diversion.
 
@Makaveli that's the ash history sorting and removing duplicates.
Open two shells one with htop and in the other enter
Code:
diversion ash_history

It looks like the installer adds this into the /jffs/scripts/post-mount.div so that it runs every time the usb drive is mounted.

From what I can tell from the code in the main diversion file, there is a sort_ash_history function that is run either when:
1) you launch diversion with diversion_ash_history as you mention
2) you choose the option "reset shell history" within diversion.

The code seems to do the following:
1) sorts your shell history in reverse alphabetical order, removing all duplicates and line breaks.
2) moves any line containing "diversion" to the bottom of the file.

The only functional thing this seems to do is, since it puts all your diversion commands at the bottom of the history list, they are quickly accessible with arrow up on your next login to the router.

I'm quite confused why Diversion has this functionality - especially to run automatically at every post-mount?

That being said - I shouldn't think it is harmful (other than being a non-advertised behavior that the user may not want).
However I suppose this high CPU can happen if a user has an exceptionally large .ash_history.

For those of you seeing high CPU utilization, what is the number of lines in your history. Find this with:

Code:
cat /jffs/.ash_history | wc -l

I suspect that those with utilization issues might have tens or hundred of thousands of lines?
 
After uploading firmware, initializing, rebooting twice to make sure /jffs was populated and writable, installing Diversion, amtm, and from amtm creating a swapfile and Skynet. I've seen it on 384.6, 384.7 alpha 1 and 2. High cpu load occured after rebooting, with (very much) similar behaviour as in @Makaveli's screenshot lasted continuously and I needed to reboot twice to bring back the CPU load to nearly idle. I haven't measured frequency, didn't think of that. At first I thought it were just background processes running after uploading new firmware, but now @Makaveli has the same kind of issue (and I know @skeal had them too - see the 384.7 alpha thread) I'm starting to wonder whether it can be caused by something else. Not blaming Diversion, but the behaviour seems identical to what others have observed.
I had a similar problem as stated in OP following the install of diversion. I did a cold boot and it fixed it. I have not had the problem since. I have rebooted several times and changed settings as well and still no problem since having to cold boot.

[RESOLVED]One observation I have seen, is a quick spike in cpu usually one of the two cores spikes up to about 50% and then resumes its normal output. I'm referring to the graph on the network map page.

EDIT: Turns out the spike every so often is my OVPN client.
 

Attachments

  • ASUS Wireless Router RT AC3100   Network Map.png
    ASUS Wireless Router RT AC3100 Network Map.png
    224.1 KB · Views: 405
Last edited:
The only functional thing this seems to do is, since it puts all your diversion commands at the bottom of the history list, they are quickly accessible with arrow up on your next login to the router.

I'm quite confused why Diversion has this functionality - especially to run automatically at every post-mount?
It sorts the .ash_history file, a function that is not built into the command line options of BusyBox. It also keeps the .ash_history file in jffs so it survives a reboot. Running it at boot ensures you have a sorted file when next logging in with ssh.

Adding the last diversion commands to the top is a feature that Diversion users might find handy.
Keeping the ash history and sorting it has been added way back in earlier AB-Solution releases.

If your history is too long, just runs sh in Diversion, this resets the file. It can be found in the expanded menu o.
 
The symptoms may be the same but without top/htop output it is all speculation, and could be completely unrelated to Diversion.

That's absolutely true, therefore I'm not 'pointing fingers'. I thought I'd just mention I saw something similar occur that might be related. We're here to help, right?
 
@thelonelycoder A question regarding a custom hostslist. My hostslist looks as follows:

Code:
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts

The first line is in there by default I assume (it was a clean Diversion 'standard' install) and I've added the second one through the UI. No doubt there will be several duplicates. Does Diversion filter them out? If not, does it affect performance in any way?
 
@thelonelycoder A question regarding a custom hostslist. My hostslist looks as follows:

Code:
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts

The first line is in there by default I assume (it was a clean Diversion 'standard' install) and I've added the second one through the UI. No doubt there will be several duplicates. Does Diversion filter them out? If not, does it affect performance in any way?
The first is the standard file, the second adds additional hosts. What remains after update-bf.div has done its work is essentially the second file.
Might as well ditch the first.
 
The first is the standard file, the second adds additional hosts. What remains after update-bf.div has done its work is essentially the second file.
Might as well ditch the first.
Thanks for the fast reply, removed the first hosts file using the UI.
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top