Linux.com

linuxcrazy

linuxcrazy

  • Linux.com Member
  • Posts: 2
  • Member Since: 10 Jul 13
  • Last Logged In: 10 Oct 13

Latest Posts

Posted by
Topic
Post Preview
Posted
  • linuxcrazy
    MRTG
    MRTG consists of a Perl script which uses SNMP to read the traffic counters of your routers and a fast C program which logs the traffic data and creates beautiful graphs representing the traffic on the monitored network connection. These graphs are embedded into webpages which can be viewed from any modern Web-browser. MRTG is not limited to monitoring traffic, though. It is possible to monitor any SNMP variable you choose. You can even use an external program to gather the data which should be monitored via MRTG. MRTG uses to monitor things such as System Load, Login Sessions, Modem availability and more. MRTG even allows you to accumulate two or more data sources into a single graph. MRTG (Multi Router Traffic Grapher) is an application that allows us to observe the traffic of a network. It generates html pages with graphs which are refreshed according to our network’s current state. Make sure SNMP server is working. Without proper working [url=http://www.expertslogin.com/linux-how-to/snmp-configuration-file/]SNMP Server[/url], mrtg will not work. Therefore, first step is making sure snmp up and running. Type the following rpm command to find out, if snmp server installed or not [code]# rpm -qa | grep snmp[/code] Determine if snmp server is running or not [code]# ps -aux | grep snmp[/code] [b]OUTPUT[/b] [b]root 5512 0.0 2.3 5872 3012 pts/0 S 22:04 0:00 /usr/sbin/snmpd[/b] Install SNMP using the following command as a root user [code]# yum install net-snmp-utils net-snmp[/code] [code]# service snmpd start[/code] Make sure snmpd service starts automatically, when linux comes us (add snmpd service): [code]# chkconfig --add snmpd # chkconfig snmpd on[/code] Check snmp server configured properly [code]# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex[/code] OUTPUT [b]ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1[/b] [b]ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.0.3 = 2[/b] [b]MRTG[/b] Mrtg software may install during initial installation; you can verify if MRTG installed or not with the following RPM command: [code]#rpm -qa | grep mrtg[/code] Install MRTG [code]#yum install mrtg[/code] Configure mrtg (a) Create a document root to store mrtg graphs/html pages for Apache web-server, enter: [code]# mkdir -p /var/www/html/mymrtg/[/code] (b) Run any one of the following cfgmaker command to create mrtg configuration file: [code]# cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg.cfg public@localhost[/code] OR (make sure FQDN resolves. In the following example I'm using rh9.test.com i.e. my router's FQDN address) [code]# cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg1.cfg public@rh9.test.com[/code] (c) Create a default index page for your MRTG configuration, run: [code]# indexmaker --output=/var/www/html/mymrtg/index.html /etc/mrtg/mymrtg.cfg[/code] (d) Copy all tiny png files to your mrtg path, run: [code]# cp -av /var/www/html/mrtg/*.png /var/www/html/mymrtg/[/code] First test run for mrtg (a) Run mrtg command from command line with your configuration file, enter: [code]# mrtg /etc/mrtg/mymrtg.cfg[/code] Note: You may get few warning message for the first time; please ignore them. (b) Fire your favorite web browser (like FireFox ) and type the url http://www.your-name.com/mymrtg/ or http://your-ip-here/mymrtg/ Create crontab entry so that mrtg graph / images get generated every 5 minutes [code]# crontab -e[/code] Add mrtg cron job entry to configuration file (append following line to it) [b]*/5 * * * * /usr/bin/mrtg /etc/mrtg/mymrtg.cfg --logging /var/log/mrtg.log[/b] Close and save file. You are done with MRTG configuration. You do not want to give access to everyone to your snmp server for security reasons. SNMP server uses UDP port # 161 and 162 for communication. Use Linux IPTABLES firewall command to restrict access to your SNMP server.
    Link to this post 17 Jul 13

    MRTG consists of a Perl script which uses SNMP to read the traffic counters of your routers and a fast C program which logs the traffic data and creates beautiful graphs representing the traffic on the monitored network connection. These graphs are embedded into webpages which can be viewed from any modern Web-browser. MRTG is not limited to monitoring traffic, though. It is possible to monitor any SNMP variable you choose. You can even use an external program to gather the data which should be monitored via MRTG. MRTG uses to monitor things such as System Load, Login Sessions, Modem availability and more. MRTG even allows you to accumulate two or more data sources into a single graph. MRTG (Multi Router Traffic Grapher) is an application that allows us to observe the traffic of a network. It generates html pages with graphs which are refreshed according to our network’s current state. Make sure SNMP server is working. Without proper working SNMP Server, mrtg will not work. Therefore, first step is making sure snmp up and running.

    Type the following rpm command to find out, if snmp server installed or not

    # rpm -qa | grep snmp

    Determine if snmp server is running or not

    # ps -aux | grep snmp

    OUTPUT
    root 5512 0.0 2.3 5872 3012 pts/0 S 22:04 0:00 /usr/sbin/snmpd


    Install SNMP using the following command as a root user

    # yum install net-snmp-utils net-snmp

    # service snmpd start

    Make sure snmpd service starts automatically, when linux comes us (add snmpd service):

    # chkconfig --add snmpd
    # chkconfig snmpd on

    Check snmp server configured properly

    # snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

    OUTPUT
    ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
    ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.0.3 = 2

    MRTG
    Mrtg software may install during initial installation; you can verify if MRTG installed or not with the following RPM command:

    #rpm -qa | grep mrtg

    Install MRTG

    #yum install mrtg

    Configure mrtg

    (a) Create a document root to store mrtg graphs/html pages for Apache web-server, enter:

    # mkdir -p /var/www/html/mymrtg/

    (b) Run any one of the following cfgmaker command to create mrtg configuration file:

    # cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg.cfg public@localhost

    OR (make sure FQDN resolves. In the following example I'm using rh9.test.com i.e. my router's FQDN address)

    # cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg1.cfg public@rh9.test.com

    (c) Create a default index page for your MRTG configuration, run:

    # indexmaker --output=/var/www/html/mymrtg/index.html /etc/mrtg/mymrtg.cfg

    (d) Copy all tiny png files to your mrtg path, run:

    # cp -av /var/www/html/mrtg/*.png /var/www/html/mymrtg/

    First test run for mrtg

    (a) Run mrtg command from command line with your configuration file, enter:

    # mrtg /etc/mrtg/mymrtg.cfg

    Note: You may get few warning message for the first time; please ignore them.

    (b) Fire your favorite web browser (like FireFox ) and type the url http://www.your-name.com/mymrtg/ or http://your-ip-here/mymrtg/

    Create crontab entry so that mrtg graph / images get generated every 5 minutes

    # crontab -e

    Add mrtg cron job entry to configuration file (append following line to it)

    */5 * * * * /usr/bin/mrtg /etc/mrtg/mymrtg.cfg --logging /var/log/mrtg.log

    Close and save file. You are done with MRTG configuration.

    You do not want to give access to everyone to your snmp server for security reasons. SNMP server uses UDP port # 161 and 162 for communication. Use Linux IPTABLES firewall command to restrict access to your SNMP server.

  • linuxcrazy
    Difference Between tr and sed Command
    In Linux every thing is in files and some time we need to edit files to make some changes. There are many command line utilities like vim, vi, nano etc that allow us to open file, find the particular word from file and replace it with our correct word. If we want to modify a large file without opening, there are also many command line utilities as echo, sed and tr in Linux that will allow us to modify a file without opening it. Sometimes we can do same modification in a file with sed and tr. As per below example we can use sed and tr command for same purpose. Where we can use both sed or tr, we will prefer to [url=http://www.expertslogin.com/how-tos/linux-tr-command/]use of tr command[/url] because the tr is more faster. Of course, in many practical cases, the speed difference is too small to notice. Suppose we have a string as "This+is+test+for+tr+and+sed" and we want to replace '+' with white-space ' ' and this type of replacement can be done with both tr as well sed command as below [code][user@test ~]$ echo This+is+test+for+tr+and+sed |tr '+' ' ' This is test for tr and sed[/code] [code][user@test ~]$ echo This+is+test+for+tr+and+sed |sed 's/\+/ /g' This is test for tr and sed[/code] We can use sed and tr commands as editor and basic text transformations, but there are difference in uses of tr command and sed command. [b]Difference between tr and sed[/b] tr command Translate, squeeze, delete characters from standard input, writing to standard output. on the other hand sed is a stream editor or it is used to perform basic text transformations on an input stream tr perform character based transformation but sed perform string based transformation. For example [code][user@test ~]$ echo I am a good boy | tr 'good' 'test' I am a tsst bsy[/code] tr has done character based transformation and it is replacing good to best as [b]g=b, o=e, o=s, d=t[/b] and because o is double so it ignore first rule and using o=s and output is as above. [code][user@test ~]$ echo I am a good boy | sed 's/good/best/g' I am a best boy[/code] But sed is string based transformation and if there will 'good' string more than one time those will replace with 'best'. But in other cases tr command also more useful and easier. Just suppose that we have entered braces '{}' by mistake instead of parenthesis '()' in a file test.txt and we can translate braces with parenthesis with tr. [code][user@test ~]$ tr '{}' '()' < test.txt > newtest.txt [/code] It will replace '{}' with '()' from test.txt and save output in newtest.txt.
    Link to this post 10 Jul 13

    In Linux every thing is in files and some time we need to edit files to make some changes. There are many command line utilities like vim, vi, nano etc that allow us to open file, find the particular word from file and replace it with our correct word. If we want to modify a large file without opening, there are also many command line utilities as echo, sed and tr in Linux that will allow us to modify a file without opening it. Sometimes we can do same modification in a file with sed and tr. As per below example we can use sed and tr command for same purpose. Where we can use both sed or tr, we will prefer to use of tr command because the tr is more faster. Of course, in many practical cases, the speed difference is too small to notice.

    Suppose we have a string as "This+is+test+for+tr+and+sed" and we want to replace '+' with white-space ' ' and this type of replacement can be done with both tr as well sed command as below

    [user@test ~]$ echo This+is+test+for+tr+and+sed |tr '+' ' '
    This is test for tr and sed

    [user@test ~]$ echo This+is+test+for+tr+and+sed |sed 's/\+/ /g'
    This is test for tr and sed

    We can use sed and tr commands as editor and basic text transformations, but there are difference in uses of tr command and sed command.

    Difference between tr and sed

    tr command Translate, squeeze, delete characters from standard input, writing to standard output. on the other hand sed is a stream editor or it is used to perform basic text transformations on an input stream

    tr perform character based transformation but sed perform string based transformation.

    For example

    [user@test ~]$ echo I am a good boy | tr 'good' 'test'
    I am a tsst bsy

    tr has done character based transformation and it is replacing good to best as g=b, o=e, o=s, d=t and because o is double so it ignore first rule and using o=s and output is as above.

    [user@test ~]$ echo I am a good boy | sed 's/good/best/g'
    I am a best boy

    But sed is string based transformation and if there will 'good' string more than one time those will replace with 'best'.

    But in other cases tr command also more useful and easier. Just suppose that we have entered braces '{}' by mistake instead of parenthesis '()' in a file test.txt and we can translate braces with parenthesis with tr.

    [user@test ~]$ tr '{}' '()' < test.txt > newtest.txt

    It will replace '{}' with '()' from test.txt and save output in newtest.txt.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board