Skip to content

Instantly share code, notes, and snippets.

View cswingler's full-sized avatar

Chrys Swingler cswingler

View GitHub Profile
@cimmanon
cimmanon / psql.md
Created May 2, 2017 17:22
PostgreSQL cheat sheet for MySQL users

I use PostgreSQL via the psql client. If you use a different client (eg. pgAdmin, etc.), I don't know how much will translate over.

One nice difference between psql and mysql (cli) is that if you press CTRL+C, it won't exit the client.

User administration

Login as superuser (via shell)

psql -U postgres
@andreipak
andreipak / tcpstats.sh
Created August 2, 2013 22:31
TCP Connections Stats for Zabbix
#!/bin/bash
/sbin/ss -ant | awk "{if (NR>1) {state[\$1]++}} END {host = \"-\"; \
for (i in state) {s=i; \
sub (/ESTAB/, \"establ\", s); sub (/LISTEN/, \"listen\", s); sub (/SYN-SENT/, \"synsent\", s); \
sub (/SYN-RECV/, \"synrecv\", s); sub (/FIN-WAIT-1/, \"finw1\", s); sub (/FIN-WAIT-2/, \"finw2\", s); \
sub (/CLOSE-WAIT/, \"closew\", s); sub (/TIME-WAIT/, \"timew\", s); print host, \"tcp.\"s, state[i]}}" \
| /usr/bin/zabbix_sender -vv -c /etc/zabbix/zabbix_agentd.conf -i - 2>&1
echo "1"
exit 0