Syed Jahanzaib Personal Blog to Share Knowledge !

January 31, 2013

Troubleshooting IBM ULT3580-TD3 Tape Drive in Windows 2003 > Short Notes


tape

Recently we had a severe power failure and our UPS didn’t provided backup and got shutdown immediately. Upon restoring every thing back to normal, One of Tape Drive (IBM ULT3580-TD3 SCSI Drive) connected with our File Server didn’t respond properly and failed to backup on tape, Also it didn’t appeared in ntbackup Media List.

I tried every possible way to troubleshoot it but no use. I tried removing / Enabling Disabling Tape Drive/Scsi Card, but didn’t worked out. Tape Drive and SCSI card were detecting properly in Device Manager but in RSM (Removable Storage Manager)  , it showed RED cross on Tape Drive with  multiple instance of Tape Drive. When I took properties of the drive, it showed following error.

the object identifier does not represent a valid object

Some images . . .

device manager.

tape-error-in-rsm.

I did the following to resolve the issue.

1) First delete all instances of IBM ULT3580 from RSM which are marked as red cross. as showed in the above picture.

2) Update Adaptec SCSI card 29329ALP – Ultra320 SCSI card firmware to latest one from Adaptec web site, Search in Google.)
http://www.adaptec.com/en-us/speed/scsi/windows/u320_scsi_v7006_win32_cert_exe.htm

3) Update IBM Tape ULT3580-TD3 driver from
http://delivery04.dhe.ibm.com/sar/CMA/STA/02mq3/9/IBMTape.x86_6217.zip
Extract it to any folder and execute install_exclusive.exe , after it updates it will ask you to reboot, simply Reboot.

After reboot complete , Open the command prompt and issue following command.

rsm view /tlibrary

Result should be something below

C:\>rsm view /tlibrary

LIBRARY

Off-line Media
Kingston DT 101 G2 USB Device
HP DVD Writer 1260r
IBM ULT3580-TD3 SCSI Sequential Device

The command completed successfully.

Now issue following command

rsm.exe refresh /lf”IBM ULT3580-TD3 SCSI Sequential Device”

wait 1 -2 minutes

Now again execute RSM and see if it shows OK,
As showed in the image below . .  .

rsm-ok

Execute NTBACKUP and hopefully it will work out this time.
🙂

.

Default ID Password for IBM Tape Library TS3200

ID = admin
Password = secure

Also read following , maybe helpful for any specific case.
http://thetazblog.taznetworks.com/2006/01/sbs-backup-error-code-0x800710d8.html

☺☻☺☻☺☻

If you receive message while ejecting tape cartridge from the library gui

” Lock by host” then simply stop RSM Service on all connected hosts (if its FC library and connected with multiple hosts) .

 

Regard’s
SYED JAHANZAIB

Advertisements

January 16, 2013

Backup Files via CMD/Batch/ntbackup Scripts [Personnel Notes]


Salam to All,

Following are few backup batch files that I have used at my office to perform backup operation using scheduled backup tasks. I am posting them just for reference so they can be used as archiving or possibly useful for others too having same task.

 


MOVE folders (including files/subfolders)  Older than X days to another location using legendary ROBOCOPY 😉

robocopy   C:\SOURCE_FOLDER_LOCATION   D:\TARGET_FOLDER_LOCATION   /s   /e   /MOVE   /minage:2

/s : includes Sub Folders / Files
/e : include Empty folders as well
/MOVE : after copying, delete matching data from source
/minage : set criteria in days

Change the minage:2 to your desired number of days.


DELETE FOLDERS OLDER THEN XX DAYS USING POWESHELL
[Added 16th October, 2015]

To delete FOLDERS (including files or sub folders) older then X days, you can use following powershell command, fully tested with windows 2008


PowerShell -Command "& Get-ChildItem "D:\Data" | Where-Object {$_.PSIsContainer -and $_.LastWriteTime -le [System.DateTime]::Now.AddDays(-3)} | Remove-Item -Recurse -Force"


Move Files to another folder/drive using ROBOCOPY – Older then 365 Days


robocopy D:\Users\Syed_Jahanzaib  X:\Users\Syed_Jahanzaib_Archive /MOVE /MINAGE:365 /E

