Syed Jahanzaib Personal Blog to Share Knowledge !

August 16, 2017

IBM Lotus Domino: Layman’s approach to move Archive’s to new partition

Filed under: IBM Related — Syed Jahanzaib / Pinochio~:) @ 9:16 AM

bg_domino2


Scenario:

We are using IBM’s Lotus Domino 8.x on Windows 2008 R2 with following folders structure.

  • D:\LOTUS\DOMINO\DATA\MAIL   > 500 GB , users inbox
  • D:\LOTUS\DOMINO\DATA\MAIL\ARCHIVE > 1000 GB , users archived mails

Archiving policy is enabled on the server-end which runs on a weekly basis, It moves One year old email from the inbox folder to ARCHIVE folder with a_username structure. Disk Space was getting low in D: partition therefore I had added new drive (E:) and wanted to move user ARCHIVE(s) to new partition E:\ARCHIVE

There were few solutions to perform the operation, Online & Offline.

With Online approach we could use the Domino’s builtin MOVE operation (via domino admin client) in which we dont have to take any shutdown, but then we would need to get the timing right. If the mailfiles are not moved into the new folder before our  scheduled , server archive runs then new archive files will be created which may complicate things.

But since I was able to afford 2 hours down time I took the OS cut/paste option.


I did following

  1. Quit the Domino via Admin Client, then Stop the Domino Services via SERVICES.
  2. Moved (Cut n Paste) ARCHIVE folder from D to E: drive (e:\archive2 folder)
  3. In D:\LOTUS\DOMINO\DATA\MAIL folder , I created a text file called ARCHIVE.DIR
    In text file put I added path E:\ARCHIVE).
  4. Start Domino Server service (Or better to restart the server).

& all went fine.

I am big fan of Domino’s own MOVE operation, but after few months, I will be replacing this machine with new server, then it would be a problem to move the archives again. there fore above Operation was a good choice from Layman’s management perspective 🙂

Hope it will help someone with same situation.


Regard's
~Syed Jahanzaib~

August 15, 2017

Playing with the `radpostauth` table in Freeradius

Filed under: Radius Manager — Syed Jahanzaib / Pinochio~:) @ 3:40 PM

Freeradius is a well known billing system which is commonly used by ISP’s worldwide due to its reliability,  highly customizable and versatility. Many 3rd party vendors have made some good GUI fronted to manage the FR back-end engine.

It also sues mysql to facilitate logging of various users details. One of the table called radpsotauth which can hold information about users successfull/failed login attempts. Using this table, we can compliment our own GUI or 3rd party fronted (for easy management of freeradius engine) like DMASoftlab radius manager Authentication Log section so that admin / support can see users authentication logs. With some modification we can add useful information for quick troubleshooting example why user denied the authentication request, either invalid mac, wrong password, or account expired.

Note to *.*

  • You can add UNLAG query as well to apply IF statement, and add REPLY result according to your requirements.
  • This post was written for some reference purposes & will be updated as per request.
  • This guide is incomplete post. But it can be used as a reference as well for future retrieval

Example:

showing auth logs with errors numbers.JPG

As we can see in above image that in Radius Reply column, it clearly showing why user is denied like invalid mac address , account expires, invalid service reference (when user account id disabled in dma).

To enable these features we have to perform few steps as following …

 


RADDB DEFAULT CONFIG

First we need to edit the default sites config file for raddb.

Edit following file

nano /usr/local/etc/raddb/sites-available/default

Now search for “post-auth {” section

To make it simple and copy-paste format, Use following


post-auth {
sqlippool
reply_log
exec
sql
Post-Auth-Type REJECT {
sql
attr_filter.access_reject
}
}

As showed in the image below …

psot-auth section

Save & Exit.


#DIALUP.CONF Section

Edit the post-auth section in /usr/local/etc/raddb/sql/mysql/dialup.conf file

At the end of this file you will see “postauth_query” section. You need to change it

Old post-auth query

old-dialup

After changing

new-dialup

or copy paste text as below…


#######################################################################
# Authentication Logging Queries
#######################################################################
# postauth_query - Insert some info after authentication
#######################################################################

postauth_query = "INSERT INTO ${postauth_table} \
(username, pass, reply, authdate, nasipaddress, mac) \
VALUES ( \
'%{User-Name}', \
'%{%{User-Password}:-%{Chap-Password}}', \
'%{reply:Packet-Type} - %{reply:Reply-Message}', \
'%S', \
'%{NAS-IP-Address}', \
'%{Calling-Station-Id}')"

Save & Exit.


#Alter the RADPOSTAUTH table using mysql cmd …

Using mysql cmd, we will perform 2 functions

  1. Increase the REPLY column length to accommodate longer reply messages display properly
  2. Add the MAC Address column so we can detect the calling user device mac address
mysql -uroot -pPASSWORD
use radius;
ALTER TABLE radpostauth MODIFY `reply` VARCHAR( 100 );
ALTER TABLE radpostauth ADD COLUMN mac TEXT;
exit

Restart the RADIUSD service

service radiusd restart

using CMD, you can now see the authentication log table

mysql -uroot -pPASSWORD -e “use radius; select * from radpostauth;”

& you will see the information

phpmyadmin query for table

1 JOHN     123456     Access-Reject - The account has expired=21      2017-08-15 [14:14:05       192.168.1.1         10:FE:ED:33:BD:AX

Notes:

  • You can modify the messages appearing in the different columns, you can add your own customized columns as well like called station, or others
  • You can add UNLAG query as well to apply IF statement, and add REPLY result according to your requirements.
  • It can chew up your disk space, so try to make text shortest possible, like error codes only, not the whole text.
  • scheduled a cron job so that it can empty the table on weekly/monthly basis so that it may not swallow disk space plus performance should remain optimal.
  • If used in heavy environment it can put considerable strain on your system resources by putting large quantity of mysql INSERT queries into the table.

 

 


Regard’s
Syed Jahanzaib

 

July 26, 2017

Mikrotik script to monitor local device with optional SMS alert

Filed under: Mikrotik Related — Syed Jahanzaib / Pinochio~:) @ 2:04 PM

Note to Self:

Following is a simple script I made to monitor local device & upon status change, it will send SMS only. It was customized according to local requirements. You can refine at , add remove any option as per taste. There are lot of good working scripts available on the internet. Just try not to blindly copy paste any one else script. Read it many times until you understand clearly what its made for & what functions it will perform. I have added some comments for the clarity.

Script, Script, Why use Script ?

Why use such complicated scripts while you can do this easily with builtin net-watch or windows base applications like the Dude, or Nix base Nagios, and so many other tools? the answer is simple, using script you have more Power, more control, more maneuverability , customized bizarre and strange actions you can take. Above all, Learning & feeling of Power you have over the system 🙂 this alone justification is enough for me to use scripting 🙂

Thank you
~Syed Jahanzaib~


Script Output Examples:

When Device is DOWN …

1- deviec down

.

When Device is UP (restored) …

2- deviec up

.

Example of SMS received:

2017-07-26 13.44.01


the Script !


# This is Mikrotik Script for Local Device Link monitoring by IP
# - with Optional SMS Alert. We are using local Linux base KANNEL
# You can modify it to add EMAIL alerts as well using GMAIL or local Mail Gw.
# system as SMS gateway with local modem attached
# Script By Syed Jahanzaib / # https://aacable.wordpress.com
# Email : aacable at hotmail dot com
# Script Last Modified : 26-July-2017

# Set Device IP here
:global DEVICE1host1 "10.0.0.8"

#:log warning "Checking status of Ubnt Device $DEVICE1host1 by ping ..."

:local i 0;
:local F 0;
:local date;
:local time;
:set date [/system clock get date];
:set time [/system clock get time];

:global DEVICE1LanStatus;
:global DEVICE1LanLastChange;

# Company Name, Dont use SPACEC Here, because our KANNEL system dont liek spaces, use + sign instead
:local COMPANY "ZABBO"
# Dont use SPACEC Here, because our KANNEL system dont liek spaces, use + sign instead
:local DEVNAME "MailServer"

# Setting Date Time variables
:local sub1 ([/system identity get name])
:local sub2 ([/system clock get date])
:local sub3 ([/system clock get time])

# Number of Ping Count, how many times mikrotik should ping the target device
:local PINGCOUNT "5"
# Ping threshold
:local PINGTS "5"

# Provide details of Kannel SMS gateway, ID pass, and cell numbers on which sms is required
:local KURL "http://KANNEL-GW-IP-OR-NAME:13013/cgi-bin/sendsms"
:local KID "kannel"
:local KPASS "KANNELPASS"
:local cell1 "03333021909"

# SMS Msg format for Kannel SMS gateway (donot use spaces in it)
:local MSGDOWNSMS "$COMPANY+ALERT:%0A$DEVNAME%0A$DEVICE1host1+is+now+DOWN."
:local MSGUPSMS "$COMPANY+INFO:%0A$DEVNAME%0A$DEVICE1host1+is+now+UP."

# LOG error
:local DOWNLOG1 "$COMPANY ALERT: $DEVNAME with IP $DEVICE1host1 is now DOWN ..."
:local UPLOG1 "$COMPANY INFO: $DEVNAME with IP $DEVICE1host1 is now UP ..."

# Start the SCRIPT
# DONOT EDIT BELOW

# If Script is running for the first time , consider target device UP,
# Just to avoid any errors in the script dueto empty variable.
:if ([:len $DEVICE1LanStatus] = 0) do={
:set DEVICE1LanStatus "UP";
}

# 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 $DEVICE1host1 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 (($DEVICE1LanStatus="UP")) do={

# If the link is down, then LOG warning in Mikrotik LOG window [Zaib]
:log error "$DOWNLOG1";
:set DEVICE1LanStatus "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 DEVICE1LanLastChange ($time . " " . $date);
# Send SMS via KANNEL for DOWN Status
:log warning "Sending SMS for DOWN status of $DEVNAME $DEVICE1host1 ..."
/tool fetch url="$KURL\?username=$KID&password=$KPASS&to=$cell1&text=$MSGDOWNSMS"

# If ping reply received, then LOG UP and take action as required
} else={:set DEVICE1LanStatus "DOWN";}
} else={
:if (($DEVICE1LanStatus="DOWN")) do={
# If link is UP, then LOG info and warning in Mikrotik LOG window [Zaib]
:log warning "$UPLOG1"
:set DEVICE1LanStatus "UP";

# Send SMS via KANNEL for UP Status
:log warning "Sending SMS for UP status of $DEVNAME $DEVICE1host1 ..."
/tool fetch url="$KURL\?username=$KID&password=$KPASS&to=$cell1&text=$MSGUPSMS"
:set date [/system clock get date];
:set time [/system clock get time];
:set DEVICE1LanLastChange ($time . " " . $date);

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

# Script ends here ...

Expanding Guest IDE disk in ESXI

Filed under: Forefront TMG 2010 Related — Syed Jahanzaib / Pinochio~:) @ 9:47 AM

We are using VMWARE Esxi 5.0 server hosting few VM guests. One of our guest machine which is acting as proxy/filter system (Forefront TMG 2010 ) for our users, its  disk space was getting lower (as its total size was 60 GB only). I installed this TMG in year 2012 & I was missing its patches / service packs therefore I was avoiding doing fresh installation. As per Vmware documentation, you cannot increase IDE disk size.

disk_not_increasing


I tried another workaround but for some reasons, it didn’t worked in my case.
I used below workaround & it worked perfectly for me.

  • Power OFF the Target guest VM.
  • Login to ESXI Server via putty or any SSH client.
  • Navigate to folder where your guest VMDK file reside,
  • e.g: /vmfs/volumes/XXXXX/Guestname
  • Note down the .vmdk file name & issue expand command against that file
vmkfstools -X 200G TMG.VMDK

-X = expand
200G = size to increase (total size)
TMG.VMDK = File name which we want to expand

As showed in the image below …

1- space added

Depends on your hardware speed, it may take some time to complete the operation. I had some good IBM hardware & it took around 1-2 minutes to increase the size from 60GB to 200GB.

After few minutes it will populate to ESXI client automatically.

Now power ON the guest machine, and increase the size as required , either using Windwos Disk Management tool or cmd. I used MiniTool Partition Wizard Server Edition 7.1 which worked beautifully to complete the task without any hassle.

Below is Image after the task finished.

2- space added. final snap

 

 

June 16, 2017

Quick Notes on moving MySQL database(s) directory to New Partition

Filed under: Linux Related — Syed Jahanzaib / Pinochio~:) @ 4:59 PM

moving

Following are short notes on how you can move mysql db directory to another partition.

Background:

Our Government base telecom authority called PTA (in PK) regularly issues letter to local ISP’s asking them to keep user traffic data for period of minimum one year.

As showed here (Thanks to Mr. Khalid for providing this notice copy)

pta letter

We know that almost all small scale ISP are natting there users by using local dsl or other medium bandwidth, and keeping private IP data traffic is (almost) useless because finding any thing from such data is like finding a needle in the haystack. If OP is assigning users with public ip, then OP should record users public ip assignment only like showed here, but as private natted IP are still being used therefore OP should save users traffic as per law despite of it will almost useless in practical)

In general we can log user traffic by using mikrotik own small scale web proxy, or adding external proxy like SQUID and route all traffic to squid proxy and keep logs there.

But if you are using Radius Manager, we have option of CONNECTION TRACKING. Using this method, we can track all users connection in mysql DB.

c1

c2

Connection Tracking requires lot of disk space for local ISP. Recently I recommend many OP to use SSD disk as SSD disks are more reliable , long life & offer fast disk access with minimal latency, but as SSD are costly therefore as alternative, we can add secondary disk for mysql like 2.TB and move our MySQL DB in this drive, rest OS or RM will operate from our primary SSD.


Scenario:

We have 2 disk in system as follows

  1. 128 GB SSD [Ubuntu 12.4 installed along with radius manager 4.1.5]
  2. 2 TB SATA Disk [Empty & Mounted as /2tb, howto mount disk read this ]

So our requirement is to move MySQL DB to this 2 TB disk.


Quick Cmd’s …

First login to MySQL and see your current Data Directory location.


mysql> select @@datadir;
+-------------+
| @@datadir |
+-------------+
| /var/lib/mysql |
+-------------+
1 row in set (0.00 sec)

Now we need to move this folder to our new 2tb. Follow below ,,,


Stop MySQL Service & Moves files to 2 TB Disk

sudo service mysql stop

Copy mysql DB Data directory to our 2tb disk with permissions intact, this part is crucial, pay attention to this section. We will use RSYNC to have same permission level in new folder.

sudo rsync -av /var/lib/mysql /2tb/

Rename current MySQL DB directory /var/lib/mysql to .bak [for backup purposes so that in case any thing goes wrong , we still have this restore point]

sudo mv /var/lib/mysql /var/lib/mysql.bak

Change PATH in MySQL INF file

Edit mysql inf file to change the DB directory

sudo nano /etc/mysql/my.cnf

in this file, find DATADIR line and change the old path to new one As showed below …

datadir = /2tb/mysql

Save & Exit


Apparmor Section [for Ubuntu OS]:

Allow new folder in APPARMOR (if you will skip this, you will get access / permission  errors)

sudo nano /etc/apparmor.d/tunables/alias

at the bottom add this line

alias /var/lib/mysql/ -> /2tb/mysql/,

Save n Exit.

It’s also recommended to disable SELINUX.


Start MySQL & Test

Now start the mysql service

service mysql start

& if all ok you may see following …

mysql start/running, process 1881

further verify it with process check

root@radius:~# ps aux |grep mysql
mysql 1881 0.1 3.9 328928 40536 ? Ssl 16:09 0:00 /usr/sbin/mysqld

Login to my mysql and verify all db/tables showing ok


root@radius:~# mysql -uroot -pMYSQLPASSWORD
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 964
Server version: 5.5.54-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select @@datadir;
+-------------+
| @@datadir |
+-------------+
| /2tb/mysql/ |
+-------------+
1 row in set (0.00 sec)

mysql>

🙂


Regard’s
Syed Jahanzaib

June 7, 2017

Generating Refill Cards in Radius Manager

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

On Demand Guide!

DMASoftlab Radius Manager is a nice billing system for any ISP. It works on Linux base OS like Ubuntu / Centos etc. It uses Free-radius as back-end engine and PHP as fronted GUI. It provides variety of ways to manage users. You can manually create users . Or it also provide self registration service for user via registration option where user can sign up, choose his Id / Package & renew it using refill card.

Radius manager provides 2 type of Cards system.

  1. Prepaid Cards
  2. Refill Cards [Scratch card]

 

1- Prepaid cards are simpler as they contains username / password , and starts counting expiry/quota after first usage / login from user. they also binds with selected service. This is suitable for environment where users join.leave very frequently, like Cafe’s / restaurants / public hotspot places.

2- Refill cards does not contains any user name or password. they contains only amount, which user can deposit in his account himself by login to the UCP , user control panel and use redeem voucher option). Refill cards are useful if you have more permanent type of clients who renews on monthly basis. Using refill cards, you can providers with liberty to change his service on his own if required. off course he would required higher amount of refill card to renew his new upscale service. but user can do it all on his own if required. so its kind of fully automatic system as well.

