Install MRTG Directadmin CentOS 5 32/64bit
Problem : MRTG Graph in DirectAdmin cp + CentOS Solutions: yum -y install gd gd-devel libpng libpng-devel zlib zlib-devel net-snmp net-snmp-utils mrtg..
aptitude -y install mrtg
mkdir /usr/local/bin/mrtgx/
vim /usr/local/bin/mrtgx/mem.sh
#!/bin/sh
USED=`free -b|grep cache:|cut -d ":" -f2|cut -c1-11`
#FREE=`free -b|grep cache:|cut -d ":" -f2|cut -c12-22`
echo $USED
echo $USED
vim /usr/local/bin/mrtgx/eth.pl
#!/usr/bin/perl
use strict;
my $if = $ARGV[0] || mrtg_die();
open(F, "</proc/net/dev") || mrtg_die();
my @LINES = <F>;
close(F);
foreach (grep(/\s+$if\:/, @LINES)) {
/\s+$if\:(\s*\d*){1}/;
my $recv = $1;
$recv =~ s/\s+//g;
/\s+$if\:(\s*\d*){9}/;
my $sent = $1;
$sent =~ s/\s+//g;
print "$recv\n$sent\n0\n0\n";
}
sub mrtg_die() {
print "0\n0\n0\n0\n";
}
vim /usr/local/bin/mrtgx/eth.sh
#!/bin/sh
if [ "$1" != "" ] ; then
cat /proc/net/dev |grep $1|cut -d ":" -f2 | awk '{print ($1) "\n" ($9) }'
else
cat /proc/net/dev |grep lo|cut -d ":" -f2 | awk '{print ($1) "\n" ($9) }'
fi
echo "0";
echo "0";
vim /usr/local/bin/mrtgx/loadavg.sh
#!/bin/sh
awk </proc/loadavg '{print (100*$1) "\n" (100*$2) }'
hostname;
echo "loadavg";
vim /usr/local/bin/mrtgx/tcpconn.sh
#!/bin/sh
if [ "$1" = "" ] ; then
O=`/bin/netstat -nt | fgrep ESTABLISHED | wc -l`
label='numconns'
else
O=`/bin/netstat -nt | fgrep ESTABLISHED | fgrep "$1" | wc -l`
label="$1"
fi
echo $O
echo $O
hostname
echo "$label"
vim /usr/local/bin/mrtgx/ping.pl
#!/usr/bin/perl
use strict;
use warnings;
use Net::Ping;
use Time::HiRes;
my $host = shift;
my $p = Net::Ping->new("icmp");
$p->hires();
my ($ret, $duration, $ip) = $p->ping($host, 5.5);
if ( $ret ) {
printf "%.0f\n", 1000 * $duration;
} else {
print "0\n";
}
# Value "in" for mrtg
print "0\n";
# Value "out" for mrtg
print "\n";
# A comment for mrt
print "$host\n";
$p->close();
chmod +x /usr/local/bin/mrtgx/*
mv /etc/mrtg.cfg /etc/mrtg.cfg.bak-
vim /etc/mrtg.cfg
# -------------------------------------------
# OLCNET mrtg.cfg 17072011
# -------------------------------------------
# Global Config
# -------------------------------------------
WorkDir: /var/www/mrtg
#RunAsDaemon:Yes
Interval:5
WriteExpires: Yes
EnableIPv6: no
Background[_]:#CCCCCC;
Colours[_]:LIGHTBLUE#0099FF,ORANGE#FF6600,BLUE#0000FF,RED#FF0000
Options[_]: nopercent,growright,noinfo,gauge
# eth0
# -------------------------------------------
Title[eth0]: Ethernet Trafic
PageTop[eth0]: <h1>Ethernet Trafic</h1>
Target[eth0]: `/usr/local/bin/mrtgx/eth.sh venet0`
Options[eth0]: bits,growright
MaxBytes[eth0]: 100000000
# Memory
# -------------------------------------------
Title[mem]: Memory Usage
PageTop[mem]: <h1>Memory Usage</h1>
Target[mem]: `/usr/local/bin/mrtgx/mem.sh`
Options[mem]: gauge,noinfo,nopercent,growright,nobanner,noarrow,pngdate
MaxBytes[mem]: 16384000000
YLegend[mem]: Bytes
ShortLegend[mem]: Bytes
LegendO[mem]: Mem Used :
WithPeak[mem]: wmy
Kilo[mem]:1024
# TCP Connection
# -------------------------------------------
Title[server-numconns]: Server TCP connections
Target[server-numconns]: `/usr/local/bin/mrtgx/tcpconn.sh`
PageTop[server-numconns]: <h1>TCP connections</h1>
MaxBytes[server-numconns]: 3000
YLegend[server-numconns]: Connections
ShortLegend[server-numconns]: Connections
LegendO[server-numconns]: Connections
Options[server-numconns]: gauge, growright
## CPU Load
# -------------------------------------------
Target[server-cpu]: `/usr/local/bin/mrtgx/loadavg.sh`
MaxBytes[server-cpu]: 10000
Title[server-cpu]: CPU Load
PageTop[server-cpu]: <h1>CPU Load</h1>
YLegend[server-cpu]: Load x 100%
ShortLegend[server-cpu]: load
Legend1[server-cpu]: CPU Load (x 100%)
Legend2[server-cpu]:
LegendI[server-cpu]: 1min load
LegendO[server-cpu]: 5min load
Options[server-cpu]: gauge,nopercent,integer,growright
# Latency Local
# -------------------------------------------
Target[ping_local]: `/usr/local/bin/mrtgx/ping.pl www.tot.co.th`
Title[ping_local]: Latency Local
PageTop[ping_local]: <h1>Latency Local</h1>
LegendO[ping_local]:
MaxBytes[ping_local]: 10000
Options[ping_local]: gauge,growright
LegendI[ping_local]: Ping in ms
ShortLegend[ping_local]: ms
YLegend[ping_local]: ms
Factor[ping_local]: 1
# Latency Inter
# -------------------------------------------
Target[ping_inter]: `/usr/local/bin/mrtgx/ping.pl www.google.com`
Title[ping_inter]: Latency Inter<
PageTop[ping_inter]: <h1>Latency Inter</h1>
LegendO[ping_inter]:
MaxBytes[ping_inter]: 10000
Options[ping_inter]: gauge,growright
LegendI[ping_inter]: Ping in ms
ShortLegend[ping_inter]: ms
YLegend[ping_inter]: ms
Factor[ping_inter]: 1
mkdir /var/www/mrtg
env LANG=C mrtg /etc/mrtg.cfg
env LANG=C mrtg /etc/mrtg.cfg
env LANG=C mrtg /etc/mrtg.cfg
perl -pi -e 's/#RunAsDaemon:Yes/RunAsDaemon:Yes/' /etc/mrtg.cfg
env LANG=C mrtg /etc/mrtg.cfg
indexmaker --output=/var/www/mrtg/index.html /etc/mrtg.cfg
ln -s /var/www/mrtg /var/www/html/mrtgx
September 7, 2013
Problem : MRTG Graph in DirectAdmin cp + CentOS Solutions: yum -y install gd gd-devel libpng libpng-devel zlib zlib-devel net-snmp net-snmp-utils mrtg..
วิธีล้างแคช cloudflare ง่ายๆ กดใช้งานได้จากตรง admin menubar ด้านของ Wordpress เพียงแค่เพิ่มโค้ดในไฟล์ function.php ของ theme ที่ใช้งานอยู่ อย่าลืมใส่..
OS CentOS yum install libxml2-devel libxslt-devel libgcrypt-devel OS Debian aptitude install libxslt1.1 libxslt1-dev libgcrypt11-dev libxml2 libxml2-d..
Problem: ./map-server_sql: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory Solutions: ap..
#1. Install file module (PHP 5.2.x) cd /tmp/ wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz tar xvfz Z..
Mod_evasive คือ module เสริม ชนิดหนึ่งของ apache ซึ่งทำหน้าที่ ตรวจจับ การ request ผ่าน service apache โดย มีขั้นตอนการทำงาน คือ ถ้า IP ใด มีการ reque..