There is confusion here and elsewhere, I believe the following is correct:

  1. minage and maxage actually refer to the last modified date of the file (not creation date)
  2. minlad and maxlad actually refer to the last access date of the file.

 


 

Few days back, a new oracle server was added in our IT dept. It is an oracle database server which serves many users request in our company. There was an annoying manual backup task that we have to perform on it on daily basis , the :@ task was to run 2 shortcut which creates backup dump files in E: drive, and then we have to manually rename the 2 dump files according to current date and then move them in other date-wise folder.

Quite annoying , isn’t it ? I mean still do we have to perform simple tasks like taking backup manually where every task is being done Automatically ?
Stupid enough ! 😛

It was quite easy to do this task automatically in LINUX environment, but as currently i am working in MS (Microshit or Microsoft environment) I manage to done it with built-in DOS commands. Following is the complete dos batch file or call it the Backup script 😉 , I just added in Schedule task, Now it runs daily and saves my time.

@echo off
Echo Oracle Backup Organizer Script.
Echo Developed by Syed Jahanzaib / aacable@hotmail.com
Echo Make sure you have the backkup folder where backup is copied on daily basis by other script.
Echo Setting current date
set dt=%date:~-4,4%%date:~-10,2%%date:~-7,2%

Echo Map File Server backup folder in local computer using admin account.
net use B: \\FILES_SERVER\D$\home\cic /USER:zaib-admin@localdomain admin-passwd

Echo Copying already created oracle Dump files (which you can create by using backup file scheduled to run daily)
Echo into remote file server with current date for backup - FILES_SERVER

copy e:\backup\Cic_final.Dmp B:\cic-backup.%dt%.dmp
copy e:\backup\nae_final.dmp B:\nae-backup.%dt%.dmp

Echo Renaming dump files to current date for the date wise backup
ren e:\backup\Cic_final.Dmp cic-backup.%dt%.dmp
ren e:\backup\nae_final.dmp nae-backup.%dt%.dmp

echo.
echo All Backup done. Allah Hafiz


 

NTBACKUP with EMAIL the LOGS and START/END Time Report

This Script will first backup the data defined in “backup-data” to Tape Drive (In my case it was IBM LTO-3) and then email the LOG to your defined email addresses (in “mail-to” section) It will also record the total time of the backup and will attache it to the email.

@echo off
rem # Syed Jahanzaib #
rem #######################################################
rem Setting various Descriptions via environment variables
rem #######################################################

setlocal enableextensions enabledelayedexpansion
set starttime=%time%
set dt=%date:~-4,4%%date:~-10,2%%date:~-7,2%
set logpath="C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data"
set srvname=SERVER_X
set backup-data=C:\backup\Tape Backup of Different Data.bks
set description=SERVER_X - Autobackup Different Data
set jobname=SERVER_X - Tape Backup of Different Data
set attachment=C:\backup\SERVER_X-ntbackup-%dt%.txt
set mail-subject=SERVER_X-NTBACKUP LOG for Different Data
set mail-body=SERVER_X-NTBACKUP LOG for Different Data
set mail-to="aacable@hotmail.com","aacable@hotmail.com"
set footer=Automated Backup and Email Logs Script Created by Syed_Jahanzaib

rem ######################################
rem Starting Backup in IBM LTO3 Tape Drive
rem ######################################

c:\windows\system32\rsm.exe refresh /lf"IBM ULT3580-TD3 SCSI Sequential Device"
ping -r 9 127.0.0.1 >null
start /wait C:\WINDOWS\system32\ntbackup.exe backup "@%backup-data%" /n "%jobname%" /d "%description%" /j "%jobname%" /l:s /p "LTO Ultrium" /UM /v:no /r:yes /rs:no /hc:on /m normal

rem ############
rem NTBackup END
rem ############

rem ### Copy current date LOG to C:\backup
forfiles -p %logpath% -s -m *.log -d 0 -c "cmd /c copy @file %attachment%"

rem #########################
rem STart END Time Algorithm
rem #########################

ping -n 2 127.0.0.1 >nul: 2>nul:
set endtime=%time%
set total="echo Total   = %tot%"

