Monday, February 22, 2016

Graph Base Policy

Graph Base Policy

First need to get these:
- On Router allow your server IP to check that Router
- Info on Router: router-01#show policy-map interface tenGigabitEthernet 0/0/1.298 output

Step1:  Get ifindex for the cl-ggc. (The fastest way is get this index from Cacti)
index: 44

Step2: Get the cbQosIfndex for corresponding IfIndex in router
snmpwalk -v 2c -cPuBlic_SNMP router-01 1.3.6.1.4.1.9.9.166.1.1.1.1.4 | grep -i 44

SNMPv2-SMI::enterprises.9.9.166.1.1.1.1.4.704 = INTEGER: 44 in 704
SNMPv2-SMI::enterprises.9.9.166.1.1.1.1.4.706 = INTEGER: 44 out 706

Step3: Below is the mib to get the names of class-map configured on the router
snmpwalk -v2c -c PuBlic_SNMP router-01 1.3.6.1.4.1.9.9.166.1.7.1.1.1 |egrep -i cl-ggc
SNMPv2-SMI::enterprises.9.9.166.1.7.1.1.1.366370270 = STRING: "cl-ggc"

Step4: cbQosConfigIndex can be for the class-map can be fetch from following mib
snmpwalk -v2c -c PuBlic_SNMP router-01 1.3.6.1.4.1.9.9.166.1.5.1.1.2 | egrep -i 'Gauge32: 366370270'
SNMPv2-SMI::enterprises.9.9.166.1.5.1.1.2.704.65536 = Gauge32: 366370270
SNMPv2-SMI::enterprises.9.9.166.1.5.1.1.2.706.65536 = Gauge32: 366370270

So:
in: TenGi 0/0/1.298 - customer - youtube - in
.1.3.6.1.4.1.9.9.166.1.15.1.1.11.704.65536

out: TenGi 0/0/1.298 - customer - youtube - out
.1.3.6.1.4.1.9.9.166.1.15.1.1.11.706.65536

On Cacti need to add these policy in and out, and create the graph policy and select those policy in and out.

Saturday, February 20, 2016

Ubuntu Repository - 14.10

Ubuntu Repository - 14.10

Some your Ubuntu repo was broken, error or can not install any packages, 
Comment your own repo and add these line and run 
deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

Friday, February 19, 2016

Script Check WiFi Users Connected

Script Check WiFi Users Connected

#!/bin/bash
# By: Vannak Ken
# This script going to check on the connected user on wifi in the wifi listed.
TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S`
MAILTO="ken.vannakk@gmail.com vannak.ken@example.com"
for i in `cat /opt/scripts/wifi/all-wifi.txt`;
    do
        # ------------------------------- NUMBER USERS CONNECTED ------------------------------------------ #
        USERCONNECTED=`snmpwalk $i -v 1 -c PuBlic_SNMP-RO enterprises.41112.1.4.5.1.15.1 |awk '{print $4}'`
        echo "$i : $USERCONNECTED" >> /opt/scripts/wifi/wifi-report-$TIMESTAMP.txt
        #USERS CONNECT MORE THE 20 SEND EMAIL
        USERMAX=20
        if [[ "$USERCONNECTED" -ge "$USERMAX" ]];
                then
                        echo "$i Users More Than 20." > /opt/scripts/wifi/wifi-20users-or-more.txt
                        mail -s "$i Users More Than 20" $MAILTO < /opt/scripts/wifi/wifi-20users-or-more.txt
                else
                        echo "$i Users Less Than 20"
        fi
        # ------------------------------------------------------------------------------------------------- #
        # -------------------------------- CHECK WIFI NO USER OR CAN NOT CONNECTED ------------------------ #
        NOUSER=0
        if [[ "$USERCONNECTED" == "$NOUSER" ]]; then
                       echo "$i No Users connected." > /opt/scripts/wifi/wifi-no-users-connected.txt
                        mail -s "$i No Users connected." $MAILTO < /opt/scripts/wifi/wifi-no-users-connected.txt
                else
                        if [[ -z "$USERCONNECTED" ]] ; then
                                echo "$i Cannot Connected." > /opt/scripts/wifi/wifi-cannot-connected.txt
                                mail -s "$i Cannot Connected" $MAILTO < /opt/scripts/wifi/wifi-cannot-connected.txt
                           else
                                echo "$i Connected normally."
                        fi
        fi
        # ------------------------------------------------------------------------------------------------- #
    done
# Send email with ttached the report
mail -s "Wifi Report - $TIMESTAMP" $MAILTO < /opt/scripts/wifi/wifi-report-$TIMESTAMP.txt
rm -rf /opt/scripts/wifi/wifi-20users-or-more.txt
rm -rf /opt/scripts/wifi/wifi-no-users-connected.txt
rm -rf /opt/scripts/wifi/wifi-cannot-connected.txt
# Remove old report
find /opt/scripts/wifi/ -name "*.txt" -mtime +30 -exec rm -f {} \;

Friday, February 5, 2016

Script Monitor SSH

Script Monitor SSH

This is the script that monitor SSH session that check grep the specific word in the SSH login file. 

#!/bin/bash
cat /var/log/secure |egrep '(Accepted password|session opened for)' > /var/log/monitor-ssh.log
tail -F /var/log/secure | egrep --line-buffered '(Accepted password|session opened for)' | while read ;
do
mail -s "User Loged In - ServerName" ken.vannakk@gmail.com < /var/log/monitor-ssh.log ;
done
# ------------------------------------------------ End Of Script ----------------------------------------------------#

Copy this content above  put in a file and set in the crond.

Note: Run this script only one time, and keep it process running to keep monitor.