Refill cards does not binds with any specific service, they contains only AMOUNT. Once the user add deposit using refill card code, his account wont get auto renewed (although we can use script for it) . He have to activate the service as well after depositing amount. So in short user have to perform 2 steps in order to renew his account. Using refill cards, you just have to only sell cards to user, rest user will maintain on his own.

Example:

We have created a service with 1mb speed, 15gb quota & 30 days expiry limit. We want to create refill cards so that we sell refill card to user, and user will renew his account by using the portal.

Service Example:

2- services


To create refill cards, Goto Card System / Generate Cards

1- refill card menu

 

3- refill generation process

To view these generated cards, Goto Cards System  / List Refill Cards

view refill

As you can see in above screenshot, it have generated cards. You can view it in CSV which will contains cards details in the text format (for local customized card printing in bulk), and if you click on PDF button, it will show you cards in ready to print format using PDF viewer As showed in the image below

refill card in pdf

Now you can sell this card to users and they can use it from there user panel called UCP.


Using REFILL card to renew account.

From user end, login to user portal, and you will see something like this for new / expired user

1- user.PNG

As we can see that user account is in expired state, to renew it ,

Goto REDEEM VOUCHER & enter the code of refill card.

2- refill number

Once submit, it will add 100 Rs deposit in user account. Goto HOME tab and you will see following

deposite

Notice that now user have 100 rs in DEPOSIT but the account is still in EXPIRED status. We will use this deposit amount to renew / activate the account.

Goto Purchase credits, and select 1 in AMOUNT field. As showed in the image below …

1- purchase credits

 

2- refill done

 

3- refill done

Go back to HOME tabe

4- done

Account is now active, and user can login by hotspot / ppp or whatever auth method you have in your mikrotik or other NAS.

You can also refill cards by sending SMS to the radius system connected gsm modem. You will be requiring KANNEL along with Play SMS as well. I shared the idea here.

https://aacable.wordpress.com/2015/05/25/sharing-ideas-renew-expired-user-account-via-sms-in-dmasoftlab-radius-manager/

reill-with-no-quota-showing-it


 

Done.

 

Blocking WhatsApp in Mikrotik

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

block whatsapp image.PNG

Updates: This guide may no longer work as whatsapp have moved there ip pool to facebook pool. as stated here.

(You may still be able to block the whatsapp by using script to catch only whatsapp related ip’s which may take some time to catch all the related ip’s but maybe some other contents will be blocked as well. you need to do deep inspection in this regard. I am not removing this post just for reference purposes)

Dear partners,
Please note that we have migrated the latest IP pools of WhatsApp to Facebook Mobile Partner Portal. Feel free to browse to the Settings page of the portal and download the latest WhatsApp IP pool: https://fb.me/mpp_support
Further IP pool updates are also done through the portal and are no longer distributed via email or through WhatsApp web site.
If you have not yet registered on the Mobile Partner Portal or have difficulties accessing it – please request access through the following form and we’ll be happy to assist: https://fb.me/mpp_access
For any technical requests please contact us through the Support section of the portal: https://fb.me/mpp_support
WhatsApp team


In order to block WhatsAPP application in Mikrotik I used WhatsAPP provided address list [167 IPV4 addresses as of June,2017] in order to block the app. [there are already many guides on internet, but I used old school method to block this app & got success!]. Please beware that if user uses vpn, then this restriction will not be effective.

I am sharing two methods to achieve the same target. There is also another method in which you forcefully divert users dns traffic to your mikrotik dns and use script to fetch ip addresses associated with any URL having whatsapp in it, but I am not discussing it here at a moment.

You can also automate this task by fetching the list from whatsapp directly and import it in address list , so that you can always have updated whatsapp servers list. Although the list doesn’t update very frequently but still its good idea to automate it with scheduler.


Method #1 – Download list & import to address list along with firewall block rule

 

1- Download whatsapp IP (CIDR) list from

https://www.whatsapp.com/cidr.txt

Save it as  cidr.txt

Note: If you dont have ipv6 , then open this file and remove all the IPV6 addressess or else you will see below error while importing 

ipv6 error

 

2- Upload this cidr.txt file to Mikrotik FILES section.

[if you use fetch method to download file directly to mikrotik, then you dont need to upload file manualy, but I used this method because most local networks are running on ipv4, so I had to remove ipv6 entries first in order to import list)

cidr

 

3- Import the file contents (which includes ip addresses) using following script. you can simply copy paste it. make sure file name is correct in it.

{
:local content [/file get [/file find name=cidr.txt] contents]
:local contentLen [:len $content]
:local lineEnd 0
:local line ""
:local lastEnd 0
:while ($lineEnd < $contentLen) do={
:set lineEnd [:find $content "\r\n" $lastEnd]
:if ([:len $lineEnd] = 0) do={
:set lineEnd $contentLen
}
:set line [:pick $content $lastEnd $lineEnd]
:set lastEnd ($lineEnd + 2)
/ip firewall address-list add list="whatsapp_list" address=$line
}
}

If successfull , you will see address list as below [currently 167 entries] …

whtsapp address list

4- Create Firewall Filter rule to block requests going to whatsapp_list 

/ip firewall filter
add action=drop chain=forward comment="Block Whatsapp address list - zaib" disabled=yes dst-address-list=whatsapp_list

Result!

block whatapp result

Done!







Method #2 – Copy Paste Method with ipV4 package only.

Open Terminal & copy paste following code. It will add address list name ‘whatsapp_list’ along with firewall rule to block requests going to this list.

/ip firewall address-list
add address=31.13.64.51 list=whatsapp_list
add address=31.13.65.49 list=whatsapp_list
add address=31.13.66.49 list=whatsapp_list
add address=31.13.68.52 list=whatsapp_list
add address=31.13.69.240 list=whatsapp_list
add address=31.13.70.49 list=whatsapp_list
add address=31.13.71.49 list=whatsapp_list
add address=31.13.72.52 list=whatsapp_list
add address=31.13.73.49 list=whatsapp_list
add address=31.13.74.49 list=whatsapp_list
add address=31.13.75.52 list=whatsapp_list
add address=31.13.76.81 list=whatsapp_list
add address=31.13.77.49 list=whatsapp_list
add address=31.13.78.53 list=whatsapp_list
add address=31.13.80.53 list=whatsapp_list
add address=31.13.81.53 list=whatsapp_list
add address=31.13.82.51 list=whatsapp_list
add address=31.13.83.51 list=whatsapp_list
add address=31.13.84.51 list=whatsapp_list
add address=31.13.85.51 list=whatsapp_list
add address=31.13.86.51 list=whatsapp_list
add address=31.13.87.51 list=whatsapp_list
add address=31.13.88.49 list=whatsapp_list
add address=31.13.90.51 list=whatsapp_list
add address=31.13.91.51 list=whatsapp_list
add address=31.13.92.52 list=whatsapp_list
add address=31.13.93.51 list=whatsapp_list
add address=31.13.94.52 list=whatsapp_list
add address=31.13.95.63 list=whatsapp_list
add address=50.22.198.204/30 list=whatsapp_list
add address=50.22.210.32/30 list=whatsapp_list
add address=50.22.210.128/27 list=whatsapp_list
add address=50.22.225.64/27 list=whatsapp_list
add address=50.22.235.248/30 list=whatsapp_list
add address=50.22.240.160/27 list=whatsapp_list
add address=50.23.90.128/27 list=whatsapp_list
add address=50.97.57.128/27 list=whatsapp_list
add address=75.126.39.32/27 list=whatsapp_list
add address=108.168.174.0/27 list=whatsapp_list
add address=108.168.176.192/26 list=whatsapp_list
add address=108.168.177.0/27 list=whatsapp_list
add address=108.168.180.96/27 list=whatsapp_list
add address=108.168.254.65 list=whatsapp_list
add address=108.168.255.224 list=whatsapp_list
add address=108.168.255.227 list=whatsapp_list
add address=157.240.0.53 list=whatsapp_list
add address=157.240.1.53 list=whatsapp_list
add address=157.240.2.53 list=whatsapp_list
add address=157.240.3.53 list=whatsapp_list
add address=157.240.6.53 list=whatsapp_list
add address=157.240.7.54 list=whatsapp_list
add address=157.240.8.53 list=whatsapp_list
add address=157.240.9.53 list=whatsapp_list
add address=157.240.10.53 list=whatsapp_list
add address=157.240.11.53 list=whatsapp_list
add address=157.240.12.53 list=whatsapp_list
add address=157.240.13.54 list=whatsapp_list
add address=158.85.0.96/27 list=whatsapp_list
add address=158.85.5.192/27 list=whatsapp_list
add address=158.85.46.128/27 list=whatsapp_list
add address=158.85.48.224/27 list=whatsapp_list
add address=158.85.58.0/25 list=whatsapp_list
add address=158.85.61.192/27 list=whatsapp_list
add address=158.85.224.160/27 list=whatsapp_list
add address=158.85.233.32/27 list=whatsapp_list
add address=158.85.249.128/27 list=whatsapp_list
add address=158.85.254.64/27 list=whatsapp_list
add address=169.44.23.192/27 list=whatsapp_list
add address=169.44.36.0/25 list=whatsapp_list
add address=169.44.57.64/27 list=whatsapp_list
add address=169.44.58.64/27 list=whatsapp_list
add address=169.44.80.0/26 list=whatsapp_list
add address=169.44.82.96/27 list=whatsapp_list
add address=169.44.82.128/27 list=whatsapp_list
add address=169.44.82.192/26 list=whatsapp_list
add address=169.44.83.0/26 list=whatsapp_list
add address=169.44.83.96/27 list=whatsapp_list
add address=169.44.83.128/27 list=whatsapp_list
add address=169.44.83.192/26 list=whatsapp_list
add address=169.44.84.0/24 list=whatsapp_list
add address=169.44.85.64/27 list=whatsapp_list
add address=169.44.87.160/27 list=whatsapp_list
add address=169.44.167.0/27 list=whatsapp_list
add address=169.45.71.32/27 list=whatsapp_list
add address=169.45.71.96/27 list=whatsapp_list
add address=169.45.87.128/26 list=whatsapp_list
add address=169.45.169.192/27 list=whatsapp_list
add address=169.45.182.96/27 list=whatsapp_list
add address=169.45.210.64/27 list=whatsapp_list
add address=169.45.214.224/27 list=whatsapp_list
add address=169.45.219.224/27 list=whatsapp_list
add address=169.45.237.192/27 list=whatsapp_list
add address=169.45.238.32/27 list=whatsapp_list
add address=169.45.248.96/27 list=whatsapp_list
add address=169.45.248.160/27 list=whatsapp_list
add address=169.46.52.224/27 list=whatsapp_list
add address=169.46.111.144/28 list=whatsapp_list
add address=169.47.5.192/26 list=whatsapp_list
add address=169.47.6.64/27 list=whatsapp_list
add address=169.47.33.128/27 list=whatsapp_list
add address=169.47.35.32/27 list=whatsapp_list
add address=169.47.37.128/27 list=whatsapp_list
add address=169.47.40.128/27 list=whatsapp_list
add address=169.47.42.96/27 list=whatsapp_list
add address=169.47.42.160/27 list=whatsapp_list
add address=169.47.42.192/26 list=whatsapp_list
add address=169.47.47.160/27 list=whatsapp_list
add address=169.47.130.96/27 list=whatsapp_list
add address=169.47.192.192/27 list=whatsapp_list
add address=169.47.194.128/27 list=whatsapp_list
add address=169.47.198.128/27 list=whatsapp_list
add address=169.47.212.160/27 list=whatsapp_list
add address=169.53.29.128/27 list=whatsapp_list
add address=169.53.48.32/27 list=whatsapp_list
add address=169.53.71.224/27 list=whatsapp_list
add address=169.53.81.64/27 list=whatsapp_list
add address=169.53.250.128/26 list=whatsapp_list
add address=169.53.252.64/27 list=whatsapp_list
add address=169.53.255.64/27 list=whatsapp_list
add address=169.54.2.160/27 list=whatsapp_list
add address=169.54.44.224/27 list=whatsapp_list
add address=169.54.51.32/27 list=whatsapp_list
add address=169.54.55.192/27 list=whatsapp_list
add address=169.54.193.160/27 list=whatsapp_list
add address=169.54.210.0/27 list=whatsapp_list
add address=169.54.222.128/27 list=whatsapp_list
add address=169.55.67.224/27 list=whatsapp_list
add address=169.55.69.128/26 list=whatsapp_list
add address=169.55.74.32/27 list=whatsapp_list
add address=169.55.75.96/27 list=whatsapp_list
add address=169.55.100.160/27 list=whatsapp_list
add address=169.55.126.64/26 list=whatsapp_list
add address=169.55.210.96/27 list=whatsapp_list
add address=169.55.235.160/27 list=whatsapp_list
add address=173.192.162.32/27 list=whatsapp_list
add address=173.192.219.128/27 list=whatsapp_list
add address=173.192.222.160/27 list=whatsapp_list
add address=173.192.231.32/27 list=whatsapp_list
add address=173.193.205.0/27 list=whatsapp_list
add address=173.193.230.96/27 list=whatsapp_list
add address=173.193.230.128/27 list=whatsapp_list
add address=173.193.230.192/27 list=whatsapp_list
add address=173.193.239.0/27 list=whatsapp_list
add address=174.36.208.128/27 list=whatsapp_list
add address=174.36.210.32/27 list=whatsapp_list
add address=174.36.251.192/27 list=whatsapp_list
add address=174.37.199.192/27 list=whatsapp_list
add address=174.37.217.64/27 list=whatsapp_list
add address=174.37.243.64/27 list=whatsapp_list
add address=174.37.251.0/27 list=whatsapp_list
add address=179.60.192.51 list=whatsapp_list
add address=179.60.195.51 list=whatsapp_list
add address=184.173.136.64/27 list=whatsapp_list
add address=184.173.147.32/27 list=whatsapp_list
add address=184.173.161.64 list=whatsapp_list
add address=184.173.173.116 list=whatsapp_list
add address=184.173.179.32/27 list=whatsapp_list
add address=185.60.216.53 list=whatsapp_list
add address=185.60.218.53 list=whatsapp_list
add address=185.60.219.53 list=whatsapp_list
add address=192.155.212.192/27 list=whatsapp_list
add address=198.11.193.182/31 list=whatsapp_list
add address=198.11.251.32/27 list=whatsapp_list
add address=198.23.80.0/27 list=whatsapp_list
add address=208.43.115.192/27 list=whatsapp_list
add address=208.43.117.79 list=whatsapp_list
add address=208.43.122.128/27 list=whatsapp_list
# Adding firewall rule to block whatsapp address list.
/ip firewall filter
add action=drop chain=forward comment="Block Whatsapp address list" dst-address-list=whatsapp_list

Result:

block whatapp result


Regard’s
Syed Jahanzaib

June 2, 2017

Howto install DMASoftlab Radius Manager in Centos 7 – 64bit

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

centos7

dma415

No doubt, Radius billing is one of the most important point of focus in any ISP network. ISP finance depends on this system to work smoothly. There are various ready made radius application based on LINUX are available in the market to cater different requirements of various operators. Among many, DMASoftlab Radius Manager is one of the most cheapest but feature rich radius candidate starting from 99$ only. It provide variety of options for any ISP. best thing is its ONE TIME COST only & it works life time 🙂 , you can install it locally on your system or on cloud as well, it requires Linux base OS like Debian/Ubuntu/Centos. Its full features can be viewed at Radius Manager web site. It required very little resources to run, provide plenty of user administration functions, backup / restoration / management is quite simple as well. plus in background you can accompany it with many scripting of your own to perform various customized functions.

We all know that cloud is every where now and almost all hosting providers are now providing latest versions of operating system like Centos 7. Some of us are well aware that DMA Radius Manager is quite comfortable with following flavors of nix …

  • Ubuntu 12.4 / 32bit [*** Best OS & my personnel choice, as recovery & troubleshooting is much easier in this variant]
  • Centos 6.5/6.6

But now a days many operators are switching to cloud where hosting providers are not providing older versions of centos/ubuntu. As i had to do few installation on cloud for few clients & I had to recall all the bits & bytes to do the installation every time, therefore I am posting step by step copy paste friendly version of guide on howto install Radius Manager in Centos 7. I posted ready made scripts for Ubuntu 12 Installation Script &Centos 6 in previous guides but This one is for Centos 7 to make installation quicker. I will make its script but better to do it manually as Centos 7 is a bit tricky which will give you some tough time in various aspects

  • OS Used in this guide = CentOS Linux release 7.3.1611 (Core)

Steps:

1# Disabling Firewall to avoid interruption

First we will update YUM & install nano for easy text editing, as many of us are not much comfortable with VI. NANO is better …

yum install update
yum -y install nano

* Disable IPTABLES

service iptables stop
chkconfig iptables off

* Disable SELINUX

So that it may not interfere with our installation/accessing. To disable builtin firewall permanently in centos, edit following

nano /etc/selinux/config

and change the

SELINUX=enforcing

to

SELINUX=disabled

Save & Exit .

*Disable Firewall(Daemon)

Now Disable Firewall’Daemon’ so that it may not interfere with our installation/accessing

systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld

Reboot system to take effect.


2# Installing various supporting modules !

1- Installing EPEL Repo to download various other supporting packages like mysql,apache etc

rpm -ivh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
yum -y install mc wget crontabs make gcc libtool-ltdl curl mysql-devel php php-mysql php-gd php-snmp php-process ntp alpine mariadb-server mariadb php-mcrypt cronie wget net-tools psmisc
yum -y install glibc.i686 libgcc_s.so.1
systemctl start mariadb.service
systemctl enable mariadb.service

3# Configuring Mysql Section

Now initiate mysql initial setup

mysql_secure_installation

Above command will ask few queries, read and select accordingly. ** Make sure to setup mysql root password **

*Now start / enable APACHE services 

systemctl start httpd.service
systemctl enable httpd.service

4# Adding IONCUBE module in PHP

Verify your PHP version  by php -v & copy the iocube load accordingly.
At my station, I had `PHP 5.4.16 (cli) (built: Nov  6 2016 00:29:02)` version installed by YUM.

wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar -xvzf ioncube_loaders_lin_x86-64.tar.gz
cd ioncube
mv ioncube_loader_lin_5.4.so /usr/lib64/php/modules/
chmod 777 /usr/lib64/php/modules/ioncube_loader_lin_5.4.so

Now add ioncube library in php

nano /etc/php.ini

and add following line after [PHP] heading, usually this heading is in first line.

zend_extension = /usr/lib64/php/modules/ioncube_loader_lin_5.4.so

& restart APACHE service so it can load the new module

systemctl restart httpd.service

re-run ​​’php -v to verify you have something like [if successfull]

PHP 5.4.16 (cli) (built: Nov 6 2016 00:29:02)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com unconfigured) v6.1.0 (), Copyright (c) 2002-2017, by ionCube Ltd.

5# Download FREERADIUS & compile.

cd /temp
wget http://www.dmasoftlab.com/cont/download/freeradius-server-2.2.0-dma-patch-2.tar.gz
tar -xvzf freeradius-server-2.2.0-dma-patch-2.tar.gz
cd freeradius-server-2.2.0
./configure
make
make install

Above may take some time to compile. After its done, issue following command to initiate radius

radiusd -X

If you get error in first attempt, try to run it again, and you may see following message on success

centos-radiusdx

Now press CTRL+C to return to command prompt.


 

6- Radius DB creation in MYSQL

Create mysql DATABASES for radius usage. Make sure to change the passwords where required, example mysql root password. It’s OK to use default passwords for the test flight, but for production server Its Highly recommended to use different passwords while you do the installation.

mysql -u root -pYOURMYSQLPASS
CREATE DATABASE radius;
CREATE DATABASE radius;
CREATE DATABASE conntrack;
CREATE USER 'radius'@'localhost' IDENTIFIED BY 'radius123';
CREATE USER 'conntrack'@'localhost' IDENTIFIED BY 'conn123';
GRANT ALL ON radius.* TO radius@localhost;
GRANT ALL ON conntrack.* TO conntrack@localhost;

7# Download & Install RADIUS MANAGER 4.1.0

cd /temp/
wget http://wifismartzone.com/files/rm_related/radiusmanager-4.1.0.tgz
tar zxvf radiusmanager-4.1.0.tgz
cd radiusmanager-4.1.0
chmod 755 install.sh
# Now start the Radius Install Script.
# once you will run INSTALL.SH , it will ask various queries, select according to your OS choice 

./install.sh

8# Access Radius Manager Administration Panel

Now try to access your radius manager admin panel from any browser pointing to ..

http://yourip/radiusmanager/admin.php

If all ok , you will see following window in your browser

dma-login-ok

* Default ID Password 
ID = admin
Password = 1111

Enjoy,

~*~*~*~*~*~*~*~*~*~*~*~*~*~*~

If you see error or blank page, use following Apache error/access logs for further trouble shoot. Most common causes are invalid license files / in-correct php ioncube files.

tail -f /var/log/httpd/error_log
tail -f /var/log/httpd/access_log

 


# TIPS

 

TIP#1 – How to create Virtual NIC with customized / cloned MAC address

First check what ethernet name you have currently, mostly its eth0, [change it according to your network].

ip link add link eth0 address 00:11:22:33:44:55 eth0.1 type macvlan
ifconfig eth0.1 up
ifconfig eth0.1 10.0.0.2

Verify if NIC is created with our desired NIC as well.

ifconfig

# Restart APACHE service if required, YKWIM ; )

systemctl restart httpd.service

TIP#2 – Deploying PATCH 4.1.5 for Centos

DMA released few patches for its radius application. Latest version is 4.1.6 , but I usually prefer to go with 4.1.5. Following is quick copy paste version to upgrade. Make sure that you have proper working installation of radius manager & if you are not much familiarized with the restoration process then you should backup your current installation before proceeding.

# SYED JAHANZAIB
# HTTPS://AACABLE . WORDPRESS . COM
# AACABLE at HOTMAIL dot COM
mkdir /temp
cd /temp
wget http://wifismartzone.com/files/rm_related/radiusmanager-4.1-cumulative_patch.tgz
tar zxvf /temp/radiusmanager-4.1-cumulative_patch.tgz
cd /temp/radiusmanager-4.1-cumulative_patch/
cp -vrf www/radiusmanager/* /var/www/html/radiusmanager
chmod 755 bin/rm*
service rmpoller stop
cp bin/* /usr/local/bin
cp raddb/acct_users /usr/local/etc/raddb
chmod 640 /usr/local/etc/raddb/acct_users
chown root.root /usr/local/etc/raddb/acct_users
service radiusd restart
service rmpoller start

For more information, please refer to

Dmasoftlab Radius Manager 4.1.5 Patch


Note: If you find any errors in this guide, please do let me know

Thanks & Best Regard’s

~SYED JAHANZAIB~

May 26, 2017

Howto bypass specific client from PCC & route to specific WAN link [Part-2]

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

Distribution.jpg


Scenario:

Since many asked the same query, so rather to reply individually, here is one method I used at one OP & it works fine. You may opt for others solution which ever is easy for you. the thing is it should work thats it:)]

We have configured Mikrotik as 3 wan load balancer [DSL links]. PPPoE Server is configured as well. All working Good. Now we have introduced premium package for dedicated users & we want to route them via newly added 4th WAN link only so there service should work smoothly even in peak times as well. therefore we need to bypass this group from the PCC & route them to 4th WAN link which has dedicated CIR bandwidth.

Solution:

There are always different ways to achieve any task. It depends on the Operator expertise, & network scenario as well.

Copy Paste WILL Not work !

Every network is different ~ I am sharing this code so you should learn concepts. Minimize copy paste culture, invent your solutions by understanding logic’s & implement it by modifying or creating code. 

Drink Wiki & you shall succeed 😀

~ zaiB

In this example I am showing one example, [You may opt for others which ever is easy for you. the thing is it should work that’s it:) ]

  1. make pppoe pool-1 in address list. [This one for general clients = 172,16.0.1-172,16.0.255 ]
  2. make pppoe pool-2 in address list  [This one for dedicated clients = 172,16.1.1-172,16.1.255 ]
  3. when you will create normal users , assign them pppoe pool-1
  4. when you will create dedicated users , assign them pppoe pool-2
  5. In your Mangle rules, where you mark connections (classifier section] , make sure you specify pppoe pool-1 list in source address list. Also you need to duplicate this rule, and in source address list, select pool-2, basically we will mark connections for both pools, and assign them different marking connection name.
  6. now in mark routing section, repeat above, and mark routing for both marked connections.
  7. in Nat, create natting rules so traffic can be natted by all 4 wan links. you can trim this by single rule as well 🙂
  8. in Routes, create rules for all marked packets, for normal clients, user wan1-3, for dedicated clients marked packets, route them specific wan link [like wan4]

* Working Example


/ip pool
# General users pppoe profile pool, which will be routed in 3 wan links
add name=pool-1 ranges=172.16.0.1-172.16.0.254
# Dedicated users pppoe profile pool, which will be routed via wan-4 link only
add name=pool-2 ranges=172.16.1.1-172.16.1.254

/ip firewall address-list
# General users pool list, which will be routed in 3 wan links
add address=172.16.0.1-172.16.0.255 list=pool-1
# Dedicated users pool list , which will be routed via wan-4 link only
add address=172.16.1.1-172.16.1.255 list=pool-2

/ip firewall mangle

add action=accept chain=prerouting comment=PCC in-interface=pppoe-out-1
add action=accept chain=prerouting comment=PCC in-interface=pppoe-out-2
add action=accept chain=prerouting comment=PCC in-interface=pppoe-out-3
add action=accept chain=prerouting comment=PCC in-interface=pppoe-out-4

# Marking connections for dedicated clients from pool-2 address list, to be routed via WAN-3 link only
add action=mark-connection chain=prerouting comment="Mark pool-2 dedicated Users Connections" new-connection-mark=pool2-conn passthrough=yes src-address-list=15mb-pool-list
add action=mark-routing chain=prerouting comment="Mark pool-2 dedicated Users Routing Pkts" connection-mark=pool2-conn dst-address-type="" log-prefix=20mb_ new-routing-mark=pool2-route passthrough=yes

# Marking connections for general users clients from pool-1 address list, to be distributed among 3 wan link
add action=mark-connection chain=prerouting comment=PCC_MARK_CONNECTION dst-address-type=!local new-connection-mark=wan1_conn passthrough=yes per-connection-classifier=src-address:3/0 src-address-list=pool-1
add action=mark-connection chain=prerouting comment=PCC_MARK_CONNECTION dst-address-type=!local new-connection-mark=wan2_conn passthrough=yes per-connection-classifier=src-address:3/1 src-address-list=pool-1
add action=mark-connection chain=prerouting comment=PCC_MARK_CONNECTION dst-address-type=!local new-connection-mark=wan3_conn passthrough=yes per-connection-classifier=src-address:3/2 src-address-list=pool-1

# Marking routing form above marked conections, for general users
add action=mark-routing chain=prerouting comment=PCC_MARK_ROUTING connection-mark=wan1_conn new-routing-mark=to_wan1 passthrough=yes
add action=mark-routing chain=prerouting comment=PCC_MARK_ROUTING connection-mark=wan2_conn new-routing-mark=to_wan2 passthrough=yes
add action=mark-routing chain=prerouting comment=PCC_MARK_ROUTING connection-mark=wan3_conn new-routing-mark=to_wan3 passthrough=yes

/ip firewall nat
# Allow natting for dedicated clients, to be nat via wan-4
add action=masquerade chain=srcnat comment="ALLOW NATTING FOR POOL-2 Dedicated USERS " out-interface=pppoe-out-4 src-address-list=pool-2
# Allow natting for general clients, to be nat via wan link number 1-2-3
add action=masquerade chain=srcnat comment=NATTING_DSL_1 out-interface=pppoe-out-1 src-address-list="pool-1"
add action=masquerade chain=srcnat comment=NATTING_DSL_2 out-interface=pppoe-out-2 src-address-list="pool-1"
add action=masquerade chain=srcnat comment=NATTING_DSL_3 out-interface=pppoe-out-3 src-address-list="pool-1"

/ip route
# Route for general users marked traffic - to be passed via 3 wan links
add check-gateway=ping distance=1 gateway=pppoe-out-1 routing-mark=to_wan1
add check-gateway=ping distance=1 gateway=pppoe-out-2 routing-mark=to_wan2
add check-gateway=ping distance=1 gateway=pppoe-out-3 routing-mark=to_wan3

# Route for dedicated users marked traffic - to be passed via wan-4 link only
add comment="Route Rule for dedicated users to go via WAN-4 only " distance=1 gateway=pppoe-out-4 routing-mark=pool2-route


Regard’s
Syed Jahanzaib

April 27, 2017

iBBi Switcher – Cisco Management Tool

Filed under: Cisco Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 4:29 PM


iBBi Switcher – Cisco Monitoring Tool

This is another application I made in C# using Visual Studio 2012. I generally use Cisco Configuration Assistant tool to Manage/Monitor our Cisco switches. Its great , works flawlessly, but still sometimes I need some thing quick to just monitor port status without  using full sized apps , above all the biggest advantage for our local environment is that I can give this app to local support staff and technician easily without giving them any further access to any panel.

Development is Powerful & Fun as well ~

Functions:

This app uses SNMPSHARPNET  library to query remove device by SNMP. It performs following actions …

  • Once Start button is pressed, It will first check if remote device or its SNMP is responding, if not give error (without freezing User Interface), If Response is OK, then continue further
  • Query all 24 ports with there description dynamically, Update the labels and Up/Down image according to the status.
  • Update Timer Label to see when last update on ports were made
  • Strip Menu for info/Exit Function.
  • Exit button on top right corner to exit the app immediately
  • Display progress bar to indicate process is active
  • Display CPU progress bar with temperature as well
  • Once START button is pushed, disable it to prevent duplication, added error as well.
  • STOP button to stop monitoring and timer and revert labels/images to default.
  • In Status Box window, display any ports UP / DOWN Status As showed in the image below

port down


the Code:

First download SNMPSHARPNET library and import it.

// C# / VS2012
// This is another application I made in C# using Visual Studio 2012.
// I generally use Cisco Configuration Assistant tool to Manage/Monitor our Cisco switches.
// Its great , works flawlessly, but still sometimes I need some thing quick to just monitor port status without using full sized apps
// above all the biggest advantage for our local environment is that I can give this app to local support staff and technician easily
// without giving them any further access to any panel.
// Make sure to download the SNMPSHARPNET library before using this code.
// Syed Jahanzaib
// aacable at hotmail dot com
// http:// aacable dot wordpress dot com
// 27-April-2017
using System;
using System.Net;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using SnmpSharpNet;
using System.Threading.Tasks;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public class Globals
{
public static string P1 = "";
public static string P2 = "";
public static string P3 = "";
public static string P4 = "";
public static string P5 = "";
public static string P6 = "";
public static string P7 = "";
public static string P8 = "";
public static string P9 = "";
public static string P10 = "";
public static string P11 = "";
public static string P12 = "";
public static string P13 = "";
public static string P14 = "";
public static string P15 = "";
public static string P16 = "";
public static string P17 = "";
public static string P18 = "";
public static string P19 = "";
public static string P20 = "";
public static string P21 = "";
public static string P22 = "";
public static string P23 = "";
public static string P24 = "";
public static string PL1 = "";
public static string PL2 = "";
public static string PL3 = "";
public static string PL4 = "";
public static string PL5 = "";
public static string PL6 = "";
public static string PL7 = "";
public static string PL8 = "";
public static string PL9 = "";
public static string PL10 = "";
public static string PL11 = "";
public static string PL12 = "";
public static string PL13 = "";
public static string PL14 = "";
public static string PL15 = "";
public static string PL16 = "";
public static string PL17 = "";
public static string PL18 = "";
public static string PL19 = "";
public static string PL20 = "";
public static string PL21 = "";
public static string PL22 = "";
public static string PL23 = "";
public static string PL24 = "";
public static string CPU = "";
public static string TEMPER = "";

}
public Form1()
{
InitializeComponent();
timer1.Stop();
timer1.Enabled = false;
}
private void Form1_Load(object sender, EventArgs e)
{
portReset();
datelabel.Text = DateTime.Now.ToLongDateString();
timelabel.Text = DateTime.Now.ToLongTimeString();
}
private void portReset()
{
port1.Image = Properties.Resources.port_nostatus;
port2.Image = Properties.Resources.port_nostatus;
port3.Image = Properties.Resources.port_nostatus;
port4.Image = Properties.Resources.port_nostatus;
port5.Image = Properties.Resources.port_nostatus;
port6.Image = Properties.Resources.port_nostatus;
port7.Image = Properties.Resources.port_nostatus;
port8.Image = Properties.Resources.port_nostatus;
port9.Image = Properties.Resources.port_nostatus;
port10.Image = Properties.Resources.port_nostatus;
port11.Image = Properties.Resources.port_nostatus;
port12.Image = Properties.Resources.port_nostatus;
port13.Image = Properties.Resources.port_nostatus;
port14.Image = Properties.Resources.port_nostatus;
port15.Image = Properties.Resources.port_nostatus;
port16.Image = Properties.Resources.port_nostatus;
port17.Image = Properties.Resources.port_nostatus;
port18.Image = Properties.Resources.port_nostatus;
port19.Image = Properties.Resources.port_nostatus;
port20.Image = Properties.Resources.port_nostatus;
port21.Image = Properties.Resources.port_nostatus;
port22.Image = Properties.Resources.port_nostatus;
port23.Image = Properties.Resources.port_nostatus;
port24.Image = Properties.Resources.port_nostatus;
p1textBox1.Text = null;
p2textBox1.Text = null;
p3textBox1.Text = null;
p4textBox1.Text = null;
p5textBox1.Text = null;
p6textBox1.Text = null;
p7textBox1.Text = null;
p8textBox1.Text = null;
p9textBox1.Text = null;
p10textBox1.Text = null;
p11textBox1.Text = null;
p12textBox1.Text = null;
p13textBox1.Text = null;
p14textBox1.Text = null;
p15textBox1.Text = null;
p16textBox1.Text = null;
p17textBox1.Text = null;
p18textBox1.Text = null;
p19textBox1.Text = null;
p20textBox1.Text = null;
p21textBox1.Text = null;
p22textBox1.Text = null;
p23textBox1.Text = null;
p24textBox1.Text = null;
plabel1.Text = null;
plabel2.Text = null;
plabel3.Text = null;
plabel4.Text = null;
plabel5.Text = null;
plabel6.Text = null;
plabel7.Text = null;
plabel8.Text = null;
plabel9.Text = null;
plabel10.Text = null;
plabel11.Text = null;
plabel12.Text = null;
plabel13.Text = null;
plabel14.Text = null;
plabel15.Text = null;
plabel16.Text = null;
plabel17.Text = null;
plabel18.Text = null;
plabel19.Text = null;
plabel20.Text = null;
plabel21.Text = null;
plabel22.Text = null;
plabel23.Text = null;
plabel24.Text = null;
cpulabel.Text = null;

StatusTextBox1.Text = String.Empty;
this.statusLoadinBar.Image = null;
}
private async void snmpGetFunc()
{
timer1.Enabled = true;
this.Invoke((MethodInvoker)delegate
{
lastUpdateLabel.Text = "Last Updated @" + DateTime.Now.ToLongDateString() + DateTime.Now.ToLongTimeString();
});
OctetString community = new OctetString("PUBLIC");
AgentParameters param = new AgentParameters(community);
param.Version = SnmpVersion.Ver2;
IpAddress agent = new IpAddress("10.0.0.1");
UdpTarget target = new UdpTarget((IPAddress)agent, 161, 1000, 1);
Pdu pdu = new Pdu(PduType.Get);
// Make SNMP request to test if device is responding or not
try
{
//Query Switch name, just for testing if SNMP/Device is reponding or NOT : ~ D / zaib
//pdu.VbList.Add(".1.3.6.1.2.1.1.5.0");
SnmpV2Packet result = (SnmpV2Packet)target.Request(pdu, param);
}
catch (SnmpException ex)
{
this.Invoke((MethodInvoker)delegate
{
this.StatusTextBox1.AppendText("\r\n" + ex.Message + "Either Device or SNMP not responding. Retrying again ...");
});
target.Dispose();
return;
}
if (timer1.Enabled == true)
{
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10101");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10102");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10103");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10104");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10105");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10106");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10107");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10108");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10109");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10110");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10111");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10112");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10113");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10114");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10115");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10116");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10117");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10118");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10119");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10120");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10121");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10122");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10123");
pdu.VbList.Add("1.3.6.1.2.1.2.2.1.8.10605");
// Ports End
// Now quering switch port names related data
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10101");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10102");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10103");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10104");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10105");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10106");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10107");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10108");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10109");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10110");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10111");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10112");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10113");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10114");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10115");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10116");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10117");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10118");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10119");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10120");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10121");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10122");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10123");
pdu.VbList.Add("1.3.6.1.2.1.31.1.1.1.18.10605");
// CPU Usage
pdu.VbList.Add("1.3.6.1.4.1.9.2.1.56.0");
// Temprature
pdu.VbList.Add("1.3.6.1.4.1.9.9.13.1.3.1.3.1006");
// Get all data by SNMP query
SnmpV2Packet result = (SnmpV2Packet)target.Request(pdu, param);
// End
// Update Global Variables that will be used for few other functions
Globals.P1 = result.Pdu.VbList[0].Value.ToString();
Globals.P2 = result.Pdu.VbList[1].Value.ToString();
Globals.P3 = result.Pdu.VbList[2].Value.ToString();
Globals.P4 = result.Pdu.VbList[3].Value.ToString();
Globals.P5 = result.Pdu.VbList[4].Value.ToString();
Globals.P6 = result.Pdu.VbList[5].Value.ToString();
Globals.P7 = result.Pdu.VbList[6].Value.ToString();
Globals.P8 = result.Pdu.VbList[7].Value.ToString();
Globals.P9 = result.Pdu.VbList[8].Value.ToString();
Globals.P10 = result.Pdu.VbList[9].Value.ToString();
Globals.P11 = result.Pdu.VbList[10].Value.ToString();
Globals.P12 = result.Pdu.VbList[11].Value.ToString();
Globals.P13 = result.Pdu.VbList[12].Value.ToString();
Globals.P14 = result.Pdu.VbList[13].Value.ToString();
Globals.P15 = result.Pdu.VbList[14].Value.ToString();
Globals.P16 = result.Pdu.VbList[15].Value.ToString();
Globals.P17 = result.Pdu.VbList[16].Value.ToString();
Globals.P18 = result.Pdu.VbList[17].Value.ToString();
Globals.P19 = result.Pdu.VbList[18].Value.ToString();
Globals.P20 = result.Pdu.VbList[19].Value.ToString();
Globals.P21 = result.Pdu.VbList[20].Value.ToString();
Globals.P22 = result.Pdu.VbList[21].Value.ToString();
Globals.P23 = result.Pdu.VbList[22].Value.ToString();
Globals.P24 = result.Pdu.VbList[23].Value.ToString();
Globals.PL1 = result.Pdu.VbList[24].Value.ToString();
Globals.PL2 = result.Pdu.VbList[25].Value.ToString();
Globals.PL3 = result.Pdu.VbList[26].Value.ToString();
Globals.PL4 = result.Pdu.VbList[27].Value.ToString();
Globals.PL5 = result.Pdu.VbList[28].Value.ToString();
Globals.PL6 = result.Pdu.VbList[29].Value.ToString();
Globals.PL7 = result.Pdu.VbList[30].Value.ToString();
Globals.PL8 = result.Pdu.VbList[31].Value.ToString();
Globals.PL9 = result.Pdu.VbList[32].Value.ToString();
Globals.PL10 = result.Pdu.VbList[33].Value.ToString();
Globals.PL11 = result.Pdu.VbList[34].Value.ToString();
Globals.PL12 = result.Pdu.VbList[35].Value.ToString();
Globals.PL13 = result.Pdu.VbList[36].Value.ToString();
Globals.PL14 = result.Pdu.VbList[37].Value.ToString();
Globals.PL15 = result.Pdu.VbList[38].Value.ToString();
Globals.PL16 = result.Pdu.VbList[39].Value.ToString();
Globals.PL17 = result.Pdu.VbList[40].Value.ToString();
Globals.PL18 = result.Pdu.VbList[41].Value.ToString();
Globals.PL19 = result.Pdu.VbList[42].Value.ToString();
Globals.PL20 = result.Pdu.VbList[43].Value.ToString();
Globals.PL21 = result.Pdu.VbList[44].Value.ToString();
Globals.PL22 = result.Pdu.VbList[45].Value.ToString();
Globals.PL23 = result.Pdu.VbList[46].Value.ToString();
Globals.PL24 = result.Pdu.VbList[47].Value.ToString();
Globals.CPU = result.Pdu.VbList[48].Value.ToString();
Globals.TEMPER = result.Pdu.VbList[49].Value.ToString();
this.Invoke((MethodInvoker)delegate
{
//Update Port Description / Names Text Labels
plabel1.Text = Globals.PL1;
plabel2.Text = Globals.PL2;
plabel3.Text = Globals.PL3;
plabel4.Text = Globals.PL4;
plabel5.Text = Globals.PL5;
plabel6.Text = Globals.PL6;
plabel7.Text = Globals.PL7;
plabel8.Text = Globals.PL8;
plabel9.Text = Globals.PL9;
plabel10.Text = Globals.PL10;
plabel11.Text = Globals.PL11;
plabel12.Text = Globals.PL12;
plabel13.Text = Globals.PL13;
plabel14.Text = Globals.PL14;
plabel15.Text = Globals.PL15;
plabel16.Text = Globals.PL16;
plabel17.Text = Globals.PL17;
plabel18.Text = Globals.PL18;
plabel19.Text = Globals.PL19;
plabel20.Text = Globals.PL20;
plabel21.Text = Globals.PL21;
plabel22.Text = Globals.PL22;
plabel23.Text = Globals.PL23;
plabel24.Text = Globals.PL24;
cpulabel.Text = Globals.CPU + " %";
temper_label.Text = Globals.TEMPER + "c";

int cpuint = Int32.Parse(Globals.CPU);
progressBar1.Value = cpuint;

//});
if (Globals.P1 == "1")
{
port1.Image = Properties.Resources.port_up;
p1textBox1.Text = Globals.P1;
}
else
{
port1.Image = Properties.Resources.port_down;
}
if (Globals.P2 == "1")
{
port2.Image = Properties.Resources.port_up;
p2textBox1.Text = Globals.P2;
}
else
{
port2.Image = Properties.Resources.port_down;
}
if (Globals.P3 == "1")
{
port3.Image = Properties.Resources.port_up;
p3textBox1.Text = Globals.P3;
}
else
{
port3.Image = Properties.Resources.port_down;
}
if (Globals.P4 == "1")
{
port4.Image = Properties.Resources.port_up;
p4textBox1.Text = Globals.P4;
}
else
{
port4.Image = Properties.Resources.port_down;
}
if (Globals.P5 == "1")
{
port5.Image = Properties.Resources.port_up;
p5textBox1.Text = Globals.P5;
}
else
{
port5.Image = Properties.Resources.port_down;
}
if (Globals.P6 == "1")
{
port6.Image = Properties.Resources.port_up;
p6textBox1.Text = Globals.P6;
}
else
{
port6.Image = Properties.Resources.port_down;
}
if (Globals.P7 == "1")
{
port7.Image = Properties.Resources.port_up;
}
else
{
port7.Image = Properties.Resources.port_down;
}
if (Globals.P8 == "1")
{
port8.Image = Properties.Resources.port_up;
}
else
{
port8.Image = Properties.Resources.port_down;
}
if (Globals.P9 == "1")
{
port9.Image = Properties.Resources.port_up;
}
else
{
port9.Image = Properties.Resources.port_down;
}
if (Globals.P10 == "1")
{
port10.Image = Properties.Resources.port_up;
}
else
{
port10.Image = Properties.Resources.port_down;
}
if (Globals.P11 == "1")
{
port11.Image = Properties.Resources.port_up;
}
else
{
port11.Image = Properties.Resources.port_down;
}
if (Globals.P12 == "1")
{
port12.Image = Properties.Resources.port_up;
}
else
{
port12.Image = Properties.Resources.port_down;
}
if (Globals.P13 == "1")
{
port13.Image = Properties.Resources.port_up;
}
else
{
port13.Image = Properties.Resources.port_down;
}
if (Globals.P14 == "1")
{
port14.Image = Properties.Resources.port_up;
}
else
{
port14.Image = Properties.Resources.port_down;
}
if (Globals.P15 == "1")
{
port15.Image = Properties.Resources.port_up;
}
else
{
port15.Image = Properties.Resources.port_down;
}
if (Globals.P16 == "1")
{
port16.Image = Properties.Resources.port_up;
}
else
{
port16.Image = Properties.Resources.port_down;
}
if (Globals.P17 == "1")
{
port17.Image = Properties.Resources.port_up;
}
else
{
port17.Image = Properties.Resources.port_down;
}
if (Globals.P18 == "1")
{
port18.Image = Properties.Resources.port_up;
}
else
{
port18.Image = Properties.Resources.port_down;
}
if (Globals.P19 == "1")
{
port19.Image = Properties.Resources.port_up;
}
else
{
port19.Image = Properties.Resources.port_down;
}
if (Globals.P20 == "1")
{
port20.Image = Properties.Resources.port_up;
}
else
{
port20.Image = Properties.Resources.port_down;
}
if (Globals.P21 == "1")
{
port21.Image = Properties.Resources.port_up;
}
else
{
port21.Image = Properties.Resources.port_down;
}
if (Globals.P22 == "1")
{
port22.Image = Properties.Resources.port_up;
}
else
{
port22.Image = Properties.Resources.port_down;
}
if (Globals.P23 == "1")
{
port23.Image = Properties.Resources.port_up;
}
else
{
port23.Image = Properties.Resources.port_down;
}
if (Globals.P24 == "1")
{
port24.Image = Properties.Resources.port_up;
p24textBox1.Text = Globals.P24;
}
else
{
port24.Image = Properties.Resources.port_down;
p24textBox1.Text = Globals.P24;
}
});
ClearTextBox1TimeOnly();
}
}
private static bool isRun = false;
private static readonly object syncLock = new object();
public void ClearTextBox1TimeOnly()
{
lock (syncLock)
{
if (!isRun)
{
this.Invoke((MethodInvoker)delegate
{
StatusTextBox1.Text = String.Empty;
this.StatusTextBox1.Text += string.Format("Starting monitoring of Cisco Switch Ports. Activated [5 sec delay] ... \r\n");
});
isRun = true;
}
}
}
// Start the app. start button
private async void button1_Click(object sender, EventArgs e)
{
if (timer1.Enabled == true)
{
this.StatusTextBox1.Text += string.Format("Monitoring already started. Stop it to first to start new instance !\r\n");
}
else
{
startButton.Enabled = false;
isRun = false;
timer1.Enabled = true;
timer1.Start();
this.statusLoadinBar.Image = Properties.Resources.loading_gif;
//await Task.Run(() =>
//{
//await Task.Run(() => snmpGetFunc();
//});
Task.Factory.StartNew(() => snmpGetFunc());
this.StatusTextBox1.Text += string.Format("Starting monitoring of Cisco Switch Ports. \r\n");
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void exitToolStripMenuItem1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void timer4dt_Tick(object sender, EventArgs e)
{
timelabel.Text = DateTime.Now.ToLongTimeString();
timer4dt.Start();
}
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
private void stopButton_Click(object sender, EventArgs e)
{
if (timer1.Enabled == true)
{
startButton.Enabled = true;
timer1.Enabled = false;
timer1.Stop();
portReset();
this.StatusTextBox1.AppendText("\r\nMonitoring of switch have been Stopped on user request \r\n");
}
else
{
this.StatusTextBox1.AppendText("\r\nMonitoring not started yet !\r\n");
startButton.Enabled = true;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
Task.Factory.StartNew(() => snmpGetFunc());
}
private void exitButton_Click(object sender, EventArgs e)
{
this.statusLoadinBar.Image = null;
timer1.Stop();
portReset();
this.StatusTextBox1.AppendText("\r\nExiting on user request \r\n");
Application.Exit();
}
private void StatusTextBox1_TextChanged(object sender, EventArgs e)
{
StatusTextBox1.SelectionStart = StatusTextBox1.Text.Length;
StatusTextBox1.ScrollToCaret();
}
private void p1textBox1_TextChanged(object sender, EventArgs e)
{
if (Globals.P1 == "1")
this.StatusTextBox1.AppendText("\r\nPort 1 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 1 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p2textBox1_TextChanged(object sender, EventArgs e)
{
if (Globals.P2 == "1")
this.StatusTextBox1.AppendText("\r\nPort 2 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 2 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p3textBox1_TextChanged(object sender, EventArgs e)
{
if (Globals.P3 == "1")
this.StatusTextBox1.AppendText("\r\nPort 3 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 3 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p4textBox1_TextChanged(object sender, EventArgs e)
{
if (Globals.P4 == "1")
this.StatusTextBox1.AppendText("\r\nPort 4 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 4 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p5textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P5 == "1")
this.StatusTextBox1.AppendText("\r\nPort 5 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 5 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p6textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P6 == "1")
this.StatusTextBox1.AppendText("\r\nPort 6 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 6 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p7textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P7 == "1")
this.StatusTextBox1.AppendText("\r\nPort 7 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 7 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p8textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P8 == "1")
this.StatusTextBox1.AppendText("\r\nPort 8 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 8 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p9textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P9 == "1")
this.StatusTextBox1.AppendText("\r\nPort 9 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 9 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p10textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P10 == "1")
this.StatusTextBox1.AppendText("\r\nPort 10 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 10 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p11textBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P11 == "1")
this.StatusTextBox1.AppendText("\r\nPort 11is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 11is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p12TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P12 == "1")
this.StatusTextBox1.AppendText("\r\nPort 12 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 12 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p13TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P13 == "1")
this.StatusTextBox1.AppendText("\r\nPort 13 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 13 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p14TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P14 == "1")
this.StatusTextBox1.AppendText("\r\nPort 14 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 14 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p15TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P15 == "1")
this.StatusTextBox1.AppendText("\r\nPort 15 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 15 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p17TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P17 == "1")
this.StatusTextBox1.AppendText("\r\nPort 17 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 17 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p18TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P18 == "1")
this.StatusTextBox1.AppendText("\r\nPort 18 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 18 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p19TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P19 == "1")
this.StatusTextBox1.AppendText("\r\nPort 19 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 19 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p20TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P20 == "1")
this.StatusTextBox1.AppendText("\r\nPort 20 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 20 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p21TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P21 == "1")
this.StatusTextBox1.AppendText("\r\nPort 21 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 21 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p22TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P22 == "1")
this.StatusTextBox1.AppendText("\r\nPort 22 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 22 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}
private void p23TextBox1_TextChanged_1(object sender, EventArgs e)
{
if (Globals.P23 == "1")
this.StatusTextBox1.AppendText("\r\nPort 23 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 23 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

private void p24textBox1_TextChanged(object sender, EventArgs e)
{
if (Globals.P24 == "1")
this.StatusTextBox1.AppendText("\r\nPort 24 is now UP @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
else
this.StatusTextBox1.AppendText("\r\nPort 24 is now DOWN! @" + DateTime.Now.ToLongDateString() + " / " + DateTime.Now.ToLongTimeString());
}

}
}

Regard’s
Syed Jahanzaib

Older Posts »

%d bloggers like this: