Obsah

ÚVOD » tajná oblast CLnet » 3comCiscoHuaweiIPv6LinuxMicrosoftNovellRouterboardVMwareostatní instalaceknihovna


04.01.2015 09:55

Cacti

instalace

yum install net-snmp* rrdtool*
svn checkout svn://svn.cacti.net/cacti/cacti/branches/0.8.8 ./cacti

spine

svn checkout svn://svn.cacti.net/cacti/spine/branches/0.8.7/ spine

Skripty

cron

# Cacti
*/5 * * * * cactiuser /usr/bin/php /home/www/cacti/poller.php > /dev/null 2>&1
12  4 * * * cactiuser /usr/bin/php /home/www/cacti/cli/poller_reindex_hosts.php --id=All --qid=all > /dev/null 2>&1
12  5 * * * cactiuser /usr/bin/php /home/www/cacti/cli/poller_graphs_reapply_names.php -id=All > /dev/null 2>&1

iptables.pl

#!/usr/bin/perl
#
# Oznacovani paketu pro mereni prenosu
#
# $IPTABLES -N InetOut
# $IPTABLES -A InetOut  -o eth0  -j RETURN
# $IPTABLES -A OUTPUT  -o eth0  -j InetOut
# $IPTABLES -A FORWARD  -o eth0  -j InetOut
#
# $IPTABLES -N InetIn
# $IPTABLES -A InetIn  -i eth0  -j RETURN
# $IPTABLES -A INPUT  -i eth0  -j InetIn
# $IPTABLES -A FORWARD  -i eth0  -j InetIn
#
# Pak se spusti: iptables.pl Inet
#
# Sudo Configuration (/etc/sudoers)
# > www-data    ALL = NOPASSWD: /usr/share/cacti/scripts/iptables.pl
#
# The Input String should be set to "sudo <path_cacti>/scripts/iptables.pl <chain>"
# and you will need to setup an input field so that the <chain> argument can be passwd.
#
# The data input type should be set to COUNTER
#
#
 
 
@smery = ("In","Out");
 
if ($ARGV[0]) {
    foreach $smer (@smery) {
        $chains = `/sbin/iptables -xnvL | grep -A 2 'Chain $ARGV[0]$smer'`;
        @chains = split(/\n/, $chains);
        $chains[2] =~ /[\W+]?[0-9]+\W+([0-9]+)\W+/;
        print "bytes_$smer:$1 ";
    }
}
else {
    print "Usage: $0 Chain\n";
}

packet_loss.pl

#!/usr/bin/perl
 
$ping = `ping -c 5 $ARGV[0] | grep loss`; 
$ping =~ m/(.*, )(.*)%/; 
 
print $2; 

cacti_graph_template_packet_loss.xml

mbmon.pl

#!/usr/bin/perl
#
#  Monitoring teplot 
#
@data =  split(/\n/, `/usr/bin/mbmon -r -c 1`);
foreach $value (@data) {
	$value =~ s/ //g;
	print "$value ";
}

sqladv.php

<?php
$var = $argv[1];
mysql_connect("localhost", "root", "xxxxx") or die ("No connect");
$res = mysql_query("SHOW STATUS") or die("No query");
while ($a = mysql_fetch_row($res)) {
    $stat[$a[0]] = $a[1];
}
printf("%s", $stat[$var]);
mysql_close();
?>

rrdupdate.sh

#!/bin/sh
 
RRA_PATH=/var/www/cacti/rra
for rdd in `ls $RRA_PATH | grep traffic`
do
    rrdtool tune $RRA_PATH/$rdd --maximum traffic_in:1000000000 --maximum traffic_out:1000000000
done

Ubiquiti wifi

#!/usr/bin/perl
use strict;
#use warnings;
 
use LWP::UserAgent;
use HTTP::Cookies;
use JSON;
 
if (($#ARGV+1) ne 4) {
 exit();
}
 
my $host = $ARGV[0];
my $port = $ARGV[1];
my $user = $ARGV[2];
my $pass = $ARGV[3];
 
my $cookie_jar = HTTP::Cookies->new();
my $browser  = LWP::UserAgent->new();
my $response = '';
my $json = JSON->new();
 
$browser->cookie_jar($cookie_jar);
$response = $browser->get(
    "https://${host}:${port}/login.cgi"
);
 
$response = $browser->post(
    "https://${host}:${port}/login.cgi",
    Content_Type => 'form-data',
    Content => [
    username => ${user},
    password => ${pass},
    ],
);
 
$response = $browser->get(
    "https://${host}:${port}/status.cgi"
);
 
#print ("apmac:"        .$json->decode($response->content)->{wireless}->{apmac} ." ");
print ("ccq:"   .$json->decode($response->content)->{wireless}->{ccq}/10 ." ");
print ("signal:".$json->decode($response->content)->{wireless}->{signal} ." ");
print ("noisef:".$json->decode($response->content)->{wireless}->{noisef} ." ");
#print ("snr:"   .$json->decode($response->content)->{wireless}->{noisef} ." ");
print ("txrate:".$json->decode($response->content)->{wireless}->{txrate} ." ");
print ("rxrate:".$json->decode($response->content)->{wireless}->{rxrate} ." ");
print ("channel:".$json->decode($response->content)->{wireless}->{channel});

XML configs

wlan-client

<interface>
	<name>Wireless Clients</name>
	<description>Clients connect to AP</description>
	<oid_index>.1.3.6.1.4.1.762.2.9.1.1.2</oid_index>
	<fields>
		<name>
			<name>Client Name</name>
			<method>walk</method>
			<source>value</source>
			<direction>input</direction>
			<oid>.1.3.6.1.4.1.762.2.9.1.1.4</oid>
		</name>
		<MacAddr>
			<name>MAC addr</name>
			<method>walk</method>
			<source>value</source>
			<direction>input</direction>
			<oid>.1.3.6.1.4.1.762.2.9.1.1.2</oid>
		</MacAddr>
		<SnrShow>
			<name>Signal-to-Noise Ratio (SNR) - average</name>
			<method>walk</method>
			<source>value</source>
			<direction>input</direction>
			<oid>.1.3.6.1.4.1.762.2.9.1.1.7</oid>
		</SnrShow>
		<TotalBytesShow>
			<name>Total bytes</name>
			<method>walk</method>
			<source>value</source>
			<direction>input</direction>
			<oid>.1.3.6.1.4.1.762.2.9.1.1.5</oid>
		</TotalBytesShow>
		<SNR>
			<name>Signal-to-Noise Ratio (SNR) - average</name>
			<method>walk</method>
			<source>value</source>
			<direction>output</direction>
			<oid>.1.3.6.1.4.1.762.2.9.1.1.7</oid>
		</SNR>
		<TotalBytes>
			<name>Total bytes</name>
			<method>walk</method>
			<source>value</source>
			<direction>output</direction>
			<oid>.1.3.6.1.4.1.762.2.9.1.1.5</oid>
		</TotalBytes>
	</fields>
</interface>

šablony