• This repository has been archived on 30/Mar/2020
  • Stars
    star
    949
  • Rank 48,153 (Top 1.0 %)
  • Language
    Perl
  • License
    Other
  • Created over 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tools for Linux/Unix sysadmins.

sysadmin-utils

This repository contains a small collection of scripts that might be useful to sysadmins. I put it together myself to centralise the small tools that I find useful, and it seems to be popular.

I used to solicit the inclusion of new tools, but have slowly come to realize that "less is more". I love the idea of sysadmins, developers, and other people building up their own toolkits, but also find that people submit things that I just don't understand the appeal of.

It makes sense that personal-tools are very personal, but it does mean rejection is almost always the default behaviour and that makes me feel bad.

Instead of adding things here consider this repository a small collection of things that I use, and if you want to take some/all of utilities into your own use then please do so. If not then I would strongly encourage you to consider what tools would make your daily-life more useful and then collect them, document them, and publish them yourself.

In short the value here is the idea of collecting your commonmost utilities and making them easy to install and update from one central-source. Not the specific tools themselves.

There is a replacement repository which is still open, and which new additions can be made more freely:

ago

Show how long ago a file/directory was modified in a human-readable fashion.

Example:

 $ ./ago /etc/passwd
 /etc/passwd 15 weeks ago

Alternatives:

  • stat and ls both show ages, but not in a human-readable fashion.

chronic

Run a command, hiding STDOUT and STDERR if it completes successfully.

Example:

 ./chronic cp /etc/passwd /tmp/not/found

This is designed to be used for cron-jobs, where output is generally ignored in the case of success.

This was written by Joey Hess and is part of moreutils.

cidr2ip

Given a set of CIDR ranges output the individual IPs in the range(s).

Example:

 $ ./cidr2ip 192.168.0.0/24
 192.168.0.0
 192.168.0.1
 192.168.0.2
 192.168.0.3
 192.168.0.4
 ..

collapse

Remove extraneous whitespace from lines, and remove empty-lines entirely.

Example:

 $ echo -e "Test1\n    f  \n\nTest2\n\n\n\n" | ./collapse
 Test1
 f
 Test2

Alternatives:

  • tr
  • ...

dupes

Report on duplicate files, via a SHA1 hash of the contents, recursively.

Example:

$ dupes
./.git/logs/HEAD
./.git/logs/refs/heads/master
./.git/refs/heads/master
./.git/refs/remotes/origin/master

Alternatives:

empty-dir

Indicate, via return code, whether a given directory is empty or not.

Example:

if empty-dir /etc; then echo "We're broken" ; fi

expand-ipv6

Expand an abbreviated/compressed IPv6 address to the full-form.

Example:

 ./expand-ipv6 fe80::1 2001:41c8:10b:103::111
 fe80:0000:0000:0000:0000:0000:0001
 2001:41c8:010b:0103:0000:0000:0111

Alternatives:

  • sipcalc
  • ...

graphite_send

A simple script to send a consistent set of metrics & values to a remote graphite instance.

The metrics may be extended via small "plugins", which are nothing more than shell/perl/ruby/python scripts in a particular directory.

Example:

 graphite_send -v

NOTE Some metrics will only be sent if the invoking user is root.

Alternatives

ipaddr

Get IP addresses easily, either all IPs, all those which are IPv4/IPv6, or those for a device. Designed primarily for scripting.

Example:

  $ ./ips -4
  lo 127.0.0.1
  eth0 80.68.84.102
  eth0 80.68.84.104

Or to see all IPv6 addreses on eth0:

  $ ipaddr -6 -d eth0
  eth0 2001:41c8:10b:102::10
  eth0 fe80::216:3eff:fe08:16a4

NOTE Requires compilation via make build.

Alternatives:

  • ip -[46] addr show
  • ifconfig -a

maybe

In a similar vein to true and false the maybe command exits with a status code of zero or one, depending on a random number.

It can be useful in scripts which need to test-failures, or which benefit from randomness:

Example:

 maybe && echo "I pass"

 maybe || echo "I fail"

multi-ping

Ping a host, regardless of whether it is an IPv6 or IPv4 host.

Example:

 $ multi-ping steve.org.uk
 Host steve.org.uk - 80.68.85.46 alive
 Host steve.org.uk - 2001:41c8:125:46:0:0:0:10 alive

As a convenience you may also specify URIs as arguments, for example:

 $ multi-ping http://steve.org.uk/foo/bar
 Host steve.org.uk - 80.68.85.46 alive
 Host steve.org.uk - 2001:41c8:125:46:0:0:0:10 alive

Requirements:

  • The Net::DNS perl module.
  • The ping + ping6 binaries.

mysql-slave-check

If the current host is a MySQL slave this script will test that the slave replication is still working.

Replication is regarded as being OK if the following three conditions are true:

  • The output of "SHOW SLAVE STATUS" includes: Slave_IO_Running: Yes
  • The output of "SHOW SLAVE STATUS" includes: Slave_SQL_Runing: Yes
  • The slave is less than 24 hours behind the master.

Example:

 # ./mysql-slave-check
 The replication appears to show an error:
 ..
 Master_Host: da-db1
 Master_User: slave
 Master_Port: 3306
 Connect_Retry: 60
 Master_Log_File: mysql-bin.000124
 Read_Master_Log_Pos: 65667
 Relay_Log_File: relay-log.001139
 Relay_Log_Pos: 27251
 Relay_Master_Log_File: mysql-bin.000124
 Slave_IO_Running: No
 Slave_SQL_Running: No
 ..

The script exits silently if all is well, unless you add "--verbose":

 # ./mysql-slave-check -v
 The slave is running, successfully.
 Replication lag: 0 seconds

Requirements:

  • There must be a file /etc/mysql/debian.cnf with valid "user=" and "password=" lines.

pyhttpd

A simple Python HTTP server, which has been updated to allow it to bind to arbitrary IP addresses, specifically to allow you to bind to localhost.

Example:

 $ ./pyhttpd 127.0.0.1:8080
 Serving HTTP on 127.0.0.1 port 8080 ...

or

 $ ./pyhttpd 8080
 Serving HTTP on 0.0.0.0 port 8080 ...

randpass

Generate a single random password via /dev/urandom.

Example:

  $ ./randpass
  cT3j7Zp6
  $ ./randpass -n 10
  ulHrNvYLaa
  $ ./randpass -n 20 -f
  oe[d7+e.{Uw=L'RO~[]{

(Adding "-f" uses the full alphabet of possible symbols, otherwise only alpha-numeric values are shown. "-n" sets the length of the generated password.)

Existing alternatives:

  • apg
  • gpw
  • pwgen
  • ...

since

Show the new output since previously reading a file. This is useful for keeping track of logfile updates.

Example:

   $ ./since /var/log/messages >/dev/null
   $ logger "testing the log"
   $ ./since /var/log/messages
   Apr 20 11:24:37 precious skx: testing the log

Existing alternatives:

  • logtail

ssh-auth-types

Show the authentication types presented by a remote SSH server.

Example:

 $ ./ssh-auth-types precious
 publickey password

 $ ./ssh-auth-types ssh.example.com
 publickey

ssh-test

Test whether ssh connections to a list of hosts will succeed, by testing each in order.

Example:

 $ ./ssh-test host.list.txt
 ssh.steve.org.uk    ... OK
 www.steve.org.uk    ... OK
 foo.example.com:222 ... OK

 $ cat host.list.txt
 ssh.steve.org.uk
 www.steve.org.uk
 foo.example.com:222

The format of the input-file is:

[user@]hostname1[:port]
[user@]hostname2[:port]
..

splay

Sleep for a random amount of time, limited by the given max value. (Default is 5 minutes).

Example:

  $ ./splay -v
  Sleeping for 77 seconds from max splay-time of 300 seconds

  $ ./splay -v -m 20
  Sleeping for 7 seconds from max splay-time of 20 seconds

Existing alternatives:

ssl-expiry-date

Report the date, and number of days, until the given SSL certificate expires. Multiple domain-names may be accepted and each is tested in turn.

The default output is "noisy", but you may add "-d" to simplify this to the domain-name and the number of days remaining on the certificate.

Example:

  ./ssl-expiry-date  bbc.co.uk
  bbc.co.uk
      Expires: Sep 18 13:50:57 2016 GMT
      Days: 266

  ./ssl-expiry-date -d bbc.co.uk steve.org.uk
  bbc.co.uk: 266
  steve.org.uk: 82

timeout

Timeout allows you to run a command which will be killed after the given number of seconds.

Example:

    # Kill the command after 63 seconds.
    ./timeout -t 63 top

    # Kill the command after two minutes, five seconds.
    ./timeout -t 2:5 top

    # Kill the command after three hours, five minutes, and seven seconds
    ./timeout -t 3:5:7 top

until-success

Repeat the specific command until it succeeds - run at least once always.

Example:

     ./until-success ssh example.com -l root -i ~/.ssh/example.com.key

Trivial (ba)sh alternatives:

  • while true ; do $cmd; done
  • watch -n 2 $cmd

when-up

Waits until a given host is online, determined by ping, until executing a given command.

Example:

 $ ./when-up 1.2.3.4 ssh [email protected]
 Waiting for 1.2.3.4 to come online...
 Last login: Sat Dec 28 23:25:01 2013 from 5.6.7.8
 [email protected]:~#

Alternatives:

until-error

Repeat the specific command until it fails - run at least once always.

Example:

     ./until-error ssh example.com -l root -i ~/.ssh/example.com.key

Trivial (ba)sh alternatives:

  • while true ; do $cmd; done
  • watch -n 2 $cmd

when-down

Waits until a given host is down

Example:

 $ ./when-down 1.2.3.4 echo "down"
 Waiting for 1.2.3.4 to get down...
 down

Alternatives:

  • until-error ping -c 1 -W 1 1.2.3.4; echo "down"

which-shell

Identify the shell we're running under.

For example:

 $ which-shell
 dash

Existing alternatives:

  • ls -l /bin/sh

with-lock

Run a command, unless an existing copy of that command is already running, via the creation of a temporary lockfile.

For example:

 with-lock rsync ...

The lockfile-name is based upon the SHA1 hash of the command to be executed and the current User-ID.

Existing alternatives:

  • lckdo - Requires you to build your own lockfile name.
  • flock - Requires you to build your own lockfile name.

Problems

Please report any issue/suggestions via the github repository:

Author

Steve Kemp [email protected]

More Repositories

1

bookmarks.public

A template for self-hosted bookmarks using HTML & jQuery.
JavaScript
662
star
2

tunneller

Allow internal services, running on localhost, to be accessed over the internet..
Go
474
star
3

simple.vm

Simple virtual machine which interprets bytecode.
C
459
star
4

deployr

A simple golang application to automate the deployment of software releases.
Go
334
star
5

gobasic

A BASIC interpreter written in golang.
Go
325
star
6

go.vm

A simple virtual machine - compiler & interpreter - written in golang
Go
322
star
7

simple-vpn

A simple VPN allowing mesh-like communication between nodes, over websockets
Go
284
star
8

monkey

An interpreted language written in Go
Go
272
star
9

sysbox

sysadmin/scripting utilities, distributed as a single binary
Go
218
star
10

esp8266

Collection of projects for the WeMos Mini D1
C++
165
star
11

kilua

A minimal text-editor with lua scripting.
C++
160
star
12

sos

Simple Object Storage (I wish I could call it Steve's Simple Storage, or S3 ;)
Go
150
star
13

github-action-publish-binaries

Publish binaries when new releases are made.
Shell
137
star
14

evalfilter

A bytecode-based virtual machine to implement scripting/filtering support in your golang project.
Go
117
star
15

rss2email

Convert RSS feeds to emails
Go
112
star
16

e-comments

External comments for static HTML pages, a lightweight self-hosted disqus alternative.
JavaScript
101
star
17

cpmulator

Golang CP/M emulator for zork, Microsoft BASIC, Turbo Pascal, Wordstar, lighthouse-of-doom, etc
Go
97
star
18

lighthouse-of-doom

A simple text-based adventure game
C
95
star
19

linux-security-modules

A place to store my toy linux-security modules.
C
90
star
20

marionette

Something like puppet, for the localhost only.
Go
85
star
21

kpie

Simple devilspie-like program for window manipulation, with Lua.
C
79
star
22

foth

Tutorial-style FORTH implementation written in golang
Go
78
star
23

dhcp.io

Dynamic DNS - Via Redis, Perl, and Amazon Route53.
Perl
68
star
24

templer

A modular extensible static-site-generator written in perl.
Perl
63
star
25

overseer

A golang-based remote protocol tester for testing sites & service availability
Go
62
star
26

assembler

Basic X86-64 assembler, written in golang
Go
61
star
27

math-compiler

A simple intel/AMD64 assembly-language compiler for mathematical operations
Go
60
star
28

node-reverse-proxy.js

A reverse HTTP-proxy in node.js
JavaScript
54
star
29

webmail

A golang webmail server.
Go
52
star
30

dotfiles

Yet another dotfile-repository
Emacs Lisp
49
star
31

github2mr

Export all your github repositories to a form suitable for 'myrepos' to work with.
Go
46
star
32

puppet-summary

The Puppet Summary is a web interface providing reporting features for Puppet, it replaces the Puppet Dashboard project
Go
46
star
33

org-worklog

A template for maintaining a work-log, via org-mode.
42
star
34

rss2hook

POST to webhook(s) when new feed-items appear.
Go
37
star
35

tweaked.io

The code behind http://tweaked.io/
JavaScript
36
star
36

pam_pwnd

A PAM module to test passwords against previous leaks at haveibeenpwned.com
C
35
star
37

critical

A simple/minimal TCL interpreter, written in golang
Go
34
star
38

alphavet

A golang linter to detect functions not in alphabetical order
Go
32
star
39

dns-api-go

The code behind https://dns-api.org/
Go
31
star
40

markdownshare.com

The code which was previously used at http://markdownshare.com/
Perl
29
star
41

github-action-tester

Run tests when pull-requests are opened, or commits pushed.
Shell
26
star
42

bfcc

BrainFuck Compiler Challenge
Go
22
star
43

maildir-tools

Golang-based utility which can be used for scripting Maildir things, and also as a basic email client
Go
22
star
44

purppura

A server for receiving and processing alerts & events.
Go
21
star
45

cpm-dist

A curated collection of CP/M software
C
20
star
46

implant

Simple utility for embedding files/resources inside golang binaries
Go
20
star
47

chronicle2

Chronicle is a simple blog compiler, written in Perl with minimal dependencies.
Perl
20
star
48

z80-examples

Z80 assembly-language programs.
Makefile
19
star
49

dns-api.org

The code which was previously used at https://dns-api.org/
Perl
19
star
50

yal

Yet another lisp interpreter
Go
16
star
51

ephemeris

A static blog-compiler
Go
15
star
52

markdownshare

The code behind https://markdownshare.com/
Go
15
star
53

aws-utils

A small collection of AWS utilities, packaged as a single standalone binary.
Go
14
star
54

z80retroshield

Arduino library for driving the Z80 retro-shield.
Shell
13
star
55

predis

A redis-server written in Perl.
Perl
12
star
56

github-action-build

Build a project, creating artifacts
Shell
12
star
57

webserver-attacks

Identify attacks against webservers via simple rules
Perl
12
star
58

Device-Osram-Lightify

Interface to the Osram Lightify system
Perl
12
star
59

labeller

Script label addition/removal for gmail/gsuite email.
Go
10
star
60

da-serverspec

ServerSpec.org configuration for the Debian-Administration cluster.
Ruby
10
star
61

docker-api-gateway

Trivial API-gateway for docker, via HAProxy
Go
10
star
62

http2xmpp

HTTP to XMPP (jabber) bridge.
Perl
9
star
63

nanoexec

Trigger commands over a nanomsg queue
C
9
star
64

go-experiments

Repository containing experiments as I learn about golang
Go
9
star
65

golang-metrics

Automatic submission of system metrics to graphite, for golang applications
Go
8
star
66

pass

password-store distribution, with plugins.
Shell
8
star
67

ms-lite

A collection of plugins for a qpsmtpd-powered virtual-host aware SMTP system.
Perl
8
star
68

remotehttp

Magic wrapper to deny HTTP-requests to to "local" resources.
Go
8
star
69

dashboard

Redis & node.js powered dashboard skeleton
JavaScript
8
star
70

Buffalo-220-NAS

Installing NFS on a Buffalo 220 NAS device
Shell
8
star
71

asql

A toy utility to process Apache log files via SQL.
Perl
7
star
72

knownfs

A FUSE-based filesystem that exports ~/.ssh/known_hosts
Go
7
star
73

mpd-web

Simple HTTP view of an MPD server
Go
7
star
74

DockerFiles

Container for various dockerfiles.
Shell
6
star
75

yawns

Yet another weblog/news site
Perl
6
star
76

org-diary

Easily maintain a simple work-log / journal with the use of org-mode
Emacs Lisp
6
star
77

cidr_match.js

A simple module to test whether a given IPv4 address is within a particular CIDR range.
JavaScript
6
star
78

mod_writable

Disallow serving writable files under Apache 2.4.x
C
5
star
79

mod_blacklist

A simple Apache module to blacklist remote hosts.
C
5
star
80

arduino-mega-z80-simplest

The simplest possible project combining an Arduino Mega and a Zilog Z80 processor
C++
4
star
81

turtle

A simple turtle-implementation, using FORTH as a scripting-language
Go
4
star
82

purple

A simplified version of mauvealert
Perl
3
star
83

subcommands

Easy subcommand handling for a golang based command-line application
Go
3
star
84

runme

A quick hack for running commands from README.md files
Go
3
star
85

thyme

A simple package-building system, using docker
Perl
2
star
86

httpd

Simple golang HTTP server
Go
2
star
87

edinburgh.io

Open pub database
JavaScript
2
star
88

lexing-parsing-linting-stuffs

Code to go with my talk
Python
2
star
89

run-directory

A simple application inspired by `run-parts`.
Go
2
star
90

Redis--SQLite

Redis-Compatible module which writes to SQLite
Perl
2
star
91

devopswithdocker.com

Repository created for the Helsinki University course.
Dockerfile
2
star
92

aws-list

Export a dump of all running EC2 instances, along with AMI details, AMI age, etc, etc.
1
star
93

WebService--Amazon--Route53--Caching

Perl module to cache the results of WebService::Amazon::Route53
Perl
1
star
94

calibre-plugins

A small collection of calibre-plugins.
Python
1
star
95

org-tag-cloud

Easily maintain a tag-cloud of org-mode tags.
Emacs Lisp
1
star
96

headerfile

Parse files with simple key:value headers, easily.
Go
1
star
97

z80-cpm-scripting-interpreter

A trivial I/O language, with repl, written in z80 assembler to run under CP/M.
Makefile
1
star
98

Test--RemoteServer

The Perl module Test::RemoteServer
Perl
1
star