Syed Jahanzaib Personal Blog to Share Knowledge !

May 29, 2014

Radius Manager Self Registration Captcha Image Not Showing

Filed under: Radius Manager — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 1:01 PM

temp-image-error


 

Updated: 18th November, 2014


 

If you have dmasoftlab radius manager’s SELF REGISTRATION option enabled, and the user is unable to see the captcha image while trying to self register his account then check following.

Make sure /var/www/radiusmanager/tmpimages folder do exists, (this path is valid for Ubuntu , But
If you have Centos/Fedora then try with /var/www/html/radiusmanager/tmpimages

If tmpimages is not present then create it, and assign it proper permissions for the WEB server user.


 
Example:    [ubuntu]

  • mkdir /var/www/radiusmanager/tmpimages
  • chown www-data /var/www/radiusmanager/tmpimages

.

Example:    [Centos, Fedora]

  • mkdir /var/www/html/radiusmanager/tmpimages
  • chown apache /var/www/html/radiusmanager/tmpimages

 


 

Now check again and you will see the images showing properly.

 

captcha

.

.

Regard’s
Syed Jahanzaib

 

May 28, 2014

PTCL vDSL modem hang issue and its workaround

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

modem

Updated: October, 2014

The script is well tested with mikrotik 5.2x only

Recently at a network, the operator was facing PTCL 50mb via vDSL modem (HUAWEI HG622 & CELLPIPE model) hangs frequently. The interval between hanging was different , sometimes 3-4 times daily or after 14-16 hours. Ping to the modem also timeout and when the operator restart the modem, every thing works fine, but its painful to do it manually specially in late night hours when no one at help desk to do the stupid job of resetting.

[It is also observed that PTA is actively blocking users public ips from which suspected grey traffic (Like VPN, HOTSPOT SHIELD and tunneling type applications, and specially VOIP) is passing through, so disconnecting , and reconnecting again assigns you new public ip and internet starts working again.)

The workaround I made was to

  • Try Using Good Quality UPS with automatic voltage control,
  • Configured the modem in BRIDGE mode,
  • Add pppoe client dialer in the Mikrotik ppp section,so mikrotik handles the wan dialing itself, not the modem
  • Then add a script with scheduler which will keep checking two internet hosts connectivity at 1 minute interval or as required) , and if it found no reply from both host , then it disables the default dialer (pppoe-out1) and redial the connection after 10 seconds of PAUSE/DELAY (to prevent any dial-flood).
  • It also sends an email to admin [configurable] so that he should be aware of what happening behind his back 😛 . You can skip email section if you don’t require notifications.

SCRIPT FOR MULTIPLE HOST MONITORING

 

Following is an EXPORT version of the script, name it wanmonitor. You should modify it as per your local need.

# Following script is a modified version from the Mikrotik forum.
# http://forum.mikrotik.com/viewtopic.php?f=9&t=85505
# Modified few contents to suite local requirements and description added
# Regard's / Syed Jahanzaib / https://aacable.wordpress.com

# Script Starts here...
# DUAL Internet Host (to avoid false failure) to be checked You can modify them as per required, JZ

# set GMAIL smtp IP auto
:global gmailsmtp
:set gmailsmtp [:resolve "smtp.gmail.com"];

# Add two hosts for monitoring internet connectivity
:local host1   "8.8.8.8"
:local host2   "208.67.222.123"
 
# Do not modify data below without proper understanding.
:local i 0;
:local F 0;
:local date;
:local time;
:global InternetStatus;
:global InternetLastChange;
 
# PING each host 5 times
:for i from=1 to=5 do={
if ([/ping $host1 count=1]=0) do={:set F ($F + 1)}
if ([/ping $host2 count=1]=0) do={:set F ($F + 1)}
:delay 1;
};
 
# If both links are down and all replies are timeout, then link is considered down
:if (($F=10)) do={
:if (($InternetStatus="UP")) do={
:log error "WARNING : The INTERNET link seems to be DOWN. Please Check";
:set InternetStatus "DOWN";
 
## ADD YOUR RULES HERE, LIKE ROUTE CHANGE OR WHAT EVER IS REQUIRED, Example is below ...
:log error "PTCL LINK SEEMS TO BE DOWN, Resetting PPPoE Dialer and wait for at least 10 seconds before redialing / zaib"
 /interface pppoe-client disable pppoe-out1
/sys script run siren
:delay 10
 /interface pppoe-client enable pppoe-out1

:set date [/system clock get date];
:set time [/system clock get time];
:set InternetLastChange ($time . " " . $date);
} else={:set InternetStatus "DOWN";}
} else={
 
## If reply is received , then consider the Link is UP
:if (($InternetStatus="DOWN")) do={
:log warning "WARNING :The INTERNET link have been restored";
:set InternetStatus "UP";
 
## ADD YOUR RULES HERE, LIKE ROUTE CHANGE OR WHAT EVER IS REQUIRED, Example is below ...
:local currentIP
:local externalInterface "pppoe-out1"

## get the current IP address from the external interface
:set currentIP [/ip address get [find interface="$externalInterface"] address]

## Strip netmask
:for i from=( [:len $currentIP] - 1) to=0 step=-1 do={
:if ( [:pick $currentIP $i] = "/") do={
:set currentIP [:pick $currentIP 0 $i]

# Show warning in Mikrotik LOG window
:log warning "PTCL LINK RE - CONNECTED with new WAN IP = $currentIP, Please check and confirm / zaib"

# Disable or Enable EMAIL alert feature as required
#/tool e-mail send to="aacable@hotmail.com.com" password=YOURMAILPASSWD subject="$[/system clock get date] $[/system clock get time] -- PTCL DSL pppoe Dialer RE-CONNECTED AND UP NOW, New WAN IP is $currentIP / zaib" from=aacable79@gmail.com server=$gmailsmtp tls=yes body="$[/system clock get date] $[/system clock get time] : PTCL Link was down, so the wan monitor script disconnected the pppoe-out1 dialer and reconnected after 10 seconds of delay. New WAN IP is $currentIP  . Thank you / aacable@hotmail.com"

}
}
 
:set date [/system clock get date];
:set time [/system clock get time];
:set InternetLastChange ($time . " " . $date);
} else={:set InternetStatus "UP";}
}
 
# Script Ends Here.
# Thank you / zaib

.

SCHEDULER CONFIGURATION (to check wan connectivity every minute)


/system scheduler
add comment="Schedular for WAN Monitor tun run every minute on MT" disabled=no interval=1m name="wan monitor script 1 minute check" on-event=wanmonitor policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api start-date=jul/10/2014 start-time=16:34:32

 

EMAIL CONFIGURATION (if email alerts are required)

You can skip this email config section if you don’t want to receive notifications via email. also you have to remove it from the main script also. Modify the gmail smtp as required.


/tool e-mail
set address=173.194.69.109 from=your_email@gmail.com password=your_password port=587 starttls=no user=your_username

Done.


 

 

When there will be no response from the internet (Google dns or hosts you have set) , then netwatch will trigger down script section, which will disconnect the active pppoe-out1 dialer connection, wait 10 seconds, then redial the connection again and log alert and shoots email.

As showed in the image below …

1- link up


 

 

1.

.

.


 

NOTES

  • You can increase the interval and timeout value as per your requirement, ideally it should be a bit higher.
  • Its recommended to monitor your ISP gateway + one internet host to avoid False result.

Second Version of the above script with sms / email support, and re connect wan pppoe-out1 dialer


# WAN 1 Monitor Script for mikrotik by using two internet host
# With optional Email and SMS Alert, modem is attached to local mikrotik in this example
# but i have added kannel sms gateway and gmail option too. Added many variables
# by Syed Jahanzaib
# https://aacable.wordpress.com
# Email : aacable at hotmail dot com
# Script Last Modified : 25-NOV-2015 / 13:00

# Set variables
:local i 0;
:local F 0;
:local date;
:local time;
:global "DSL1netstatus"
:global "dsl1netlastchange"

