Search This Blog

2020-09-27

Windows 10 Hardware Temperature Monitoring Tools

Tool to monitor temperature of hardware components in Windows 10

Open Hardware Monitor - portable open source version of hwmonitor

Core Temp - more CPU measurement features

2020-09-23

Terminal Ping Sweep

Result: List of IP addresses that respond to ping on the specified prefix
  1. Modify the prefix variable as necessary, and paste into terminal
  2. prefix="192.168.0."
  3. Copy and Paste the rest of the following script into the terminal application
  4. for i in {1..100}
    do
            ping -c1 -W1 -i0.2 $prefix$i > /dev/null
            if [ $? -eq 0 ]
            then
                    echo $prefix$i
            fi
    done
    

2020-08-15

Windows cmd ping sweep

Instead of installing a third party application which has the possibility to have spyware or other bad stuff in it. If you only need to do a ping sweep with no additional features it's probably easier just to do it in CMD.
  1. Open up cmd
  2. Run the following
  3. for /L %z in (1,1,254) do @ping 10.0.0.%z -w 10 -n 1 | find "Reply"

Where:

  • (1,1,254) indicates to test every address from 1-254
  • 10.0.0. is the network address prefix of addresses you want to test
  • %z is filled in with numbers from (1,1,254)
  • -w 10 - only waits 10ms before moving on
  • -n 1 - only tries once before moving on
  • find "Reply" looks for a succesful ping result and ignores unsuccessful

2019-01-23

Scheduling Internet Speed Tests on Synology

SSH into the synology device

Download the following script to whichever directory you like

wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py


Allow execute permissions

chmod +x


Create a scheduled task via "Task Scheduler" section in control panel
Run Command should look similar to the following

/bin/python /path_to_script/speedtest.py


For some reason the output doesn't appear in the task scheduler window when the full output is displayed

However, the results are appearing properly in the email notification and when I reduce the amount of output by modifying the script a bit it displays properly as well
python speedtest.py --no-download --simple

You can automatically log the output of any script to a file as well in Task Scheduler.
This can be done by going to the Task Scheduler app, Settings, enabling output recording, and specifying a directory to store output.


References:
https://forum.synology.com/enu/viewtopic.php?t=130824
https://www.reddit.com/r/synology/comments/76wxd8/speedtestcli_on_diskstation/

2015-12-07

Clean Console Log Output

To remove colour codes and redraw characters from console to make console logs more readable.


#!/usr/bin/env perl
while (<>) {
s/ \e[ #%()*+\-.\/]. |
(?:\e\[|\x9b) [ -?]* [@-~] | # CSI ... Cmd
(?:\e\]|\x9d) .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL)
(?:\e[P^_]|[\x90\x9e\x9f]) .*? (?:\e\\|\x9c) | # (DCS|PM|APC) ... ST
\e.|[\x80-\x9f] //xg;
print;
}


Usage:

less /path/to/console.log | cleanLog | less

2015-09-14

Account Locked Due to Failed Logins

I spent this morning fat fingering/forgetting my password so many times my account was locked out.

I'm using SUSE 11.

The way in which I managed to fix it is by rebooting the system, going into grub.

Pressing 'e' on the boot loadeder and adding "init=/bin/bash" to the end to boot to a bash prompt.

Changed my password by using

passwd $username


Then unlocking my account by using

pam_tally2 -u $username -r

where the -r resets login attempt

2015-07-21

Limiting Bandwidth Using Robocopy

Robocopy does not have any built in bandwidth limiter by rate specifically.

But what you can do is use the inner packet gap switch /ipg:n to simulate a lower bandwidth by adding more delay between packets.

The equation to use to calculate is as follows:

Where
D is the calculated latency or inner packet gap
Bd is the desired bandwidth you would like to transfer at
Ba is the available bandwidth to you

Example:
If my
Bd is 200kbps
Ba is 1000kbps

D=((1000-200)/(1000*200))*512*1000=2048


Therefore my /ipg:n will be /ipg:2048

References:
https://yellowtriangle.wordpress.com/2012/06/28/bandwidth-throttling-with-robocopy/
http://www.zeda.nl/index.php/en/copy-files-on-slow-links
https://technet.microsoft.com/en-us/library/cc733145.aspx

2015-07-11

Sourcing Files in Bash

I never quite understood why when you changed .bashrc you had to type the source command in order to make changes active.

Now I understand and it's fairly straight forward.

Your current bash environment is defined by a PID that can be found using

echo $$


Any newly spawned bash processes for scripts will fork off of that process and be given a new process ID.

All variables for that newly spawned process will be local to that newly forked process.

If you would like the variables that would typically be local to your forked script to be active in your current shell you can use the source command in order to make them local to your current shell.

This acts in the same way when you would like to make variables in the .bashrc script local to your current shell. When the computer boots it runs .bashrc and puts variables in your current shell. If you would like to make any variable changes to re-read into your current shell. Similarly to how you would make variables to a remote script available to your local shell by using the source command you can do the same for .bashrc

Example:

source script.sh

The above will make all variables in script.sh available to your local shell at echo $$


source .bashrc

The above will make all variables in script .bashrc available to your local shell at echo $$

2015-06-18

2015-04-29

Create Redhat Syncronized Repo with Reposync

Prerequisites

  • Server registered with the appropriate version of RedHat
  • HTTP/FTP server to host repo files

Instructions

Install required components for managing yum repositories and createrepo utility for building new repo indexes.

yum install yum-utils createrepo


Register with RedHat to gain access to their repos

rhn_register

OR

subscription-manager register --username $username --password $password --auto-attach


Repos will be populated automatically upon registration and you can then list them using:

subscription-manager repos --list


Download the repos to a path of your chosing

reposync --gpgcheck -l --repoid=$repoid --download_path=$path


Create the repo against the directory where your rpm packages exist

cd $path
createrepo $path


Enable the local repo

vi /etc/yum.repos.d/rhel.repo

[rhel-repo]
name=Red Hat Enterprise Linux 7 - x86_64
baseurl=http://$server/$path
enabled=1
gpgcheck=0


Ensure the repo works, this will likely build the index at the same time. I've seen elsewhere where cache is refreshed using yum makecache but I haven't run into a scenario where I have to do that yet.

yum repolist


References:
https://access.redhat.com/solutions/23016
http://kb.kristianreese.com/?View=entry&EntryID=77