wandibudiana

My Server Log

Sep 21st, 2012
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.97 KB | None | 0 0
  1. Installasi HTPROXY di Debian 6.05
  2. RIG : AMD X3 440 Memory = 6 GB Hardisk = 500 GB
  3. topologinya Squid sejajar client ( ip proxy satu subnet dgn client)
  4.  
  5. MODEM------MT-----Swicth----client
  6. |
  7. Debian
  8.  
  9.  
  10.  
  11. Local = 192.168.2.30
  12. Client = 192.168.2.1-192.168.2.20
  13. PROXY = 192.168.2.28
  14.  
  15. /ip firewall nat
  16. add action=dst-nat chain=dstnat comment="TRANSPARENT PROXY SEJAJAR" disabled=no dst-port=80 in-interface=Local protocol=tcp src-address=!192.168.2.28 to-addresses=\
  17. 192.168.2.28 to-ports=3128
  18. add action=src-nat chain=srcnat disabled=no out-interface=Local protocol=tcp src-address-list=Local-Address to-addresses=192.168.2.30 to-ports=0-65535
  19.  
  20. /ip firewall address-list add address=192.168.2.1-192.168.2.27 list=Local-Address
  21. /ip firewall address-list add address=192.168.2.1-192.168.2.28 list=Proxy-Address
  22.  
  23.  
  24.  
  25. /ip dns
  26. set allow-remote-requests=yes cache-max-ttl=1w cache-size=4096KiB \
  27. max-udp-packet-size=512 servers="203.130.208.18,203.130.193.74,203.130.196.5, \
  28. 222.124.204.34,203.130.196.6,208.67.222.222,208.67.220.220,180.131.144.144, \
  29. 180.131.145.145"
  30.  
  31. /ip dns static
  32. add address=192.168.2.28 disabled=no name=proxy.hade.war.net ttl=1d
  33.  
  34.  
  35.  
  36. ip 192.168.2.28
  37. netmask 255.255.255.0
  38. gateway 192.168.2.30
  39. name server addresses = 192.168.2.30
  40. host = proxy
  41. domain = hade.war.net
  42.  
  43. partisi
  44.  
  45. # 1 Primary 6.1 GB swap swap
  46. # 5 Logical 80 GB brtfs /cache-1
  47. # 6 Logical 80 GB brtfs /cache-2
  48. # 7 Logical 80 GB brtfs /cache-3
  49. # 8 Logical 80 GB brtfs /cache-4
  50. # 9 Logical 80 GB brtfs /cache-5
  51. # 10 Logical 80 GB brtfs /cache-6
  52. # 3 Primary 14 GB ext4 /
  53.  
  54.  
  55.  
  56. mulai installasi via remote as root
  57. tambah repo webmin dan installasi build-essential supaya extract tar.bz2 tidak error
  58.  
  59. [CODE]
  60. echo deb http://download.webmin.com/download/repository sarge contrib | tee -a /etc/apt/sources.list
  61. cd /root
  62. wget http://www.webmin.com/jcameron-key.asc
  63. apt-key add jcameron-key.asc
  64. apt-get update && apt-get upgrade
  65. [/CODE]
  66.  
  67.  
  68.  
  69. Jika memory kurang dari 4 lewati saja tahapan ini
  70. [CODE]
  71. apt-get apt-get install linux-image-2.6.32-5-686-bigmem linux-headers-2.6.32-5-686-bigmem
  72. reboot
  73. [/CODE]
  74.  
  75. Tuning Up
  76. Optimalkan file system cache & ubah opsi untuk partisi cache
  77. Disabled fsck (file system check)
  78.  
  79. Angka standart Drive Cache adalah 0 2 ——>> ganti dengan 0 0 (INGAT HANYA DRIVE CACHE)
  80. Opsi Directory /cache :
  81. gunakan opsi noatime,barrier=0 0 0
  82.  
  83. contoh
  84.  
  85. # /cache-1 was on /dev/sda5 during installation
  86. UUID=6f346352-cdce-4f3e-a197-f123a6c09ca4 /cache-1 btrfs default 0 2
  87.  
  88. # /cache-1 was on /dev/sda5 during installation
  89. UUID=6f346352-cdce-4f3e-a197-f123a6c09ca4 /cache-1 btrfs noatime,compress,noacl,barrier=0 0 0
  90.  
  91. [CODE]
  92. apt-get -y install unbound build-essential
  93. cd /etc/unbound
  94. wget ftp://FTP.INTERNIC.NET/domain/named.cache
  95. unbound-control-setup
  96. chown unbound:root unbound_*
  97. chmod 440 unbound_*
  98. [/CODE]
  99.  
  100.  
  101.  
  102. nano /etc/unbound/unbound.conf
  103. delete isinya ganti dengan
  104.  
  105. server:
  106. verbosity: 1
  107. statistics-interval: 120
  108. num-threads: 1
  109. interface: 0.0.0.0
  110. outgoing-range: 512
  111. num-queries-per-thread: 1024
  112. msg-cache-size: 16m
  113. rrset-cache-size: 32m
  114. msg-cache-slabs: 4
  115. rrset-cache-slabs: 4
  116. cache-max-ttl: 86400
  117. infra-host-ttl: 60
  118. infra-lame-ttl: 120
  119. infra-cache-numhosts: 10000
  120. infra-cache-lame-size: 10k
  121. do-ip4: yes
  122. do-ip6: no
  123. do-udp: yes
  124. do-tcp: yes
  125. do-daemonize: yes
  126.  
  127. #access-control: 0.0.0.0/0 allow
  128. access-control: 192.168.0.0/16 allow
  129. #access-control: 172.16.0.0/12 allow
  130. #access-control: 10.0.0.0/8 allow
  131. access-control: 127.0.0.0/8 allow
  132. access-control: 0.0.0.0/0 refuse
  133.  
  134. chroot: "/etc/unbound"
  135. username: "unbound"
  136. directory: "/etc/unbound"
  137. #logfile: "/etc/unbound/unbound.log"
  138. #use-syslog: yes
  139. logfile: ""
  140. use-syslog: no
  141. pidfile: "/etc/unbound/unbound.pid"
  142. root-hints: "/etc/unbound/named.cache"
  143.  
  144. identity: "proxy.hade.war.net"
  145. version: "1.4"
  146. hide-identity: yes
  147. hide-version: yes
  148. harden-glue: yes
  149. do-not-query-address: 127.0.0.1/8
  150. do-not-query-localhost: yes
  151. module-config: "iterator"
  152.  
  153. #zone localhost
  154. local-zone: "localhost." static
  155. local-data: "localhost. 10800 IN NS localhost."
  156. local-data: "localhost. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800"
  157. local-data: "localhost. 10800 IN A 127.0.0.1"
  158.  
  159. local-zone: "127.in-addr.arpa." static
  160. local-data: "127.in-addr.arpa. 10800 IN NS localhost."
  161. local-data: "127.in-addr.arpa. 10800 IN SOA localhost. nobody.invalid. 2 3600 1200 604800 10800"
  162. local-data: "1.0.0.127.in-addr.arpa. 10800 IN PTR localhost."
  163.  
  164. #zone hade.war.net
  165. local-zone: "hade.war.net." static
  166. local-data: "hade.war.net. 86400 IN NS ns.hade.war.net."
  167. local-data: "hade.war.net. 86400 IN SOA hade.war.net. hostmaster.hade.war.net. 3 3600 1200 604800 86400"
  168. local-data: "hade.war.net. 86400 IN A 192.168.2.28"
  169. local-data: "www.hade.war.net. 86400 IN A 192.168.2.28"
  170. local-data: "ns.hade.war.net. 86400 IN A 192.168.2.28"
  171. local-data: "mp3.hade.war.net. 86400 IN A 192.168.2.28"
  172.  
  173. local-zone: "2.168.192.in-addr.arpa." static
  174. local-data: "2.168.192.in-addr.arpa. 10800 IN NS hade.war.net."
  175. local-data: "2.168.192.in-addr.arpa. 10800 IN SOA hade.war.net. hostmaster.hade.war.net. 4 3600 1200 604800 864000"
  176. local-data: "28.2.168.192.in-addr.arpa. 10800 IN PTR hade.war.net."
  177.  
  178.  
  179. forward-zone:
  180. name: "."
  181. forward-addr: 203.130.208.18
  182. forward-addr: 203.130.193.74
  183. forward-addr: 203.130.196.5
  184. forward-addr: 222.124.204.34
  185. forward-addr: 203.130.196.6
  186. forward-addr: 208.67.222.222
  187. forward-addr: 208.67.220.220
  188. forward-addr: 180.131.144.144
  189. forward-addr: 180.131.145.145
  190.  
  191. remote-control:
  192. control-enable: yes
  193. control-interface: 127.0.0.1
  194. control-port: 953
  195. server-key-file: "/etc/unbound/unbound_server.key"
  196. server-cert-file: "/etc/unbound/unbound_server.pem"
  197. control-key-file: "/etc/unbound/unbound_control.key"
  198. control-cert-file: "/etc/unbound/unbound_control.pem"
  199.  
  200. save
  201.  
  202. rubah resolv.conf
  203.  
  204. [CODE]
  205. cat > /etc/resolv.conf
  206. # Begin /etc/resolv.conf
  207. domain proxy.hade.war.net
  208. nameserver 127.0.0.1
  209. nameserver 192.168.2.30
  210. # End /etc/resolv.conf
  211. EOF
  212. [/CODE]
  213.  
  214. unbound-checkconf /etc/unbound/unbound.conf
  215.  
  216. reboot
  217.  
  218. Tuning Up
  219.  
  220. Optimalkan file system cache & ubah opsi untuk partisi cache
  221. Disabled fsck (file system check)
  222.  
  223. Angka standart Drive Cache adalah 0 2 ——>> ganti dengan 0 0 (INGAT HANYA DRIVE CACHE)
  224.  
  225. Opsi Directory /cache :
  226.  
  227. gunakan opsi noatime,barrier=0 0 0
  228.  
  229. contoh
  230.  
  231. # /cache-1 was on /dev/sda5 during installation
  232. UUID=6f346352-cdce-4f3e-a197-f123a6c09ca4 /cache-1 btrfs default 0 2
  233.  
  234.  
  235.  
  236. # /cache-1 was on /dev/sda5 during installation
  237. UUID=6f346352-cdce-4f3e-a197-f123a6c09ca4 /cache-1 btrfs noatime,compress,noacl,barrier=0 0 0
  238.  
  239.  
  240. nano /etc/sysctl.conf
  241.  
  242. kernel.panic = 30
  243. kernel.panic_on_oops = 30
  244. kernel.sysrq = 0
  245. kernel.core_uses_pid = 1
  246. kernel.msgmnb = 65536
  247. kernel.msgmax = 65536
  248. fs.file-max = 65536
  249. vm.swappiness = 0
  250. vm.vfs_cache_pressure=50
  251. vm.mmap_min_addr = 4096
  252. vm.overcommit_ratio = 0
  253. vm.overcommit_memory = 0
  254. kernel.shmmax = 268435456
  255. kernel.shmall = 268435456
  256. vm.min_free_kbytes = 65536
  257. net.ipv6.conf.all.disable_ipv6 = 1
  258. net.ipv4.tcp_syncookies = 1
  259. net.ipv4.tcp_syn_retries = 5
  260. net.ipv4.tcp_synack_retries = 2
  261. net.ipv4.tcp_max_syn_backlog = 4096
  262. net.ipv4.ip_forward = 0
  263. net.ipv4.conf.all.forwarding = 0
  264. net.ipv4.conf.default.forwarding = 0
  265. net.ipv4.conf.all.accept_source_route = 0
  266. net.ipv4.conf.default.accept_source_route = 0
  267. net.ipv4.conf.all.rp_filter = 1
  268. net.ipv4.conf.default.rp_filter = 1
  269. net.ipv4.conf.all.accept_redirects = 0
  270. net.ipv4.conf.default.accept_redirects = 0
  271. net.ipv4.conf.all.log_martians = 0
  272. net.ipv4.conf.default.log_martians = 0
  273. net.ipv4.tcp_fin_timeout = 15
  274. net.ipv4.tcp_keepalive_time = 300
  275. net.ipv4.tcp_keepalive_probes = 5
  276. net.ipv4.tcp_keepalive_intvl = 15
  277. net.ipv4.conf.all.bootp_relay = 0
  278. net.ipv4.conf.all.proxy_arp = 0
  279. net.ipv4.tcp_dsack = 1
  280. net.ipv4.tcp_sack = 1
  281. net.ipv4.tcp_fack = 1
  282. net.ipv4.tcp_timestamps = 1
  283. net.ipv4.icmp_echo_ignore_all = 0
  284. net.ipv4.icmp_echo_ignore_broadcasts = 1
  285. net.ipv4.icmp_ignore_bogus_error_responses = 1
  286. net.ipv4.ip_local_port_range = 1024 65535
  287. net.ipv4.tcp_rfc1337 = 1
  288. net.ipv4.tcp_congestion_control = cubic
  289. net.ipv4.tcp_window_scaling = 1
  290. net.ipv4.tcp_mem = 65536 131072 262144
  291. net.ipv4.udp_mem = 65536 131072 262144
  292. net.ipv4.tcp_rmem = 8192 87380 16777216
  293. net.ipv4.udp_rmem_min = 16384
  294. net.core.rmem_default = 87380
  295. net.core.rmem_max = 16777216
  296. net.ipv4.tcp_wmem = 8192 65536 16777216
  297. net.ipv4.udp_wmem_min = 16384
  298. net.core.wmem_default = 65536
  299. net.core.wmem_max = 16777216
  300. net.core.somaxconn = 32768
  301. net.core.netdev_max_backlog = 4096
  302. net.core.dev_weight = 64
  303. net.core.optmem_max = 65536
  304. net.ipv4.tcp_max_tw_buckets = 1440000
  305. net.ipv4.tcp_tw_recycle = 1
  306. net.ipv4.tcp_tw_reuse = 1
  307. net.ipv4.tcp_max_orphans = 16384
  308. net.ipv4.tcp_orphan_retries = 0
  309. net.ipv4.ipfrag_high_thresh = 512000
  310. net.ipv4.ipfrag_low_thresh = 446464
  311. net.ipv4.tcp_no_metrics_save = 1
  312. net.ipv4.tcp_moderate_rcvbuf = 1
  313. net.unix.max_dgram_qlen = 50
  314. net.ipv4.neigh.default.gc_thresh3 = 2048
  315. net.ipv4.neigh.default.gc_thresh2 = 1024
  316. net.ipv4.neigh.default.gc_thresh1 = 32
  317. net.ipv4.neigh.default.gc_interval = 30
  318. net.ipv4.neigh.default.proxy_qlen = 96
  319. net.ipv4.neigh.default.unres_qlen = 6
  320. net.ipv4.tcp_ecn = 1
  321. net.ipv4.tcp_reordering = 3
  322. net.ipv4.tcp_retries2 = 15
  323. net.ipv4.tcp_retries1 = 3
  324.  
  325.  
  326.  
  327. setelah di save,
  328. sysctl -p
  329.  
  330.  
  331. Kurangi TCP TIME_WAIT setting, default value (60 in Debian 6)
  332.  
  333. echo 4 > /proc/sys/net/ipv4/tcp_fin_timeout
  334.  
  335. ulimit -n 65535 # Sets number of open files for this process and it's children
  336.  
  337. nano /etc/profile file and ensure that the file does not contain any commands that set ulimit values.
  338. Add the following commands to the end of the /etc/profile file
  339.  
  340. ulimit -Hn 65536
  341. ulimit -Sn 65535
  342.  
  343.  
  344. echo 65536 > /proc/sys/fs/file-max
  345. echo "* soft nofile 65536" >> /etc/security/limits.conf
  346. echo "* hard nofile 65536" >> /etc/security/limits.conf
  347. echo "root soft nofile 65536" >> /etc/security/limits.conf
  348. echo "root hard nofile 65536" >> /etc/security/limits.conf
  349. echo "proxy soft nofile 65536" >> /etc/security/limits.conf
  350. echo "proxy hard nofile 65536" >> /etc/security/limits.conf
  351. echo "session required pam_limits.so" >> /etc/pam.d/common-session
  352. modprobe ip_conntrack
  353.  
  354.  
  355. kemudian tambahkan ip_contrack di /etc/modules
  356. nano /etc/modules
  357.  
  358. tambahkan kalimat berikut baris paling bawah :
  359.  
  360. ip_conntrack
  361.  
  362. save
  363.  
  364.  
  365.  
  366. Install squid
  367.  
  368.  
  369.  
  370. [CODE]
  371.  
  372. cd /home
  373.  
  374. wget http://squid-proxy-pkg.googlecode.com/files/deb-htproxy_14942_i386.tar.bz2
  375.  
  376. tar xvf deb-htproxy_14942_i386.tar.bz2
  377.  
  378. dpkg -i *.deb
  379.  
  380. /etc/init.d/squid stop
  381.  
  382. [/CODE]
  383.  
  384.  
  385.  
  386. 64 only for a reccord
  387.  
  388. [CODE]
  389.  
  390. cd /home
  391.  
  392. wget http://squid-proxy-pkg.googlecode.com/files/deb-htproxy_14942_x86-64.tar.bz2
  393.  
  394. tar xvf deb-htproxy_14942_x86-64.tar.bz2 && dpkg -i *.deb
  395.  
  396. dpkg -i *.deb
  397.  
  398. /etc/init.d/squid stop
  399.  
  400. [/CODE]
  401.  
  402.  
  403.  
  404. # Hapus cache
  405.  
  406. rm -rf /var/spool/squid/*
  407.  
  408.  
  409.  
  410. edit squid.conf sesuai kondisi
  411.  
  412.  
  413.  
  414.  
  415.  
  416. http_port 3229 transparent
  417.  
  418. visible_hostname www.hade.war.net
  419.  
  420.  
  421.  
  422. #partisi cachedir maksimal 80% dari total jumlah volume yang kosong
  423.  
  424. #dan sesuaikan dengan besar memory setelah di kurangi memory untuk system OS dan aplikasi yang lainya,
  425.  
  426. #untuk 32 bit OS I386 setiap 1 Gb Hardisk membutuhakn 10 Mb RAM
  427.  
  428. #untuk 64 bit OS I386 setiap 1 Gb Hardisk membutuhakn 14 Mb RAM
  429.  
  430. # 480 G . 75 % = 360 G. 10 = 3600 MB Untuk Cache
  431.  
  432. # dari 6144 memory yg terinstall karena onboard vga terbaca 6053 ( free -m )
  433.  
  434. # 6053 = 1536 + 3600 + 953 ( cache memory + cache + system dan mrtg)
  435.  
  436. cache_mem 1536 MB
  437.  
  438.  
  439.  
  440. #Contoh cache dir untuk disk 80Gb dengan sisa space yang kosong 70Gb, kita gunakan 50% saja = 35GB
  441.  
  442. # dir untuk cache 80Gb digunakan 75% = 60 GB
  443.  
  444. ###############################################################################################
  445.  
  446. cache_dir aufs /cache-1 60000 140 256
  447.  
  448. cache_dir aufs /cache-2 60000 140 256
  449.  
  450. cache_dir aufs /cache-3 60000 140 256
  451.  
  452. cache_dir aufs /cache-4 60000 140 256
  453.  
  454. cache_dir aufs /cache-5 60000 140 256
  455.  
  456. cache_dir aufs /cache-6 60000 140 256
  457.  
  458.  
  459.  
  460. #CONTOH DNS speedy open dns dan nawala
  461.  
  462. dns_nameservers 203.130.208.18
  463.  
  464. dns_nameservers 203.130.193.74
  465.  
  466. dns_nameservers 203.130.196.5
  467.  
  468. dns_nameservers 222.124.204.34
  469.  
  470. dns_nameservers 203.130.196.6
  471.  
  472. dns_nameservers 208.67.222.222
  473.  
  474. dns_nameservers 208.67.220.220
  475.  
  476. dns_nameservers 180.131.144.144
  477.  
  478. dns_nameservers 180.131.145.145
  479.  
  480. ##############################################################
  481.  
  482.  
  483.  
  484. # Antisipasi patch game ukuran besar
  485.  
  486. maximum_object_size 700000 KB
  487.  
  488.  
  489.  
  490. # storeurl_rewrite_children 30
  491.  
  492. quick_abort_min 0 KB
  493.  
  494. quick_abort_max 0 KB
  495.  
  496. quick_abort_pct 100
  497.  
  498. storeurl_rewrite_children 15
  499.  
  500.  
  501.  
  502.  
  503.  
  504. include /etc/squid/safeSearch.conf
  505.  
  506.  
  507.  
  508. chown proxy:proxy /cache-* && chmod 777 /cache-*
  509.  
  510. squid -z
  511.  
  512. squid -f /etc/squid/squid.conf -z && /etc/init.d/squid start
  513.  
  514.  
  515.  
  516. iptables -F
  517.  
  518. iptables -X
  519.  
  520. iptables -t nat -F
  521.  
  522. iptables -t nat -X
  523.  
  524. iptables -t mangle -F
  525.  
  526. iptables -t mangle -X
  527.  
  528. iptables -P INPUT ACCEPT
  529.  
  530. iptables -P OUTPUT ACCEPT
  531.  
  532. iptables -A INPUT -s 192.168.0.0/16 -m state --state NEW -p tcp --dport 53 -j ACCEPT
  533.  
  534. iptables -A INPUT -s 192.168.0.0/16 -m state --state NEW -p udp --dport 53 -j ACCEPT
  535.  
  536. iptables -A INPUT -p tcp -s 192.168.0.0/16 --dport 80 -j ACCEPT
  537.  
  538. iptables -A INPUT -p udp -s 192.168.0.0/16 --dport 3128 -j ACCEPT
  539.  
  540. iptables -t nat -A PREROUTING -i eth0 -p udp --dport 80 -j REDIRECT --to-port 3229
  541.  
  542. iptables-save -c > /etc/iptables.up.rules
  543.  
  544.  
  545.  
  546. apt-get install sharutils ccze webmin
  547.  
  548. Server Log Mrtg
  549. http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html
  550.  
  551. mrtg tanpa snmp on Debian Squeeze
  552. disini kita hanya akan menggunakan script bash dan perl untuk menggantikan snmpwalk
  553.  
  554. data yang di graph :
  555. cache size, ethernet traffic, memory usage, cpu load, tcp connection dan latency
  556.  
  557. apt-get install gcc make perl apache2 libgd-tools mrtg-contrib mrtg
  558.  
  559. cd /usr/local/bin
  560.  
  561. nano mem.sh
  562.  
  563. #!/bin/sh
  564.  
  565. # Thierry Nkaoua [email protected]
  566.  
  567. USED=`free -b|grep cache:|cut -d ":" -f2|cut -c1-11`
  568. #FREE=`free -b|grep cache:|cut -d ":" -f2|cut -c12-22`
  569. echo $USED
  570. echo $USED
  571.  
  572. nano eth.pl
  573.  
  574. #!/usr/bin/perl
  575.  
  576. use strict;
  577.  
  578. my $if = $ARGV[0] || mrtg_die();
  579.  
  580. open(F, "</proc/net/dev") || mrtg_die();
  581. my @LINES = <F>;
  582. close(F);
  583.  
  584. foreach (grep(/\s+$if\:/, @LINES)) {
  585. /\s+$if\:(\s*\d*){1}/;
  586. my $recv = $1;
  587. $recv =~ s/\s+//g;
  588.  
  589. /\s+$if\:(\s*\d*){9}/;
  590. my $sent = $1;
  591. $sent =~ s/\s+//g;
  592.  
  593. print "$recv\n$sent\n0\n0\n";
  594. }
  595.  
  596. sub mrtg_die() {
  597. print "0\n0\n0\n0\n";
  598. }
  599.  
  600. nano loadavg.sh
  601.  
  602. #!/bin/sh
  603. awk </proc/loadavg '{print (100*$1) "\n" (100*$2) }'
  604. hostname;
  605. echo "loadavg";
  606.  
  607. nano tcpconn.sh
  608.  
  609. #!/bin/sh
  610.  
  611. if [ "$1" = "" ] ; then
  612. O=`/bin/netstat -nt | fgrep ESTABLISHED | wc -l`
  613. label='numconns'
  614. else
  615. O=`/bin/netstat -nt | fgrep ESTABLISHED | fgrep "$1" | wc -l`
  616. label="$1"
  617. fi
  618. echo $O
  619. echo $O
  620. hostname
  621. echo "$label"
  622.  
  623. nano ping.pl
  624.  
  625.  
  626. #!/usr/bin/perl
  627. use strict;
  628. use warnings;
  629. use Net::Ping;
  630. use Time::HiRes;
  631.  
  632. my $host = shift;
  633.  
  634. my $p = Net::Ping->new("icmp");
  635. $p->hires();
  636. my ($ret, $duration, $ip) = $p->ping($host, 5.5);
  637. if ( $ret ) {
  638. printf "%.0f\n", 1000 * $duration;
  639. } else {
  640. print "0\n";
  641. }
  642.  
  643. # Value "in" for mrtg
  644. print "0\n";
  645. # Value "out" for mrtg
  646. print "\n";
  647. # A comment for mrt
  648. print "$host\n";
  649. $p->close();
  650.  
  651.  
  652.  
  653. chmod +x *
  654. nano /etc/mrtg.cfg
  655.  
  656. # -------------------------------------------
  657. # HADENET
  658. # -------------------------------------------
  659. WorkDir: /var/www/mrtg
  660. #RunAsDaemon:Yes
  661. Interval:5
  662. WriteExpires: Yes
  663. EnableIPv6: no
  664. Background[_]:#CCCCCC;
  665. Colours[_]:LIGHTBLUE#0099FF,ORANGE#FF6600,BLUE#0000FF,RED#FF0000
  666. Options[_]: nopercent,growright,noinfo,gauge
  667.  
  668. # eth0
  669. # -------------------------------------------
  670.  
  671. Title[eth0]: Ethernet Trafic
  672. PageTop[eth0]: <h1>Ethernet Trafic</h1>
  673. Target[eth0]: `/usr/local/bin/eth.pl eth0`
  674. Options[eth0]: bits
  675. MaxBytes[eth0]: 100000000
  676.  
  677. # Memory
  678. # -------------------------------------------
  679.  
  680. Title[mem]: Memory Usage
  681. PageTop[mem]: <h1>Memory Usage</h1>
  682. Target[mem]: `/usr/local/bin/mem.sh`
  683. Options[mem]: gauge,noinfo,nopercent,growright,nobanner,noarrow,pngdate
  684. MaxBytes[mem]: 1024000000
  685. YLegend[mem]: Bytes
  686. ShortLegend[mem]: Bytes
  687. LegendO[mem]: Mem Used :
  688. WithPeak[mem]: wmy
  689. Kilo[mem]:1024
  690.  
  691. # TCP Connection
  692. # -------------------------------------------
  693.  
  694. Title[server-numconns]: Server TCP connections
  695. Target[server-numconns]: `/usr/local/bin/tcpconn.sh`
  696. PageTop[server-numconns]: <h1>TCP connections</h1>
  697. MaxBytes[server-numconns]: 1000
  698. YLegend[server-numconns]: Connections
  699. ShortLegend[server-numconns]: Connections
  700. LegendO[server-numconns]: Connections
  701. Options[server-numconns]: gauge, growright
  702.  
  703. ## CPU Load
  704. # -------------------------------------------
  705.  
  706. Target[server-cpu]: `/usr/local/bin/loadavg.sh`
  707. MaxBytes[server-cpu]: 500
  708. Title[server-cpu]: CPU Load
  709. PageTop[server-cpu]: <h1>CPU Load</h1>
  710. YLegend[server-cpu]: Load*100
  711. ShortLegend[server-cpu]: load
  712. Legend1[server-cpu]: CPU Load (x 100)
  713. Legend2[server-cpu]:
  714. LegendI[server-cpu]: 1min load
  715. LegendO[server-cpu]: 5min load
  716. Options[server-cpu]: gauge,nopercent,integer,growright
  717.  
  718. # Latency Local
  719. # -------------------------------------------
  720.  
  721. Target[ping_local]: `/usr/local/bin/ping.pl www.indowebster.com`
  722. Title[ping_local]: Latency Local
  723. PageTop[ping_local]: <h1>Latency Local</h1>
  724. LegendO[ping_local]:
  725. MaxBytes[ping_local]: 10000
  726. Options[ping_local]: gauge,growright
  727. LegendI[ping_local]: Ping in ms
  728. ShortLegend[ping_local]: ms
  729. YLegend[ping_local]: ms
  730. Factor[ping_local]: 1
  731.  
  732. # Latency Inter
  733. # -------------------------------------------
  734.  
  735. Target[ping_inter]: `/usr/local/bin/ping.pl www.facebook.com`
  736. Title[ping_inter]: Latency Inter<
  737. PageTop[ping_inter]: <h1>Latency Inter</h1>
  738. LegendO[ping_inter]:
  739. MaxBytes[ping_inter]: 10000
  740. Options[ping_inter]: gauge,growright
  741. LegendI[ping_inter]: Ping in ms
  742. ShortLegend[ping_inter]: ms
  743. YLegend[ping_inter]: ms
  744. Factor[ping_inter]: 1
  745.  
  746.  
  747. mkdir /var/www/mrtg
  748.  
  749. env LANG=C mrtg /etc/mrtg.cfg
  750.  
  751. jalankan 3 x sampai error hilang
  752.  
  753. indexmaker --output=/var/www/mrtg/index.html /etc/mrtg.cfg
  754.  
  755. 192.168.2.28/mrtg
  756.  
  757. edit lagi file /etc/mrtg.cfg
  758. nano /etc/mrtg.cg
  759.  
  760. hilangkan tanda “#” di depan RunAsDaemon:Yes
  761.  
  762. jalankan sekali lagi mrtg untuk aktifkan daemon mrtg
  763. env LANG=C mrtg /etc/mrtg.cfg
  764.  
  765. buat index.html
  766. indexmaker --output=/var/www/mrtg/index.html /etc/mrtg.cfg
  767.  
  768. akses via broser ke http://[ip-address]/mrtg
  769.  
  770. buka webmin, kita akan buat start-up mrtg dari webmin
  771.  
  772. webmin > system > bootup and shutdown > Create a new bootup and shutdown action
  773.  
  774. note
  775.  
  776. * Target[eth0]: `/usr/local/bin/eth.pl eth0` > jika ethernet yg aktif bukan eth0, ganti eth0 dengan ethernet card yang aktif. jalankan ifconfig untuk melihat ethernet yang aktif
  777. * Target[ping_inter]: `/usr/local/bin/ping.pl www.yahoo.com` > silahkan diganti dengan host lain sesuai selera misalnya microsoft.com ato cuma IP-nya tidak perlu pakai hostname. hanya pastikan host yang anda pakai reliable
Advertisement
Add Comment
Please, Sign In to add comment