Skip to content

Instantly share code, notes, and snippets.

Avatar

Viktor Manyushin vmanyushin

View GitHub Profile
View gist:228b5b6449fb9dc1d6bab3b726c23d7d
socat -t100 -v UNIX-LISTEN:/var/run/php-fpm.sock,mode=777,reuseaddr,fork UNIX-CONNECT:/var/run/php-fpm.sock.original
@vmanyushin
vmanyushin / sender.sh
Created Feb 20, 2019
send values to zabbix without sender
View sender.sh
#!/bin/bash
# ver 0.1
# emulate zabbix_sender -z zabbix -s eol.lan -k systemd.abandoned -v 35
ZBX=zabbix.lan
NUM=$(echo -n "35" | perl -e 'foreach$c(split(//,<STDIN>)){printf"%x",ord($c);}')
echo -n "5a425844015c000000000000007b2272657175657374223a2273656e6465722064617461222c2264617461223a5b7b22686f7374223a22656f6c2e6c616e222c226b6579223a2273797374656d642e6162616e646f6e6564222c2276616c7565223a22${NUM}227d5d7d" | xxd -r -p | nc $ZBX 10051
@vmanyushin
vmanyushin / strrnd.pl
Created Oct 23, 2018
Random string generator
View strrnd.pl
perl -e 'sub rndStr{ join"",@_[ map{rand @_}1..shift]};for($i=0;$i<$ARGV[0];$i++){ print rndStr($ARGV[1],'A'..'Z')."\n";}' 1 254
View joinFields.php
<?php
class Row {
public function __construct(array $attributes = [])
{
foreach ($attributes as $name => $value) {
$this->{$name} = $value;
}
}
}
View dict_from_csv
<dictionaries>
<dictionary>
<name>asn</name>
<layout>
<hashed />
</layout>
<source>
<file>
<path>/opt/ASN.csv</path>
<format>CSV</format>
View nginx-indent.awk
#!/usr/bin/awk -f
{sub(/^[ \t]+/,"");idx=0}
/\{/{ctx++;idx=1}
/\}/{ctx--}
{id="";for(i=idx;i<ctx;i++)id=sprintf("%s%s", id, "\t");printf "%s%s\n", id, $0}
#!/usr/bin/awk -f
# 4 space edition
{sub(/^[ \t]+/,"");idx=0}
/\{/{ctx++;idx=1}
@vmanyushin
vmanyushin / dump.sh
Last active Aug 29, 2018
Dump http request with headers
View dump.sh
tcpdump -i any port 80 -A | grep -A 10 -P '(GET|POST|OPTIONS|PUT|DELETE).*?HTTP/1.[01]' | perl -ne 's/^.*?(?=(GET|POST|OPTIONS|PUT|DELETE))//g; print;'
@vmanyushin
vmanyushin / leaflet.js
Created Jul 23, 2018
leaflet click on polygon
View leaflet.js
// http://jsfiddle.net/guspersson/yfe1g5zs/
// Create the map
var map = L.map('map').setView([79, -100], 5);
// Set up the OSM layer
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{maxZoom: 18}).addTo(map);
//Handle click on polygon
View findip.sh
# find next free ip address
# fping required
#
export SUBNET=25; echo $(for i in $(seq 10 253); do ip="172.16.${SUBNET}.${i}"; fping -c 1 -t 500 $ip &> /dev/null; if [ $? -eq 1 ]; then echo $ip; break; fi; done)
@vmanyushin
vmanyushin / gist:cc37c84e7ae05a23a55f09e13fa7cef3
Created Oct 26, 2017
enable automatic host inventory for all hosts
View gist:cc37c84e7ae05a23a55f09e13fa7cef3
insert into host_inventory (hostid, inventory_mode) SELECT hostid, 1 FROM hosts;
You can’t perform that action at this time.