Quantcast
Channel: Syed Jahanzaib – Personal Blog to Share Knowledge !
Viewing all 409 articles
Browse latest View live

Plotting Negative Value in rrdtool graph

$
0
0

Recently I was configuring an mrtg/rrd graph Where I had to display negative value as well along with others, but as per my findings mrtg/rrd graph doesn’t allow plotting Negative value. Let’s say we want to plot the temperature where we get both plus and negative values at different time of the day/night.

To do so, we have to tune the required rrd file to allow such storing.

Example: we have test.rrd file.
First get info by rrdtool

rrdtool info test.rrd |grep ds

you may see following

rrdtool info test.rrd |grep ds
ds[ds0].index = 0
ds[ds0].type = "GAUGE"
ds[ds0].minimal_heartbeat = 600
ds[ds0].min = 0.0000000000e+00
ds[ds0].max = 1.0000000000e+02
ds[ds0].last_ds = "0"
ds[ds0].value = 0.0000000000e+00
ds[ds0].unknown_sec = 0
ds[ds1].index = 1
ds[ds1].type = "GAUGE"
ds[ds1].minimal_heartbeat = 600
ds[ds1].min = 0.0000000000e+00
ds[ds1].max = 1.0000000000e+02
ds[ds1].last_ds = "0"
ds[ds1].value = 0.0000000000e+00
ds[ds1].unknown_sec = 0

now modify it by

rrdtool tune test.rrd --minimum ds0:-100

Now query rrdtool info again

rrdtool info test.rrd |grep ds
ds[ds0].index = 0
ds[ds0].type = "GAUGE"
ds[ds0].minimal_heartbeat = 600
ds[ds0].min = -1.0000000000e+02
ds[ds0].max = 1.0000000000e+02
ds[ds0].last_ds = "0"
ds[ds0].value = 0.0000000000e+00
ds[ds0].unknown_sec = 0
ds[ds1].index = 1
ds[ds1].type = "GAUGE"
ds[ds1].minimal_heartbeat = 600
ds[ds1].min = 0.0000000000e+00
ds[ds1].max = 1.0000000000e+02
ds[ds1].last_ds = "0"
ds[ds1].value = 0.0000000000e+00
ds[ds1].unknown_sec = 0

You will see the difference in ds[ds0].min value. Now we are good to go with negative plotting.

An example on how to plot negative values.

negative tempr.PNG


Regard’s
Syed Jahanzaib


Filed under: Linux Related

Craziness with the MRTG along with BASH

$
0
0

 


City vs Data Center Temperature !

Following is a temperature graph to compare difference between City temperature vs Data Center temperature. I made it for some local presentation purposes. Since I had no external sensor available for outside temperature monitoring, therefore I used external bash script to gather data from the internet using ‘Pakistan Meteorological Department PMD‘ website  and then after filtering , output only required data.  For NOC I used internal UPS sensor snmp query.

http://www.pmd.gov.pk/FFD/cp/pcurrenttemp.asp

1-noc-vs-karachi-temperature

 

 

#cat /temp/weather.sh


#!/bin/sh
#set -x
# Script to download KARACHI city temperature from Pakistan MET Dept web site  and output only temperature related information
# It will also query the NCO room temperature using UPS sensor via snmp query
# I made this script to create City temperature vs NOC temperature comparison MRTG graph
# Created : 9th-DEC-2016
# Syed Jahanzaib
# aacable[at]hotmail[dot]com
# http://aacableDOTwordpressDOTcom

####### Various Variables #########

# City temperature temporary holders in /tmp folder
CITY_TEMPR_HOLDER="/tmp/khiweather.txt"
CITY_TEMPR_4_OFFLINE="/tmp/khiweather_offline.txt"
# Variables for UPS IP and SNMP community string. It ilwl be used to acquire data center temperature using UPS sensor
UPS_IP="10.0.0.10"
UPS_SNMP_STR="public"
# OID for temperature sensor using USP SNMP card/sendor
UPS_OID="1.3.6.1.4.1.13400.2.62.2.1.2.0"
URL="http://www.pmd.gov.pk/FFD/cp/pcurrenttemp.asp"

############################################################################
####### PART - 1 , DATA CENTER Temperature query via UPS SNMP enabled sensor
############################################################################

# Store DATA Center temperature queries result in buffer
NOC_TEMPR=`snmpwalk -v1 -c $UPS_SNMP_STR $UPS_IP -Onqv $UPS_OID`

# Divide stored buffer by 100 to get human readable format in Celsius
NOC_TEMPR_FINAL=`echo $(($NOC_TEMPR/100))`

# Validate if temperature is not valid, liek url not accessible, or other errors
# If error found, then PRINT ZERO 0 VALUE , else print the acquired result
NOC_TEMPR_FINAL_VALID=`echo ${#NOC_TEMPR_FINAL}`
if [ $NOC_TEMPR_FINAL_VALID -eq 2 ]; then
echo "$NOC_TEMPR_FINAL"
else
echo "0"
fi

###########################################################################
####### PART - 2 , QUERY KARACHI CITY TEMPERATURE FORM THE INTERNET
# USING PAKISTAN MET DEPt for KARACHI website, than TRIM THE RESULT #######
###########################################################################

CITY_TEMPR=`lynx -cache=1 -dump $URL > $CITY_TEMPR_HOLDER`
CITY_TEMPR_VALUE=`grep -A 1 "Karachi" $CITY_TEMPR_HOLDER |sed '2q;d' | awk '{print $1}'`
CITY_TEMPR_VALID=`echo ${#CITY_TEMPR_VALUE}`

# Validate if temperature is not valid, like URL not accessible, OR other errors
# If error found, then PRINT last valid VALUE
if [ $CITY_TEMPR_VALID -eq 2 ]; then
#CITY_TEMPR_VALUE_FINAL=`echo $(($CITY_TEMPR_VALUE - 1))`
echo "$CITY_TEMPR_VALUE"
echo "$CITY_TEMPR_VALUE" > $CITY_TEMPR_4_OFFLINE
else
cat $CITY_TEMPR_4_OFFLINE
fi

###################
####### END #######
###################


MRTG CFG file for weather

WorkDir:/var/www/mrtg
### MONITORING KARACHI Temprature vs our DATA Center ###
Target[KARACHI_CITY_vs_NOC_tempr]: `/temp/weather.sh`
Title[KARACHI_CITY_vs_NOC_tempr]: Temprature Monitoring / Data Center vs Karachi City using PAK MET Site by zaib
PageTop[KARACHI_CITY_vs_NOC_tempr]: <h1>Temprature Monitoring / Data Center vs Karachi City using PAK MET Site by zaib</h1>
Options[KARACHI_CITY_vs_NOC_tempr]: gauge, growright, nopercent
MaxBytes[KARACHI_CITY_vs_NOC_tempr]: 60
Colours[KARACHI_CITY_vs_NOC_tempr]: B#467EEE,R#FF0000,BLUE#2184FF,RED#ff4f27
YLegend[KARACHI_CITY_vs_NOC_tempr]: Temprature
ShortLegend[KARACHI_CITY_vs_NOC_tempr]: c
LegendI[KARACHI_CITY_vs_NOC_tempr]: NOC Temprature
LegendO[KARACHI_CITY_vs_NOC_tempr]: City Temprature
Legend1[KARACHI_CITY_vs_NOC_tempr]: NOC Temprature
Legend2[KARACHI_CITY_vs_NOC_tempr]: City Temprature
#Unscaled[KARACHI_CITY_vs_NOC_tempr]: dwmy

 

 


Data Center Room Temperature & Humidity !

2-noc-tempr-vs-humidity

Above graph was made using Emerson Liebert UPS sensor using following OID’s and MRTG CFG

Temperature: 1.3.6.1.4.1.13400.2.62.2.1.2.0
Humidity: 1.3.6.1.4.1.13400.2.62.2.1.3.0


WorkDir:/var/www/mrtg
### MONITORING NOC ROOM TEMP ###
Target[noc_room_temp]: 1.3.6.1.4.1.13400.2.62.2.1.2.0&1.3.6.1.4.1.13400.2.62.2.1.3.0:public@10.0.0.1 / 100
Options[noc_room_temp]: gauge, growright, nopercent
MaxBytes[noc_room_temp]: 100
Colours[noc_room_temp]: B#467EEE,R#FF0000,RED#ff4f27,DIRTY YELLOW#E6B420
#Unscaled[noc_room_temp]: dwmy
YLegend[noc_room_temp]: NOC Room Temprature/Humidity
Title[noc_room_temp]: NOC Room Tempr/Humidity
PageTop[noc_room_temp]: <h1>NOC Room Tempr/Humidity</h1>
ShortLegend[noc_room_temp]: c/%
LegendI[noc_room_temp]: Temprature
LegendO[noc_room_temp]: Humidity
Legend1[noc_room_temp]: C NOC_Room Temp
Legend2[noc_room_temp]: Humidity


I will add more graphs later …

Regard’s

zaib!


Filed under: Linux Related, Uncategorized

Tik: 9 wan pcc with vpn server

$
0
0

~ There are no absolute answers in this universe, only assumptions, guesses, Jeopardies
Syed Jahanzaib !


r1222464_16033207

9-wann-pcc-zaib

Just a reference post. Default PCC may not work if you are using VPN server (to provide net access to local users via dialer) , So you may need to tweak it very little in order to make it work.

Disclaimer: 
The script in this post is made for reference purposes only. This is no way a COPY PASTE material which you can use it as a whole. every config is different and is build according to the network. Just try to read it and get the logics , modify them as per local requirements and then implement it. You may need to play a bit or tweak it in order to make it Workable config.


Scenario:

Hardware Used : Mikrotik – Rb1100ahx2

  • 9 DSL (ptcl) routers are connected with the RB1100ahx2
  • Ports name have been renamed to friendlier label for easy marking.
    Example Port 1-9 are renamed as WANx , and Port 10 is marked as Local
  • VPN Server is configured on same RB, and users dials in to this server in order to access internet.
  • No DHCP is being used on this setup as OP prefers to use static ips due to some specific circumstances.

the scriptO!

# Make sure to adjust it as per your setup

# Local Interface connected with the Users Switch
/ip address
add address=10.0.0.1/24 interface=Local network=10.0.0.0

# WAN interfaces IP addresses, which are connected with ptcl dsl routers
/ip address
add address=192.168.1.2/24 interface=WAN1 network=192.168.1.0
add address=192.168.2.2/24 interface=WAN2 network=192.168.2.0
add address=192.168.3.2/24 interface=WAN3 network=192.168.3.0
add address=192.168.4.2/24 interface=WAN4 network=192.168.4.0
add address=192.168.5.2/24 interface=WAN5 network=192.168.5.0
add address=192.168.6.2/24 interface=WAN6 network=192.168.6.0
add address=192.168.7.2/24 interface=WAN7 network=192.168.7.0
add address=192.168.8.2/24 interface=WAN8 network=192.168.8.0
add address=192.168.9.2/24 interface=WAN9 network=192.168.9.0

# Add IP pool for VPN dialer users, which will be allowed to use internet
/ip pool
add name=vpn-pool ranges=172.16.0.1-172.16.0.255

# Add VPN Profile for users , example 1mb per user profile
/ppp profile
add change-tcp-mss=yes dns-server=110.0.0.1,8.8.8.8 local-address=10.0.0.1 name=vpn-1mb only-one=yes rate-limit=1024k/1024k remote-address=vpn-pool use-encryption=yes

/interface pptp-server server set authentication=pap,chap,mschap1,mschap2 default-profile=vpn-1mb enabled=yes

# Enable DNS server
/ip dns
set allow-remote-requests=yes servers=8.8.8.8

/ip firewall address-list
add address=172.16.0.1-172.16.0.255 list=local_vpn_users_internet_allowed_list

# This is a local sharing server
add address=192.168.10.1 list=local_sharing_server

/ip firewall mangle

# Bypass Local Media Sharing server from PCC, so user can access it / Adjust it according to your need/ Jz
add action=accept chain=prerouting comment="Allow access to local sharing server / bypass them from the PCC" dst-address-list=local_sharing_server

# Accept traffic going to DSL Routers / Adjust it according to your need/ Jz
add action=accept chain=prerouting dst-address=192.168.1.0/24
add action=accept chain=prerouting dst-address=192.168.1.0/24
add action=accept chain=prerouting dst-address=192.168.2.0/24
add action=accept chain=prerouting dst-address=192.168.3.0/24
add action=accept chain=prerouting dst-address=192.168.4.0/24
add action=accept chain=prerouting dst-address=192.168.5.0/24
add action=accept chain=prerouting dst-address=192.168.6.0/24
add action=accept chain=prerouting dst-address=192.168.7.0/24
add action=accept chain=prerouting dst-address=192.168.8.0/24
add action=accept chain=prerouting dst-address=192.168.9.0/24

# Mark connections using PCC for 9 WAN / Adjust it according to your need / Jz
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark=WAN1_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:9/0 src-address-list=local_vpn_users_internet_allowed_list
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark=WAN2_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:9/1 src-address-list=local_vpn_users_internet_allowed_list
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark=WAN3_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:9/2 src-address-list=local_vpn_users_internet_allowed_list
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark=WAN4_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:9/3 src-address-list=local_vpn_users_internet_allowed_list
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark=WAN5_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:9/4 src-address-list=local_vpn_users_internet_allowed_list
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark=WAN6_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:9/5 src-address-list=local_vpn_users_internet_allowed_list
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark=WAN7_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:9/6 src-address-list=local_vpn_users_internet_allowed_list
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark=WAN8_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:9/7 src-address-list=local_vpn_users_internet_allowed_list
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark=WAN9_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:9/8 src-address-list=local_vpn_users_internet_allowed_list

# Mark routing for above marked connections, so that it can be used in ROUTE section / Adjust it according to your need/ Jz
add action=mark-routing chain=prerouting connection-mark=WAN1_conn new-routing-mark=to_WAN1 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN2_conn new-routing-mark=to_WAN2 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN3_conn new-routing-mark=to_WAN3 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN4_conn new-routing-mark=to_WAN4 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN5_conn new-routing-mark=to_WAN5 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN6_conn new-routing-mark=to_WAN6 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN7_conn new-routing-mark=to_WAN7 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN8_conn new-routing-mark=to_WAN8 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN9_conn new-routing-mark=to_WAN9 passthrough=yes

# Add NAT/MASQUERADE rule allowing only allowed users, restricted to allowed users only
add action=masquerade chain=srcnat comment="Allow Local Sharing Servers / NATING" dst-address-list=local_sharing_server
add action=masquerade chain=srcnat comment="WAN-1 / Allow Internet Access - For VPN Users only" out-interface=WAN1 src-address-list=local_vpn_users_internet_allowed_list
add action=masquerade chain=srcnat comment="WAN-2 / Allow Internet Access - For VPN Users only" out-interface=WAN2 src-address-list=local_vpn_users_internet_allowed_list
add action=masquerade chain=srcnat comment="WAN-3 / Allow Internet Access - For VPN Users only" out-interface=WAN3 src-address-list=local_vpn_users_internet_allowed_list
add action=masquerade chain=srcnat comment="WAN-4 / Allow Internet Access - For VPN Users only" out-interface=WAN4 src-address-list=local_vpn_users_internet_allowed_list
add action=masquerade chain=srcnat comment="WAN-5 / Allow Internet Access - For VPN Users only" out-interface=WAN5 src-address-list=local_vpn_users_internet_allowed_list
add action=masquerade chain=srcnat comment="WAN-6 / Allow Internet Access - For VPN Users only" out-interface=WAN6 src-address-list=local_vpn_users_internet_allowed_list
add action=masquerade chain=srcnat comment="WAN-7 / Allow Internet Access - For VPN Users only" out-interface=WAN7 src-address-list=local_vpn_users_internet_allowed_list
add action=masquerade chain=srcnat comment="WAN-8 / Allow Internet Access - For VPN Users only" out-interface=WAN8 src-address-list=local_vpn_users_internet_allowed_list
add action=masquerade chain=srcnat comment="WAN-9 / Allow Internet Access - For VPN Users only" out-interface=WAN9 src-address-list=local_vpn_users_internet_allowed_list

# Adding routes for marked traffic
# Each DSL router ip is in series like 192.168.1.1 / 2.1 / 3.1 and so on

/ip route
add check-gateway=ping distance=1 gateway=192.168.1.1 routing-mark=to_WAN1
add check-gateway=ping distance=1 gateway=192.168.2.1 routing-mark=to_WAN2
add check-gateway=ping distance=1 gateway=192.168.3.1 routing-mark=to_WAN3
add check-gateway=ping distance=1 gateway=192.168.4.1 routing-mark=to_WAN4
add check-gateway=ping distance=1 gateway=192.168.5.1 routing-mark=to_WAN5
add check-gateway=ping distance=1 gateway=192.168.6.1 routing-mark=to_WAN6
add check-gateway=ping distance=1 gateway=192.168.7.1 routing-mark=to_WAN7
add check-gateway=ping distance=1 gateway=192.168.8.1 routing-mark=to_WAN8
add check-gateway=ping distance=1 gateway=192.168.9.1 routing-mark=to_WAN9

# Adding routes for default routes, so that if any WAN goes down, those packets should go via MAIN table : ) kind of fail over/ Jz
add check-gateway=ping comment="WAN-1 / DEFAULT ROUTE" distance=1 gateway=192.168.1.1
add check-gateway=ping comment="WAN-2 / DEFAULT ROUTE" distance=2 gateway=192.168.2.1
add check-gateway=ping comment="WAN-3 / DEFAULT ROUTE" distance=3 gateway=192.168.3.1
add check-gateway=ping comment="WAN-4 / DEFAULT ROUTE" distance=4 gateway=192.168.4.1
add check-gateway=ping comment="WAN-5 / DEFAULT ROUTE" distance=5 gateway=192.168.5.1
add check-gateway=ping comment="WAN-6 / DEFAULT ROUTE" distance=6 gateway=192.168.6.1
add check-gateway=ping comment="WAN-7 / DEFAULT ROUTE" distance=7 gateway=192.168.7.1
add check-gateway=ping comment="WAN-8 / DEFAULT ROUTE" distance=8 gateway=192.168.8.1
add check-gateway=ping comment="WAN-9 / DEFAULT ROUTE" distance=9 gateway=192.168.9.1

W/Salam


Filed under: Uncategorized

Incorrect key file for table ‘./conntrack/xxxx@xxxxxx@xxxxxx.MYI’; try to repair it

$
0
0

corruption

Incorrect key file for table ‘./conntrack/2016@002d12@002d16.MYI’; try to repair it

If you see the above error while accessing Connection Tracking Reports in Radius Manager then …

Recommendations:

  • Make sure you aave plenty of Disk Space. Storage drive should be fast for high load servers preferably SSD or RAID based storage ,
  • Plenty of Memory is usually a good idea for DB systems ,
  • If its a heavy production server, try to move connection tracking to separate host as it takes lots of space and it adds good amount of payload to the CPU as well.
  • Perform tuning to enhance the mysql engine

To repair table …

Goto the conntrack folder [Ubuntu]
cd /var/lib/mysql/conntrack/
service mysql stop
# Change the file number as shown in the error 
myisamchk -r -v -f 2016@002d12@002d16.MYI

Once repair is done, start mysql / restart apache2 services , and test the desired tracking report again.

Regard’s
~Syed Jahanzaib~


Filed under: Radius Manager, Uncategorized

Single Script to Create All Storage CFG file in MRTG

$
0
0

auto

Reference Post:

It’s a headache if you want to create configuration file in bulk for all the storage available in remote servers, that includes disks/memory. To make life a little easier, I made following script which simply query the storage indexes and create CFG file in /cfg folder.

#!/bin/bash
# Script to query remote server
#set -x
# Colors Config . . . [[ JZ . . . ]]
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
MIB_NAME="HOST-RESOURCES-MIB"

#If MIB is not present, EXIT with error
MIB_CHECK=`locate $MIB_NAME > /tmp/miblocate.txt`
MIB_CHECK_RESULT=`cat /tmp/miblocate.txt`
if [ -z "$MIB_CHECK_RESULT" ]; then
echo -e "$COL_RED MRTG ERROR MNF1: HOST-RESOURCES-MIB not found, cannot continue without it. Download them first ... $COL_RESET"
exit 1
fi

HOST="$1"
# Temporary Folder where all CFG will be placed . . . [[ JZ . . . ]]
CFGDIR="cfg"
# Checking if $CFGDIR folder is previously present or not . . .
{
if [ ! -d "/$CFGDIR" ]; then
echo
echo -e "$COL_RED /$CFGDIR folder not found, Creating it so all cfg will be placed here . . . $COL_RESET"
mkdir /temp
else
echo
echo -e "$COL_GREEN /$CFGDIR folder is already present , so no need to create it, Proceeding further . . . $COL_RESET"
echo
fi
}

CFG_FILE_NAME="/$CFGDIR/storage.$1.cfg"
SNMP_STRING="PUBLIC"
snmpwalk -Os -c $SNMP_STRING -v 2c -m "/cfg/mibs/HOST-RESOURCES-MIB" $HOST hrStorageDescr |
sed -nre 's,hrStorageDescr.([0-9]*) = STRING: (.*),\1 \2,p' |
grep -Ev ' /(proc|sys)($|/)' |
while read NM DESC; do

STORAGE_SIZE=`snmpwalk -Onqv -Os -c $SNMP_STRING -v 2c -m "/cfg/mibs/HOST-RESOURCES-MIB" $HOST hrStorageSize.${NM}`
ALLOCATION_UNIT=`snmpwalk -Onqv -Os -c $SNMP_STRING -v 2c -m "/cfg/mibs/HOST-RESOURCES-MIB" $HOST hrStorageAllocationUnits.${NM} | awk '{print $1}'`

# FORMULAS
MAXSIZE_BITS=`echo $(($STORAGE_SIZE*$ALLOCATION_UNIT*8))`
MAXSIZE_MB=`echo $(($STORAGE_SIZE*$ALLOCATION_UNIT/1024/1024))`
MAXSIZE_GB=`echo $(($STORAGE_SIZE*$ALLOCATION_UNIT/1024/1024/1024))`
MAXSIZE_TB=`echo $(($STORAGE_SIZE*$ALLOCATION_UNIT/1024/1024/1024/1024))`

#TITLE LINES
MAXSIZE_MB_T=`echo "scale=2; $STORAGE_SIZE*$ALLOCATION_UNIT / 1024 / 1024" | bc -l`
MAXSIZE_GB_T=`echo "scale=2; $STORAGE_SIZE*$ALLOCATION_UNIT/1024/1024/1024" | bc -l`
MAXSIZE_TB_T=`echo "scale=2; $MAXSIZE_GB/1000" | bc -l`

if [ $MAXSIZE_BITS -eq 0 ]; then
MAXSIZE_BITS="1"
fi
# Under 1GB TITLE
if [ $MAXSIZE_MB -lt 1024 ]; then
#echo "$hrStorageSize.${NM} = MAX Size in MB = $MAXSIZE_MB_T"
MAXSIZE_TITLE="MAX Size in MB = $MAXSIZE_MB_T"
fi
# ABOVE 1GB TITLE
if [ $MAXSIZE_MB -gt 1024 ]; then
#echo "$hrStorageSize.${NM} = MAX Size in GB = $MAXSIZE_GB_T"
MAXSIZE_TITLE="MAX Size in GB = $MAXSIZE_GB_T"
fi
# ABOVE 1 TB TITLE
if [ $MAXSIZE_MB -gt 1048576 ]; then
#echo "$hrStorageSize.${NM} = MAX Size in TB = $MAXSIZE_TB_T"
MAXSIZE_TITLE="MAX Size in TB = $MAXSIZE_TB_T"
fi

IDENT="stor_$(echo "${DESC}" | tr '[A-Z]/ ' '[a-z]_' | sed 's/\:/-/g')"
echo "Target[${IDENT}]: hrStorageUsed.${NM}&hrStorageSize.${NM}:$SNMP_STRING@$HOST * hrStorageAllocationUnits.${NM}&hrStorageAllocationUnits.${NM}:$SNMP_STRING@$HOST"
echo "Title[${IDENT}]: $HOST - Storage: ${DESC} : / $MAXSIZE_TITLE"
echo "PageTop[${IDENT}]: <h1>$HOST - Storage: ${DESC} Report / $MAXSIZE_TITLE</h1>"
echo "Kilo[${IDENT}]: 1024"
echo "MaxBytes[${IDENT}]: $MAXSIZE_BITS"
echo "ShortLegend[${IDENT}]: iB"
echo "YLegend[${IDENT}]: Bytes"
echo "Legend1[${IDENT}]: Used"
echo "Legend2[${IDENT}]: Total"
echo "LegendI[${IDENT}]: Used:"
echo "LegendO[${IDENT}]: Total:"
echo "Options[${IDENT}]: gauge,growright,nobanner,nopercent"
done > $CFG_FILE_NAME

if [ -f $CFG_FILE_NAME ];
then
echo -e "$COL_GREEN MRTG CFG file name $CFG_FILE_NAME for $HOST is created ... $COL_RESET"
else
echo -e "$COL_RED ERROR: Unable to create CFG FILEs, check script errors ... $COL_RESET"
fi

echo -e "$COL_GREEN
SCRIPT ENDS HERE ... $COL_RESET"


Run Method:

./querystorage.sh 10.0.0.1

1


CFG Files Example:


Target[stor_c-_label-os__serial_number_b6ff670d]: hrStorageUsed.1&hrStorageSize.1:PUBLIC@10.0.0.1 * hrStorageAllocationUnits.1&hrStorageAllocationUnits.1:PUBLIC@10.0.0.1
Title[stor_c-_label-os__serial_number_b6ff670d]: 10.0.0.1 - Storage: C: Label:OS Serial Number b6ff670d : / MAX Size in GB = 278.14
PageTop[stor_c-_label-os__serial_number_b6ff670d]: <h1>10.0.0.1 - Storage: C: Label:OS Serial Number b6ff670d Report / MAX Size in GB = 278.14</h1>
Kilo[stor_c-_label-os__serial_number_b6ff670d]: 1024
MaxBytes[stor_c-_label-os__serial_number_b6ff670d]: 2389226520576
ShortLegend[stor_c-_label-os__serial_number_b6ff670d]: iB
YLegend[stor_c-_label-os__serial_number_b6ff670d]: Bytes
Legend1[stor_c-_label-os__serial_number_b6ff670d]: Used
Legend2[stor_c-_label-os__serial_number_b6ff670d]: Total
LegendI[stor_c-_label-os__serial_number_b6ff670d]: Used:
LegendO[stor_c-_label-os__serial_number_b6ff670d]: Total:
Options[stor_c-_label-os__serial_number_b6ff670d]: gauge,growright,nobanner,nopercent

Target[stor_d-_label-Data__serial_number_f40779eb]: hrStorageUsed.2&hrStorageSize.2:PUBLIC@10.0.0.1 * hrStorageAllocationUnits.2&hrStorageAllocationUnits.2:PUBLIC@10.0.0.1
Title[stor_d-_label-Data__serial_number_f40779eb]: 10.0.0.1 - Storage: D: Label:Data Serial Number f40779eb : / MAX Size in TB = 1.11
PageTop[stor_d-_label-Data__serial_number_f40779eb]: <h1>10.0.0.1 - Storage: D: Label:Data Serial Number f40779eb Report / MAX Size in TB = 1.11</h1>
Kilo[stor_d-_label-Data__serial_number_f40779eb]: 1024
MaxBytes[stor_d-_label-Data__serial_number_f40779eb]: 9566888624128
ShortLegend[stor_d-_label-Data__serial_number_f40779eb]: iB
YLegend[stor_d-_label-Data__serial_number_f40779eb]: Bytes
Legend1[stor_d-_label-Data__serial_number_f40779eb]: Used
Legend2[stor_d-_label-Data__serial_number_f40779eb]: Total
LegendI[stor_d-_label-Data__serial_number_f40779eb]: Used:
LegendO[stor_d-_label-Data__serial_number_f40779eb]: Total:
Options[stor_d-_label-Data__serial_number_f40779eb]: gauge,growright,nobanner,nopercent

Target[stor_physical_memory]: hrStorageUsed.5&hrStorageSize.5:PUBLIC@10.0.0.1 * hrStorageAllocationUnits.5&hrStorageAllocationUnits.5:PUBLIC@10.0.0.1
Title[stor_physical_memory]: 10.0.0.1 - Storage: Physical Memory : / MAX Size in GB = 31.81
PageTop[stor_physical_memory]: <h1>10.0.0.1 - Storage: Physical Memory Report / MAX Size in GB = 31.81</h1>
Kilo[stor_physical_memory]: 1024
MaxBytes[stor_physical_memory]: 273308712960
ShortLegend[stor_physical_memory]: iB
YLegend[stor_physical_memory]: Bytes
Legend1[stor_physical_memory]: Used
Legend2[stor_physical_memory]: Total
LegendI[stor_physical_memory]: Used:
LegendO[stor_physical_memory]: Total:
Options[stor_physical_memory]: gauge,growright,nobanner,nopercent


Graph Examples:

2

Jz!


Filed under: Linux Related

Howto get combined average Load of multi core CPU by BASH

$
0
0

Small script to acquire combined cpu load (average) from remote server. I required to acquire ESXI multicore cpu load to plot mrtg graph.


#!/bin/bash
# Script to query ESXI server
#set -x
HOST="$1"
SNMP_STRING="public"
TMP_HOLDER="/tmp/cpuinfo.$HOST"
OID="hrProcessorLoad."
MIB="/cfg/mibs/HOST-RESOURCES-MIB"
snmpwalk -v2c -c $SNMP_STRING -m "$MIB" $HOST |grep $OID | awk '{print $4}' > $TMP_HOLDER
CPU_CORE=`cat $TMP_HOLDER | wc -l`
CPU_LOAD_SUM=`cat $TMP_HOLDER | awk '{ sum += $1 } END { print sum }'`
CPU_LOAD_FINAL=`echo "scale=2; $CPU_LOAD_SUM/$CPU_CORE" | bc -l`
echo $CPU_LOAD_FINAL
echo $CPU_LOAD_FINAL


Result:

(following result is average value of my esxi server which have 2 physical processor with 6 cores each, so virtually there are 24 cores for ESXI)

root@linux:/temp# ./cpu_load.sh 10.0.0.1

6.70
6.70


CFG example:

ESXI Server -10.0.0.1- CPU Utilization ###
Target[esxi_cpu_1010.0.0.1]: `/temp/cpu_load.sh 10.0.0.1`
Options[esxi_cpu_1010.0.0.1]: growright, gauge, integer, noo
MaxBytes[esxi_cpu_1010.0.0.1]: 100
LegendI[esxi_cpu_1010.0.0.1]: Total CPU Cores Used %
LegendO[esxi_cpu_1010.0.0.1]:
Legend1[esxi_cpu_1010.0.0.1]: Total CPU Cores Used %
Legend2[esxi_cpu_1010.0.0.1]:
Title[esxi_cpu_1010.0.0.1]: ESXI Server -10.0.0.1- CPU Load %
PageTop[esxi_cpu_1010.0.0.1]: <h1>ESXI Server -10.0.0.1- CPU Load %</h1>
Unscaled[esxi_cpu_1010.0.0.1]: ymwd
ShortLegend[esxi_cpu_1010.0.0.1]: %
YLegend[esxi_cpu_1010.0.0.1]: % CPU Used
Colours[esxi_cpu_1010.0.0.1]: RED#ff4f27,DIRTY YELLOW#E6B420,RED#ff4f27,DIRTY YELLOW#E6B420

J.

 


Filed under: Linux Related

Ubiquiti Unifi Notes & Odd methods of acquiring Info

$
0
0

ubiquity


1- Odd method to acquire total number of active WiFi Clients

Bash script to acquire some info via UniFi controller like active number of WiFi clients connected with different UniFi AP LR in the company.


#!/bin/bash
# Script to query active clients by curl from unifi controller
# Syed jahanzaib / aacable . wordpress . com / aacable at hotmail dot com
# 2nd-January-2017
#set -x
# UniFi Controller IP and Port
IP="10.0.0.1"
PORT="8443"
COOKIE="/tmp/cookies.txt"
TMP_HOLDER="/tmp/$IP.active.wifi.clients.txt"
# pattern to match to count active clients using string matching
PATTERN="hostname"

# First Login to controller via CURL
curl -s "https://$IP:$PORT/api/login" --data-binary '{"username":"admin","password":"CONTROLLERPASSWORD","strict":true}' --compressed --insecure -c $COOKIE > /dev/null

# Download Statistics from controller using CURL
curl -s --insecure -b $COOKIE -c $COOKIE "https://$IP:$PORT/api/s/default/stat/sta" > $TMP_HOLDER

# Count active users by pattern match,  what an odd method, may not work correctly, but so far working for me
ACTIVE=`cat $TMP_HOLDER | grep -o $PATTERN | wc -l`
echo $ACTIVE
echo $ACTIVE


Result in command …

unifi-active

 

CFG file for MRTG …

# Unifi Controller - WiFi Active WiFi Clients - syed.jahanzaib
Target[unifi_wifi_active_users]: `/temp/unifi-client.sh`
Title[unifi_wifi_active_users]: Active Wifi Clients via Unifi Controller
PageTop[unifi_wifi_active_users]: <H1>Active Wifi Clients via Unifi Controller</H1>
MaxBytes[unifi_wifi_active_users]: 50000
Colours[unifi_wifi_active_users]: B#8888ff,B#0813B7,B#5398ff,B#0813B7
Options[unifi_wifi_active_users]: growright,nopercent,gauge,integer,nobanner,printrouter,pngdate,noo
LegendI[unifi_wifi_active_users]: Active Wifi Users
LegendO[unifi_wifi_active_users]:
YLegend[unifi_wifi_active_users]: Active Wifi Users
Legend1[unifi_wifi_active_users]: Active Wifi Users
Legend2[unifi_wifi_active_users]:
ShortLegend[unifi_wifi_active_users]:
#Unscaled[unifi_wifi_active_users]: dwmy

MRTG Graph for Active WiFi Clients via UniFi Controller …

1-wifi

  •  – – – – – – – – –
  •  – – – – – – – – –
  •  – – – – – – – – –
  •  – – – – – – – – –

Following are some snapshots from the UniFi Controller for some comparison that script is working accurate so far …
(However it is still under observation to monitor its accuracy result / zaib)

1

2


2- Odd method to acquire total number of Active Access Points Vs Down [Registered in UniFi Controller]

Bash script to acquire total number of registered access points (unifi AP-LR) and there status as well to compare Active vs down.


#!/bin/bash
# Script to query active clients by curl from unifi controller
#set -x
IP="10.0.0.1"
PORT="8443"
COOKIE="/tmp/cookies.txt"
TMP_HOLDER="/tmp/$IP.total.ap.txt"
PATTERN="adopted"
curl -s "https://$IP:$PORT/api/login" --data-binary '{"username":"admin","password":"CONTROLLERPASSWORD","strict":true}' --compressed --insecure -c $COOKIE > /dev/null
curl -s --insecure -b $COOKIE -c $COOKIE "https://$IP:$PORT/api/s/default/stat/device" > $TMP_HOLDER
ACTIVE=`cat $TMP_HOLDER | grep -o $PATTERN | wc -l`
DOWN=`grep -oP '\"state\" : \K[^ ]*' $TMP_HOLDER | grep 0 | wc -l`
echo $DOWN
echo $ACTIVE

Result in command …

[Total access points  vs DOWN]

ap-up-vs-down

CFG file for MRTG …


# Unifi Controller - UniFi AP-LR - Active Access Points vs DOWN
Target[unifi_ap_total_vs_down]: `/temp/unifi-devices.sh`
Title[unifi_ap_total_vs_down]: UniFi AP-LR - Active Access Points vs DOWN
PageTop[unifi_ap_total_vs_down]: <H1>UniFi AP-LR - Active Access Points vs DOWN</H1>
MaxBytes[unifi_ap_total_vs_down]: 5000
Colours[unifi_ap_total_vs_down]: B#0000FF,R#FF0000,B#0000FF,R#FF0000
Options[unifi_ap_total_vs_down]: growright,nopercent,gauge,integer,nobanner,printrouter,pngdate
LegendI[unifi_ap_total_vs_down]: Active AP -->
LegendO[unifi_ap_total_vs_down]: Down AP -->
YLegend[unifi_ap_total_vs_down]: Active vs Down
Legend1[unifi_ap_total_vs_down]: Active Access Points
Legend2[unifi_ap_total_vs_down]: Down Access Points
ShortLegend[unifi_ap_total_vs_down]:
#Unscaled[unifi_ap_total_vs_down]: dwmy

MRTG Graph for Active WiFi AP DEVICES via UniFi Controller …

3-active-vs-down-ap


3# Upgrade UniFi AP LR Access Point via SSH/CLI

We have few unifi AP-LR  Wireless Access Points in our company which are connected with the Unifi Controller ver 5.2.9.0 on windows 2008 r2 / x64 server. For some unknown reasons I was unable to upgrade the access point’s firmware from the controller. Therefore I upgraded all AP’s via SSH method which is posted below …

First download the appropriate firmware and upload it to some web server. (at the time of upgrading the latest firmware version was  3.7.21.5389 , you make sure to download latest one available)
Select your model / download from following link …

https://www.ubnt.com/download/unifi/

[Luckily I had local web server available so I simply put this file into my /var/www folder (for ubuntu)]

 

Now login in the access point via SSH , and issue this command

upgrade http://101.0.0.1/BZ.ar7240.v3.7.21.5389.161017.0923.bin

Make sure to change the path or ip according to your network. Once its upgraded it rebooted and new Firmware was 3.7.21.5389


I will post more info later … 3.7.21.5389

Regard’s
Syed Jahanzaib


Filed under: Ubiquiti

Gathering Stats from remote Windows via Linux Shell

$
0
0

Reference Post:

Following are few simple methods to query information for various instances like remote windows service status , performance monitor instance result with trimming , , execute commands on remote windows box , all being done from our beloved Linux boX😉

I must admit that even after spending years in this field, I still feel myself very doodle, blockhead & light brain in almost every topic or subject I get confronted with ! STML plays an important role in my Deficiency  ‘_’    –😉

ots1087__97717-1410905363-1280-1280


Executing command on remote windows server, and get its result in output

$WINEXE --user=$DOMAIN/$ADMINID%$ADMINPASS //$SERVERIP "C:\TEMP\COMMAND.EXE -syntax-if-any"

Note: above command requires WINEXE tool (Linux tools to execute command on remote windows)

Querying Remote Windows Performance Monitor Instances

Example, we have Forefront TMG 2010 and we want to see its Cache Hit % from our linux box shell, so we can use following command (It was real hard to escape nested double quotes :O )

This is very very useful command and it took few hours for me to trim the required result for plotting graph.

winexe -U domain/admin%"password" //MYSERVER 'typeperf -sc 1 -si 1 "\\MYSERVER\Forefront TMG Web Proxy\Cache Hit Ratio (%)"'

and with bash script I used it like

root@linux:/temp# cat tmg-cachehit.sh

#!/bin/bash
# Script to query TMG cache HIT after trimming
#set -x
IP="10.0.0.1"
DOMAIN="MYDOMIN"
ID="ADMIN"
PASS="PASSWORD"
TMP_HOLDER="/tmp/$IP.cache.hit.txt"
winexe -U $DOMAIN/$ID%"$PASS" //$IP 'typeperf -sc 1 -si 1 "\\101.11.11.6\Forefront TMG Web Proxy\Cache Hit Ratio (%)"' > $TMP_HOLDER
RESULT=`cat $TMP_HOLDER | sed -n 3p | awk '{print $2}' | cut -d "," -f 2 | tr -d '"' | cut -f1 -d"."`
echo $RESULT
echo $RESULT

Result:

tmg-cache-hit


Check remote windows service status

Example if we want to query service status result of Lotus domino mail server  from our linux box …

root@linux:/temp# net rpc service status "Lotus Domino Server (DLotusDominodata)" -I 10.0.0.1 --user=DOMAIN/ADMINID%PASSWORD

RESULT:

Lotus Domino Server (DLotusDominodata) service is running.
Configuration details:
Controls Accepted = 0x5
Service Type = 0x110
Start Type = 0x2
Error Control = 0x0
Tag ID = 0x0
Executable Path = "X:\Lotus\nservice.exe" "=X:\Lotus\notes.ini" "-jc" "-c"
Load Order Group =
Dependencies = /
Start Name = LocalSystem
Display Name = Lotus Domino Server (DLotusDominodata)

Allah Shuker


I used all above commands in various script for alerts and mrtg graphing. you can use it to fulfill any customized requirements.

Regard’s
Syed Jahanzaib


Filed under: Linux Related, Uncategorized

Windows User Login Logs

$
0
0

Disclaimer:
This is a reference post for myself, to recall it later when i need it.
There are tons of tools/apps that can automate such tasks,Example you can do it via GPO (if you are in domain environment), or use dedicated tools, or just simply sort views in event viewer.

But being lazy/blockhead or fond of fetching result using out of the box approach, I try to select method that works for me and which seems easy to me plus with some learning. You may follow the internet to get more elegant / less complicated solution. Read it just to add ideas on how dumb-heads like me doing there work in other dimension approach , lean so that you may enhance it or at least not follow it for many reasons ;). This was a drafted version, later I modified this task for more presentable formatting. Windows batch file is far behind in advance coding as compare to bash, but we understand the limitation dueo to Microsoft platform.

I used WINTAIL to view real time logging of the specific system. we can modify the scripting to any level we want it to be. example we can log this info at our linux based mysql server, email the event, etc etc 😀

Sky is the only limit !

Zaib!


Scenario#1:

We have a domain environment in our office. At one windows 7 workstation, we have some important application installed which is access by specific users Remote (RDP and Dameware remote app) session & dueto some specific issues, the management wanted to store its full logs for following events only …

  1. When user login to the workstation
  2. When user logoff from the workstation
  3. When user connect to any previous session, either local or by remote
  4. When user re-login to the system (unlock)

Following information should be recorded in simple log file at remote server

  1. Event Type: LOGIN OR LOGOFF
  2. RDP Client IP: If the user is logged in via RDP, his ip should be logged
  3. DAMEWARE IP: If the user is logged in using DAMEWARE remote app, his IP should be logged
  4. Remote Client PC DNS Name: Remote client windows DNS name should be logged
  5. Username: Domain User ID which is being used to logging to the workstation
  6. Computername: name of workstation on which user is logging to
  7. Date / Time

 


Solution using Windows Batch File [Drafted but tested Version on Windows 7 / 64bit]

Requirements:

  • grep
    [Linux tool for windows version]
  • sed
    [Linux tool for windows version]
  • login-log.cmd
    our batch file
  • task scheduler task to trigger it on different events we required

Download grep/sed and place all contents in its bin folder to C:\windows\system32 so that it can be accessed from any path.

login-log.cmd

@echo off
rem ### Batch file to be configured in Task Manager to log events
rem ### to remote server log file
rem ### Syed Jahanzaib
cls
rem Create Backup folder if not exists already
set TEMPLOC="C:\BACKUP"
if not exist "%TEMPLOC%" mkdir %TEMPLOC%
set LOGLOCAL="%TEMPLOC%\LOCAL.LOG"
rem ### Log Server Folder where logs will be saved
set LOGSERVER="\\LOGSERVER\userlog\%USERNAME%.log"
set IPFILE="%TEMPLOC%\IP.TXT"
set COMPFILE="%TEMPLOC%\COMPNAME.TXT"
set IPADD=
set DAMWIP=
set COMPNAME=
rem ### Delete old holders adn tasks if any
del %IPFILE% 2> nul
del %COMPFILE% 2> nul
taskkill /F /IM nslookup.exe 2> nul

rem ###
::# Get IP Address of local PC
for /f "skip=1 tokens=2 delims=[]" %%* in (
'ping.exe -n 1 %Computername%') Do (set "LOCALIP=%%*" & goto:exitFor1)
:exitFor1

rem ### Get IP address for any RDP session, IF ANY,
netstat -na | find "3389" | find "ESTABLISHED" | awk "{print $3}" | sed s/:.*// > %IPFILE%
set /p IPADD=<%IPFILE%
IF "%IPADD%"=="" (
set IPADD=x
)

rem ### If no RDP session found, then skip nslookup to avoid any delay
set "filter=c:\backup/ip.txt"
for %%A in (%filter%) do if %%~zA==0 goto :skipname
nslookup %IPADD% | sed -n "4p" | awk "{print $2}" > %COMPFILE%
set /p COMPNAME=<%COMPFILE%

rem ### Check for any DAMEWARE remote app session and log its ip/name
:skipname
netstat -na | find "6129" | find "ESTABLISHED" | sed -n "2p" | awk "{print $3}" | sed s/:.*// > c:\damwip.txt
set /p DAMWIP=<c:\damwip.txt
rem echo %DAMWIP%
set "filter=c:\damwip.txt"
rem for %%A in (%filter%) do if %%~zA==0 echo no damw
REM goto :skipdamw
rem ### if no damware ip session found, make it null x
IF "%DAMWIP%"=="127.0.0.1" (
set DAMWIP=x
)

rem ### If there is no remote session for both RDP and DW , then set variable accordingly
:skipdamw
if "%DAMWIP%"=="x" goto :1
nslookup %DAMWIP% | sed -n "4p" | awk "{print $2}" > c:\backup\damwip.txt
set /p COMPNAME=<c:\backup\damwip.txt
goto :skip
:1
if "%IPADD%"=="x" goto :cond
goto :skip
:cond
set IPADD=LOCAL-LOGIN
set DAMWIP=LOCAL-LOGIN
:skip

if "%COMPNAME%"=="" set COMPNAME=LOCAL-LOGIN
REM --- SERVER LOG FILE
echo --------------------------------- >> %LOGSERVER%
ECHO LOGIN >> %LOGSERVER%
echo RDP Client IP: %IPADD% - / DW IP: %DAMWIP% / Remote Client PC: %COMPNAME%
echo Login User: %USERNAME% / To: %COMPUTERNAME% / Local IP: %LOCALIP% / %DATE% %TIME%
echo RDP Client IP: %IPADD% - DW IP: %DAMWIP% / Remote Client PC: %COMPNAME% >> %LOGSERVER%
echo Username - %USERNAME% / Computer - %COMPUTERNAME% / %DATE% %TIME% >> %LOGSERVER%
echo --------------------------------- >> %LOGSERVER%

REM --- LOCAL LOG FILE
echo --------------------------------- >> %LOGLOCAL%
ECHO LOGIN >> %LOGLOCAL%
echo RDP Client IP: %IPADD% - DW IP: %DAMWIP% / Remote Client PC: %COMPNAME% >> %LOGLOCAL%
echo Username - %USERNAME% / Computer - %COMPUTERNAME% / %DATE% %TIME% >> %LOGLOCAL%

echo --------------------------------- >> %LOGLOCAL%


Windows Task Scheduler Configuration >

task1

task-1

task2

 


Result:

Now you can open the log file at log server, or local pc as well.

 


LOGIN
RDP Client IP: x - DW IP: 10.0.0.58 / Remote Client PC: zaib.pc
Username - user.id / Computer - APPSRV / Thu 01/19/2017 14:31:36.68
---------------------------------
---------------------------------
LOGOFF -- APPSRV APPSRV Thu 01/19/2017 14:31:41.09
---------------------------------
---------------------------------
LOGIN
RDP Client IP: LOCAL-LOGIN - DW IP: LOCAL-LOGIN / Remote Client PC: LOCAL-LOGIN
Username - user.id / Computer - APPSRV / Thu 01/19/2017 14:33:11.35
---------------------------------
LOGIN -- user.id APPSRV Thu 01/19/2017 14:33:16.02
---------------------------------
LOGOFF -- user.id APPSRV Thu 01/19/2017 14:33:23.14
---------------------------------
LOGIN -- user.id APPSRV Thu 01/19/2017 15:35:03.51
---------------------------------
LOGIN
RDP Client IP: 10.1.2.250 - DW IP: x / Remote Client PC: seconduser.domain
Username - APPSRV / Computer - APPSRV / Thu 01/19/2017 15:35:04.54
---------------------------------


Scenario#2:

Log information of every user login/logout in %username%.txt in remote server folder .

Using Domain GPO , set it to execute login-log.cmd file at Startup


@echo off
echo LOGIN -- %USERNAME% %COMPUTERNAME% %CLIENTNAME% %DATE% %TIME% >> \\LOGSERVER\userlog\%USERNAME%.log

at remote log server, you can set permission so that user can only write in it, but not explore it.

permission


blah blah blah

Syed.Jahanzaib


Filed under: Microsoft Related

Check remote windows logged-in user/lock status via BASH

$
0
0

locked

Scenario:

We have Active Directory environment in our office. Clients OS are mixed starting from windows 2000/2003/2008 and Win7.
For some specific reasons/policy, our helpdesk staff is often required to inquire if the employee is working on his workstation or if his/her windows status is locked.

Solution:

Since I am using my Ubuntu box to manage most of the Active Directory functions using Webmin/BASH scripts, therefore I made a small bash script which queries for remote windows logged in user session and windows locked/unlocked status.

The bash script does the following …

  • Check for remote PC PING Status, if ping fails, exit with error
  • Get remote windows IP via NSLOOKUP using local DNS
  • Current Logged-in user and their status
  • Current status of windows either its locked/unlocked.
  • TRIM the results and display according to our taste

the Script!

> root@linux:/temp# cat winuserstatus.sh

#!/bin/bash
# Script to check remote windwos status, like Loggedin + Windows Lock/Unlock status
# More functions can be added/removed as required.
# I attached this script to webmin for our Support dept.
# Syed Jahanzaib / aacable.wordpress.com / aacable @ hotmail . com
# Created: 25-JAN-2017

# set -x
QUSER_HOLDER="/tmp/$1.quser"
LOCK_HOLDER="/tmp/$1.lockstatus"
REMOTE_PC="$1"
PING_ATEMPTS="1"
PING_STATUS="/tmp/$1.ping.status"
LOCAL_DNS_IP="10.0.0.1"

# Domain credentials details so that winexe can execute commands on all domain clients
DOMAIN="domain.local"
DOMAIN_ADMIN="admin"
ADMIN_PASS="password"

# Empty All Holders
> $QUSER_HOLDER
> $LOCK_HOLDER
> $PING_STATUS

# Check if remote PC is accessibel or not,
## IF PING FAILS then inform accordingly and EXIT
ping -q -c $PING_ATEMPTS $REMOTE_PC &>/dev/null > $PING_STATUS
PING_RESULT=`cat $PING_STATUS`
if [ "$PING_RESULT" = "" ]; then
echo "ERROR: Unknown HOST. Exiting"
exit 1
fi

# Print PC NAME (from $1 variable)
echo "
Remote PC = $1"

# Print IP of remote PC via nslookp using local DNS
echo "IP Details =
`nslookup $1 | grep Address | sed /$LOCAL_DNS_IP/d`"

# If ping failed, then print Error and EXIT
if [[ $(ping -q -c $PING_ATEMPTS $REMOTE_PC) == @(*100% packet loss*) ]]; then
echo "$1 not responding to ping request, probably system is not UP"
exit 1
fi

# Query remote windows Logged in user using Linux WINEXE tool
winexe -U $DOMAIN/$DOMAIN_ADMIN%"$ADMIN_PASS" //$1 "quser" > $QUSER_HOLDER
QUSER_RESULT=`cat $QUSER_HOLDER |grep Active`
if [ "$QUSER_RESULT" = "" ]; then
echo "
User Status = No user is active"
else
echo "
User Status = Logged in User found ... details as below ...
$QUSER_RESULT
"
fi

# Query remote windows TASK list to find if windows is locked/unlocked
winexe -U $DOMAIN/$DOMAIN_ADMIN%"$ADMIN_PASS" //$1 "tasklist" > $LOCK_HOLDER
LOCK_RESULT=`cat $LOCK_HOLDER |grep -E "LogonUI.exe|logon.scr"`
if [ "$LOCK_RESULT" = "" ]; then
echo "
Windows Status = Windows is UN-LOCKED!"
else
echo "
Windows Status = Windows is LOCKED"
fi

# Script function ends here
# Thank you


Result:

When User is logged in and windows is LOCKED!

root@linux:/temp# /temp/winuserstatus.sh WORKSTAION-1

Remote PC = WORKSTAION-1
IP Details =
Address: 10.0.0.20
Address: 10.0.0.21

User Status = Logged in User found ... details as below ...
jahan.zaib console 13 Active 1+00:53 1/23/2017 1:57 PM
Windows Status = Windows is LOCKED

When User is logged in and windows is UN-LOCKED!

root@linux:/temp# /temp/winuserstatus.sh WORKSTAION-1

Remote PC = WORKSTAION-1
IP Details =
Address: 10.0.0.21
Address: 10.0.0.20

User Status = Logged in User found ... details as below ...
jahan.zaib console 13 Active 1+00:53 1/23/2017 1:57 PM
Windows Status = Windows is UN-LOCKED!

When User is NOT logged in and windows is LOCKED as well !


root@linux:/temp# /temp/winuserstatus.sh SERVER-2

Remote PC = SERVER-2
IP Details =
Address: 101.11.11.2
No User exists for *

User Status = No user is active

Windows Status = Windows is LOCKED

Regard’s
Syed Jahanzaib


Filed under: Microsoft Related

Acquiring Cisco Switch Customized Report via Sms/Email

$
0
0

test


Scenario:

We have few Cisco switches installed in our network. the OP wants to receive specific switch report via email, by sending SMS to the system (on demand or scheduled), and the system should return the detailed report by email with following details ….

The Task is quite simple, and surely it can be done with more better approach or professional coding, but this is just mine exploration which is working fine for my static requirements. We can add about any other information in the script, as per required.


Requirements for report:

  • The report should be customized according to the OP taste. For this purpose we made an script which does the following
  • Check if IP is missing, exit with error, and return error by email to Admin, otherwise Continue to Next Step…
  • Check if IP is invalid, exit with error, and return error by email to Admin, otherwise Continue to Next Step…
  • Check if IP is not accessible by ping, exit with error, and return error by email to Admin, otherwise Continue to Next Step…
  • Check if SNMP UDP port 161 is not accessible by nmap, exit with error, and return error by email to Admin, otherwise Continue to Next Step…
  • Check if remote device is not a Cisco switch, exit with error, and return error by email to Admin, otherwise Continue to Next Step…
  • Automatically check for all available ports like 24/28/48/52 etc,
  • Check Switch Mode/Type/Firmware/CPU Usage/Switch Uptime/Vlan Count etc
  • Check all Ports Up/Down Status / Port Speed / Last Status Change etc
  • Script start/end Time stamp.

Tools Used in this post … [Extra]

  • Kannel/playsms for receiving SMS and execute the script which will in return sends response by email (or sms) [ I have covered kannel and playSMS in my previous guides at my blog]
  • nmap to query remote device SNMP UDP 161 port [you can use some other methods as well]
  • sendEmail tool to send email [you can use some other methods as well]
    • [ I have covered sendEmail tool usage in my previous guide at my blog]

zaiB!


the Script!


#!/bin/sh
# Script to detect Cisco switch Port status / speed / Description / last status changed with various checks
# Useful for admins who want to query there switch information by SMS / email,
# like we can configure this script to be executed from incoming SMS (using playSMS) and send result by email
# Scripted Designed by: Syed Jahanzaib&nbsp;
# http:// aacable . wordpress . com / aacable @ hotmail . com
# Ceated On: 27-January-2017

# to debug script , remove # from following line
#set -x

# Color Codes, we can use these codes to color our black world output
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"

# Hostname and other Variables
# Take ip from command line variable
IP="$1"
# Switch SNMP community string
SNMP_STRING="PUBLIC"
HOSTNAME=`hostname`
COMPANY="zaib (Pvt) Ltd."
FOOTER="Powered By Syed.Jahanzaib"
DATE=`date`

# EMAIL RELATED and KANNEL INFO
# for down status, we have to use GMAIL to send email
KANNELURL="127.0.0.1:13013"
KANNELID="kannel"
KANNELPASS="KANNEL_PASSOWRD"
CELL1="03333021909"
# GMAIL Section
GMAILID="YOUR_GMAILID@gmail.com"
GMAILPASS="GMAIL_PASSWORD"
ADMINMAIL1="aacableAThotmail.com"

#Email Subject Body etc
EMAIL_SUB="INFO: Switch IP $IP - Report @ $DATE"
EMAIL_BODY="/tmp/$ip.email.txt"
echo "
$IP SWITCH QUERY Starts @ $DATE

"

echo "
$IP SWITCH QUERY Starts @ $DATE

" &gt; $EMAIL_BODY

############ DIFFERENT ERROR's VARIABLES ###########
ERR_NOIP="ERROR: Please provide IP of switch

Eaxmple:
portquery 192.168.155.255"

ERR_INVALID_IP="ERROR: Invalid IP address detected. Please provide valid IP of switch

Eaxmple:
portquery 192.168.155.255"

ERR_PING_FAILED="ERROR: Switch IP $IP PING is DOWN ... cannot proceed further... Wziring"
ERR_SNMP="ERROR: Switch IP $IP SNMP not responding. Cannot continue without it... Exiting"
ERR_NO_CISCO="ERROR: $IP - Remote device type doesn't look like CISCO switch... Exiting"

PORTS_TMP_HOLDER="/tmp/$IP.port.numbers"
PORTS_TMP_HOLDER_FINAL="$IP.port.numbers.final"

# If IP is not provided with variable , give error
if [ -z "$IP" ]; then
echo "$ERR_NOIP"
# Send Email reply to Admin for IP not provided error
echo "$ERR_NOIP" &gt;&gt; $EMAIL_BODY
/temp/sendEmail-v1.56/sendEmail -u "$EMAIL_SUB" -o tls=yes -s smtp.gmail.com:587 -t $ADMINMAIL1 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$EMAIL_BODY -o message-content-type=text
exit 1
fi

# Check for IP addrrss validity, IP must be in format like `port query10.0.0.1`
if expr "$IP" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' &gt;/dev/null; then
echo "IP OK" &gt; /dev/null
else
echo "$ERR_INVALID_IP"
# Send Email reply to Admin for invalid IP
echo "$ERR_INVALID_IP" &gt;&gt; $EMAIL_BODY
/temp/sendEmail-v1.56/sendEmail -u "$EMAIL_SUB" -o tls=yes -s smtp.gmail.com:587 -t $ADMINMAIL1 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$EMAIL_BODY -o message-content-type=text
exit 1
fi

# Check if REMOTE DEVICE is accessibel or not, if not then EXIT immediately with error / zaib
#if [[ $(ping -q -c 3 P) == @(*100% packet loss*) ]]; then
PING_LOSS=`ping -c 1 -q $IP | grep -oP '\d+(?=% packet loss)'`
if [ "$PING_LOSS" = "100" ]; then
echo "$ERR_PING_FAILED"
# Send Email reply to Admin for IP not responding
echo "$ERR_PING_FAILED" &gt;&gt; $EMAIL_BODY
/temp/sendEmail-v1.56/sendEmail -u "$EMAIL_SUB" -o tls=yes -s smtp.gmail.com:587 -t $ADMINMAIL1 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$EMAIL_BODY -o message-content-type=text
exit 1
fi

# Check if SNMP port is responding or not, because we require SNMP to query all results
SNMP_PORT_QUERY=`nmap -sU -p 161 $IP | grep open`
if [ -z "$SNMP_PORT_QUERY" ]; then
echo "$ERR_SNMP"
# Send Email reply to Admin for SNMP not responding
echo "$ERR_SNMP" &gt;&gt; $EMAIL_BODY
/temp/sendEmail-v1.56/sendEmail -u "$EMAIL_SUB" -o tls=yes -s smtp.gmail.com:587 -t $ADMINMAIL1 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$EMAIL_BODY -o message-content-type=text
exit 1
fi

# Determine device OS type, if it doesnt contains 'Cisco IOS' word, then exit
DETECT_SW_OS=`snmpwalk -v1 -c $SNMP_STRING $IP 1.3.6.1.2.1.1.1 | grep -R "Cisco IOS"`
if [ -z "$DETECT_SW_OS" ]; then
echo "$ERR_NO_CISCO"
echo "$ERR_NO_CISCO" &gt;&gt; $EMAIL_BODY
/temp/sendEmail-v1.56/sendEmail -u "$EMAIL_SUB" -o tls=yes -s smtp.gmail.com:587 -t $ADMINMAIL1 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$EMAIL_BODY -o message-content-type=text
exit 1
fi

# Switch name variable / mib etc
MIB="/cfg/mibs/HOST-RESOURCES-MIB"
SW_NAME=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP iso.3.6.1.2.1.1.5.0`
SW_MODEL=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP .1.3.6.1.2.1.47.1.1.1.1.13.1001`
SW_FW=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP .1.3.6.1.2.1.1.1.0 | sed -n '1p'`
SW_CPU_USAGE=`snmpwalk -Oqvn -v1 -c $SNMP_STRING $IP 1.3.6.1.4.1.9.2.1.56.0`
SW_UPTIME=`snmpwalk -v1 -c $SNMP_STRING $IP .1.3.6.1.2.1.1.3.0 | sed 's:.*)::'`
SW_VLAN_COUNT=`snmpwalk -v1 -c $SNMP_STRING $IP iso.3.6.1.2.1.47.1.2.1.1.2 | wc -l`
# Query Port number after trimming and store in file, it will be used for port counting and switch media type as well / zaib
snmpwalk -v1 -c gt $IP .1.3.6.1.2.1.2.2.1.2 | sed '/Stack\|Vlan\|Null/d' &gt; $PORTS_TMP_HOLDER

# Count total ports in switch
PORT_COUNT=`cat $PORTS_TMP_HOLDER | wc -l`

# Query Switch type like if its megabit or gigabit, we will do it using FAST word, pretty lame but its working good for me / zaib
SW_TYPE_Q=`cat $PORTS_TMP_HOLDER | grep Fast`
if [ -z "$SW_TYPE_Q" ]; then

###########################################################
# Consider Switch as GIGAbit and do actions based upon it #
###########################################################

# Print
INFO_HEADER="Switch Model: $SW_MODEL
Switch Name: $SW_NAME
Switch type: GIGABIT Model
Switch Fw : $SW_FW
Switch Uptime: $SW_UPTIME
Switch CPU Usage: $SW_CPU_USAGE
Switch VLAN Numbers: $SW_VLAN_COUNT

Ports Status :
"
echo "$INFO_HEADER"

# Add text for Email Body
echo "$INFO_HEADER" &gt;&gt; $EMAIL_BODY

# Some junk maths
cat $PORTS_TMP_HOLDER | grep -o -P '.{0,0}101.{0,2}' | sed 's/101//' &gt; $PORTS_TMP_HOLDER_FINAL
cat $PORTS_TMP_HOLDER_FINAL | while read ports
do
num=$[$num+1]
PORT_N=`echo $ports`
PORT_DESC_Q=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP 1.3.6.1.2.1.31.1.1.1.18.101$PORT_N | tr -d '"' | grep -E "[[:alnum:]]"`
SW_PORT_LAST_ST_CHANGE=`snmpwalk -On -v1 -c $SNMP_STRING $IP .1.3.6.1.2.1.2.2.1.9.101$PORT_N | sed 's:.*)::'`
if [ "$PORT_DESC_Q" = "" ]; then
PORT_DESC="n/a"
else
PORT_DESC="$PORT_DESC_Q"
fi
PORT_Q=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP 1.3.6.1.2.1.2.2.1.8.101$PORT_N`
if [ "$PORT_Q" -eq 1 ]; then
PORT_STATUS="UP"
else
PORT_STATUS="DOWN"
fi
if [ "$PORT_STATUS" = "DOWN" ]; then
PORT_SPEED="n/a"
else
PORT_SPEED_Q=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP iso.3.6.1.2.1.2.2.1.5.101$PORT_N`
PORT_SPEED=`echo $(($PORT_SPEED_Q/1000/1000)) mbps`
fi
PORT_NAME=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP 1.3.6.1.2.1.31.1.1.1.18.101$PORT_N`

# Finally Spit out all the info gaterhed by above junk code 😀 / zaib
echo "PORT_Number: $PORT_N / Status: $PORT_STATUS / Name: $PORT_DESC / Speed: $PORT_SPEED / Port_Last_Status_Change = $SW_PORT_LAST_ST_CHANGE"
echo "PORT_Number: $PORT_N / Status: $PORT_STATUS / Name: $PORT_DESC / Speed: $PORT_SPEED / Port_Last_Status_Change = $SW_PORT_LAST_ST_CHANGE" &gt;&gt; $EMAIL_BODY
done

###########################################################
# Consider Switch as Megabit and do actions based upon it #
###########################################################
else
#Print
INFO_HEADER="Switch Model: $SW_MODEL
Switch Name: $SW_NAME
Switch type: MEGABIT Model
Switch Fw : $SW_FW
Switch Uptime: $SW_UPTIME
Switch CPU Usage: $SW_CPU_USAGE
Switch VLAN Numbers: $SW_VLAN_COUNT

Ports Status :
"
echo "$INFO_HEADER"
# Add text for Email Body
echo "$INFO_HEADER" &gt;&gt; $EMAIL_BODY

cat $PORTS_TMP_HOLDER | grep -o -P '.{0,0}100.{0,2}' | sed 's/100//' &gt; $PORTS_TMP_HOLDER_FINAL
cat $PORTS_TMP_HOLDER_FINAL | while read ports
do
num=$[$num+1]
PORT_N=`echo $ports`
PORT_DESC_Q=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP 1.3.6.1.2.1.31.1.1.1.18.100$PORT_N | tr -d '"' | grep -E "[[:alnum:]]"`
SW_PORT_LAST_ST_CHANGE=`snmpwalk -On -v1 -c $SNMP_STRING $IP .1.3.6.1.2.1.2.2.1.9.100$PORT_N | sed 's:.*)::'`
if [ "$PORT_DESC_Q" = "" ]; then
PORT_DESC="n/a"
else
PORT_DESC="$PORT_DESC_Q"
fi
PORT_Q=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP 1.3.6.1.2.1.2.2.1.8.100$PORT_N`
if [ "$PORT_Q" -eq 1 ]; then
PORT_STATUS="UP"
PORT_SPEED_Q=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP iso.3.6.1.2.1.2.2.1.5.100$PORT_N`
PORT_SPEED=`echo $(($PORT_SPEED_Q/1000/1000)) mbps`
else
PORT_STATUS="DOWN"
PORT_SPEED="n/a"
PORT_NAME=`snmpwalk -Oqv -v1 -c $SNMP_STRING $IP 1.3.6.1.2.1.31.1.1.1.18.100$PORT_N`
fi
# Finally Spit out all the info gaterhed by above junk code 😀 / zaib
echo "PORT_Number: $PORT_N / Status: $PORT_STATUS / Name: $PORT_DESC / Speed: $PORT_SPEED / Port_Last_Status_Change = $SW_PORT_LAST_ST_CHANGE"
echo "PORT_Number: $PORT_N / Status: $PORT_STATUS / Name: $PORT_DESC / Speed: $PORT_SPEED / Port_Last_Status_Change = $SW_PORT_LAST_ST_CHANGE" &gt;&gt; $EMAIL_BODY
done
fi

# Send the result via EMAIL to admin emails as mentioned in start.
# Add footer
DATE=`date`
echo "
Switch Query Ends Here at $DATE

$COMPANY
$FOOTER"
echo "
Switch Query Ends Here at $DATE

$COMPANY
$FOOTER" &gt;&gt; $EMAIL_BODY
/temp/sendEmail-v1.56/sendEmail -u "$EMAIL_SUB" -o tls=yes -s smtp.gmail.com:587 -t $ADMINMAIL1 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$EMAIL_BODY -o message-content-type=text
#cat $MSGDOWNHOLDER | curl "http://$KANNELURL/cgi-bin/sendsms?username=$KANNELID&amp;password=$KANNELPASS&amp;to=$CELL1" -G --data-urlencode text@-

# Script Ends here #


Result/Report Sample:

 

Result via Email:

1- sw-report.PNG


Result in CMD:


#### root@ubuntu:/temp# ./portquery.sh 192.168.255.254

192.168.255.254 SWITCH QUERY Starts @ Sat Jan 28 00:49:07 PKT 2017
Switch Model: "WS-C3750G-24PS-S"
Switch Name: "X-switch"
Switch type: GIGABIT Model
Switch Fw : "Cisco IOS Software, C3750 Software (C3750-IPBASE-M), Version 12.2(35)SE5, RELEASE SOFTWARE (fc1)
Switch Uptime: 13 days, 17:24:37.14
Switch CPU Usage: 6
Switch VLAN Numbers: 57

Ports Status :

PORT_Number: 01 / Status: UP / Name: n/a / Speed: 1000 mbps / Port_Last_Status_Change = 0:01:19.59
PORT_Number: 02 / Status: DOWN / Name: ServerX / Speed: n/a / Port_Last_Status_Change = 0:01:13.07
PORT_Number: 03 / Status: UP / Name: Server4 / Speed: 1000 mbps / Port_Last_Status_Change = 7 days, 23:46:45.26
PORT_Number: 04 / Status: UP / Name: n/a / Speed: 1000 mbps / Port_Last_Status_Change = 7 days, 23:46:44.53
PORT_Number: 05 / Status: UP / Name: n/a / Speed: 1000 mbps / Port_Last_Status_Change = 0:01:16.08
PORT_Number: 06 / Status: UP / Name: n/a / Speed: 1000 mbps / Port_Last_Status_Change = 7 days, 23:46:42.48
PORT_Number: 07 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.07
PORT_Number: 08 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.07
PORT_Number: 09 / Status: DOWN / Name: vlanX / Speed: n/a / Port_Last_Status_Change = 0:01:13.07
PORT_Number: 10 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 13 days, 1:53:58.05
PORT_Number: 11 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 12 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 13 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 14 / Status: DOWN / Name: test-trunk-XX-new / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 15 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 16 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 17 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 18 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 19 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 20 / Status: UP / Name: XXX_gb_media_test / Speed: 1000 mbps / Port_Last_Status_Change = 0:01:16.09
PORT_Number: 21 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 22 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 23 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:13.08
PORT_Number: 24 / Status: DOWN / Name: up_2_jr_sw / Speed: n/a / Port_Last_Status_Change = 0:01:11.68
PORT_Number: 25 / Status: UP / Name: up-2-XXX / Speed: 1000 mbps / Port_Last_Status_Change = 0:01:18.92
PORT_Number: 26 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:11.71
PORT_Number: 27 / Status: DOWN / Name: n/a / Speed: n/a / Port_Last_Status_Change = 0:01:11.72
PORT_Number: 28 / Status: UP / Name: XXX-SWX by FC / Speed: 1000 mbps / Port_Last_Status_Change = 12 days, 10:12:00.62

Switch Query Ends Here at Sat Jan 28 00:49:22 PKT 2017

zaib (Pvt) Ltd.
Powered By Syed.Jahanzaib
Jan 28 00:49:26 ubuntu sendEmail[16553]: Email was sent successfully!


playSMS COMMAND sample config [for incoming sms action]

playsms command.PNG

 

playSMS log when incoming message with specific keyword ‘switch x.x.x.x’ is received

127.0.0.1 localhost 2017-01-28 01:11:32 PID588ba9743d5c2 - L2 kannel__call # start load:/var/www/playsms/plugin/gateway/kannel/geturl.php
127.0.0.1 localhost 2017-01-28 01:11:32 PID588ba9743d5c2 - L3 kannel__incoming # remote_addr:127.0.0.1 remote_host:localhost t:[2017-01-28 03:11:27] q:[+923333021909] a:[switch X.X.X.X] Q:[13013] smsc:[] smsc:[]
127.0.0.1 localhost 2017-01-28 01:11:32 PID588ba9743d5c2 - L3 recvsms # isrecvsmsd:1 dt:2017-01-28 03:11:27 sender:+923333021909 m:switch X.X.X.X receiver:13013 smsc:
127.0.0.1 localhost 2017-01-28 01:11:32 PID588ba9743d5c2 - L2 kannel__call # end load geturl
- - 2017-01-28 01:11:32 PID58798d2cbeb7d - L3 recvsmsd # id:261 dt:2017-01-28 03:11:27 sender:+923333021909 m:switch X.X.X.X receiver:13013 smsc:
- - 2017-01-28 01:11:32 PID58798d2cbeb7d - L3 recvsms_process # dt:2017-01-28 03:11:27 sender:+923333021909 m:switch X.X.X.X receiver:13013 smsc:
- - 2017-01-28 01:11:32 PID58798d2cbeb7d - L3 gateway_decide_smsc # SMSC supplied:[] configured:[] decided smsc:[]
- - 2017-01-28 01:11:32 PID58798d2cbeb7d - L3 sms__command # command_exec:/var/lib/playsms/sms_command/1/portquery.sh 'X.X.X.X'
- - 2017-01-28 01:11:58 PID58798d2cbeb7d - L3 recvsms_process # feature:sms_command datetime:2017-01-28 03:11:27 sender:+923333021909 receiver:13013 keyword:SWITCH message:X.X.X.X raw:switch X.X.X.X smsc:

once the sms is received the playsms will execute the script, and will reply back by email or sms OR according to the configuration set in the script.


Regard’s

Syed Jahanzaib


Filed under: Cisco Related, Uncategorized

Windows 7 Error: 0x800704cf / Unable to Access remote network shared resources

$
0
0

windows-cannot-access-shared-folder

fotolia_3115040_m_tile

Windows cannot access \\testpc
Error Code: 0x800704cf

If your system is a workstation joined with local domain controller and you are getting above (same) error while trying to access ANY shared resource/system on the network, then you may try following fix. This error gave me straight 1 hour headache, so I really don’t want anyone else to bang their head on the wall for the same.

Fix >     :~)

  • Open (Currently active) Network Adapter properties,
  • UNCHECK the ‘Client for microsoft Networks‘  / OK
  • Open Regedit, & Navigate to “HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\NetBT\Parameters”
  • Create a new key with following parameters

Type: DWORD Value
Name: SMBDeviceEnabled
Data: 1

  • Once Done, Restart your computer, & MAKE SURE TO ENABLE THE ‘CLIENT FOR MICROSOFT NETWORK’ in the adapter settings.

Now check and hopefully you will be able to access the shared resources without any error.

TIP/Additional Commands

  • ipconfig /flushdns
  • nbtstat -RR
  • netsh int ip reset
  • netsh winsock reset

Regard’s
Syed Jahanzaib


Filed under: Uncategorized

Windows Event-Viewer Logging to MYSQL

$
0
0

out-of-the-box

In our small office environment, we are using Windows 2008 R2 Active Directory for user management/authentication and control purpose. Dueto some standard operating procedure I was asked to log User Account Creation / Removal events in Linux base mySQL DB. Since windows doesn’t provide option to directly export event into linux base mysql, therefore I made an workaround for it using specific windows events tagged with task scheduler approach. Not to mention , this approach of using task scheduler with events is not a new thing, but it was definitely a bit confusing for a numbnuts like ME on how to acquire only the very specific fields trimmed according to our taste and get it logged in remote linux mysql db. but Alhamdulillah I managed to get it in few hours struggling.

z@iB

Items I used in this post are …

  • Windows 2008 R2 server with Active Directory
  • c:\temp folder to hold temporary information for the triggered event
  • e:\userlog\ folder to hold all logs
  • Event ID which will be logged in local log file and mySQL DB [as required] :

    4720

    New User Account Created

    4726

    User Account Deleted
  • Two batch files which will be executed when specific event will occur.
  • Mysql (I used mysql-5.7.17-winx64.zip) package to add entries in mySQL DB name events 

You can download mysql-5.7.17-winx64.zip from fmy Google Drive at

mysql-5.7.17-winx64 by Syed Jahanzaib


New Account Batch File for LOG [ac-new-log.bat]

@echo off
set MYSQL_HOST=10.0.0.1
set MYSQL_ID=your_mysqlid
set MYSQL_PASS=your_password
set MYSQL_DB=your_events
set MYSQL_TB=your_table
set ACTION=Account Created
set HOLDER=c:\temp\acnew-temp.txt
set LOGFILE=e:\userlog\users-created-log.log
type nul > %HOLDER%
wevtutil qe security /rd:true /f:text /c:1 /q:"*[System/EventID=4720]" > %HOLDER%
for /f "tokens=4" %%a in ('type %HOLDER% ^| find /i "Account Name"') do set accname=%%a
for /f "tokens=3" %%a in ('type %HOLDER% ^| find /i "Event ID"') do set eventid=%%a
for /f "tokens=2" %%a in ('type %HOLDER% ^| find /i "Date"') do set dt=%%a
set HEADER=%eventid% : %accname% / %ACTION% @ ... %dt%
echo %HEADER%
echo %HEADER% >> %LOGFILE%
c:\mysql\bin\mysql -h %MYSQL_HOST% -u%MYSQL_ID% -p%MYSQL_PASS% -e "use %MYSQL_DB%; INSERT INTO %MYSQL_TB% (eventid,type,account,msg) VALUES ('%eventid%','%ACTION
%','%accname%','%HEADER%');" 

Account Delete Batch File for LOG [ac-del-log.bat]

@echo off
set MYSQL_HOST=10.0.0.1
set MYSQL_ID=MY_ID
set MYSQL_PASS=MY_PASS
set MYSQL_DB=DB
set MYSQL_TB=TABLE
set ACTION=Account Deleted
set HOLDER=c:\temp\acdel-temp.txt
set LOGFILE=e:\userlog\users-deleted-log.log
type nul > %HOLDER%
wevtutil qe security /rd:true /f:text /c:1 /q:"*[System/EventID=4726]" > %HOLDER%
for /f "tokens=3" %%a in ('type %HOLDER% ^| find /i "Account Name"') do set accname=%%a
for /f "tokens=3" %%a in ('type %HOLDER% ^| find /i "Event ID"') do set eventid=%%a
for /f "tokens=2" %%a in ('type %HOLDER% ^| find /i "Date"') do set dt=%%a
set HEADER=%eventid% : %accname% / %ACTION% @ ... %dt%
echo %HEADER%
echo %HEADER% >> %LOGFILE%
c:\mysql\bin\mysql -h %MYSQL_HOST% -u%MYSQL_ID% -p%MYSQL_PASS% -e "use %MYSQL_DB%; INSERT INTO %MYSQL_TB% (eventid,type,account,msg) VALUES ('%eventid%','%ACTION%','%accname%','%HEADER%');" 

Attaching Batch files with Specific Event ID

On Domain Controller, open event viewer, goto 4720 event, right click and select ‘Attach Task to This Event‘ and in trigger select your batch file. (for account creation)

As showed in the image below

1- accoutn creation - attach batch file via event viewer.png

1.5 - triggers.PNG

2- trigger action.PNG

Repeat same for event id 4726.

Ok to finish it.


Creating DB in mySQL

Now create a new DB with required name and tables in mySQL …

One example is as follows.

mydb.sql


;-- MySQL dump 10.13 Distrib 5.5.54, for debian-linux-gnu (i686)
--
-- Host: localhost Database: events
-- ------------------------------------------------------
-- Server version 5.5.54-0ubuntu0.12.04.1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `mymaindb`
--

DROP TABLE IF EXISTS `mymaindb`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mymaindb` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`eventid` varchar(40) DEFAULT NULL,
`type` varchar(255) NOT NULL,
`account` varchar(255) NOT NULL,
`msg` varchar(10000) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=462 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `mymaindb`
--

LOCK TABLES `mymaindb` WRITE;
/*!40000 ALTER TABLE `mymaindb` DISABLE KEYS */;
INSERT INTO `mymaindb` VALUES (459,'2017-02-13 08:39:45','4720','Account Created','testing.act','4720 : testing.act / Account Created @ ... 2017-02-13T12:02:05.777'),(461,'2017-02-13 08:49:46','4726','Account Deleted','testing.act','4726 : testing.act / Account Deleted @ ... 2017-02-13T12:02:38.521');
/*!40000 ALTER TABLE `mymaindb` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2017-02-13 14:47:11

to import above DB , use following command …

mysql -uroot -pROOTPASS < mydb.sql

Script Result in CMD:

Now try to create/delete a user account in active directory, and you will see the result in mysql db.

I recommend to debug first, to make sure things are working ok, execute the bat file manually to see the results

ac-new-log.bat

script result.PNG

.

Script Result in mySQL DB :

[all above fuss was made just to acquire only specific data trimmed as per out taste, and get it logged in in remote linux mySQL otherwise task was very easy in general]

phpmyadmin snapshot

php-result

mysql cmd line snapshot


mysql> select * from MY_DB;
+-----+---------------------+---------+-----------------+-------------+--------------------------------------------------------------------+
| id | datetime | eventid | type | account | msg |
+-----+---------------------+---------+-----------------+-------------+--------------------------------------------------------------------+
| 459 | 2017-02-13 13:39:45 | 4720 | Account Created | testing.act | 4720 : testing.act / Account Created @ ... 2017-02-13 13:39:45 |
| 461 | 2017-02-13 13:49:46 | 4726 | Account Deleted | testing.act | 4726 : testing.act / Account Deleted @ ... 2017-02-13 13:39:45 |
+-----+---------------------+---------+-----------------+-------------+--------------------------------------------------------------------+
2 rows in set (0.00 sec)


This is a itty-bitty example only, on how you can build your own customized solution using out of the box approach !

Syed Jahanzaib


Filed under: Uncategorized

Personnel Notes on Active Directory

$
0
0

ad

Recently our IT dept was going through yearly Audit and we had to provide active directory details asked by the auditor team. I used few commands that saved lot of time to get our desired/trimmed results. and since I mostly use my Ubuntu box to manage large portion of my network, therefore i made few scripts using these commands to be executed from linux based pc.

I had to repeat the whole search criteria every time by refreshing the memory/google, and since it this is a repeating task , and I had to go through the search process every time, I thought to make all these documented so that I can retrieve them when required.

I also linked these scripts with the Linux base WEBMIN, so they can be called by GUI for support staff as well.


Most queries are executed from Linux base system using WINEXE, if you are using windows only then you may want to modify it as required, I am just showing an way of executing AD commands via powershell using *nix 🙂 . The most annoyed thing was to wrap the commands in single/double quotes along with other parameters to make it single liner execution bomb.




Command to Display All users along with every detail / information

winexe -U DOMAIN/ID%PASS //101.11.11.5 'powershell.exe -command "import-module activedirectory; Get-ADUser -Filter * -Properties *"'

Command to display only single user information as mentioned

winexe -U DOMAIN/ID%PASS //101.11.11.5 'powershell.exe -command "import-module activedirectory; Get-ADUser ZAIB-USER-NAME -Properties *"'

Command to display only specific information

winexe -U DOMAIN/ADMIN%"PASSWORD" //10.0.0.0 'powershell.exe -command "import-module activedirectory; Get-ADUser -Filter * -Properties * | select Name,UserPrincipalName,Enabled,LockedOut,Created,LastLogonDate"' 

Show Members from SPECIFIC GROUP group only

dsquery group -samid "Domain Admins" | dsget group -members | dsget user

Show specific user OU & MemberOf

$user = get-aduser USERX;
$memb = (GET-ADUSER –Identity USERX –Properties MemberOf | Select-Object MemberOf).MemberOf -replace "DC=DCNAME*" -replace "CN="
$uo = $user.distinguishedname.substring($user.distinguishedname.indexof(",") + 1,$user.distinguishedname.Length - $user.distinguishedname.indexof(",") - 1)
write-host "$($user.Name) = $($uo.split(',')[0])"
echo "Member of:" $memb

 

Command to get all users and show only following fields

UserPrincipalName,Created,Enabled,MemberOf

winexe -U DOMAIN/ID%PASSWORD //10.0.0.1 'powershell.exe -command "import-module activedirectory; Get-ADUser -Filter * -Properties * | select
UserPrincipalName,Created,Enabled,MemberOf |Format-Table -Property * -AutoSize | Out-String -Width 4096 | Out-File c:\1.txt"'

Query for speciifc User belongs to which groups

winexe -U DOMAIN/ID%PASS //10.0.0.1 'powershell.exe -command "import-module activedirectory; (GET-ADUSER –Identity zaib.user –Properties MemberOf |  Select-Object MemberOf).MemberOf"'

Get Members List of specific Group

winexe -U DOMAIN/ID%PASS //10.0.0.1 'powershell.exe -command "import-module activedirectory; Get-ADGroupMember "'"'Domain Admins'"' |Select name,distinguishedName |  Format-Table -AutoSize"'

Show All Users Created Dated Only using PowerShell

winexe -U DOMAIN/ID%PASSWORD //10.0.0.1 'powershell.exe -command "import-module activedirectory; Get-ADUser -Filter * -Properties Created | Select-Object Name,Created | Sort-Object Created"'

Show Users created in Last 30 days

winexe -U DOMAIN/ID%PASSWORD //10.0.0.1 'powershell.exe -command "import-module activedirectory; $When = ((Get-Date).AddDays(-30)).Date; Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated"'

Show Users created in specific after DATE RANGE

Get-ADUser -Filter * -properties whencreated | ? { $_.whenCreated -ge (get-date "January 1, 2017") -and  $_.whenCreated -le (get-date "January 31, 2017")} |Select Samaccountname,whenCreated,office 

Show Users created in specific after DATE RANGE

winexe -U DOMAIN/ID%PASS //10.0.0.1 'powershell.exe -command "import-module activedirectory;Get-ADUser -Filter * -properties whencreated | ? { $_.whenCreated -ge (get-date "'"'January 1, 2017'"') -and $_.whenCreated -le (get-date "'"'January 31, 2017'"')} |Select Samaccountname,whenCreated,office"'

Show Users DELETED in specific DATA RANGE … [powershell commands]

[datetime]$StartTime = "1/1/2017"
[datetime]$EndTime = "1/15/2017"
Get-ADObject -Filter {(isdeleted -eq $true) -and (name -ne "Deleted Objects") -and (ObjectClass -eq "user")} -includeDeletedObjects -property whenChanged | Where-Object {$_.whenChanged -ge $StartTime -and $_.whenChanged -le $EndTime} |Select Name,whenChanged |Format-Table

Show DISABLED Users Only …

#Method 1 using PS
winexe -U DOMAIN/ID%PASS //10.0.0.1 'powershell.exe -command "import-module activedirectory; search-adaccount -UsersOnly -AccountDisabled | select samAccountName"'

Show users who have not logged in Since 60 days


winexe -U DOMAIN/ID%PASS //10.0.0.1 'powershell.exe -command "import-module activedirectory; $domain = "DOMAIN-NAME"; $DaysInactive = 60; $time = (Get-Date).Adddays(-($DaysInactive)); Get-ADUser -Filter {LastLogonTimeStamp -lt $time -and enabled -eq $true} -Properties LastLogonTimeStamp"'
# Method 3 using dsquery
dsquery user "dc=Your_Domain_Name" -inactive 2

Show DISABLED Users Only using DSQUERY

dsquery user -disabled | dsget user -display -email -dept -title

Show Only Specific User Details [ Method#2]

winexe -U DOMAIN/ID%PASSWORD //10.0.0.1 'Net user ZAIB /domain"'

Get DHCP info from server to acquire some customized report

# 10.0.0.1 IS DOMAIN
# 101.0.0.0 is our scope
winexe -U DC/ID%PASSWRORD //10.0.0.1 'netsh dhcp server scope 101.0.0.0 show clients 1'

Dump DHCP

# Dump DHCP
# 101.11.11.5 IS DOMAIN
# 101.11.14. IS MOBILE DEVICES IP SERIES, SO WE ARE CATCHING IT
# 101.11.11.36 IS GATEWAY
# 101.11.11.6 IS OTHER GATEWAY
winexe -U DC/ID%immi_ar0Z //101.11.11.5 'netsh dhcp server \\DCSERVERNAME dump' &gt; /tmp/dhcp_temp.txt
cat /tmp/dhcp_temp.txt | grep 101.11.14. | awk '{ print $11,$12}' | sed -e 's/"101.11.11.6"//g' -e 's/"101.11.11.36"//g' -e 's/"//g' -e 's/ BOTH//g' | sed '/ \r/d' | sort
cat /tmp/dhcp_temp.txt | grep 101.11.14. | awk '{ print $11,$12}' | sed -e 's/"101.11.11.6"//g' -e 's/"101.11.11.36"//g' -e 's/"//g' -e 's/ BOTH//g' | sed '/ \r/d' | sort | wc -l


Regard’s
Syed Jahanzaib


Filed under: Microsoft Related

Modifying ‘tombstoneLifetime’ value in Active Directory

$
0
0

Default lifetime for tombstone.jpg


What is tombstone Lifetime?

The AD tombstone lifetime determines how long deleted items exist in AD before they are purged, for example users  or other objects. The default value in Windows 2008 is 180 Days.

Why I need to modify its default value,  ?

We want to increase it for some audit purpose, specially to track deleted objects (example how many Users were deleted in last 1 or 2 years)

Let’s Start …

METHOD # 1 – Using GUI Method

Execute ADSIEdit tool by

%SystemRoot%\system32\adsiedit.msc

  • Now using ADSIEdit tool, connect to your domain controller.
  • Navigate to CN=Directory Services , Right click and select Properties.
  • Find tombstoneLifetime and Click Edit,
  • Now define value in days for how long you want to increase the value. I wanted 2 years so I put 630 . This values must be in DAYS.

As showed in the image below …

tombstone.PNG

Note: By Some mistake, i typed 630, whereas the actual number for 2 years is 730, so change it accordingly


METHOD # 2 – Using PowerSHELL Command

Setting Two Years Tombstone Lifetime

Import-Module ActiveDirectory
$ConfNameContext = Get-ADRootDSE | Select-Object -Expandproperty configurationNamingContext
Set-ADObject -Identity "CN=Directory Service,CN=Windows NT,CN=Services,$ConfNameContext" -Replace @{'tombstonelifetime'='730'}

Querying tombstoneLifetime value via command

 

# Using dsquery command

dsquery * " cn=Directory Service,cn=Windows NT,cn=Services,cn=Configuration,dc=agp1" -scope base -attr tombstonelifetime

[COMMAND RESULT OUTPUT]

tombstonelifetime
730

# Using POWERSHELL 

#1

(get-adobject “cn=Directory Service,cn=Windows NT,cn=Services,$(([adsi](“LDAP://RootDSE”)).configurationNamingContext)” -properties “tombstonelifetime”).tombstonelifetime

#2

Import-Module ActiveDirectory
$ConfNameContext = Get-ADRootDSE | Select-Object -Expandproperty configurationNamingContext
Get-ADObject -Identity “CN=Directory Service,CN=Windows NT,CN=Services,$ConfNameContext” -properties tombstonelifetime |Format-List

Note / z@iB:

I found out that all commands doesn’t show default tombstoneLifetime. Once I modify the value, then I was able to see the value using above commands.

Regard’s
Syed Jahanzaib


Filed under: Microsoft Related

PowerShell Reference [Continued Post]

$
0
0

pwoershell-logo

coffe code.PNG

Following is reference post for Powershell command line usage to achieve different tasks. Recently I had to perform various administration tasks on more than 20 windows based servers , and using scripting it made my life a bit easier and I let the scripting  do the task on my behalf on scheduled basis 😉

These are very common tasks, commands but when you combine them with the Linux shell, they become ultra powerful and best thing is that you can create / add  some ‘ Artificial Intelligence ‘ in it. I have posted just basic level to hide the sensitivity of original tasks.

Following is collection of my own R&D, some commands are picked from Stackoverflow/Spicework forums as well.


General PowerShell Related CMD


Check PowerShell Version

$PSVersionTable.PSVersion
Upgrade PowerShell to Version 4 in Windows 7 - 64bit
https://blogs.technet.microsoft.com/heyscriptingguy/2014/11/09/weekend-scripter-install-powershell-4-0-in-windows-7/

Check Powershell Version & Process Architecture

#Check PowerShell Version
$PSVersionTable
# Check Processor Architecture
$env:PROCESSOR_ARCHITECTURE
# Get list of installed HOTFIX with details
Get-HotFix | Format-Table

 # Import Active Directory module

import-module activedirectory

Show Folder Size (in GB) | Sort by Size | Select top 10

This was intense task for me, and I was not able to sort it on my own. so I have to take help from stackoverflow and spicework forums.

Scenario:

We have a Windows 2008 R2  base file server where users have there shared folders.
Example:

  • D:\USERS
  • D:\USERS\USER1
  • D:\USERS\USER2
  • D:\USERS\USER3
  • D:\USERS\USER4
  • D:\USERS\USER5

All users folders have several hundreds sub folders in it.

Task:

Execute functions from Linux base system , which should remote to file server by winexe, execute powershell script, which should perform functions like

  • List all users folder name
  • Last modified time
  • Size conversion auto in kb/mb/gb ( order by size)
  • Email the result [customized] using sendEmail / gmail.

First the powershell script name foldersize.ps1 which will actually perform the functions on file server. we will copy this script in c:\temp on remote file server.

foldersize.ps1


param ($Path = ".")
$disk = ([wmi]"\\FILESERVER\root\cimv2:Win32_logicalDisk.DeviceID='D:'")
"D: GB Total = {0:#.0}
D: GB Used {2:#.0}
D: GB Free {1:#.0} " -f ($disk.Size/1GB),($disk.FreeSpace/1GB),($disk.Size/1GB-$disk.FreeSpace/1GB) | write-output

Get-WmiObject Win32_LogicalDisk -Filter "DriveType='3'" `
-ComputerName FILESERVER | `
Format-Table `
@{l="Server";e={$_.SystemName}}, `
@{l="Drive Letter";e={$_.DeviceID}}, `
@{l="Free Space on Disk (GB)";e={"{0:n2}" -f ($_.freespace/1gb)}}, `
@{l="Total Disk Space (GB)";e={"{0:n2}" -f ($_.size/1gb)}}, `
@{l="Percentage Used";e={ "{0:P2}" -f (1 - ([Int64]$_.FreeSpace / [Int64]$_.Size)) }}

$PrettySizeColumn = @{name="Size";expression={
$size = $_.Size
if ( $size -lt 1KB ) { $sizeOutput = "$("{0:N2}" -f $size) B" }
ElseIf ( $size -lt 1MB ) { $sizeOutput = "$("{0:N2}" -f ($size / 1KB)) KB" }
ElseIf ( $size -lt 1GB ) { $sizeOutput = "$("{0:N2}" -f ($size / 1MB)) MB" }
ElseIf ( $size -lt 1TB ) { $sizeOutput = "$("{0:N2}" -f ($size / 1GB)) GB" }
ElseIf ( $size -lt 1PB ) { $sizeOutput = "$("{0:N2}" -f ($size / 1TB)) TB" }
ElseIf ( $size -ge 1PB ) { $sizeOutput = "$("{0:N2}" -f ($size / 1PB)) PB" }
$sizeOutput
}}

Get-ChildItem -Path $Path | Where-Object {$_.PSIsContainer} | ForEach-Object {
$size = ( Get-ChildItem -Path $_.FullName -Recurse -Force | where {!$_.PSIsContainer} | Measure-Object -Sum Length).Sum
$obj = new-object -TypeName psobject -Property @{
Path = $_.Name
Time = $_.LastWriteTime
Size = $size
}
$obj
} | Sort-Object -Property Size -Descending | Select-Object Path, Time, $PrettySizeColumn

try to execute this file on the file server from powershell terminal. It should give you proper results. JUST BE VERY SURE TO READ THE SCRIPT VERY WELL, AS IT SHOULD BE MODIFIED AS PER YOUR REQUIREMENTS, PLUS I USED DOMAIN ADMIN ID, SO I HAD ALL THE ACCESS ON ALL THE COMPUTERS FROM MY PC /REMOTELY AS WELL.

.\foldersize.ps1 -Path  \\FILESERVER\C$\Softwares\IMAGES_ISO

Once done,  make a bash script in your linux (ubuntu) system  which will execute the above script remotely and will customized the result and email to the admin.

BASH FILE / folder_iquiry.sh which will run the ps file from linux terminal


#!/bin/bash
#set -x
# This bash script will query remote file server storage using Powershell Commands.
# It will send report via email with relevant details like top used folders , Very useful some times.
# Syed Jahanzaib / aacableAThotmailDOTcom
# http://aacableDOTwordpressDOTcom
# 20-feb-2017
start=`date +%s`
COMPANY="ZAIB"
SRVNAME="SRV01"
SRV_FRIENDLY_NAME="File Server D:Drive"
IP="10.0.0.1"
DOMAIN="DC.LOCAL"
PASS="PASSWORD"
ID="ADMIN"
#TARGET DIRECTORY
TDIR="d:\users"
TEMP_HOLDER="/tmp/xdrive_temp_raw_report.txt"
TEMP_HOLDER_FINAL="/tmp/xdrive_final_mail_report.txt"
> $TEMP_HOLDER
> $TEMP_HOLDER_FINAL
DATE=`date`

# GMAIL DETAILS to send EMAIL alert
SENDMAILAPP="/temp/sendEmail-v1.56/sendEmail"
GMAILID="ADMIN_GMAIL_ID@gmail.com"
GMAILPASS="GMAIL_PASS"
# Add recipient email address below
ADMINMAIL1="aacableAThotmailDOTcom"

MSG_SUB="$COMPANY $SRV_FRIENDLY_NAME - $SRVNAME - / Weekly Report @ $DATE"
MSG_BODY="$COMPANY $SRV_FRIENDLY_NAME - $SRVNAME - Weekly Report for Users D: drive folder's sorted by size
@ $DATE
"

FOOTER="Automated Weekly Report Generated using Linux Powered Powershell !!
Sys. Admin
$COMPANY IS Dept."

echo "
$MSG_BODY
" > $TEMP_HOLDER

#QUERY SERVER X: DRIVE
winexe -U $DOMAIN/$ID%"$PASS" //$IP 'powershell.exe -inputformat none -command "c:\temp\foldersize.ps1 -Path '"$TDIR"' ' >> $TEMP_HOLDER

# Remove Junk Line with unknonw character, which is unique or specific occured in my lab test

end=`date +%s`
echo "It took $(($end - $start)) seconds to complete this task..." >> $TEMP_HOLDER
echo "
$FOOTER" >> $TEMP_HOLDER

#Print result
cat $TEMP_HOLDER
#send email
sendemail -u "$MSG_SUB" -o tls=yes -s smtp.gmail.com:587 -t $ADMINMAIL1 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$TEMP_HOLDER -o message-content-type=text

# Script ends here

Now execute file from linux terminal like this...

/temp/folder_inquiry.sh

SAMPLE:

userreport.PNG

 


Show Folder Size (in GB) | Sort by Size | Select top 10

[This method have one BIG disadvantage, dueto 260 characters limit in windows, it may not show files/folders above then this limit. so it may not give your correct result if you have some deep folder structure/long files name in it.]

#Windows PS Version
ls c:\temp | select Name, @{Name="Type";Expression={if($_.psIsContainer){"---Directory---"}else{"---File---"}}}, @{Name="Size(GB)";Expression={[Math]::Round($(ls $_.FullName -recurse| measure Length -sum).Sum/1GB, 2)}}| sort -property "Size(GB)" -desc | Select -First 10

# Linux Winexe format
winexe -U DC/ID%PASS //IP 'powershell.exe -inputformat none -command "ls c:\backup\ | select Name, @{Name='"'"'"Type"'"'"';Expression={if($_.psIsContainer){'"'"'"Directory"'"'"'}else{'"'"'"File"'"'"'}}}, @{Name='"'"'"Size(GB)"'"'"';Expression={[Math]::Round($(ls $_.FullName -recurse| measure Length -sum).Sum/1GB, 3)}}| sort -property '"'"'"Size(GB)"'"'"' -desc | Select -First 10"'

Example of C:\temp contents ...

  • C:\TEMP
  • C:\TEMP\FOLDER1
  • C:\TEMP\FOLDER-1\SUB_FOLDER
  • C:\TEMP\FOLDER-1\SUB_FOLDER_MORE
  • C:\TEMP\FOLDER2
  • C:\TEMP\FOLDER3

This will query all folders/sub-folders inside the c:\temp folder, and display only the main folders name including sizes of subfolder as well ..

Name Type Size(GB)
---- ---- --------
Win2008_test Directory 28.9
Ubuntu-PHP-API Directory 2.75
ubuntu-freeradius Directory 2.15
zaib_temp_radius Directory 2.09
MIKROTIK-1 - Copy Directory 0.39

 


Show files with Name & Size greater than 5 GB

[This was required in a script where I schedule it to email the top users in mail server by querying the folder directly]

Following command is formatted to be executed by WINEXE [Linux]

winexe -U $DOMAIN/$ID%"$PASS" //$IP 'powershell.exe -inputformat none -command "Get-ChildItem -Path '"$TDIR"' | Where-Object {$_.length -gt 5GB} | Sort-Object -descending -Property Length | Format-Table Name,@{name='"'"'Size GB'"'"';expression={$_.length/1GB};FormatString='"'"'N1'"'"'}"' | sed -e "$DEL_LINE" | sed '/^\s*$/d' |nl >> $TEMP_HOLDER

Script to get specific folder files and specific  folder total size, sort and email to admin on every Monday / Weekly

#!/bin/bash
#set -x
# This bash script will query remote lotus domino mail server storage using Powershell Commands.
# It will send report via email with erelevant details, Very useful some times.
# Syed Jahanzaib / aacableAThotmailDOTcom
# http://aacableDOTwordpressDOTcom
# 20-feb-2017
COMPANY="ZAIB"
SRVNAME="MYSRV"
IP="10.0.0.1"
DOMAIN="DC_NAME"
PASS="PASSWORD"
ID="ADMINISTRATOR"
TDIR="D:\lotus\domino\data\mail"
TDIR_FULL="D:\lotus"
TDIR_MAIL="D:\lotus\domino\data\mail"
TDIR_ARCH="D:\lotus\domino\data\archive"
# How many lines to be dleeted from winexe output for top users section
DEL_LINE="1,3d"
TEMP_HOLDER="/tmp/mail_top_users.txt"
TEMP_HOLDER_FULL="/tmp/mail_lotus_folder_size.txt"
> $TEMP_HOLDER
DATE=`date`

# GMAIL DETAILS to send EMAIL alert
SENDMAILAPP="/temp/sendEmail-v1.56/sendEmail"
GMAILID="ADMIN_GMAIL_ID@gmail.com"
GMAILPASS="GMAIL_PASSWORD"
# Add recipient email address below
ADMINMAIL1="aacableAThotmailDOTcom"

MSG_SUB="$COMPANY Lotus Mail Server / Weekly Report @ $DATE"
MSG_BODY="$COMPANY - $SRVNAME - Lotus Mail Server Weekly Report for Total Usage and TOP users exceeding 5GB mailbox size
@ $DATE
"
FOOTER="Automated Weekly Report Generated using Linux Powered Powershell !!
Sys. Admin
$COMPANY IS Dept."

echo "
$MSG_BODY
" > $TEMP_HOLDER

#Full size of Lotus Folder - Overall
FULL_SIZE=`winexe -U $DOMAIN/$ID%"$PASS" //$IP 'powershell.exe -inputformat none -command " "\"{0:N0}"\" -f ( (Get-ChildItem -Path '"$TDIR_FULL"' -Recurse | Measure-Object -Property Length -Sum ).Sum / 1GB)"' |sed '/^\s*$/d'`
echo "Lotus Total DATA size in GB = $FULL_SIZE" >> $TEMP_HOLDER

#Full size of Lotus MAIL Folder only
FULL_SIZE_MAIL=`winexe -U $DOMAIN/$ID%"$PASS" //$IP 'powershell.exe -inputformat none -command " "\"{0:N0}"\" -f ( (Get-ChildItem -Path '"$TDIR_MAIL"' -Recurse | Measure-Object -Property Length -Sum ).Sum / 1GB)"' |sed '/^\s*$/d'`
echo "Lotus Total User Inbox MAIL SIZE in GB = $FULL_SIZE_MAIL" >> $TEMP_HOLDER

#Full size of Lotus ARCHIVE Folder only
FULL_SIZE_ARCH=`winexe -U $DOMAIN/$ID%"$PASS" //$IP 'powershell.exe -inputformat none -command " "\"{0:N0}"\" -f ( (Get-ChildItem -Path '"$TDIR_ARCH"' -Recurse | Measure-Object -Property Length -Sum ).Sum / 1GB)"' |sed '/^\s*$/d'`
echo "Lotus User's ARCHIVE Folder SIZE in GB = $FULL_SIZE_ARCH" >> $TEMP_HOLDER

echo "----------------------------------------------
Lotus Users List whose inbox is exceeding 5 GB" >> $TEMP_HOLDER

#Only Top users exceeding 5GB
winexe -U $DOMAIN/$ID%"$PASS" //$IP 'powershell.exe -inputformat none -command "Get-ChildItem -Path '"$TDIR"' | Where-Object {$_.length -gt 5GB} | Sort-Object -descending -Property Length | Format-Table Name,@{name='"'"'Size GB'"'"';expression={$_.length/1GB};FormatString='"'"'N1'"'"'}"' | sed -e "$DEL_LINE" | sed '/^\s*$/d' |nl >> $TEMP_HOLDER

echo "

$FOOTER" >> $TEMP_HOLDER
# Display result by cat
cat $TEMP_HOLDER
# Send email
sendemail -u "$MSG_SUB" -o tls=yes -s smtp.gmail.com:587 -t $ADMINMAIL1 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$TEMP_HOLDER -o message-content-type=text

Result of above script ...

1.PNG


Regard's
Syed Jahanzaib


Filed under: Microsoft Related

Radius Manager Theme/Skin Collection

$
0
0

Following are few customized themes for DMASOFTLAB Radius manager , Designed by various web developers.

  1. Digital Theme [Responsive as well, made by KANGNDO]
  2. Green Theme
  3. Blue Theme

 


General Steps to install theme

I assume you have DMASoftlab Radius Manager 4.1.x version installed and must be fully functional.

  • Download the theme file, unrar it in any temporary folder. you can use `tar zxvf filename.tar.gz /destination_folder`
  • Copy (or let’s say Overwrite) all the contents including files/folders from the (unzipped) folder name radiusmanager in /var/www/radiusmanager (or for CENTOS, its /var/www/html/radiusmanager). You can cp -vr syntax /source /target
  • Clear the browser cache, and reload the ACP administration control panel) page.

.


1- Digital Theme

Download Link: Radius Manager KANGNDO Theme Official Link

🙂

Sample Images:

1

2

3

4


2- Green Theme

Green Theme Download Link

green-1

 


Will update more later

 

Regard’s
Syed Jahanzaib


Filed under: Radius Manager

RM Reseller Monthly Report via GMAiL

$
0
0

hosting-by-the-hour

Disclaimer: This is not a reliable method for some OP to acquire the monthly sale report done by reseller. It requires some criteria to match like strict account creation by specific reseller id only. Better to use provided GUI in DMA_RM to inquire the proper report.

This is just a personal way of collecting reporting via automated email which MUST be cross verified by the OP .

Z@iB


BASH:

Following is a bash script which will simply query invoices, categorize it according to reseller account, format it using html coding, sort, total and send email admin.

Sample of Report is as follows.

 

1

RM Reseller Monthly Report via email

2

RM Reseller Monthly Report via email

Schelde following script via crontab @monthly. Modify information as per your local network.



#!/bin/bash
# Script to query INVOICES section of Radius manager mysql, and
# categorize it according to resellers , calculate accounts,sort and total it.
# These are my personal way of doing things, and no one is bound to agree with these.
# Created: Year 2014
# set -x
# MYSQL USER ID PASSWORD
SQLUSER="root"
SQLPASS="YOUR_MYSQL_PASSWORD"

# DATE RELATED STUFF
LASTMY=`date +'%Y-%m' -d 'last month'`
LAST_MONTH_DIGIT=`date +'%m' -d 'last month'`
YEAR_DIGIT=`date +'%Y' -d 'last month'`
LAST_MONTH_LAST_DATE=`cal $LAST_MONTH_DIGIT $YEAR_DIGIT |egrep -v [a-z] |wc -w`
START="$LASTMY-01"
END="$LASTMY-$LAST_MONTH_LAST_DATE"
FMONTH=`date +'%B-%Y' -d 'last month'`
DATE=`date`

# EMAIL RELATED STUFF
TO1="YOUR_EMAIL_ID@hotmail.com"
GMAILID="GMAIL_ID_TO_SEND_EMAIL_FROM@gmail.com"
GMAILPASS="GMAIL_PASSWORD"
CONTENT_TYPE="text/html"

# LOG FILES
FILE="/tmp/dealer_renewal_month.html"
FINALFILE="/tmp/dealer_renewal_month_final.html"
COMPANY="ZAIB(Pvt)_Ltd.
This System is powered by Syed_Jahanzaib aacable@hotmail.com"
BODY_TITLE="Report&nbsp;For&nbsp;Dealer&nbsp;Account&nbsp;asof&nbsp;$FMONTH"
> $FILE
> $FINALFILE

# HTML BODY
echo "
<pre>" > $FILE
echo "<b>$BODY_TITLE</b>" >> $FILE
echo "<b>DEALER User's_Activated Used_Amount Balance</b>
" >> $FILE

# QUERY MANAGERS FROM RM_MANAGERS TABLE
mysql -u$SQLUSER -p$SQLPASS --skip-column-names -e "use radius; select managername from rm_managers;" | while read dealer
do
num=$[$num+1]
DEALER=`echo $dealer | awk '{print $1}'`

# GATHER DATA OF ACTIVE USERS, USED AMOUNT, CURRENT BALANCE, (MOBILE NUMBER IF SMS IS REQUIRED TO SEND)
ACTIVEUSERSNO=`mysql -uroot -p$PASS --skip-column-names -e "use radius; SELECT price FROM rm_invoices LEFT JOIN rm_users ON rm_users.username = rm_invoices.username WHERE date >= '$START' AND date <= '$END' AND (paymode = '0' OR paymode = '1' OR paymode = '2' OR paymode = '3' OR paymode = '4' OR paymode = '5' OR paymode = '6' OR paymode = '7' OR paymode = '8' OR paymode = '9' OR paymode = '10' OR paymode = '11' ) AND (invgroup = '0' ) AND invnum != '' AND rm_users.owner = '$DEALER';" | sed '/credited/d' | wc -l`
USEDAMOUNT=`mysql -uroot -p$PASS --skip-column-names -e "use radius; SELECT price FROM rm_invoices LEFT JOIN rm_users ON rm_users.username = rm_invoices.username WHERE date >= '$START' AND date <= '$END' AND (paymode = '0' OR paymode = '1' OR paymode = '2' OR paymode = '3' OR paymode = '4' OR paymode = '5' OR paymode = '6' OR paymode = '7' OR paymode = '8' OR paymode = '9' OR paymode = '10' OR paymode = '11' ) AND (invgroup = '0' ) AND invnum != '' AND rm_users.owner = '$DEALER';" | sed '/credited/d' | awk '{ sum+=$1} END {print sum}'`
BALANCE=`mysql -u$SQLUSER -p$SQLPASS --skip-column-names -e "use radius; select balance from rm_managers WHERE managername = '$DEALER';" |cut -f1 -d"."`
MOBILE=`mysql -u$SQLUSER -p$SQLPASS --skip-column-names -e "use radius; select mobile from rm_managers WHERE managername = '$DEALER';"`
SRV=`mysql -uroot -p$SQLPASS --skip-column-names -e "use radius; SELECT SQL_CALC_FOUND_ROWS rm_invoices.service FROM rm_invoices LEFT JOIN rm_users ON rm_users.username = rm_invoices.username WHERE date >= '$START' AND date <= '$END' AND (paymode = '0' OR paymode = '2' ) AND (invgroup = '0' OR invgroup = '1' ) AND invnum != '' AND rm_users.owner = '$DEALER' ORDER BY id LIMIT 0, 10000;" | sed '/credited/d' | awk '{print $1}' | sort | uniq -c`

#LOOK FOR ZERO VALUE AMOUNT AND REPLACE IT WITH 0 , IF FOUND
#if [ ! -n "$USEDAMOUNT" ]; then
#if [ "USEDAMOUNT == "" ]; then
#USEDAMOUNT="X"

# PRINT ALL GATHERED DATA INTO FILE
#echo "<b>$DEALER</b> $ACTIVEUSERSNO $USEDAMOUNT - $BALANCE
#------------------------------------------------------------------------" >> $FILE
#else

# PRINT ALL GATHERED DATA INTO FILE
echo "<b>$DEALER</b> $ACTIVEUSERSNO $USEDAMOUNT - $BALANCE

Details&nbsp;of&nbsp;Services&nbsp;Activated:
Qty Service&nbsp;Name

$SRV

------------------------------------------------------------------------" >> $FILE

#fi
done

# MAKE COLUMNS SO THAT IT GETs EASIER TO READS
sed -e 's/\t//g' $FILE | column -t | sed 's/ //g' | sed 's/ User/User/g' > $FINALFILE
# GATHER DATA OF ACTIVE USERS, USED AMOUNT, CURRENT BALANCE, (MOBILE NUMBER IF SMS IS REQUIRED TO SEND)
TOTNO=`mysql -uroot -p$PASS --skip-column-names -e "use radius; SELECT price FROM rm_invoices LEFT JOIN rm_users ON rm_users.username = rm_invoices.username WHERE date >= '$START' AND date <= '$END' AND (paymode = '0' OR paymode = '1' OR paymode = '2' OR paymode = '3' OR paymode = '4' OR paymode = '5' OR paymode = '6' OR paymode = '7' OR paymode = '8' OR paymode = '9' OR paymode = '10' OR paymode = '11' ) AND (invgroup = '0' ) AND invnum != '';" | sed '/credited/d' | wc -l`
SALES=`mysql -uroot -p$PASS --skip-column-names -e "use radius; SELECT price FROM rm_invoices LEFT JOIN rm_users ON rm_users.username = rm_invoices.username WHERE date >= '$START' AND date <= '$END' AND (paymode = '0' OR paymode = '1' OR paymode = '2' OR paymode = '3' OR paymode = '4' OR paymode = '5' OR paymode = '6' OR paymode = '7' OR paymode = '8' OR paymode = '9' OR paymode = '10' OR paymode = '11' ) AND (invgroup = '0' ) AND invnum != '';" | sed '/credited/d' | paste -sd+ | bc | cut -f1 -d"."`

echo "Total Users Activated/Renewed in $FMONTH = <b>$TOTNO</b>" >> $FINALFILE
echo "Total SALES Done in $FMONTH = <b>$SALES</b>" >> $FINALFILE
echo "
<b>$COMPANY</b>" >> $FINALFILE
echo "Generated on $DATE" >> $FINALFILE
echo "</pre>
" >> $FINALFILE

##Finally send email with all the data gathered USING SEND_EMAIL TOOL
/temp/sendEmail-v1.56/sendEmail -t $TO1 -u "INFO: GT DEALERS MONTHLY BILLING INFO for $FMONTH" -o tls=yes -s smtp.gmail.com:587 -xu $GMAILID -xp $GMAILPASS -f $GMAILID -o message-file=$FINALFILE -o message-content-type=$CONTENT_TYPE
# Type file for view
cat $FINALFILE

 


Filed under: Radius Manager

Cisco Access Point Short Notes !

$
0
0

2017-03-03 16.47.48.jpg

 

Last year we replaced our old Cisco Aironet Access Points series with the new Ubiquiti AP-LR/AC model. Old switches were then placed in inventory to be used as a backup. Since these cisco AP were configured 8-10 years ago, therefore I had to reset all of them. I made short notes for the process, just in case I need it again in future or maybe useful for anyone else needing similar.

Syed.Jahanzaib


1- Cisco Aironet AP Reset to Factory Default

Note: I used Cisco Aironet AIR-AP1242AG-E-K9 access point model in this post

  1. Connect Console cable from the AP Console port to your PC COM port.
  2. Open Hyper Terminal and use below mentioned settings
    9600 baud
    8 data bits
    None parity
    1 stop bit
    Xon/Xoff Flow control .If xon/xoff flow control does not work, use no flow control.
  3. Disconnect power from access point
  4. Press and hold the MODE button while you reconnect power to the access point.
  5. Hold the MODE button until the Status LED turns amber (generally for 2-3 seconds max), and release the button
  6. After the AP reboots, it will come to default settings & you can re-configure the access point by using CLI or GUI. Default IP is 10.0.0.1

  7. The default username and password is cisco/Cisco [ 'C'  is capital in password]

As shown below ….


Press RETURN to get started.

Xmodem file system is available.
flashfs[0]: 158 files, 7 directories
flashfs[0]: 0 orphaned files, 0 orphaned directories
flashfs[0]: Total bytes: 15998976
flashfs[0]: Bytes used: 8549888
flashfs[0]: Bytes available: 7449088
flashfs[0]: flashfs fsck took 33 seconds.
Base ethernet MAC Address: 00:1e:be:25:68:d0
Initializing ethernet port 0...
Reset ethernet port 0...
Reset done!
ethernet link up, 100 mbps, full-duplex
Ethernet port 0 initialized: link is up
button pressed for 6 seconds
process_config_recovery: set IP address and config to default 10.0.0.1
Loading "flash:/c1240-k9w7-mx.124-10b.JA/c1240-k9w7-mx.124-10b.JA"...###########
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
######################################################

File "flash:/c1240-k9w7-mx.124-10b.JA/c1240-k9w7-mx.124-10b.JA" uncompressed and
installed, entry point: 0x3000
executing...

Restricted Rights Legend

Use, duplication, or disclosure by the Government is
subject to restrictions as set forth in subparagraph
(c) of the Commercial Computer Software - Restricted
Rights clause at FAR sec. 52.227-19 and subparagraph
(c) (1) (ii) of the Rights in Technical Data and Computer
Software clause at DFARS sec. 252.227-7013.

cisco Systems, Inc.
170 West Tasman Drive
San Jose, California 95134-1706

Cisco IOS Software, C1240 Software (C1240-K9W7-M), Version 12.4(10b)JA, RELEASE
SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2007 by Cisco Systems, Inc.
Compiled Wed 24-Oct-07 15:31 by prod_rel_team
Image text-base: 0x00003000, data-base: 0x00859060

Initializing flashfs...

flashfs[1]: 157 files, 7 directories
flashfs[1]: 0 orphaned files, 0 orphaned directories
flashfs[1]: Total bytes: 15998976
flashfs[1]: Bytes used: 8548352
flashfs[1]: Bytes available: 7450624
flashfs[1]: flashfs fsck took 4 seconds.
flashfs[1]: Initialization complete....done Initializing flashfs.
Radio 1 A506 7100 E8000000 A0000000 80000000 3
Radio 1 A506 6700 E8000100 A0040000 80010000 2

This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.

A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to
export@cisco.com.

cisco AIR-AP1242AG-E-K9 (PowerPCElvis) processor (revision A0) with 24566K/81
92K bytes of memory.
Processor board ID FCZ1213815G
PowerPCElvis CPU at 262Mhz, revision number 0x0950
Last reset from power-on
1 FastEthernet interface
2 802.11 Radio(s)

32K bytes of flash-simulated non-volatile configuration memory.
Base ethernet MAC Address: 00:1E:xx:xx:xx:xx
Part Number : 73-10256-06
PCA Assembly Number : 800-xxxxx-05
PCA Revision Number : A0
PCB Serial Number : FOCxxxxNE3
Top Assembly Part Number : 800-xxxx-01
Top Assembly Serial Number : FCZxxxxxxG
Top Revision Number : A0
Product/Model Number : AIR-AP1242AG-E-K9

Press RETURN to get started!


IP Related Configuration …

>

To configure new ip address


en
configure t
ip address 10.0.0.1 255.0.0.0
no ip route-cache

Now open browser and point to the ip you configured above, & do reset of config using express setup or as required 🙂

cisco aironet eexpres setup zaib.PNG


Howto ADD SSID

cisco-aironet-ssid-after-reset


Howto ENABLE RADIO / WiFi 

cisco-aironet-howto-enable-radio

Note: Enable Both Radio using above step …


To show current IP,

en
show ip interface brief

To Save Config

en
wr

 

Regard’s
Jz!


Filed under: Cisco Related

MS Project 2016 has stopped working on assign resources

$
0
0

microsoft-project-2016-license-key-e1469786312356

Recently we purchased Microsoft Project 2016 licenses for our users. In terms of Functionality – All seems to be working fine except assigning resources

Whenever user tried to assign resources using option `Assign Resources` , project crashed/stopped working with below error …

ms_project_2017_stopped_wroking

 

After little R&D, we found that this is a standard bug in MS Project 2016 and it was fixed with Patch released on February 9, 2016

February 9, 2016, update for Project 2016 (KB3114714)

After updating patch, all went fine.


Advise of the day ! (Golden Rule)

Although we have WSUS (Windows Update Servers) in our organization which regularly update the clients windows , but general patches for MS OFFICE was not selected in the checklist, & that’s the main reason why we had to face this issue. Always keep your Windows and other softwares UP TO DATE. It will keep you away from UNWANTED guests 😉 You know what I mean 🙂

Regard’s
Syed Jahanzaib


Filed under: Microsoft Related
Viewing all 409 articles
Browse latest View live