Freifunk-Gateway aufsetzen/Statistik/mrtg: Unterschied zwischen den Versionen
Aus Freifunk Franken
(remove olsr fearture) |
SebaBe (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 68: | Zeile 68: | ||
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash | ||
leasecount=$(/usr/sbin/dhcp-lease-list --parsable --lease /var/lib/dhcp/dhcpd.leases 2>&1 |wc -l) | |||
# -> zutreffendes auskommentieren | |||
# isc-dhcp-server | |||
#leasecount=$(/usr/sbin/dhcp-lease-list --parsable --lease /var/lib/dhcp/dhcpd.leases 2>&1 |wc -l) | |||
# dnsmasq | |||
#leasecount=$(cat /var/lib/misc/bat0.leases | wc -l) | |||
echo "$leasecount" | echo "$leasecount" | ||
echo "$leasecount" | echo "$leasecount" |
Version vom 17. Februar 2019, 15:39 Uhr
snmpd und mrtg installieren.
/etc/snmp/snmpd.conf: systemonly auskommentiert
rocommunity public default #-V systemonly rocommunity6 public default #-V systemonly
snmpd restarten.
Ordner anlegen:
mkdir /etc/mrtg mkdir /var/www/mrtg
Die mrtg CPU Config neu anlegen:
vi /etc/mrtg/cpu.cfg
und folgendes einfügen:
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt WorkDir: /var/www/mrtg Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@127.0.0.1 + ssCpuRawSystem.0&ssCpuRawSystem.0:public@127.0.0.1 + ssCpuRawNice.0&ssCpuRawNice.0:public@127.0.0.1 + ssCpuRawSoftIRQ.0&ssCpuRawSoftIRQ.0:public@127.0.0.1 + ssCpuRawInterrupt.0&ssCpuRawInterrupt.0:public@127.0.0.1 + ssCpuRawKernel.0&ssCpuRawKernel.0:public@127.0.0.1 RouterUptime[localhost.cpu]: public@127.0.0.1 MaxBytes[localhost.cpu]: 100 Title[localhost.cpu]: CPU Load PageTop[localhost.cpu]: <h1>Active CPU Load %</h1> Unscaled[localhost.cpu]: ymwd ShortLegend[localhost.cpu]: % YLegend[localhost.cpu]: CPU Utilization Legend1[localhost.cpu]: Active CPU in % (Load) Legend2[localhost.cpu]: Legend3[localhost.cpu]: Legend4[localhost.cpu]: LegendI[localhost.cpu]: Active LegendO[localhost.cpu]: Options[localhost.cpu]: growright,nopercent
Die mrtg dhcp config neu anlegen:
vi /etc/mrtg/dhcp.cfg
und folgendes einfügen:
WorkDir: /var/www/mrtg Title[dhcpleasecount]: DHCP-Leases PageTop[dhcpleasecount]: <H1>DHCP-Leases</H1> Options[dhcpleasecount]: gauge,nopercent,growright,noinfo Target[dhcpleasecount]: `/etc/mrtg/dhcp.sh` MaxBytes[dhcpleasecount]: 255 YLegend[dhcpleasecount]: Lease Count ShortLegend[dhcpleasecount]: x Unscaled[dhcpleasecount]: ymwd LegendI[dhcpleasecount]: Count LegendO[dhcpleasecount]:
Hier muss der MaxBytes Parameter auf die maximale Zahl der DHCP Leases eingestellt werden.
Anschließend noch das Script anlegen:
vi /etc/mrtg/dhcp.sh
chmod +x /etc/mrtg/dhcp.sh
#!/bin/bash # -> zutreffendes auskommentieren # isc-dhcp-server #leasecount=$(/usr/sbin/dhcp-lease-list --parsable --lease /var/lib/dhcp/dhcpd.leases 2>&1 |wc -l) # dnsmasq #leasecount=$(cat /var/lib/misc/bat0.leases | wc -l) echo "$leasecount" echo "$leasecount" echo 0 echo 0
Die mrtg traffic Config neu anlegen:
/usr/bin/cfgmaker --output=/etc/mrtg/traffic.cfg -zero-speed=100000000 --global "WorkDir: /var/www/mrtg" --ifdesc=name,ip,desc,type --ifref=name,desc --global "Options[_]: bits,growright" public@localhost sed -i -e 's/^\(MaxBytes.*\)$/\10/g' /etc/mrtg/traffic.cfg
Den mrtg Index neu machen:
/usr/bin/indexmaker --output=/var/www/mrtg/index.html --title="$(hostname)" --sort=name --enumerat /etc/mrtg/traffic.cfg /etc/mrtg/cpu.cfg /etc/mrtg/dhcp.cfg
Den eigenen Index neu machen:
cat /var/www/mrtg/index.html | sed -e 's/SRC="/SRC="mrtg\//g' -e 's/HREF="/HREF="mrtg\//g' > /var/www/index.html
Crontab:
*/1 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/cpu.cfg > /dev/null 2>&1 */1 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/traffic.cfg > /dev/null 2>&1 */1 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/dhcp.cfg > /dev/null 2>&1