<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Z-turn... &#187; Bash</title>
	<atom:link href="http://lfeng.me/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://lfeng.me</link>
	<description>Life is Z-turn....</description>
	<lastBuildDate>Sat, 14 Aug 2010 02:55:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>增强版3G上网流量监控</title>
		<link>http://lfeng.me/2010/01/03/an-enhanced-version-of-3g-internet-traffic-monitoring/</link>
		<comments>http://lfeng.me/2010/01/03/an-enhanced-version-of-3g-internet-traffic-monitoring/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 16:38:31 +0000</pubDate>
		<dc:creator>Lfeng</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Bandwidthd]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[WCDMA]]></category>

		<guid isPermaLink="false">http://lfeng.me/?p=222</guid>
		<description><![CDATA[昨天写了一个使用Bandwidthd监控流量，经过今天的观察，效果还不错，丫WCDMA确实快阿，烧起流量来也快，哗啦啦几十M就不见鸟= =！ 昨晚还遗留了一个问题没有解决： 因为Bandwidthd监控网段来进行流量监控，而WCDMA连接之后是动态IP，虽然现在基本确定获取的IP在112.96.0.0这个网段内，但是这个东西，我也不敢确定，那么就得弄个东西，在获取的IP不是这个网段的时候来提醒不是。 刚开始使用notify-send，遇到root权限下提示不显示在当前桌面的问题，后来在牛哄哄花主席的提醒下，设置了一下DISPLAY环境变量，出是出来了，但是跟当前用户的提示是重叠的= =！，又因为目前notify-send无法更改提示的位置，所以放弃。 这个时候牛哄哄的花主席又出来了：使用zenity，哈，问题圆满解决，修改wcdma-bandwidthd-start脚本内容入下： ?View Code BASH1 2 3 4 5 6 7 8 9 10 #!/bin/bash export DISPLAY=:0.0 #修换环境变量，显示在当前用户的第一屏 export LANG=zh_CN.utf-8 #修改语言环境，否则下面的出现中文将无法正常工作 /etc/init.d/bandwidthd start notify-send &#34;$4&#34; -i &#34;gnome-nettool&#34; -u &#34;critical&#34; -t 100000 #还是意思一下，用notify显示一下IP &#160; #当获取的IP不在112.96.0.0网段时，弹出警告框提醒 if &#91;&#91; ! &#34;$4&#34; =~ 112\.96&#40;\.&#91;0-9&#93;&#123;1,3&#125;&#41;&#123;2&#125; &#93;&#93;; then zenity --warning --text=&#34;当前获取的IP地址$4\n不在监控范围内，请重新配置Bandwidthd&#34; --width=350 fi 小测试一下，工作正常，哦耶～～～ 恩，现在可以安心用着了，不过&#8230;这流量烧的，确实心痛阿&#8230;. ==================纠结的分割线================== [...]]]></description>
			<content:encoded><![CDATA[<p>昨天写了一个使用<a href="http://lfeng.me/2010/01/02/ubuntu-use-bandwidthd-network-usage-statistics/" target="_self">Bandwidthd监控流量</a>，经过今天的观察，效果还不错，丫WCDMA确实快阿，烧起流量来也快，哗啦啦几十M就不见鸟= =！</p>
<p>昨晚还遗留了一个问题没有解决：<br />
因为Bandwidthd监控网段来进行流量监控，而WCDMA连接之后是动态IP，虽然现在基本确定获取的IP在112.96.0.0这个网段内，但是这个东西，我也不敢确定，那么就得弄个东西，在获取的IP不是这个网段的时候来提醒不是。<br />
刚开始使用notify-send，遇到root权限下提示不显示在当前桌面的问题，后来在牛哄哄花主席的提醒下，设置了一下DISPLAY环境变量，出是出来了，但是跟当前用户的提示是重叠的= =！，又因为目前notify-send无法更改提示的位置，所以放弃。 这个时候牛哄哄的花主席又出来了：使用zenity，哈，问题圆满解决，修改wcdma-bandwidthd-start脚本内容入下：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p222code2'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2222"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p222code2"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">DISPLAY</span>=:<span style="color: #000000;">0.0</span> <span style="color: #666666; font-style: italic;">#修换环境变量，显示在当前用户的第一屏</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LANG</span>=zh_CN.utf-<span style="color: #000000;">8</span> <span style="color: #666666; font-style: italic;">#修改语言环境，否则下面的出现中文将无法正常工作</span>
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>bandwidthd start
notify-send <span style="color: #ff0000;">&quot;$4&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;gnome-nettool&quot;</span> <span style="color: #660033;">-u</span> <span style="color: #ff0000;">&quot;critical&quot;</span> <span style="color: #660033;">-t</span> <span style="color: #000000;">100000</span> <span style="color: #666666; font-style: italic;">#还是意思一下，用notify显示一下IP</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#当获取的IP不在112.96.0.0网段时，弹出警告框提醒</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #ff0000;">&quot;$4&quot;</span> =~ <span style="color: #000000;">112</span>\.96<span style="color: #7a0874; font-weight: bold;">&#40;</span>\.<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span>-<span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>,<span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    zenity <span style="color: #660033;">--warning</span> <span style="color: #660033;">--text</span>=<span style="color: #ff0000;">&quot;当前获取的IP地址$4<span style="color: #000099; font-weight: bold;">\n</span>不在监控范围内，请重新配置Bandwidthd&quot;</span> <span style="color: #660033;">--width</span>=<span style="color: #000000;">350</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>小测试一下，工作正常，哦耶～～～</p>
<p style="text-align: center;"><a href="http://lfeng.me/wp-content/uploads/2010/01/screenshot_103.png"><img class="size-full wp-image-223 aligncenter" title="screenshot_103" src="http://lfeng.me/wp-content/uploads/2010/01/screenshot_103.png" alt="" width="352" height="153" /></a></p>
<p>恩，现在可以安心用着了，不过&#8230;这流量烧的，确实心痛阿&#8230;.</p>
<p>==================纠结的分割线==================<br />
好吧，我快跟<a title="LAZY bones" href="http://li2z.cn/" target="_blank">大骨头</a>一样成脚本控了&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://lfeng.me/2010/01/03/an-enhanced-version-of-3g-internet-traffic-monitoring/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
