|
Re: lug-bg: MRTG and system idle
- Subject: Re: lug-bg: MRTG and system idle
- From: gf@xxxxxx (Georgi Chorbadzhiyski)
- Date: Mon, 27 Aug 2001 11:19:26 +0300
>Ivan Dimitrov wrote:
>
> maxni opciata -l i nqma da logva veche v syslog-a. mojesh da napravish
> razni skriptove koito da se izpulnqvat zaedno sus mrtg-to ti. primerno
> vednaga sled kato prochete mrtg-to infoto ot ipchains da napravish
> ipchains -F na rule-a. taka vseki 5 min shte imash nova informacia za tova
Ne mozhesh da flushnesh samo edin rule. dazhe nemozhesh da flushnesh CHAIN
(ako si spomniam pravilno), -F shte ti zabyrshe wsichki chainove :(
Osven tova za da zasichash trafika s mrtg ne ti e nuzhno da flusvash nishto,
mrtg e napraveno taka che da otchita po-princip postoianno uvelichavashti
se stoinosti.
> koeto minava. ako iskash shte ti pratq razni skriptove koito sum pisal
> (vupreki che sa full s bugove i ipchains rule-ovete sa mi precakani) pone
> da pridobiesh predstava za kakvo govorq...
Ako na niakoi mu triabva da otchita trafik minal prez niakoe ustroistvo na
localnata mashina kydeto e mrtg-to, mozhe da izpolzva tozi script:
--------------
#!/bin/sh
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
if [ $# -eq 0 ]; then
echo "Usage: $0 dev"
exit
fi
DEV=$1
IN=$(cat /proc/net/dev | grep $DEV | sed -e "s| | |g;s| | |g;s| | |g;s| | |g;s|^ +||g;s|: |:|" | cut -d" " -f2 | sed -e "s|.*:||")
OUT=$(cat /proc/net/dev | grep $DEV | sed -e "s| | |g;s| | |g;s| | |g;s| | |g;s|^ +||g;s|: |:|" | cut -d" " -f10)
if [ "$IN" == "" ]; then echo 0; else echo $IN; fi
if [ "$OUT" == "" ]; then echo 0; else echo $OUT; fi
uptime | sed -e "s|.* up ||"
echo "$DEV@`cat /etc/HOSTNAME`"
Tozi vadi statistikite ot IPCHAINS
----------------------------
#!/bin/sh
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
input_chain="input";
output_chain="output";
input=$(ipchains -L $input_chain -x -v -n | head -1)
input_bytes=$(echo $input | sed -e "s/.*, //;s| .*||")
output=$(ipchains -L $output_chain -x -v -n | head -1)
output_bytes=$(echo $output | sed -e "s/.*, //;s| .*||")
echo $input_bytes
echo $output_bytes
uptime | cut -b 14-80
cat /etc/HOSTNAME
mrtg.conf
--------------
Target[server_eth0]: `/usr/local/mrtg/dev_stats eth0`
MaxBytes[server_eth0]: 1250000
Title[server_eth0]: Server eth0
PageTop[server_eth0]: Server eth0
===========================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers)
http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd. - Stara Zagora
|
|
|