Archive

Archive for June, 2011

คำสั่งเช็ค Lan network data ต่าง ๆ

June 29, 2011 Leave a comment

ดูข้อมูล Network เบื้องต้น eth0 = Device lan ตัวแรกeth1  = Device lan ตัวสอง

ethtool eth0

เช็ค Connect / Netstat command เพื่อดู Connection

netstat -nat

เช็ค Connect / เฉพาะ ESTABLISHED

netstat -nat | grep ‘ESTABLISHED’

Categories: Linux Tags: , , ,

วิธีลง tcptrack สำหรับ Monitor Traffic และ Connection

June 29, 2011 Leave a comment

tcptrack เป็นโปรแกรมที่ไว้ใช้สำหรับ Monitor Connection / Traffic แบบ Real-time
ลงโปรแกรมผ่าน Terminal โดยใช้คำสั่งข้างล่างนี้

สำหรับ Redhat (RHEL) / Fedora / CentOS

# cd /tmp/
# wget http://dag.wieers.com/rpm/packages/tcptrack/tcptrack-1.1.5-1.2.el5.rf.x86_64.rpm
# rpm -ivh tcptrack-1.1.5-1.2.el5.rf.x86_64.rpm

สำหรับ Debian / Ubuntu

$ sudo apt-get install tcptrack

Command เวลาใช้

tcptrack -i eth0

สามารถเลือกดูแบบ port ที่กำหนดได้ เช่น (SMTP)

# tcptrack -i eth0 port 25

หรือคำสั่งข้างล่างนี้ สำหรับ Monitor Port 80

# tcptrack -i eth0 port 80

สามารถตรวจ Connection แบบไอพีเดียวได้ด้วย

# tcptrack -i eth0 src or dst 76.11.22.12

*หมายเหตุ eth0 เป็นหมายเลข Device ของ Lan ซึ่งปกติจะเป็น eth0 หากมี Device lan เชื่อมต่อมากกว่าหนึ่งก็สามารถเปลี่ยนเป็น eth1 ได้

Categories: Linux Tags:

Time Dropdown helper

June 7, 2011 Leave a comment
        function buildDayDropdown($name='',$value='',$atr='')
        {
            $days='';
            while ( $days <= '31'){
                $day[]=$days;$days++;
            }
            return form_dropdown($name, $day, $value,$atr);
        }

        function buildYearDropdown($name='',$value='',$atr='')
        {
            $years=10;
            while ( $years <= '31'+date('y')){
                $year['20'.$years]='20'.$years;$years++;
            }
            return form_dropdown($name, $year, $value,$atr);
        }

        function buildMonthDropdown($name='',$value='',$atr='')
        {
            $month=array(
                '01'=>'January',
                '02'=>'February',
                '03'=>'March',
                '04'=>'April',
                '05'=>'May',
                '06'=>'June',
                '07'=>'July',
                '08'=>'August',
                '09'=>'September',
                '10'=>'October',
                '11'=>'November',
                '12'=>'December');
            return form_dropdown($name, $month, $value,$atr);
        }

        function buildHourDropdown($name='',$value='',$atr='')
        {
            for($x=00;$x <= 23; $x++){
                $hour[sprintf("%02d", $x)] = sprintf("%02d", $x);
            }
            return form_dropdown($name, $hour, $value,$atr);
        }
        function buildMinDropdown($name='',$value='',$atr='')
        {
            for($x=00;$x <= 59; $x++){
                $min[sprintf("%02d", $x)] = sprintf("%02d", $x);
            }
            return form_dropdown($name, $min, $value,$atr);
        }

Form Helper

June 7, 2011 Leave a comment
function countryDropdown($name='',$value='',$atr='')
{
    $CI =& get_instance();
    $query = $CI->db->get('country');
    $data[''] = '-- เลือกประเทศ --';
    if ($query->num_rows() > 0){
       foreach ($query->result_array() as $row){
           $data[$row['country_code']] = $row['country_name'];
       }
    }
    return form_dropdown($name, $data, $value,$atr);
}
Categories: Codeigniter Tags: , ,