# Check dsl-1 GATEWAY to be monitored (Currently we are monitoring internet host AROOT DNS)
:global dsl1host1 "4.2.2.1"
:global dsl1host2 "199.7.83.42"

#:global dsl1host1 "4.2.2.8"
#:global dsl1host2 "199.7.83.8"


# Number of Ping Count, how many times each host should ping
:local PINGCOUNT "30"

# PING HTRESHOLD, Multiply above value with 2 , so if you have select 5 in above example, then set below $PINGTS to 10
:local PINGTS "60"

# Setting SMS Number for admin
:local cell1 "03333021909"
# Company Name
:local COMPANY "ZAIB"

#If you dont have kannel sms gateway ignore this.
:local KURL "http://KANNEL_IP:13013/cgi-bin/sendsms"
:local KID "kannel"
:local KPASS "kpass"

# SMS Msg format for localy attached modem in mikrotik
:local MSGDOWN "$COMPANY WAN ALERT: DSL-1 is DOWN."
:local MSGUP "$COMPANY WAN INFO: DSL-1 is UP"

# Set USB Port on which usb modme is connected in Mikrotik
:local PORT "usb3"

# SMS Msg format for Kannel SMS gateway
#:local MSGDOWN "$COMPANY+WAN+ALERT:+DSL-1+is+DOWN."
#:local MSGUP "$COMPANY+WAN+INFO:+DSL-1+is+UP"


# Gmail SMTP Address / If you dont want to send email disable these
:global "gmailsmtp"
:set gmailsmtp [:resolve "smtp.gmail.com"];
:local GMAILID "YOURGMAILID@gmail.com"
:local GMAILPASS "GMAILPASS"

# Alerts n info m Send to following Support addressess
:local TO1 "ADMINMAIL@hotmail.com"
:local TO2 "ADMINMAIL2@gmail.com"

# Email Subject for DOWN Alert
:local SUBDOWN "$[/system clock get date] $[/system clock get time] -- $COMPANY_ALERT: dsl-1 Primary Internet Link DOWN"
# Email Body for DOWN Alert
:local BODYDOWN "-- dsl-1 Primary Internet Link  at $COMPANY DATA CENTER not responding, \n\nPlease check conectivity... \n\n>>>  Script Designed by ***   Syed_Jahanzaib   ****  <<<"

# Email Subject for UP Alert
:local SUBUP "$[/system clock get date] $[/system clock get time] -- $COMPANY_INFO: dsl-1 Primary Internet Link is now UP"
# Email Body for UP Alert
:local BODYUP "-- dsl-1 Primary Internet Link  at $COMPANY DATA CENTER have been restored \n\n>>>  Script Designed by ***   Syed_Jahanzaib   ****  <<<"



#######################################
#######################################
########## Start the SCRIPT ###########
########## DONOT EDIT BELOW ###########
#######################################
#######################################

# PING each host $PINGCOUNT times
# IF NOT A SINGLE PING SUCCESSFULL THEN CONSIDER LINK DOWN ## ZAIB
:for i from=1 to=$PINGCOUNT do={
if ([/ping $dsl1host1 count=1]=0) do={:set F ($F + 1)}
if ([/ping $dsl1host2 count=1]=0) do={:set F ($F + 1)}
:delay 1;
};


# If no response (all ping counts fails for both hosts, Time out, then LOG down status and take action
:if (($F=$PINGTS)) do={
:if (($DSL1netstatus="UP")) do={
:set DSL1netstatus "DOWN";

# Also add status in global variables to be used as tracking
:set date [/system clock get date];
:set time [/system clock get time];
:set dsl1netlastchange ($time . " " . $date);


##################################################
####### FOR DOWN STATUS, CHANGE THE RULES ########
##################################################

# If the link is down, then LOG info and warning in Mikrotik LOG window [Zaib]
:log error "DSL1  Gateway Not Responding..."
:log error "DSL1  Gateway Not Responding..."
:log error "DSL1  Gateway Not Responding..."

# "Emailing the DOWN status. . . "
/tool e-mail send to="$TO1" subject="$SUBDOWN" body="$[/system clock get date] $[/system clock get time]:$BODYDOWN" from=$GMAILID password=$GMAILPASS  server=$gmailsmtp start-tls=yes
/tool e-mail send to="$TO2" subject="$SUBDOWN" body="$[/system clock get date] $[/system clock get time]:$BODYDOWN" from=$GMAILID password=$GMAILPASS  server=$gmailsmtp start-tls=yes

# Send SMS via KANNEL
#/tool fetch url="$KURL\?username=$KID&password=$KPASSto=$cell1&text=$MSGDOWN"

# Send SMS via Mikrotik attached modem
/tool sms send port=$PORT phone-number=$cell1 message="$MSGDOWN" channel=0

# Disable pppoe-out1 wan1 dialer and try to re-connect one time only
:log error "DISABLING PPPOE-OUT1 WAN DIALER"
/interface pppoe-client disable pppoe-out1
:delay 10
:log warning "EN-ABLING PPPOE-OUT1 WAN DIALER"
/interface pppoe-client enable pppoe-out1

##################################################
####### FOR UP STATUS, CHANGE THE RULES ########
##################################################
# If ping is ok for 1 host as well reply received, then LOG UP and take action as required
} else={:set DSL1netstatus "DOWN";}
} else={
:if (($DSL1netstatus="DOWN")) do={

:set DSL1netstatus "UP";
# If link is UP, then LOG info and warning in Mikrotik LOG window [Zaib]
log warning "DSL1  Gateway RESTORED ..."
log warning "DSL1  Gateway RESTORED ..."
log warning "DSL1  Gateway RESTORED ..."


# "Emailing the UP status. . . "
/tool e-mail send to="$TO1" subject="$SUBUP" body="$[/system clock get date] $[/system clock get time] $BODYUP" from=$GMAILID password=$GMAILPASS server=$gmailsmtp start-tls=yes
/tool e-mail send to="$TO2" subject="$SUBUP" body="$[/system clock get date] $[/system clock get time] $BODYUP" from=$GMAILID password=$GMAILPASS server=$gmailsmtp start-tls=yes

# Send SMS via KANNEL Gateway
#/tool fetch url="$KURL\?username=$KID&password=$KPASSto=$cell1&text=$MSGUP"

# Send SMS via Mikrotik attached modem
/tool sms send port=$PORT phone-number=$cell1 message="$MSGUP" channel=0

:set date [/system clock get date];
:set time [/system clock get time];
:set dsl1netlastchange ($time . " " . $date);

} else={:set DSL1netstatus "UP";}
}


 

Howto create WAN PPPOE DIALER in Mikrotik

1- mt pppoe

 

2- pppo 2

 

3- pppo 3

 

4-connectred

DONE.


 

Regard’s
Syed Jahanzaib

May 23, 2014

Howto get DSA Output in HTML format for IBM xSeries 3650 M4 [7915] Server

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

Recently one of our newly acquired IBM xSeries 3650 M4 [7915] Server start sending email regarding Predictive Failure (PD,PAF) alerts. and on panel, we get amber light on HDD,

2014-05-15 08.57.57

To receive support from the IBM or vendor, we have to send DSA Logs. this DSA report contains each and every detail regarding all the hardware components of the machine. In the past we used DSA logs to generate html base outputs on previous 3650 or 346 series servers, but we were unable to found any installable DSA package. Only PORTABLE or PREBOOT versions were available. Since it was a production live server so we cannot take downtime to boot from dsa pre-boot cd, and the portable version produce single XML file which is not human friendly or readable. So I used following trick to make its HTML output , (provided by vendor and GOOGLE)

(Make a new folder where you dsa will generate its HTML output , in any location, e.g: c:\dsa_output)

ibm_utl_dsa_dsytd3l-9.52_portable_windows_x86-64.exe -v -d c:\dsa_output

Output Sample:

dsa_output_html.

.

Regard’s
Syed Jahanzaib

%d bloggers like this: