Skip to content

Instantly share code, notes, and snippets.

View BlueSkyDetector's full-sized avatar

Takanori Suzuki BlueSkyDetector

View GitHub Profile
@BlueSkyDetector
BlueSkyDetector / files_count.js
Created January 12, 2011 03:44
このスクリプト単体で次のように実行するとC:\のファイル数が取得可能。 > cscript //Nologo files_count.js "C:\"
function getDirectoryFilesCount(path) {
var fd = new ActiveXObject("Scripting.FileSystemObject");
var d;
var ret;
try {
d = fd.GetFolder(path);
ret = d.Files.Count;
} catch(e) {
@BlueSkyDetector
BlueSkyDetector / zabbix-1.8.4-fix_select_dns_nameserver.patch
Created April 8, 2011 15:00
fix net.tcp.dns to enable selecting name server for zabbix-1.8.4
diff -uNrp zabbix-1.8.4.orig/src/libs/zbxsysinfo/common/net.c zabbix-1.8.4/src/libs/zbxsysinfo/common/net.c
--- zabbix-1.8.4.orig/src/libs/zbxsysinfo/common/net.c 2011-01-04 22:57:50.000000000 +0900
+++ zabbix-1.8.4/src/libs/zbxsysinfo/common/net.c 2011-04-09 00:00:13.000000000 +0900
@@ -237,11 +237,6 @@ int NET_TCP_DNS(const char *cmd, const c
ip[0] = '\0';
}
- /* default parameter */
- if(ip[0] == '\0')
- {
@BlueSkyDetector
BlueSkyDetector / zabbix-1.8.4-fix_select_dns_nameserver.patch
Created April 8, 2011 16:49
fix net.tcp.dns to enable selecting nameserver for zabbix-1.8.4
diff -uNrp zabbix-1.8.4.orig/src/libs/zbxsysinfo/common/net.c zabbix-1.8.4/src/libs/zbxsysinfo/common/net.c
--- zabbix-1.8.4.orig/src/libs/zbxsysinfo/common/net.c 2011-01-04 22:57:50.000000000 +0900
+++ zabbix-1.8.4/src/libs/zbxsysinfo/common/net.c 2011-04-09 00:00:13.000000000 +0900
@@ -237,11 +237,6 @@ int NET_TCP_DNS(const char *cmd, const c
ip[0] = '\0';
}
- /* default parameter */
- if(ip[0] == '\0')
- {
@BlueSkyDetector
BlueSkyDetector / dhcp_detector.py
Created April 10, 2011 13:40
detect number of DHCP server
#!/bin/env python
from scapy.all import *
conf.checkIPaddr = False
fam,hw = get_if_raw_hwaddr(conf.iface)
dhcp_discover = Ether(dst="ff:ff:ff:ff:ff:ff")/IP(src="0.0.0.0",dst="255.255.255.255")/UDP(sport=68,dport=67)/BOOTP(chaddr=hw)/DHCP(options=[("message-type","discover"),"end"])
ans, unans = srp(dhcp_discover, iface='eth0', multi=True, timeout=2, verbose=0)
print len(ans)
@BlueSkyDetector
BlueSkyDetector / sample.txt
Created April 11, 2011 14:40
ZabbixのWeb画面の「Zabbixサーバの起動」は実質的に次のコマンドを実行しているのに等しい。Resource id #(番号)が返ればOK。先に出てるエラーは無視で。
$ php -r 'include "/etc/zabbix/zabbix.conf.php";echo "\n\n" . fsockopen($ZBX_SERVER, $ZBX_SERVER_PORT, $errnum, $errstr, 2) . "\n\n";'
PHP Notice: Use of undefined constant IMAGE_FORMAT_PNG - assumed 'IMAGE_FORMAT_PNG' in /etc/zabbix/zabbix.conf.php on line 33
Resource id #5
@BlueSkyDetector
BlueSkyDetector / map_sample.xml
Created April 27, 2011 05:53
zabbix map_sample
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export version="1.0" date="27.04.11" time="14.44">
<images>
<image>
<name>Server</name>
<imagetype>1</imagetype>
<encodedImage>iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QAAAAAAAD5Q7t/AAAF8UlEQVR42u1ZS2sUWRT+bj06ST+I3W0HZ1YNxiDoqgNuorgXYXY6MP9BAmG2WbqZP5LZCBEVN4m7ARftECHSYCtkRGUS+1HpTroeXXVmc2/N7Zuq6kfQcmHB4VbdutX1fed8595Tt4Efx48j1aMAgM5hhVTBb2xskOd5FAQB+b5Pw+GQPM8LzXVdchyHbNsm27ZpMBjQYDCg09NTevbsWaokChsbG+Q4zhnwMmgB9uTkhPr9PvX7fer1enR8fEyWZdHTp09TIRGCJ6KpCMjgu90udTodevLkyTcnMSKT89pwOKSHDx8KElMfxiwPOY6Dvb09FIvFaIZEocnX6j0iQrVaxeXLl2f2pjHrg6VSCVeuXEG3240kEHctnw8GAxiGcWb8NyEAAN1uF58+fYr07LgIAECr1cLNmzfTI5AkF7U/6d53Q2ASr0eND4Jg5vdrs4L+8uULNE2LBRQFOAiC8F5UhL5ZBIgIKysr2N3dxeLi4hkpxElEBW5ZVnoSajQauHHjBlzXjdTyJH1EBMMw0olAsVhEuVxGv99PnDrjplAxjXqed64cMM6TuP1+HwcHBxMlc1RCt9tt3L59Ox0JjQM7zTSaioTiQE9bSpyXyMwEhG6n9XoUwVRyoN1uI5/Po9VqTeV1OZlFHZVKDiwvL6NUKqFcLo8A7PV6KBQKiYWcGDs3N5feNEpEODo6ipRPo9FANpudKNGr1Wo6EgqCAG/fvsXu7i56vR5qtRpu3bqFTqeDq1
@BlueSkyDetector
BlueSkyDetector / du.js
Created May 7, 2011 09:38
> cscript //Nologo du.js "C:\test_dir"
function getDirectorySize(path) {
var fd = new ActiveXObject("Scripting.FileSystemObject");
var d;
try {
d = fd.GetFolder(path);
return d.Size;
} catch(e) {
return -1;
}
CREATE TABLE events_history_relation (
eventid bigint unsigned DEFAULT '0' NOT NULL,
history_log_id bigint unsigned DEFAULT '0' NOT NULL,
history_text_id bigint unsigned DEFAULT '0' NOT NULL,
PRIMARY KEY (eventid)
) type=InnoDB;
@BlueSkyDetector
BlueSkyDetector / fix_inherited_item_changing_error_with_no_multiplier_and_formula.patch
Created August 14, 2011 16:30
fix_inherited_item_changing_error_with_no_multiplier_and_formula.patch for zabbix-1.8.6
diff -uNrp zabbix-1.8.6.orig/frontends/php/include/forms.inc.php zabbix-1.8.6/frontends/php/include/forms.inc.php
--- zabbix-1.8.6.orig/frontends/php/include/forms.inc.php 2011-08-12 01:33:40.000000000 +0900
+++ zabbix-1.8.6/frontends/php/include/forms.inc.php 2011-08-15 01:38:21.000000000 +0900
@@ -1929,15 +1929,13 @@ ITEM_TYPE_CALCULATED $key = ''; $params
$mcb = new CCheckBox('multiplier', $multiplier == 1 ? 'yes':'no');
$mcb->setAttribute('disabled', 'disabled');
$mltpbox[] = $mcb;
- if($multiplier){
- $mltpbox[] = SPACE;
- $ctb = new CTextBox('formula', $formula, 10, 1);
diff -uNrp zabbix-1.6.9.orig/frontends/php/include/config.inc.php zabbix-1.6.9/frontends/php/include/config.inc.php
--- zabbix-1.6.9.orig/frontends/php/include/config.inc.php 2010-03-25 23:53:21.000000000 +0900
+++ zabbix-1.6.9/frontends/php/include/config.inc.php 2011-10-27 11:54:13.000000000 +0900
@@ -85,9 +85,13 @@ function TODO($msg) { echo "TODO: ".$msg
require_once 'include/validate.inc.php';
function zbx_err_handler($errno, $errstr, $errfile, $errline){
- error($errstr.'['.$errfile.':'.$errline.']');
-// show_messages();
-// die();