set /a hrs=%endtime:~0,2%
set /a hrs=%hrs%-%starttime:~0,2%

set /a mins=%endtime:~3,2%
set /a mins=%mins%-%starttime:~3,2%

set /a secs=%endtime:~6,2%
set /a secs=%secs%-%starttime:~6,2%

if %secs% lss 0 (
    set /a secs=!secs!+60
    set /a mins=!mins!-1
)
if %mins% lss 0 (
    set /a mins=!mins!+60
    set /a hrs=!hrs!-1
)
if %hrs% lss 0 (
    set /a hrs=!hrs!+24
)
set /a tot=%secs%+%mins%*60+%hrs%*3600

echo End     = %endtime%
echo Start   = %starttime%
echo Hours   = %hrs%
echo Minutes = %mins%
echo Seconds = %secs%
echo Total   = %tot%

rem ##########
rem Email LOGS
rem ##########

c:\blat\blat.exe -to %mail-to% -i %srvname% -s "%mail-subject%" -body "%mail-body%|Backup Report:|Start   = %starttime%|End     = %endtime%|Hours   = %hrs%|Minutes = %mins%||%footer%" -attach %attachment%

endlocal

rem ## THE END
rem ## Syed Jahanzaib / aacable@hotmail.com

 


 

To delete files olde then X days using FORFILES

 

forfiles /p “C:\test” /s /m *.* /c “cmd /c del @path” /d -15

 

Change /d -15 to match your requirements. you can change the del command to any other like to show the files, use echo. FORFILES is builtin command with Windwos 2003 /7. You can download it from http://www.ipass.net/davesisk/forfiles.zip

 

 


 

 

Delete Files Over 15 Days Old using ROBOCOPY

 

set _robodel=%TEMP%\~robodel MD %_robodel% ROBOCOPY “C:\source_folder” %_robodel% /move /minage:15 del %_robodel% /q

 


 

Batch File to create Windows MS SQL Backup

First create .sql file that can be called from batch file to create any specific DB backup. for example c:\zaibdb.sql

BACKUP DATABASE [Promo] TO  DISK = N'D:\DataBaseBackup\zaibdb.Bak' WITH NOFORMAT, INIT,  NAME = N'Promo-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO

now create a batch file which will call the above .sql file to start backup. for example c:\start_backup.bat

@echo off
echo Creating FULL backup in D:\zaibdb.back
echo %Date% >> D:\DataBaseBackup\zaibdb.txt
sqlcmd -S .\SQLEXPRESS -i c:\zaibdb.sql > D:\DataBaseBackup\zaibdb.txt
echo.
echo Done
rem ping 127.0.0.1 -n 10 > null
echo . >> D:\DataBaseBackup\zaibdb.txt
echo This backup set was last created at %Date%  >> D:\DataBaseBackup\zaibdb.txt
echo.

 



Another Backup script that map remote  server folder locally
and then copy the required files and then delete the files older then 20 days

@echo off
rem Syed Jahanzaib / ??? (Pvt) Ltd. IS Dept.
rem This file will copy the today's SAP exports and cofiles only to files_server\export folder,
rem which is actually mapped locally as B: drive.
rem #
rem #
rem #
rem # Mapping files_server Folder via agpis Credentials
net use B: \\files_server\

rem # Copying Last Date Export files to \\file-server\B:\export folder
forfiles -p "J:\required_folder" -s -m *.* -d 0 -c "cmd /c copy @path B:\"

rem # Copying Last Date cofiles data to \\file-server\B:\cofiles folder
forfiles -p "J:\required_folder" -s -m *.* -d 0 -c "cmd /c copy @path B:\"

rem # Deleting export older then 20 Days . . .
forfiles -p "J:\required_folder" -s -m *.* -d -20 -c "cmd /c del @path"

rem # Deleting cofiles Logs older then 20 Days . . .
forfiles -p "J:\required_folder" -s -m *.* -d -20 -c "cmd /c del @path"

.


 

Daily Backup of Required Folder using ROBOCOPY

Robocopy method which will copy only new file by matching source and destination folder/file timstamps. Its much better as it displays results in command prompt with percentage and all the necessary info any admin want. 🙂 its my favorite. You can downlod Robocopy by downloading Microsoft Resource Kit from following link.
http://www.microsoft.com/en-us/download/details.aspx?id=17657

@echo off
Robocopy /E /LOG:h:\Softwares\Servers_Related\mail-backup-log.txt B:\archive\.  T:\backup\archive
Robocopy /E /LOG+:h:\Softwares\Servers_Related\mail-backup-log.txt T:\mailserver\c$\mt\.  T:\backup\mt
Robocopy /E /LOG+:h:\Softwares\Servers_Related\mail-backup-log.txt T:\mailserver\mail\.  T:\backup\mail

Second Version of robocopy which add logs, and emails too


@echo off
rem # Syed Jahanzaib #
rem #######################################################
rem Setting various Descriptions via environment variables
rem #######################################################

setlocal enableextensions enabledelayedexpansion
set starttime=%time%
set srvname=FILE_SERVER
set description=Target_Server - Daily Status of MAIL Server Data Copied in FILE_SERVER
set jobname=Target_Server - Daily Status of MAIL Server Data Copied in FILE_SERVER
set attachment=c:\backup\mail_backup_log.txt
set mail-subject=Target_Server - Daily Status of MAIL Server Data Copied in FILE_SERVER
set mail-body=Target_Server - Daily Status of MAIL Server Data Copied in FILE_SERVER
set mail-to=aacable@hotmail.com
set footer=Automated Backup and Email Logs Script Created by  / Syed Jahanzaib

rem Delete old mail backup log file
del c:\backup\mail_backup_log.txt
rem oNLY Mail NSF files Backup
Robocopy.exe *.nsf /w:0 /r:0 /LOG:c:\backup\mail_backup_log.txt /NP /FP /TEE /ts  \\Target_Server\d$\lotus\domino\data\mail H:\Target_Server\Target_Server_LIVE_DATA\MAIL

rem Mail Tracking Backup
Robocopy.exe *.nsf  /w:0 /r:0 /LOG+:c:\backup\mail_backup_log.txt /NP /FP /ts /TEE \\Target_Server\c$\mt\ H:\Target_Server\Target_Server_LIVE_DATA\Target_Server-MT

rem Transaction Logs for mail server
Robocopy.exe *.txn /w:0 /r:0 /LOG+:c:\backup\mail_backup_log.txt /NP /FP /TEE /ts \\Target_Server\c$\logdir\. H:\Target_Server\Target_Server_LIVE_DATA\LOGDIR

set endtime=%time%
set total="echo Total   = %tot%"

set /a hrs=%endtime:~0,2%
set /a hrs=%hrs%-%starttime:~0,2%

set /a mins=%endtime:~3,2%
set /a mins=%mins%-%starttime:~3,2%

set /a secs=%endtime:~6,2%
set /a secs=%secs%-%starttime:~6,2%

if %secs% lss 0 (
set /a secs=!secs!+60
set /a mins=!mins!-1
)
if %mins% lss 0 (
set /a mins=!mins!+60
set /a hrs=!hrs!-1
)
if %hrs% lss 0 (
set /a hrs=!hrs!+24
)
set /a tot=%secs%+%mins%*60+%hrs%*3600

echo End     = %endtime%
echo Start   = %starttime%
echo Hours   = %hrs%
echo Minutes = %mins%
echo Seconds = %secs%
echo Total   = %tot%

rem ##########
rem Email LOGS
rem ##########

c:\backup\blat\blat.exe -to %mail-to%  -attach %attachment% -i %srvname% -s "%mail-subject%" -body "%mail-body%|Backup Report:|Start   = %starttime%|End     = %endtime%|Hours   = %hrs%|Minutes = %mins%||%footer%"

endlocal

rem ## THE END
rem ## Syed Jahanzaib / aacable@hotmail.com

The above commands description is as follows.
/E  = Copy sub-directories, including Empty ones
/LOG+ = Output status to LOG file (append to existing log, so previous entries along with new one should be saved together, if you don’t use + , it will overwrite existing log-file, means delete old entries and overwrite new one)).


 

XCOPY Method

Following file will copy all the data from the source folder to target folder using windows builtin copy tool XCOPY.

@echo off

echo * * *  >> C:\backup-log.txt
echo Mail Backup Starts at %date% - %time%  >> C:\backup-log.txt

C:\windows\system32\xcopy.exe B:\source-folder\*.*  T:\targetfolder /S /D /C /Y

echo Mail Backup Ends at %date% - %time%  >> C:\backup-log.txt
echo * * * >> C:\backup-log.txt 

The above commands description is as follows.

/S = Copies directories and sub-directories except empty ones.
/D =  If no date is given, copies only those files whose  source time is newer than the destination time.
/C = Continues copying even if errors occur.
/Y  = Overwrite existing files if any without prompting, its necessary when you are running xcopy via batch / script file.


 

NET USE SHARING by COMMAND


net use B: \\server\datafolder /USER:administrator@mydomain password

net use B: \\server\datafolder /USER:pc-name\administrator password

 


Set Windows 7/x IP address via COMMAND / CLI

@echo off
echo.
echo Setting IP Address to AUTO DHCP [Office DHCP Server]...
echo.
netsh interface ip set address name="Local Area Connection" source=dhcp
netsh interface ip set address name="Wireless Network Connection" source=dhcp
echo.
echo.
echo Done....
echo.
pause

 

Regard’s
Syed Jahanzaib

January 10, 2013

iSCSI SAN/NAS SOLUTION FOR ESXi SERVER (Tutorial No 5)

Filed under: VMware Related — Syed Jahanzaib / Pinochio~:) @ 3:23 PM

iSCSI SAN/NAS SOLUTION FOR ESXi SERVER (Tutorial No 5).

Personnel short notes for BLAT and Delete Files Older then X Days

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

To send email from windows command using your local company SMTP , use BLAT tool.

BLAT guide.
A wonderful guide is already available here.
http://cybergav.in/2010/10/28/how-to-send-emails-using-blat/

+++++++++++++++

First Download BLAT from following URL:
http://sourceforge.net/projects/blat/files/Blat%20Full%20Version/32%20bit%20versions/Blat%20v3.0.0/blat300_32.full.zip/download?use_mirror=autoselect

Unzip it to any folder you like.

+++++++++++++++

To install SMTP in BLAT use the below command . . .

blat -installSMTP 10.0.0.1  your-user-id@xyz.com.pk  5  25

+++++++++++++++
To send email using blat command, use the below command

blat -s “test mail” -i “test” -to  your-user-id@xyz.com.pk

+++++++++++++++
To send email with attachment of file using blat command, use the below command

blat -s “test mail” -i “Syed Jahanzaib / Admin” -to your-user-id@xyz.com.pk -body “Please see attached file” -attach c:\test.txt

+++++++++++++++

Email/Delete Files OLDER then X days Examples:

CORE EXAMPLE
forfiles -p “C:\test” -s -m *.* -d 0 -c “cmd /c c:\blat\blat.exe -to your-user-id@xyz.com.pk -i myname -s INFRA_LOGS -body INFRA_SERVERS_LOGS -attach @path”

Working EXAMPLE for file_server/ For TAPE BACKUP LOGS

forfiles -p “C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data” -s -m *.* -d 0 -c “cmd /c c:\blat\blat.exe -to your-user-id@xyz.com.pk -i myname -s INFRA_LOGS -body INFRA_SERVERS_LOGS -attach @path”

TO show (DELETE removed from syntax) FILES OLDER THEN X DAYS (in the below example its 30 days)

FORFILES /p c:\temp /d -30 /m * /c “cmd /c echo @file”

TO show (DELETE removed from syntax) FILES For TODAY

FORFILES /p c:\temp /d 0 /m * /c “cmd /c echo @file”

Windows 2003/7/2008 already have forfiles installed. but you can download it from here http://www.ipass.net/davesisk/forfiles.zip

.

Regard’s
Syed Jahanzaib

Howto send email from command via Windows using GMAIL account

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

Send Email from Windows via command prompt using GMAIL Account  🙂~

If you want to send email from windows using command prompt using gmail account, first down mailsend utility from following URL and extract it to any folder you like.

http://www.muquit.com/muquit/software/mailsend/mailsend1.16.exe.zip

Now to send email using command via your GMAIL account, use the below syntax. Remember to change the email addressees and password to match your account details.

mailsend.exe -to aacable@hotmail.com -from your-gmail-id@gmail.com  -ssl -smtp smtp.gmail.com -port 465 -sub "Testing Email via Windows cmd using GMAIL test %time%" -M "This is body text of Testing Email via Windows cmd using GMAIL. %date% %time% sending / zaib." +cc +bc -q -auth-plain -user "your-gmail-id" -pass "yourpass"

To send email with attachment, use the following

mailsend.exe -to aacable@hotmail.com -from your-gmail-id@gmail.com  -ssl -smtp smtp.gmail.com -port 465 -sub "Testing Email via Windows cmd using GMAIL test %time%" -M "This is body text of Testing Email via Windows cmd using GMAIL. %date% %time% sending / zaib." +cc +bc -q -auth-plain -user "your-gmail-id" -pass "yourpass" -attach "c:\test.txt"

It’s very handy and useful in many conditions. For example I used it to send daily tape backup log OR daily backup file to my email in the morning by scheduling it.

 

.

For more info, please read this details guide at
http://www.codeproject.com/Tips/418420/Send-email-from-command-line-using-GMail-account

.

Regard’s
Syed Jahnazaib

Mikrotik: Netwatch Script to Detect Target Server Link & Act Accordingly

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

matrix

Someone requested me to create a script that can check Squid Proxy or Target Server Link state from Mikrotik, and if the Squid Proxy / Target Server is not responding, then it should Disable the redirect NAT rule so all load can be handle by Mikrotik.You can modify this script as per your requirements. you can modify it to check WAN link, and if the WAN link is down, it can trigger SMS Script / Sound Alaram, or shift to backup WAN link by enabling diabling ROUTE’s or it can also be used to detect any wan link failure detection and change the rules accordingly.
Possibilities are endless.
So here it is.

[for ver 5.x]

Adding Comments in Redirect Rule

First add comments in required NAT rule, i.e Rule that redirects port 80 traffic to squid. You can also disable/enable rules based on the numbers, BUT its not recommended BECAUSE if you add any new rule and move it somewhere, all your scripts will disable/enable wrong rules, that is why you have to use find command and get rules this way.

You can use GUI to add comment in the rule, I am showing you an example below . . .
/ip firewall nat
add action=dst-nat chain=dstnat comment=”Redirect to SQUID” disabled=no dst-port=80 protocol=tcp to-addresses=192.168.6.1 to-ports=8080

add action=masquerade chain=srcnat comment=”Default NAT Rule for Internet Access / zaib” disabled=no to-addresses=0.0.0.0

1- nat rule

Change the host ip address as your local requirements. Its jsut an example to show you.

.

.

Adding EMAIL account in mikrotik

/tool e-mail set address=73.194.78.109 from=yourgmailid@gmail.com password=your_password port=587 start-tls=no user=your_gmailid

Adding Scripts to Enable/Disable Rule

After adding comments in the dst-nt rule, you have to create two scripts that can enable and disable the dst-nat rule. We can name them UP and DOWN.
 Copy paste the below scripts on Mikrotik Terminal. It will create two scripts in System/Scripts with the name of UP and DOWN.

DOWN SCRIPT

:log info "Squid Proxy Server is not responding. Please Check Connectivity"
/ip firewall nat disable [find comment="Redirect to SQUID"]
:log info "Emailing the DOWN status. . . "
#/tool e-mail send to="aacable@hotmail.com" password=yourgmailid subject="Squid Proxy Server is not responding. Please Check Connectivity"  body="Squid Proxy Server is not responding. Please Check Connectivity" from=yourgmailid@gmail.com server=173.194.69.109 tls=yes

UP SCRIPT

:log info "Squid Proxy Server is OK."
/ip firewall nat enable [find comment="Redirect to SQUID"]
:log info "Emailing the UP status. . . "
#/tool e-mail send to="aacable@hotmail.com" password=yourgmailid subject="Squid Proxy Server is OK."  body="Squid Proxy Server is OK." from=yourgmailid@gmail.com server=173.194.69.109 tls=yes

2- Script-List

.

Adding NETWATCH to monitor Target Server [Squid] Link Detection

Use the below script to add netwatch entry for squid / target server link detection. It will also add the UP and DOWN script for the appropriate action. For example. When the target server link is down, it will execute script DOWN which will disable the NAT redirect rule , when the target server link is up and working, it will execute the UP script which will re-enable the redirect rule.

/tool netwatch
add comment=”Netwatch to Check SQUID Server Link state / zaib” disabled=no down-script=”/sys script run down” host=192.168.6.1 interval=5m timeout=1s \
    up-script=”/sys script run up”

3 - Squid Link Detection

(Replace the host ip to match your local target server ip)

.

.

Testing THE Scripts . . .   :)~

Now test the scripts, Unplug the Target Server LAN link, and you will see something like below in the LOG.

4- link down

.

Now plugin the Target Server LAN link, and you will see something like below in the LOG.

5- link up

.

.

[For Ver 6.x]

Netwatch base monitoring for local server. copy paste following and modify necessary information before enabling this rule.


 

First setup EMAIL config.

/tool e-mail
set address=173.194.67.108 from=YOUR_GMAILID@gmail.com last-status=succeeded password=GMAIL_PASSWORD port=587 start-tls=yes user=YOUR_GMAILID

 

Now add the netwatch script … You can simply copy paste the script, modify it before pasting …

/tool netwatch
add down-script=":log warning \"Squid Proxy Server is not responding. Please C\
    heck Connectivity . . . \"\r\
    \n:global sub1 ([/system identity get name])\r\
    \n:global sub2 ([/system clock get time])\r\
    \n:global sub3 ([/system clock get date])\r\
    \n:global adminmail1 YOURGMAIL@gmail.com\r\
    \n:global gmailid  YOURGMAIL@gmail.com\r\
    \n:global gmailpwd  GMAIL_PASSWORD\r\
    \n:global gmailsmtp\r\
    \n:set gmailsmtp [:resolve \"smtp.gmail.com\"];\r\
    \n\r\
    \n# ENABLING SQUID Redirect Rule\r\
    \n/ip firewall nat disable [find comment=\"Redirect to SQUID\"]\r\
    \n\r\
    \n/tool e-mail send to=\$adminmail1 password=\$gmailpwd subject=\"\$sub3 \
    \$sub2 \$sub1 SQUID IS DOWN ... DISABLING NAT RULE\" from=\$gmailid server\
    =\$gmailip start-tls=yes  body=\"Squid Proxy Server is not responding. Ple\
    ase Check Connectivity\"" host=192.168.6.2 interval=10s timeout=3s \
    up-script=":log warning \"Squid Proxy Server is UP. Enalbing REDIRECT NAT \
    rule  . . . \"\r\
    \n\r\
    \n:global sub1 ([/system identity get name])\r\
    \n:global sub2 ([/system clock get time])\r\
    \n:global sub3 ([/system clock get date])\r\
    \n:global adminmail1 YOURGMAIL@gmail.com\r\
    \n:global gmailid  YOURGMAIL@gmail.com\r\
    \n:global gmailpwd  GMAIL_PASSWORD\r\
    \n:global gmailsmtp\r\
    \n:set gmailsmtp [:resolve \"smtp.gmail.com\"];\r\
    \n\r\
    \n# Disabling SQUID Redirect Rule\r\
    \n/ip firewall nat disable [find comment=\"Redirect to SQUID\"]\r\
    \n\r\
    \n/tool e-mail send to=\$adminmail1 password=\$gmailpwd subject=\"\$sub3 \
    \$sub2 \$sub1 Squid Proxy Server is OK UP. Enabling REDIRECT NAT rule\" fr\
    om=\$gmailid server=\$gmailsmtp start-tls=yes  body=\"Squid Proxy Server i\
    s UP. Enalbing REDIRECT NAT rule\"\r\
    \n"


 

It will add the netwatch script, and will monitor your local server and will email you as well. Modify it before using it

 


 

SCRIPT TO CHECK SQUID STATUS AND START IT IF REQUIRED

Following script [checksquid.sh] will check SQUID service status , and if it found squid stop, it will start it auto, if the squid is already running , it will do nothing :)

First create file in any folder or temp folder by

mkdir /temp
touch /temp/checksquid.sh
chmod +x  /temp/checksquid.sh

Now edit this file

nano /temp/checksquid.sh

& paste the following code

#!/bin/bash
pid=`pidof squid`
if [ "$pid" == "" ]; then
echo -e "SQUID service is NOT running, Trying to start using SERVICE command  (( IF squid is installed via apt-get or yum ))  . . ."
service squid start

# or if squid is compiled then use simple command to start squid
echo -e "Now, Trying to start using squid command ( IF Squid is Compiled from the source)  . . ."
/usr/sbin/squid
echo You should now see the squid process below ...
echo .
sleep 3
ps aux |grep squid
else
echo SQUID service is Running OK , no further action required, EXITING  . . . You should see Squid process below ...
ps aux |grep squid
fi

Save & Exit.

Test it by running

/temp/checksquid.sh

You can check any service status with above command, if the service is not running , it will try to start with.

You can create its cron entry to run it after every 5 minutes.

For example, add it using CRON by following

crontab -e

and add following line

*/5 * * * * /temp/checksquid.sh

Now save and exit.

Regard’s

Syed Jahanzaib

January 4, 2013

Windows 7 Annoying Bug: Explorer doesn’t refresh automatically when Create/delete/move any file/folder

Filed under: Microsoft Related — Tags: , — Syed Jahanzaib / Pinochio~:) @ 11:42 AM

Today I found an annoying Bug in Windows 7 (Win7 Professional x86).
When a user try to Create / Delete/ Move any file from the Desktop, it still shows at desktop and when the user press F5 , it instantly appears/disappears, seems like windows Explorer auto refresh not working properly.

This resolved the issue for me:

Go to
Tools / Folder Options / General Tab,
and at  the bottom, in the ‘Navigation Pane‘, make sure ‘Show all folders‘ and Automatically expand to current folder‘ are checked.
As showed in the image below . . .

show-files

.

show-files2.


 

Another alternate method contributed by user…

Open explorer –> right click on Documents –> in the documents library pane click the Restore Defaults button –> click Apply


 

 

Regard’s
~ SYED  JAHANZAIB ~

January 3, 2013

DynamicDNS client for windows

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

A friend of mine asked me howto configure DDNS client in Windows, so he ca remotely access his PC from the remote location, In my previous article  at
https://aacable.wordpress.com/tag/aacable-dynamicdns/
I described howto howto configure DynamicDNS (changeip.com) on Mikrotik  for remote management,but in this following short guide I will tell you how you can configure dynamicdns on windows using the ddns client.

To configure dynamicdns client (changeip.com) on windows base OS, First create your account at changeip.com (its well described at https://aacable.wordpress.com/tag/aacable-dynamicdns/)

After your account is created, now  download and install dynamic dns client (known as homingbeacon) from following location

http://www.changeip.com/dns/homingbeacon/default.aspx

Installation is fairly simple. Just clicking few next next 🙂

After installation is done, execute “The HomingBeacon Console” from the windows start menu. After its open , click on ‘I already have changeip.com account‘  (If you don’t already have the account, you can create it from the web or clicking on ‘) am a new changeip.com customer’
As showed in the image below . . .

1- pic1
.

.
Now Enter your changeip.com account id with password that you already created earlier.
As showed in the image below . . .

2- enter id passwordClick on Save & Close.

.

.

It will update the public IP of your WAN to your account at changeip.com
As showed in the image below . . .

3- update

.

Verify it by going to your changeip.com account, and see if the ip is updated properly. Now its time to configure your DSL router to create port forwarding rule, so required connections can be made from remote location.
For example you want to host HTTP Server on your local PC and want to access it remotely, open your DSL Router Page, and

Login to your dsl modem control panel.
As showed in the image below . . .

4-add nat in dsl.

.

5-add-nat-rule

.

.

 

Regard’s
Syed Jahanzaib

%d bloggers like this: