Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Mar 2002
    Posts
    782

    MRTG setup on a server

    Ok i installed the newest MRTG via RPM, i used some info i found at serverexpert.com and adapted it to my system.

    Heres my mrtg.cfg script


    WorkDir: /home/ty566t/www/mrtg

    Target[mrtg]: `/etc/mrtg/getstat.sh/`
    MaxBytes[mrtg]: 96000
    Title[mrtg]: Traffic Analysis for server #1
    PageTop[mrtg]: <H1>Stats for our Ethernet</H1>
    XSize[mrtg]: 400
    YSize[mrtg]: 200

    and my getstat.sh script

    #!/bin/bash

    # Get transmit and receive bytes.
    #
    INFO= `grep eth0 /proc/net/dev | tr -s '''' | cut -d: -f2
    RECEIVE= `echo $INFO | cut -d" "-f1`
    TRANSMIT= `echo $INFO | cut -d" "-f9`

    # Get uptime
    #
    UPTIME= `uptime | tr -s '''' | cut -d" "-f4-`

    # Final output to MRTG
    #
    echo $RECEIVE
    echo $TRANSMIT
    echo $UPTIME
    echo "auroagroup.com"

    and the error i am getting.
    root@web1 [~]# mrtg /etc/mrtg/mrtg.cfg
    Can't exec "/etc/mrtg/getstat.sh/": Not a directory at /usr/bin/mrtg line 1491.
    WARNING: Running '/etc/mrtg/getstat.sh/': Not a directory
    WARNING: Could not get any data from external command '/etc/mrtg/getstat.sh/'
    Maybe the external command did not even start. (Not a directory)

    WARNING: Problem with External get '/etc/mrtg/getstat.sh/':
    Expected a Number for 'in' but nothing'

    WARNING: Problem with External get '/etc/mrtg/getstat.sh/':
    Expected a Number for 'out' but nothing'

    ERROR: Target[mrtg][_IN_] ' $$target[0]{$mode} ' did not eval into defined data
    ERROR: Target[mrtg][_OUT_] ' $$target[0]{$mode} ' did not eval into defined data
    WARNING: Skipping Update of mrtg, inlast is not defined
    WARNING: Skipping Update of mrtg, outlast is not defined

  2. #2
    Join Date
    May 2001
    Location
    Dayton, Ohio
    Posts
    4,977
    Make:
    Target[mrtg]: `/etc/mrtg/getstat.sh/`

    Into:
    Target[mrtg]: `/etc/mrtg/getstat.sh`

    And make sure to chmod 755 /etc/mrtg/getstat.sh

  3. #3
    Join Date
    Mar 2002
    Posts
    782
    Still get similiar error.... (If anyone knows an easier way to monitor my own bandwidth via the web, that'd be great)

    /etc/mrtg/getstat.sh: line 11: unexpected EOF while looking for matching ``'
    /etc/mrtg/getstat.sh: line 19: syntax error: unexpected end of file
    WARNING: Could not get any data from external command '/etc/mrtg/getstat.sh'
    Maybe the external command did not even start. (Illegal seek)

    WARNING: Problem with External get '/etc/mrtg/getstat.sh':
    Expected a Number for 'in' but nothing'

    WARNING: Problem with External get '/etc/mrtg/getstat.sh':
    Expected a Number for 'out' but nothing'

    ERROR: Target[mrtg][_IN_] ' $$target[0]{$mode} ' did not eval into defined data
    ERROR: Target[mrtg][_OUT_] ' $$target[0]{$mode} ' did not eval into defined data
    WARNING: Skipping Update of mrtg, inlast is not defined
    WARNING: Skipping Update of mrtg, outlast is not defined
    Last edited by neonlexx; 08-04-2002 at 05:46 PM.

  4. #4
    Join Date
    May 2001
    Location
    Dayton, Ohio
    Posts
    4,977
    Yeah, I tried your file, and there is a missing character, and some bad spacing, so I got the file new..

    Code:
    #!/bin/bash
    
    # Get transmit and receive bytes.
    #
    INFO=`grep eth0 /proc/net/dev | tr -s ' ' ' ' | cut -d: -f2`
    RECEIVE=`echo $INFO | cut -d" " -f1`
    TRANSMIT=`echo $INFO | cut -d" " -f9`
    
    # Get uptime.
    #
    UPTIME=`uptime | tr -s ' ' ' ' | cut -d" " -f4-`
    
    # Final output to MRTG
    #
    echo $RECEIVE
    echo $TRANSMIT
    echo $UPTIME
    echo "auroagroup.com"
    Your config file should look like this:
    Code:
    WorkDir: /home/ty566t/www/mrtg 
    
    Target[mrtg]: `/etc/mrtg/getstat.sh` 
    MaxBytes[mrtg]: 96000 
    Title[mrtg]: Traffic Analysis for server #1 
    PageTop[mrtg]: <H1>Stats for our Ethernet</H1> 
    XSize[mrtg]: 400 
    YSize[mrtg]: 200

    I just tried the shell script on my server and it works just fine...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •