Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: HOW TO: Get Conky to show network output only on the active interface (scriptless)

  1. #1
    Join Date
    Nov 2007
    Location
    Boston, USA
    Beans
    524
    Distro
    Ubuntu 13.04 Raring Ringtail

    HOW TO: Get Conky to show network output only on the active interface (scriptless)

    I love the network speed and graphs in conky. However, I have a laptop that has 5 different interfaces:

    1) eth0 - built in ethernet
    2) eth1 - Gigabit PC card for work
    3) eth2 - Gigabit PC card for home
    4) ppp0 -- verizon wireless card
    5) wlan0 -- wireless lan (wifi)

    I want Conky to only show the 1 or 2 interfaces that are UP and in use at any given point in time. By up and in-use I mean that the interface has an active IP address.

    I found a way to do this by running a script from within ${if_empty ..} variable, but it tripled the cpu resource to run. Apparently even if you use ${execi 30 ...} if you use it within an "if" clause it runs every second, not every 30 seconds.

    At any rate, the way I got it to work was to use an execi command to create a temp file in my home directory named after the interface (.conky_eth0, .conky_ppp0, etc.). Conky creates these ever 30 seconds. I then use the ${if_existing ...} variable to conky to check for the file every second.

    The result is a low-resource, non-script way to only show the networking data for the interface I care about. Here's my entire conky...note the networking section at the end. Its a bit crowded because I jammed all the text onto one line, but you get the drift. I used the ifconfig -s command to see if the interface exists at all and then I used the ifconfig -a command to see if the interface has an IP address.

    Obviously, you'll need to edit to have it work with your specific interfaces.

    Code:
    background yes
    use_xft yes
    xftfont Trebuchet MS:size=10
    xftalpha 0.9
    update_interval 1.0
    total_run_times 0
    own_window yes
    # own_window_type normal=(minimizes with minimize all)
    # own_window_type desktop=(dissapears when clicking on desktop)
    # own_window_type override=(has border and shows up on top of everything after reboot)
    own_window_type normal
    own_window_transparent yes
    own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
    # own_window_hints below (for override)
    double_buffer yes
    minimum_size 180 5
    maximum_width 180
    draw_shades no
    draw_outline no
    draw_borders no
    draw_graph_borders no
    
    # Stippled borders?
    # stippled_borders 8
    # border margins
    # border_margin 2
    # border width
    # border_width 1
    
    default_color white
    default_shade_color red
    default_outline_color green
    
    # alignment top_left
    alignment top_right
    # alignment bottom_left
    # alignment bottom_right
    # alignment none
    
    gap_x 12
    gap_y 30
    no_buffers yes
    uppercase no
    cpu_avg_samples 2
    override_utf8_locale no
    
    # WISH LIST
    # single IP-network stuff set (auto uses the right one)
    # trim processor name ${execi 5 cat /proc/cpuinfo | grep 'model name' | sed -e 's/model name.*: //' | tail -n1}
    # fan speed (sensors??)
    # battery only if discharging (${battery} says discharging....)
    # space of /sda1 only if mounted  !!! if_mounted(mountpoint)....
    # $ platform devices????
    # Inbound: ${tcp_portmon 1 32767 count} Outbound: ${tcp_portmon 32768 61000 count}${alignr}Total: ${tcp_portmon 1 65535 count}
    
    
    
    TEXT
    System $hr
    Name:$alignr$nodename
    Arch:$alignr$machine
    Kernel:$alignr$kernel
    Uptime:$alignr$uptime
    
    Processor $hr
    CPU1: ${cpu cpu1}% ${color lightgray}${cpubar cpu1}$color
    CPU2: ${cpu cpu2}% ${color lightgray}${cpubar cpu2}$color
    Processes: ${processes}$alignr Running: ${running_processes}
    Temperature:$alignr${acpitemp} C
    
    Memory $hr
    RAM: $memperc% ${color lightgray}$membar$color
    Usage:$alignr$mem/$memmax
    
    Battery $hr
    Power: ${battery_percent}% ${color lightgray}${battery_bar BAT0}$color
    Time:$alignr${battery_time BAT0}
    
    Disk Space $hr
    Root: ${fs_used_perc /}% ${color lightgray}${fs_bar /}$color
    Usage:$alignr$fs_used/$fs_size
    Temperature: $alignr${execi 300 nc localhost 7634 | cut -d"|" -f4 ;} C
    
    Network $hr
    ${execi 30 rm -f .conky_eth0; ifconfig -s | grep eth0 > /dev/null && ifconfig -a eth0 | grep 'inet addr:' > /dev/null && touch .conky_eth0}${execi 30 rm -f .conky_eth1; ifconfig -s | grep eth1 > /dev/null && ifconfig -a eth1 | grep 'inet addr:' > /dev/null && touch .conky_eth1}${execi 30 rm -f .conky_eth2; ifconfig -s | grep eth2 > /dev/null && ifconfig -a eth2 | grep 'inet addr:' > /dev/null > /dev/null && touch .conky_eth2}${execi 30 rm -f .conky_ppp0; ifconfig -s | grep ppp0 > /dev/null && ifconfig -a ppp0 | grep 'inet addr:' > /dev/null && touch .conky_ppp0}${execi 30 rm -f .conky_wlan0; ifconfig -s | grep wlan0 > /dev/null && ifconfig -a wlan0 | grep 'inet addr:' > /dev/null && touch .conky_wlan0}${if_existing /home/username/.conky_eth0}IP (eth0):$alignr${addr eth0}
    Down: ${downspeed eth0} k/s ${alignr}Up: ${upspeed eth0} k/s
    ${color lightgray}${downspeedgraph eth0 20,80 444444 eeeeee} ${alignr}${upspeedgraph eth0 20,80 444444 eeeeee}$color
    Total: ${totaldown eth0} ${alignr}Total: ${totalup eth0}
    ${endif}${if_existing /home/username/.conky_eth1}IP (eth1):$alignr${addr eth1}
    Down: ${downspeed eth1} k/s ${alignr}Up: ${upspeed eth1} k/s
    ${color lightgray}${downspeedgraph eth1 20,80 444444 eeeeee} ${alignr}${upspeedgraph eth1 20,80 444444 eeeeee}$color
    Total: ${totaldown eth1} ${alignr}Total: ${totalup eth1}
    ${endif}${if_existing /home/username/.conky_eth2}IP (eth2):$alignr${addr eth2}
    Down: ${downspeed eth2} k/s ${alignr}Up: ${upspeed eth2} k/s
    ${color lightgray}${downspeedgraph eth2 20,80 444444 eeeeee} ${alignr}${upspeedgraph eth2 20,80 444444 eeeeee}$color
    Total: ${totaldown eth2} ${alignr}Total: ${totalup eth2}
    ${endif}${if_existing /home/username/.conky_ppp0}IP (ppp0):$alignr${addr ppp0}
    Down: ${downspeed ppp0} k/s ${alignr}Up: ${upspeed ppp0} k/s
    ${color lightgray}${downspeedgraph ppp0 20,80 444444 eeeeee} ${alignr}${upspeedgraph ppp0 20,80 444444 eeeeee}$color
    Total: ${totaldown ppp0} ${alignr}Total: ${totalup ppp0}
    ${endif}${if_existing /home/username/.conky_wlan0}IP (wlan0):$alignr${addr wlan0}
    Down: ${downspeed wlan0} k/s ${alignr}Up: ${upspeed wlan0} k/s
    ${color lightgray}${downspeedgraph wlan0 20,80 444444 eeeeee} ${alignr}${upspeedgraph ppp0 20,80 444444 eeeeee}$color
    Total: ${totaldown wlan0} ${alignr}Total: ${totalup wlan0}
    ${endif}
    Enjoy.

  2. #2
    Join Date
    Jan 2008
    Beans
    1

    Re: HOW TO: Get Conky to show network output only on the active interface (scriptless

    Hi HDave,

    from your inspiration I followed two different approach, where no exec-statements are needed at all.

    1. approach: Create the files in a script in /etc/network/if-up.d/conky and delete them in /etc/network/if-down.d/conky
    If you do this you can just delete all the "${execi 30 rm -f .conky_eth0; [...]"-statements in your .conkyrc.

    2. (better) approach: Check in /etc/network/run/ifstate if the interface is up
    In /etc/network/run/ifstate those network interfaces are listet, which are currently up and running. Conky can check this.

    In your .conkyrc delete all the "${execi 30 rm -f .conky_eth0; [...]"-statements.
    Then for all interfaces replace
    Code:
    ${if_existing /home/username/.conky_eth0}
    with
    Code:
    ${if_existing /etc/network/run/ifstate eth0=eth0}
    (You should check if your ifstate-file has the same syntax. (eth0=eth0))

    With this the .conkyrc of HDave from above would look like this:

    Code:
    background yes
    use_xft yes
    xftfont Trebuchet MS:size=10
    xftalpha 0.9
    update_interval 1.0
    total_run_times 0
    own_window yes
    # own_window_type normal=(minimizes with minimize all)
    # own_window_type desktop=(dissapears when clicking on desktop)
    # own_window_type override=(has border and shows up on top of everything after reboot)
    own_window_type normal
    own_window_transparent yes
    own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
    # own_window_hints below (for override)
    double_buffer yes
    minimum_size 180 5
    maximum_width 180
    draw_shades no
    draw_outline no
    draw_borders no
    draw_graph_borders no
    
    # Stippled borders?
    # stippled_borders 8
    # border margins
    # border_margin 2
    # border width
    # border_width 1
    
    default_color white
    default_shade_color red
    default_outline_color green
    
    # alignment top_left
    alignment top_right
    # alignment bottom_left
    # alignment bottom_right
    # alignment none
    
    gap_x 12
    gap_y 30
    no_buffers yes
    uppercase no
    cpu_avg_samples 2
    override_utf8_locale no
    
    # WISH LIST
    # single IP-network stuff set (auto uses the right one)
    # trim processor name ${execi 5 cat /proc/cpuinfo | grep 'model name' | sed -e 's/model name.*: //' | tail -n1}
    # fan speed (sensors??)
    # battery only if discharging (${battery} says discharging....)
    # space of /sda1 only if mounted  !!! if_mounted(mountpoint)....
    # $ platform devices????
    # Inbound: ${tcp_portmon 1 32767 count} Outbound: ${tcp_portmon 32768 61000 count}${alignr}Total: ${tcp_portmon 1 65535 count}
    
    
    
    TEXT
    System $hr
    Name:$alignr$nodename
    Arch:$alignr$machine
    Kernel:$alignr$kernel
    Uptime:$alignr$uptime
    
    Processor $hr
    CPU1: ${cpu cpu1}% ${color lightgray}${cpubar cpu1}$color
    CPU2: ${cpu cpu2}% ${color lightgray}${cpubar cpu2}$color
    Processes: ${processes}$alignr Running: ${running_processes}
    Temperature:$alignr${acpitemp} C
    
    Memory $hr
    RAM: $memperc% ${color lightgray}$membar$color
    Usage:$alignr$mem/$memmax
    
    Battery $hr
    Power: ${battery_percent}% ${color lightgray}${battery_bar BAT0}$color
    Time:$alignr${battery_time BAT0}
    
    Disk Space $hr
    Root: ${fs_used_perc /}% ${color lightgray}${fs_bar /}$color
    Usage:$alignr$fs_used/$fs_size
    Temperature: $alignr${execi 300 nc localhost 7634 | cut -d"|" -f4 ;} C
    
    Network $hr
    ${if_existing /etc/network/run/ifstate eth0=eth0}IP (eth0):$alignr${addr eth0}
    Down: ${downspeed eth0} k/s ${alignr}Up: ${upspeed eth0} k/s
    ${color lightgray}${downspeedgraph eth0 20,80 444444 eeeeee} ${alignr}${upspeedgraph eth0 20,80 444444 eeeeee}$color
    Total: ${totaldown eth0} ${alignr}Total: ${totalup eth0}
    ${endif}${if_existing /etc/network/run/ifstate eth1=eth1}IP (eth1):$alignr${addr eth1}
    Down: ${downspeed eth1} k/s ${alignr}Up: ${upspeed eth1} k/s
    ${color lightgray}${downspeedgraph eth1 20,80 444444 eeeeee} ${alignr}${upspeedgraph eth1 20,80 444444 eeeeee}$color
    Total: ${totaldown eth1} ${alignr}Total: ${totalup eth1}
    ${endif}${if_existing /etc/network/run/ifstate eth2=eth2}IP (eth2):$alignr${addr eth2}
    Down: ${downspeed eth2} k/s ${alignr}Up: ${upspeed eth2} k/s
    ${color lightgray}${downspeedgraph eth2 20,80 444444 eeeeee} ${alignr}${upspeedgraph eth2 20,80 444444 eeeeee}$color
    Total: ${totaldown eth2} ${alignr}Total: ${totalup eth2}
    ${endif}${if_existing /etc/network/run/ifstate ppp0=ppp0}IP (ppp0):$alignr${addr ppp0}
    Down: ${downspeed ppp0} k/s ${alignr}Up: ${upspeed ppp0} k/s
    ${color lightgray}${downspeedgraph ppp0 20,80 444444 eeeeee} ${alignr}${upspeedgraph ppp0 20,80 444444 eeeeee}$color
    Total: ${totaldown ppp0} ${alignr}Total: ${totalup ppp0}
    ${endif}${if_existing /etc/network/run/ifstate wlan0=wlan0}IP (wlan0):$alignr${addr wlan0}
    Down: ${downspeed wlan0} k/s ${alignr}Up: ${upspeed wlan0} k/s
    ${color lightgray}${downspeedgraph wlan0 20,80 444444 eeeeee} ${alignr}${upspeedgraph ppp0 20,80 444444 eeeeee}$color
    Total: ${totaldown wlan0} ${alignr}Total: ${totalup wlan0}
    ${endif}
    Regards,
    matsch

  3. #3
    Join Date
    Nov 2007
    Location
    Boston, USA
    Beans
    524
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: HOW TO: Get Conky to show network output only on the active interface (scriptless

    Hi Matsch -- Thanks for the info. I like the idea of checking this ifstate file, but I don't have a /etc/network/run directory? Where does this come from? A package?

    Also, I am unsure about the if-up.d and if-down.d idea. Check out the result an "ifconfig":

    Code:
    eth0      Link encap:Ethernet  HWaddr 00:18:8B:BD:2B:4A  
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
              Interrupt:17 
    
    eth2      Link encap:Ethernet  HWaddr 00:00:5A:00:04:55  
              inet addr:192.168.1.124  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::200:5aff:fe00:455/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:15404 errors:0 dropped:0 overruns:0 frame:0
              TX packets:12123 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:7001255 (6.6 MB)  TX bytes:1511105 (1.4 MB)
              Interrupt:18 
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:294 errors:0 dropped:0 overruns:0 frame:0
              TX packets:294 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:237964 (232.3 KB)  TX bytes:237964 (232.3 KB)
    
    vmnet1    Link encap:Ethernet  HWaddr 00:50:56:C0:00:01  
              inet addr:192.168.141.1  Bcast:192.168.141.255  Mask:255.255.255.0
              inet6 addr: fe80::250:56ff:fec0:1/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
    
    vmnet8    Link encap:Ethernet  HWaddr 00:50:56:C0:00:08  
              inet addr:192.168.175.1  Bcast:192.168.175.255  Mask:255.255.255.0
              inet6 addr: fe80::250:56ff:fec0:8/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
    
    wlan0     Link encap:Ethernet  HWaddr 00:19:7D:8E:93:35  
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
              Interrupt:17 Memory:ecffc000-ed000000
    Note that all 6 interfaces indicate they are "UP". Would a script in if-up.d really work?

    Thanks again!

  4. #4
    Join Date
    Aug 2007
    Location
    Ohio
    Beans
    31
    Distro
    Hardy Heron (Ubuntu Development)

    Re: HOW TO: Get Conky to show network output only on the active interface (scriptless

    Okay, third time editing this...

    I found out how to make it only show the OPERATIONAL network device! FINALLY!!!

    Okay, We need to find out where the system mapped our network devices. My wired connection was located at "/sys/devices/pci0000:00/0000:00:1e.0/0000:02:0e.0". (I used the "Hardware Information" under Preferences to find it. It's located under the advanced tab).
    We need now to look for a folder that has the name of the ethernet device. Mine was called "net:eth0", in there is a file called "operstate". This is the file we want conky to point to.
    So now, let's edit our conkyrc file.
    Code:
    ${if_existing /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0e.0/net:eth0/operstate up} [blablabla] ${endif}
    I did have issues with conky resizing to allow the new stuff to get on the screen. Changing "own_window_type override" seemed to fix it.

    Here is my copy of conkyrc for an example...

    Code:
    # Conky sample configuration
    #
    # the list of variables has been removed from this file in favour
    # of keeping the documentation more maintainable.
    # Check http://conky.sf.net for an up-to-date-list.
    
    # set to yes if you want Conky to be forked in the background
    background no
    
    # X font when Xft is disabled, you can pick one with program xfontsel
    #font 5x7
    #font 6x10
    #font 7x13
    #font 8x13
    #font 9x15
    #font *mintsmild.se*
    #font -*-*-*-*-*-*-34-*-*-*-*-*-*-*
    
    # Use Xft?
    use_xft yes
    
    # Xft font when Xft is enabled
    xftfont Bitstream Vera Sans Mono:size=8
    
    # Text alpha when using Xft
    xftalpha 0.8
    
    # Print everything to stdout?
    # out_to_console no
    
    # MPD host/port
    # mpd_host localhost
    # mpd_port 6600
    # mpd_password tinker_bell
    
    # Print everything to console?
    # out_to_console no
    
    # mail spool
    #mail_spool $MAIL
    
    # Update interval in seconds
    update_interval 1.0
    
    # This is the number of times Conky will update before quitting.
    # Set to zero to run forever.
    total_run_times 0
    
    # Create own window instead of using desktop (required in nautilus)
    own_window yes
    
    # If own_window is yes, you may use type normal, desktop or override
    own_window_type override
    
    # Use pseudo transparency with own_window?
    own_window_transparent yes
    
    # If own_window_transparent is set to no, you can set the background colour here
    own_window_colour black
    
    # If own_window is yes, these window manager hints may be used
    own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
    
    # Use double buffering (reduces flicker, may not work for everyone)
    double_buffer yes
    
    # Minimum size of text area
    minimum_size 280 5
    
    # Draw shades?
    draw_shades no
    
    # Draw outlines?
    draw_outline no
    
    # Draw borders around text
    draw_borders no
    
    # Draw borders around graphs
    draw_graph_borders yes
    
    # Stippled borders?
    stippled_borders 8
    
    # border margins
    border_margin 4
    
    # border width
    border_width 1
    
    # Default colors and also border colors
    default_color white
    default_shade_color black
    default_outline_color black
    
    #dexter_client no
    #dexter_server no
    #config file for libdexter (default search path: $HOME/.dexterrc; /etc/libdexter/dexter.conf)
    #dexter_config
    
    # Text alignment, other possible values are commented
    #alignment top_left
    #alignment top_right
    #alignment bottom_left
    alignment bottom_right
    #alignment none
    
    # Gap between borders of screen and text
    # same thing as passing -x at command line
    gap_x 12
    gap_y 12
    
    # Subtract file system buffers from used memory?
    no_buffers no
    
    # set to yes if you want all text to be in uppercase
    uppercase no
    
    # number of cpu samples to average
    # set to 1 to disable averaging
    cpu_avg_samples 1
    
    # number of net samples to average
    # set to 1 to disable averaging
    net_avg_samples 1
    
    # Force UTF8? note that UTF8 support required XFT
    override_utf8_locale no
    
    # Add spaces to keep things from moving about?  This only affects certain objects.
    use_spacer no
    
    # Allow each port monitor to track at most this many connections (if 0 or not set, default is 256)
    #max_port_monitor_connections 0
    
    # Maximum number of special things, e.g. fonts, offsets, aligns, etc.
    #max_specials 512
    
    # Maximum size of buffer for user text, i.e. below TEXT line.
    #max_user_text 16384
    
    # variable is given either in format $variable or in ${variable}. Latter
    # allows characters right after the variable and must be used in network
    # stuff because of an argument
    
    # stuff after 'TEXT' will be formatted on screen
    
    TEXT
    
    NC8000 - $sysname $kernel on $machine
    ${color lightgrey}AC Power:$color $acpiacadapter
    ${color lightgrey}Battery 1 Status:$color ${battery C137}  ${battery_time C137}
    ${color lightgrey}Battery 2 Status:$color ${battery C136}  ${battery_time C136}
    $stippled_hr
    ${color lightgrey}Uptime:$color $uptime ${color lightgrey}- Load:$color $loadavg
    ${color lightgrey}CPU Usage:${color #cc2222} $cpu% ${cpubar}
    ${color} ${cpugraph}
    ${color lightgrey}CPU Speed:$color $freq_dyn Mhz ${color lightgrey}CPU Temp:$color $acpitempf Degrees
    ${color lightgrey}Processes:$color $processes  ${color grey}Running:$color $running_processes
    ${color}Name              PID     CPU%   MEM%
    ${color #ddaa00} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
    ${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
    ${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
    ${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
    $color$stippled_hr
    ${color lightgrey}File Systems:
    ${color lightgrey} Root   $color${fs_free /}/${fs_size /}   ${fs_bar /}
    ${color lightgrey} Home   $color${fs_free /home}/${fs_size /home}   ${fs_bar /home}${if_mounted /media/disk}
    ${color lightgrey} MS    ${color} ${fs_free /media/disk}/${fs_size /media/disk}   ${fs_bar /media/disk}${endif}
    ${color lightgrey} RAM    $color $mem/$memmax    ${membar}
    ${color lightgrey} Swap  $color $swap/$swapmax    ${swapbar}
    ${color lightgrey}Disk Read-Write IO$color	          $diskio_read - $diskio_write
    $stippled_hr
    ${color lightgrey}Wireless Mode: $color ${wireless_mode ath0}
    ${if_existing /sys/devices/pci0000:00/0000:00:1e.0/0000:02:04.0/net:ath0/operstate up}${color lightgrey}Wireless Rate:$color ${wireless_bitrate ath0} ${color lightgrey}Link Quality: $color ${wireless_link_qual_perc ath0}
    ${color lightgrey}IP Address:$color ${addr ath0} ${color lightgrey}Associated With:$color ${wireless_essid ath0}
     Down:${color #8844ee} ${downspeed ath0} k/s${color lightgrey} ${offset 80}Up:${color #22ccff} ${upspeed ath0} k/s
    ${color #000000}${downspeedgraph ath0 32,150 ffffff ffffff} ${color #000000}${upspeedgraph ath0 32,150 ffffff ffffff}${endif}
    ${if_existing /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0e.0/net:eth0/operstate up}${color lightgrey}Wired IP Address: $color${addr eth0}
     Down:${color #8844ee} ${downspeed eth0} k/s${color lightgrey} ${offset 80}Up:${color #22ccff} ${upspeed eth0} k/s
    ${color #000000}${downspeedgraph eth0 32,150 ffffff ffffff} ${color #000000}${upspeedgraph eth0 32,150 ffffff ffffff}${endif}
    Last edited by kjbuente; January 14th, 2008 at 02:04 AM. Reason: Updated
    Free project web space <- Recovering from database crash, current projects stored unaffected...

  5. #5
    Join Date
    Nov 2007
    Location
    Boston, USA
    Beans
    524
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: HOW TO: Get Conky to show network output only on the active interface (scriptless

    Brilliant Work kjbuente!!!!!!

    It works like a charm! And is soooo much simpler. I did notice however that the directories you indicated were all linked directories to the /sys/class/net/ directory.

    So you can end up with a shorter path if you just do this:

    Code:
    ${if_existing /sys/class/net/eth0/operstate up} [blablabla] ${endif}
    Now I am motivated to also find a simpler way to determine if my Verizon modem is operational. It's a USB device, not PCI, so the approach may need to be different...

    Ahhh...sweet victory...
    Last edited by HDave; January 14th, 2008 at 03:54 AM.

  6. #6
    Join Date
    Aug 2007
    Location
    Ohio
    Beans
    31
    Distro
    Hardy Heron (Ubuntu Development)

    Re: HOW TO: Get Conky to show network output only on the active interface (scriptless

    LOL, I just noticed that they are in that directory as well. (I went to post it here, but you got to it first). It's a lot easier then trying to find were the device is mapped.

    I actually just added my verizon connection in conky right now. (via bluetooth, not usb. But should will work the some, also pcmcia would work too). When you create a connection, in /sys/class/net there will be a folder that will be created. (It is removed when the connection is closed). Just do the same as the other devices, but with one difference. Instead of it checking the file to see if it is up. It has to just check if it is there. The status stays at unknown...

    Some conky code:

    Code:
    ${if_existing /sys/class/net/ppp0/operstate}
    Thats it! Enjoy!
    Free project web space <- Recovering from database crash, current projects stored unaffected...

  7. #7
    Join Date
    Nov 2007
    Location
    Boston, USA
    Beans
    524
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: HOW TO: Get Conky to show network output only on the active interface (scriptless

    kjbuente -- thats good to know...thanks.

    An offtopic point here -- The fact that our ppp0 connection always has operstate "unknown" got me wondering if that is why the gnome network manager notification applet "nm-applet" never seems to indicate the state of my verizon dial-up connection.

    It's a small annoyance, but something I wish I could fix. Does it work for you?

    If not, check out this bug:

    https://bugs.launchpad.net/ubuntu/+s...ger/+bug/82335

  8. #8
    Join Date
    Aug 2007
    Location
    Ohio
    Beans
    31
    Distro
    Hardy Heron (Ubuntu Development)

    Re: HOW TO: Get Conky to show network output only on the active interface (scriptless

    I use gnome-ppp to connect to the internet. Works nicely exept the fact that it always say that it is dialing even though it is connected.

    I think that the operstate at unkown has a something to do with it, but not the only thing. I think it also has something to do with the fact that there is no ppp entry at /etc/networking/interfaces. (Not 100% sure that is a valid path since I'm on a friends windows machine). I wonder if we make one for it, how nm-applet would it react. I'm sure it would not be a fix, but be interesting none the less. I'll try this latter tonight when I can get my laptop again and fudge a ppp entry.

    Till then...

    Update: for thoese who use static. You can disable NetworkManager from handling a specific devices. Just comment out the device in the file mentioned above. I do not know if the connection status is sent though the dbus for apps to know if it is connected.
    Last edited by kjbuente; January 14th, 2008 at 09:14 PM. Reason: Update
    Free project web space <- Recovering from database crash, current projects stored unaffected...

  9. #9
    Join Date
    Sep 2007
    Location
    Northeast Ohio
    Beans
    48
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: HOW TO: Get Conky to show network output only on the active interface (scriptless

    eth0 (my ethernet connection)'s operstate file always reports as unknown. any idea of any work arounds?

    edit:
    Actually it looks like both eth0 and eth1's operstate files report as unknown
    Last edited by LauraSakura; January 15th, 2008 at 03:18 PM.

  10. #10
    Join Date
    Aug 2007
    Location
    Ohio
    Beans
    31
    Distro
    Hardy Heron (Ubuntu Development)

    Re: HOW TO: Get Conky to show network output only on the active interface (scriptless

    Honestly, I have no clue. Sorry...

    But that does not mean I won't try. Few questions...

    Are you using DHCP or static network connections? I noticed that the operstate just happens to go up when a DHCP address as been assigned. I have not tried static yet to see if it works, just low on time.

    What NIC are you using? Is it wired, wireless? What chipset?

    It is always at unknown if you shut down the device? (sudo ifconfig eth0 down)


    Just a though off the top of my head. It may have something to do with how the drivers communicate with the system. (That and there might be a difference between 32 and 64 bit system. I have no clue though, but I'm using 32bit for the record). I'm curently looking for another place to see if the connection is active. But not having much luck, I'm still learning how device are set as active.
    Free project web space <- Recovering from database crash, current projects stored unaffected...

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

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