Syed Jahanzaib Personal Blog to Share Knowledge !

November 26, 2015

[LAB TEST] BASH: Linux Script to check Internet/Gateway status and SMS via kannel

Filed under: Linux Related — Tags: , — Syed Jahanzaib / Pinochio~:) @ 12:10 PM

net_sms_details

Personnel notes for reference. LAB tests only. Generally not for production usage. Make sure you modify overall script to use at least two hosts for monitoring.

Testing Script to check internet /gateway status. and send alert via kannel sms, while preventing repeated alert for same status.


#!/bin/bash
# Script to check Internet Status and alert (trigger one time for each status changed)
# Host to monitor
HOST1="4.2.2.1"

# Server / This Computer name
HOSTNAME=`hostname`

COMPANY="ZAIB"
DATE=`date`

# How many PING attempts
ping_attempts=30

# Temporary file holder for host status
HOST1_STATUS="/tmp/down_hosts.txt"

# Create temp file if not already present, usually for 1st time execution
touch $HOST1_STATUS

# SMS RELATED and KANNEL INFO

# KANNEL SMS Gateway Info
KANNELURL="127.0.0.1:13013"
KANNELID="kannel"
KANNELPASS="kannel"
CELL1="03333021909"

# SMS Messages for UP / DOWN
SMS_DOWN="$COMPANY ALERT: $DATE

$HOSTNAME: Internet / $HOST1 not responding to ping request. Check internet connectivity."

SMS_UP="$COMPANY INFO: $DATE

$HOSTNAME: Internet / $HOST1 is reachable now. OK!"

SMSDOWNHOLDER="/tmp/$HOST1_down.sms"
SMSUPHOLDER="/tmp/$HOST1_up.sms"

# Run the script
echo -e "Trying to ping $HOST1 / 30 times"
for HOST in $HOST1
do
count=$(ping -c $ping_attempts $HOST | awk -F, '/received/{print $2*1}')
if [ $count -eq 0 ]; then
echo "$HOST is down"
if  [ $(grep -c "$HOST" "$HOST1_STATUS") -eq 0 ]; then
echo "$HOST is down (ping failed) at $(date) .. SENDING DOWN SMS ..."
echo "$SMS_DOWN" > /tmp/$HOST1_down.sms
echo "$HOST" >> $HOST1_STATUS

# Sending DOWN SMS via KANNEL
cat $SMSDOWNHOLDER | curl "http://$KANNELURL/cgi-bin/sendsms?username=$KANNELID&password=$KANNELPASS&to=$CELL1" -G --data-urlencode text@-

fi
else
echo "$HOST is alive"
if  [ $(grep -c "$HOST" "$HOST1_STATUS") -eq 1 ]; then
echo "$HOST is up (ping ok) at $(date)... SENDING UP SMS ..."
echo "$SMS_UP" > /tmp/$HOST1_down.sms
# Sending UP SMS via KANNEL
cat $SMSUPHOLDER | curl "http://$KANNELURL/cgi-bin/sendsms?username=$KANNELID&password=$KANNELPASS&to=$CELL1" -G --data-urlencode text@-

sed -i "/$HOST/d" "$HOST1_STATUS"
fi
fi
done

Schedule it to run after very x minutes.

Regard’s
Syed Jahanzaib

BASH: Scheduled script to check linux service status and sms/email while preventing repeated alerts

Filed under: Linux Related — Tags: , — Syed Jahanzaib / Pinochio~:) @ 12:00 PM

BOYSERVICECHECK

sms

MAIL1

Following is linux base bash script which can be scheduled to run every X minutes and it can do following …

Personnel Note:

This script was made for an operator who was facing strange problem that in random timings , the mysql or some times radiusd service stopped automatically, unfortunately the error was not sorted out as it occurs in awkward timings when no one is at NOC, so I made an workaround in the form of this script so that we can diagnose the issue later in details and in the meanwhile manually startup of services should not be required. The script was scheduled to run after every 10 minutes.

Note: This is not a solution, Just a workaround for small period of time.

This script will check one or more services status, if found stopped, it will try to re-start them, and then check there status again and output there status in email.

In this example I took MYSQL and RADIUS services.

Its much easier to use some centralized network monitoring system like Mikrotik DUDE or NAGIOS  or likewise , but as we know that every system have its known limitations, and sometime it is un necessary to setup a network monitoring system just to monitor single PC or service.
In such situation where resources are limited OR you want some thing very customized solution of your own choices with your required bells and whistles ,  its recommended to do it with simple bash without needing any 3rd party tool.

 

PSEUDO CODE:

  • Check for Service status example mysqld
  • If it found it running, then do nothing. Exit
  • If it found it STOPPED, it will send you SMS alert for down status (one time only until next status change) via KANNEL sms gateway. It will also gonna try to start the service one time.
  • If it found the service running on next run, it will send service UP info via sms. (one time only until next status change)
  • Email Alerts for UP n DOWN added on 4th Dec, 2015

SCRIPT:

mkdir /temp
touch /temp/checksrv.sh
chmod +x /temp/checksrv.sh
nano /temp/checksrv.sh

Now paste the following



#!/bin/bash
# Scheduled Script to check linux service status after every 5 minutes.
# If found stopped, send sms or email Alerts, but donot repeat it untill next status change.
# Script Designed by Syed Jahanzaib
# aacable at hotmail dot com
# https://aacable.wordpress.com
# Created : 25-NOV-2015
# Last Modified = 4th-NOV-2015 1600 hours
# Pakistan !!!
#set -x

#SRV="$1"
SRV1="$1"
DATE=`date`

STATUS_HOLDER="/tmp/$SRV1.txt"
touch $STATUS_HOLDER

# COMPANY NAME
COMPANY="ZAIB"

# Hostname
HOSTNAME=`hostname`

# KANNEL SMS Gateway Info
KANNELURL="KANNELIP:13013"
KANNELID="kannel"
KANNELPASS="kannelpass"
CELL1="03333021909"

# GMAIL ACCOUNT INFORMATION AND RELATED ....
MAILER="/temp/sendEmail-v1.56/sendEmail"
TO1="aacable at hotmail dot com"
GMAILID="YOURGMAILID@gmail.com"
GMAILPASS="YOURGMAILPASSWORD"
MAILBODYDOWN="$SRV1 DOWN"
MAILBODYUP="$SRV1 UP"
MAILSUBJECTDOWN="$COMPANY ALERT: $HOSTNAME - $SRV1 is now DOWN @ $DATE"
MAILSUBJECTUP="$COMPANY INFO: $HOSTNAME - $SRV1 is now UP @ $DATE"


# Colors Config  . . . [[ JZ . . . ]]
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
OS="1"
osver=`cat /etc/issue |awk '{print $1}'`

# OS checkup for UBUNTU
if [[ $osver == Ubuntu ]]; then
echo -e "$COL_GREEN OS = Ubuntu $COL_RESET"
set OS="Ubuntu"
OSPKG="apt-get install -y chkconfig"

else

echo -e "$COL_GREEN OS = CENTOS $COL_RESET"
set OS="CENTOS"
OSPKG="yum -y install chkconfig"
fi

########################################

# Check if no service name is given
if [ "$SRV1" == "" ]; then
echo -e "$COL_RED No service name have been provided. $COL_RESET"
echo "Usage exmaple:"
echo -e "/temp/checksrv.sh mysqld"
echo "OR"
echo -e "/temp/checksrv.sh (Depend on your OS deployment)"
echo
exit 0
else

# Check if CHKCONFIG command is installed or not.
CHK=`which chkconfig`
if [ "$CHK" == "" ]; then
echo -e "$COL_RED CHKCONFIG command is not installed.
Please install it with following command

$OSPKG $COL_RESET"
exit 0
else

# Check if service is installed / valid or not
CHKSRV=`chkconfig | grep -w $SRV1`
if [ "$CHKSRV" == "" ]; then
echo -e "$COL_RED NO SERVICE is INSTALLED WITH $SRV1 NAME. Exiting ...$COL_RESET"
exit 0
else

#########################################
############## IF ALL OK, PROCEED FURTHER
#########################################

# Query Service UPTIME
QUERYSRVUPTIME=`ps -eo "%U %c %t" |grep "$SRV1" |grep -v grep| grep root`
uptime=`echo $QUERYSRVUPTIME |awk '{ print $NF }'`

SERVICE1="$SRV1"
SUBJECT="ALERT: $SRV1 is Down..."

# SMS Msgs test for up n down
MSG_UP="$COMPANY Info:

$HOSTNAME - $SERVICE1 is now UP @ $DATE.
$SRV1 UPTIME is $uptime.
Powered by Syed.Jahanzaib"
fi

MSG_DOWN="$COMPANY Alert:

$HOSTNAME - $SERVICE1 is now DOWN @ $DATE. Trying to restarting it. wait 1 mnt for next result.

Powered by Jz"

##### CHECK FOR SERVICE STATUS

for SRVCHK in $SERVICE1
do
PID=$(pgrep $SERVICE1)
if [ "$PID" == "" ]; then
echo -e "$COL_RED $SRVCHK is down $COL_RESET "
if  [ $(grep -c "$SRVCHK" "$STATUS_HOLDER") -eq 0 ]; then
echo -e "$COL_RED ALERT: $SERVICE1 is down at $(date) / trying to restart and SENDING SMS and EMAIL....$COL_RESET"
echo "$MSG_DOWN" > /tmp/$SERVICE1_down.sms

# Sending DOWN SMS via KANNEL
cat /tmp/$SERVICE1_down.sms | curl "http://$KANNELURL/cgi-bin/sendsms?username=$KANNELID&password=$KANNELPASS&to=$CELL1" -G --data-urlencode text@-

# Sending DOWN alert EMAIL via GMAIL
$MAILER -t $TO1 -u "$MAILSUBJECTDOWN" -s smtp.gmail.com:587 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o tls=yes -o message-file=/tmp/$SERVICE1_up.sms

# Start $SERVICE1 service if found down
service $SERVICE1 start
echo "$SRVCHK" >> $STATUS_HOLDER
fi

else
echo -e "$COL_GREEN $SRVCHK is alive with Uptime of $uptime
and its PID are as follows... $COL_RESET  \n$PID"

# IF Service found UP send SMS ONE TIME
if  [ $(grep -c "$SRVCHK" "$STATUS_HOLDER") -eq 1 ]; then
echo -e "$COL_GREEN INFO ALERT : $SERVICE1 is UP at $(date)
$SRV1 Uptime is $uptime
SENDING SMS and EMAIL.... $COL_RESET"
echo "$MSG_UP" > /tmp/$SERVICE1_up.sms

# Sending UP SMS via KANNEL
cat /tmp/$SERVICE1_up.sms | curl "http://$KANNELURL/cgi-bin/sendsms?username=$KANNELID&password=$KANNELPASS&to=$CELL1" -G --data-urlencode text@-
sed -i "/$SRVCHK/d" "$STATUS_HOLDER"

# Sending UP alert EMAIL via GMAIL
$MAILER -t $TO1 -u "$MAILSUBJECTUP" -s smtp.gmail.com:587 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o tls=yes -o message-file=/tmp/$SERVICE1_up.sms


fi
fi
done
fi
fi

USAGE:

/temp/checksrv.sh mysql
#OR
/temp/checksrv.sh squid

As showed in the image below …

SMS RESULT


cmd_details

EMAIL RESULTS:

FOR EMAIL ALERTS,

2- Download sendEmail tool to send email alerts

Install sendEmail Tool

tar zxvf sendEmail-v1.56.tar.gz
cd sendEmail-v1.56/

ADD SUPPORTING LIBRARY

for ubuntu

apt-get -y install libio-socket-ssl-perl libnet-ssleay-perl perl

for centos

yum -y install perl perl-Crypt-SSLeay perl-IO-Socket-SSL

 

EMAIL CONFIGURATION AND SAMPLE RESULTS OF RECEIVING

Try to send email using command line , make sure you fill the variables with your original values like mail address password etc: Example


/temp/sendEmail-v1.56/sendEmail -t $TO1 -u "Test Email" -s smtp.gmail.com:587 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o tls=yes -m "hi"

 

MAIL1

MAIL2

SCHEDULE the SCRIPT in CRON:

Open crontab in editor

crontab -e

Now add following

# Run CHECK SERVICE script after very 5 minutes
*/5 * * * * /temp/checksrv.sh mysqld
OR
*/5 * * * * /temp/checksrv.sh mysql

SAVE and Exit!


 

Regard’s

Syed Jahanzaib

November 24, 2015

Quick Note: Limit interface total bandwidth by Queue Tree

Filed under: Mikrotik Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 3:12 PM

1

Requirement:

Limit interface total bandwidth , Lets say we want to limit ether1 interface (wan or whatever) to total 1 mb for upload / download.

Use following.


/ip firewall mangle
add action=mark-packet chain=prerouting comment="Mark Packets for Upload on WAN interface / jz" in-interface=ether1 new-packet-mark=upload
add action=mark-packet chain=postrouting comment="Mark Packets for Download on WAN interface / jz" new-packet-mark=download out-interface=ether1

/queue tree

add comment="Limit Total Traffic to 1mb in Queue Tree / Jz" disabled=yes max-limit=1M name=total-traffic parent=global queue=default
add comment="Limit upload Packets marked by mangle / Jz" disabled=yes name=upload packet-mark=upload parent=total-traffic queue=default
add comment="Limit download Packets marked by mangle / Jz" disabled=yes name=download packet-mark=download parent=total-traffic queue=default


 

You can use it to distribute specific amount of bandwidth to specific subnet or number of users. Example if you have 10 mb of bandwidth link and you want to distribute 5 mb to specific number of users. Lot of otehr queuing trick you can do.

Regard’s
Syed Jahanzaib

November 19, 2015

Changeip.com DDNS Bash Script for Linux

Filed under: Linux Related — Tags: , , , — Syed Jahanzaib / Pinochio~:) @ 10:17 AM

changeipzaib-linux-choice

Posting for personnel reference:

Following script was made to update ddns record at changeip.com from Linux base pc using bash. I found script on net as well, but didn’t worked the way i wanted, So I made one myself. Simple yet effective!

#!/bin/bash
# Changeip.com Script for Linux base systems using bash
# Created to suite local need in specific case. Well tested with CENTOS 6.x n UBUNTU 12.x
# Syed . Jahanzaib . aacable at hotmail dot com
# October , 2015
# Uncomment below to view debug log
# set -x

# Various variables, make sure to change the changeip.com credentials and hostname as required.
CIPUSER=yourchangeip_account@xxx.xxx
CIPPASS=PASSWORD
CIPHOST=changeip_password
URL="https://nic.changeip.com/nic/update?ip"
# Temp files and log file to record updates if required
EXTIP="/tmp/externalip.txt"
NEWIP="/tmp/newip.txt"
LOG="/var/log/changeip.log"
DATE=`date`

# If external ip text file not found, then create one
if [ ! -e "$EXTIP" ] ; then
touch "$EXTIP"
fi

# Download current LIVE ip from intenret to match with old ip
wget -q -O /tmp/newip.txt http://ip.changeip.com:8245
a=`cat $EXTIP`
b=`cat $NEWIP  | cut -f 2 -d "=" | cut -f 1 -d "-" -s | grep -m 1 ^`
if [[ $a != "$b" ]]
then

# changeip update now
curl "$URL=$b&u=$CIPUSER&p=$CIPPASS&hostname=$CIPHOST"

# Update New WAN IP in OLD File
echo $b > $EXTIP
echo

# Print OLD vs New Comparision for REVIEW
echo Old IP = $a
echo New IP = $b
echo Update Time = $DATE
echo Update Done.

# Print OLD vs New Comparision for REVIEW in LOG FILE for later review
echo "*********************************************"  >> $LOG
echo New IP FOUND > $LOG
echo Old IP = $a >> $LOG
echo New IP found at $DATE and IP is = $b >> $LOG

# IF OLD and NEW ip are same, then no need to update, just EXIT
else
echo $DATE / No need to change IP. DDNS BASH Script / Powered by Syed Jahanzaib
fi

# END

November 17, 2015

DMASOFTLAB Radius Manager SMS/Email Alert for already expired account!

Filed under: Radius Manager — Tags: — Syed Jahanzaib / Pinochio~:) @ 12:53 PM

sms_alert

Task:

In Radius manager billing system, it is required to send users SMS/Email informing them that his/her internet account has been expired today, using local KANNEL sms gateway via bash / curl. The only difference between this and other expiry alerts is that this script will send alert to user (usually) right after his account expires only.

 


 

OS:
Linux / Ubuntu 12.4.5 /32bit

Billing System:
DMASOFTLAB Radius Manager 4.1.5

SMS Info:
Kannel 4.x with Teltonika Serial/COM G10 Modem with ‘Ufone’ operator SIM and yearly SMS bundle package.

Teltonika ModemCOM-G10 Serial / Com used to send / receive SMS using KANNEL as SMS Gateway

 


 

Solution:

Make this script and schedule it to run daily in night.

mkdir /temp/
touch /temp/sms2expiredusers.sh
nano /temp/sms2expiredusers.sh

(& copy paste following, make sure to change the info as mentioned in variables)

#!/bin/bash
# # set -x
# BASH base SMS script to inform users that there internet account been expired in Radius Manager today.
# the simple logic can be applied for about any other task as well. I tried to make it as simple as it can be
# By Syed Jahanzaib / aacable at hotmail dot com / https://aacable.wordpress.com
# CREATED on : 17th November, 2015 / 10:am

# Modify following data before execution
SQLUSER="root"
SQLPASS="SQLPASS"
# Kannel Server IP, if its local leave it as it is
KURL="http://127.0.0.1:13013"
KID="kannel"
KPASS="kannel"
TMP="/tmp/expiredusers.sms"
DAYS="00"
COMPANY="YOUR COMPANY NAME"

### DO-NOT EDIT BELOW THIS LINE ####

#Remove temp files created by earlier execution of this script
rm -fr /tmp/*.sms
> $TMP

mysql -u$SQLUSER -p$SQLPASS --skip-column-names  -e "use radius; select username,firstname,lastname,mobile,expiration from rm_users where expiration = CURRENT_DATE() - INTERVAL $DAYS DAY;" > $TMP

# Apply Count Loop Formula to read each users (from column 1 in tmp file) data and fit individualy later in sms
num=0
cat $TMP  |awk 'NF > 1' | while read users
do
num=$[$num+1]

USR=`echo $users |awk '{print $1}'`
FNAME=`echo $users |awk '{print $2}'`
LNAME=`echo $users |awk '{print $3}'`
mobile=`echo $users | awk '{print $4}'`
exp=`echo $users | awk '{print $5}'`


######################
# ACCOUNT EXPIRY CHECK and some JUNK data transported from other scripts i made earlier.
######################

TODAY=$(date +"%Y-%m-%d")
TODAYDIGIT=`echo $TODAY  | sed -e 's/-//g'`
MONTH=$(date +"-%m")
CMONTH=`echo $MONTH  | sed -e 's/-//g'`
MONTHYEAR=$(date +"%B-%Y")
ALPHAMONTHYEAR=`echo $MONTHYEAR #| sed -e 's/-//g'`
SRVID=`mysql -u$SQLUSER -p$SQLPASS --skip-column-names  -e "use radius; SELECT srvid FROM radius.rm_users WHERE rm_users.username = '$USR';"`
SRVPRICE=`mysql -u$SQLUSER -p$SQLPASS --skip-column-names  -e "use radius;  SELECT unitprice FROM radius.rm_services WHERE rm_services.srvid = $SRVID;" |cut -f1 -d"."`

#LOOK FOR USER ACTUAL SERVICE NAME
PKGNAME=`mysql -u$SQLUSER -p$SQLPASS --skip-column-names  -e "use radius; SELECT srvname FROM radius.rm_services WHERE rm_services.srvid = '$SRVID';"`


########### ACCOUNT STATUS EXPIRED TODAY ACTION / SEND SMS OR EMAIL ############

# PRINT FETCHED VALUES into files, which we will use later to send sms using url encoded command of kannel
echo "$COMPANY ALERT:

Dear Mr. $FNAME $LNAME, Your internet account ID [$USR] with Package of [$PKGNAME] has expired on $exp.
Please pay your dues to renew your account.

For furhter information & support you may reach us at our Helpline.

$COMPANY
Powered by Jz" > /tmp/$USR.sms

# PRINT FETCHED VALUES into files,  ECHO JUST FOR SCREEN BASE INFO / ZAIB
echo "$COMPANY ALERT:
Dear Mr. $FNAME $LNAME, Your internet account ID [$USR] with Package of [$PKGNAME] has expired on $exp.
Please pay your dues to renew your account.

For furhter information & support you may reach us at our Helpline.

$COMPANY
Powered by Syed.Jahanzaib"

# SEND SMS via KANNEL to USERS about epxired account.
curl "$KURL/cgi-bin/sendsms?username=$KID&password=$KPASS&to=$mobile" -G --data-urlencode text@/tmp/$USR.sms

echo "Sleeping for 20 seconds to add delay in sms sending, to prevent your mobile SIM being blocked due to flooded sms"
sleep 20
done

Schedule it in cron ,
# Radius Manager expiry notification for today’s expired account Script

crontab -e
# add add following or as required.
@daily  /temp/sms2expiredusers.sh

Note: Some more testing need to be done, will do later and update this post.

Regard’s
Syed Jahanzaib

IBM Lotus Notes: Inbox Emails disappears when sort by DATE

Filed under: IBM Related, Uncategorized — Syed Jahanzaib / Pinochio~:) @ 9:14 AM

Today one of our company user faced strange issue in his lotus notes clients {8.5.3 FP6}.

When they just open the Inbox without any sorting, there is no problem and all mail shown. Once they try to sort the mails by ‘Date‘,  all emails in inbox view disappears.

After trying various things like refresh/replace design etc, we finally managed to sort the issue by running UPDALL on that specific db.

From the Domino Server Console  , Issue following command


load updall -R mail/USERDB.nsf

( -R : Rebuild All used views)

Fixed !

Jz!

 

November 12, 2015

Prioritize SpeedTest.Net Results via Mikrotik Queue

Filed under: Uncategorized — Tags: , — Syed Jahanzaib / Pinochio~:) @ 9:48 AM

speedtest


As implemented it yesterday , an old trick, NOTHING NEW really.

(Although I personally don’t see any reason why to prioritize such speed.test.net results, to fake whom, client or yourself ? lol)

Following is an simple demonstration on howto prioritize speedtest.net speed test.
Scenario: Client is allowed to get 512k , but when he will access speedtest.net to check the speed, he will able to see 2mb , (every user will be able to check it on 2mb limit , individually per ip basis) while his normal download/browsing will remain under 512k queue limit as showed in the picture above.

ROS CODE, Tested with 5.x and 6.x versions:


# Mark speedtest in Layer7 firewall
/ip firewall layer7-protocol
add name=speedtest regexp="^.+(speedtest).*\\\$"

# Marking SPEEDTEST.NET in mangle section using L7
/ip firewall mangle
add action=mark-connection chain=forward comment=SPEEDTEST layer7-protocol=speedtest new-connection-mark=speedtest_conn
add action=mark-connection chain=prerouting new-connection-mark=speedtest_conn protocol=tcp src-port=8080
add action=mark-packet chain=prerouting connection-mark=speedtest_conn new-packet-mark=speedtest_pkt passthrough=no
add action=mark-connection chain=postrouting dst-port=8080 new-connection-mark=speedtest_conn protocol=tcp
add action=mark-packet chain=postrouting connection-mark=speedtest_conn new-packet-mark=speedtest_pkt passthrough=no

# ADD PCQ so that i can be applied on per ip bases later in simple queue / zaib
/queue type
add kind=pcq name=download-2mb pcq-burst-rate=0 pcq-burst-threshold=0 pcq-burst-time=10s pcq-classifier=dst-address pcq-dst-address-mask=32 pcq-dst-address6-mask=64 pcq-limit=50 pcq-rate=2048k \
    pcq-src-address-mask=32 pcq-src-address6-mask=64 pcq-total-limit=2000
add kind=pcq name=upload-2mb pcq-burst-rate=0 pcq-burst-threshold=0 pcq-burst-time=10s pcq-classifier=src-address pcq-dst-address-mask=32 pcq-dst-address6-mask=64 pcq-limit=50 pcq-rate=2048k \
    pcq-src-address-mask=32 pcq-src-address6-mask=64 pcq-total-limit=2000

# Add simple QUEUE to limit speedtest.net 2mb PER USER
/queue simple
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s comment="Limit every Users at 2mb using PCQ. for speedtest only marked by mangle / zaib" direction=both disabled=no interface=all limit-at=0/0 max-limit=0/0 name=\
    "SpeedTest.Net 2Mb per use via g PCQ / zaib" packet-marks=speedtest_pkt parent=none priority=8 queue=upload-2mb/download-2mb target-addresses=192.168.5.0/24 total-queue=default-small

# Add simple QUEUE to limit user PC individually for rest of traffic, static or dynamic up to your network.
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s direction=both disabled=no interface=all limit-at=512k/512k max-limit=512k/512k name="Zaib Desktop 512k A llowed - 192.168.5.2" packet-marks="" \
    parent=none priority=8 queue=default-small/default-small target-addresses=192.168.5.2/32 total-queue=default-small
 

Move the speedtest.net queue on top! Ordering is very important in mikrotik, as rules are processed order wise , zero to bottom

Note: It can further be adjusted in PCQ, QUEUE TREE, etc etc as per network designed.


client


Regard’s
Jz

November 5, 2015

Adding External NTP Server in Domain Controller / Short Notes

Filed under: Microsoft Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 12:56 PM

SHORT NOTES FOR PERSONNEL REFERENCE ONLY


Command to check time on remote Windows PC.

all commands should be executed using administrative privileged account.

net time \\REMOTEPC

 

Adding external NTP server on DC

# Set NTP on DC / on server

w32tm /config /manualpeerlist:"59.106.180.168,0x1 62.201.215.14,0x1 "

w32tm /config /reliable:yes

net stop w32time && net start w32time

 

Command for client side windows , to force update time from DC

I added this file in GP so that every computer on reboot is forced to update time via server

# For client
net time \\DC_SERVER /set /y

 

Using PSTOOLS to execute command on remote PC.

# run command on remote computer.
PsExec.exe \\$1 -u DOMAIN\ADMIN -p PASS cmd "/c net time \\DC_SERVER /set /y"

 

Force client update from your admin PC forcefully.

I sued following script / batch file [named setrtime.bat] to manually update time on remote pc via remote, and show before/after time.

@echo off
cls
echo Current time of %1
echo -------------------------
net time \\%1
echo -------------------------
PsExec.exe \\%1 -u DOMAIN\ADMIN -p PASS cmd "/c net time \\DC_SERVER /set /y"
echo -------------------------
echo Current time of %1 AFTER CHANGING
net time \\%1

now use it like

netrtime.bat REMOTEPCNAME

Blog at WordPress.com.

%d bloggers like this: