Skip to content

Commit

Permalink
Merge pull request #126 from CiscoCloud/fix/drone
Browse files Browse the repository at this point in the history
Fix false negatives on drone tests
  • Loading branch information
langston-barrett committed Jan 12, 2016
2 parents 1bf0974 + 6ead8dc commit 95b9d08
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 33 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](http://drone04.shipped-cisco.com/api/badges/CiscoCloud/distributive/status.svg)](http://drone04.shipped-cisco.com/CiscoCloud/distributive)

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
**Table of Contents**

Expand Down
59 changes: 30 additions & 29 deletions checks/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@ package checks

import (
"fmt"
"github.com/CiscoCloud/distributive/chkutil"
"github.com/CiscoCloud/distributive/errutil"
"github.com/CiscoCloud/distributive/tabular"
log "github.com/Sirupsen/logrus"
"os/exec"
"regexp"
"strconv"
"strings"
"syscall"

"github.com/CiscoCloud/distributive/chkutil"
"github.com/CiscoCloud/distributive/errutil"
"github.com/CiscoCloud/distributive/tabular"
log "github.com/Sirupsen/logrus"
)

/*
#### Command
Description: Does this Command exit without error?
Parameters:
- Cmd (string): Command to be executed
- Cmd (string): Command to be executed
Example parameters:
- "cat /etc/my-config/", "/bin/my_health_check.py"
- "cat /etc/my-config/", "/bin/my_health_check.py"
*/

type Command struct{ Command string }
Expand Down Expand Up @@ -70,11 +71,11 @@ func (chk Command) Status() (int, string, error) {
Description: Does the combined (stdout + stderr) output of this Command match
the given regexp?
Parameters:
- Cmd (string): Command to be executed
- Regexp (regexp): Regexp to query output with
- Cmd (string): Command to be executed
- Regexp (regexp): Regexp to query output with
Example parameters:
- "cat /etc/my-config/", "/bin/my_health_check.py"
- "value=expected", "[rR]{1}e\we[Xx][^oiqnlkasdjc]"
- "cat /etc/my-config/", "/bin/my_health_check.py"
- "value=expected", "[rR]{1}e\we[Xx][^oiqnlkasdjc]"
*/

type CommandOutputMatches struct {
Expand Down Expand Up @@ -114,11 +115,11 @@ func (chk CommandOutputMatches) Status() (int, string, error) {
#### Running
Description: Is a process by this exact name Running (excluding this process)?
Parameters:
- Name (string): Process name to look for
- Name (string): Process name to look for
Example parameters:
- nginx, [kthreadd], consul-agent, haproxy-consul
- nginx, [kthreadd], consul-agent, haproxy-consul
Depedencies:
- `ps aux`
- `ps aux`
*/

type Running struct{ name string }
Expand Down Expand Up @@ -157,11 +158,11 @@ func (chk Running) Status() (int, string, error) {
#### Temp
Description: Is the core Temperature under this value (in degrees Celcius)?
Parameters:
- Temp (positive int16): Maximum acceptable Temperature
- Temp (positive int16): Maximum acceptable Temperature
Example parameters:
- 100, 110C, 98°C, 100℃
- 100, 110C, 98°C, 100℃
Depedencies:
- A configured lm-sensors (namely, `sensors`)
- A configured lm-sensors (namely, `sensors`)
*/

// TODO use uint
Expand Down Expand Up @@ -236,13 +237,13 @@ func (chk Temp) Status() (int, string, error) {

/*
#### Module
Description: Is this kernel Module installed?
Description: Is this kernel module installed?
Parameters:
- Name (string): Module name
Example parameters:
- hid, drm, rfkill
- hid, drm, rfkill
Depedencies:
- `/sbin/lsmod`
- `/sbin/lsmod`
*/

type Module struct{ name string }
Expand All @@ -259,16 +260,16 @@ func (chk Module) New(params []string) (chkutil.Check, error) {

func (chk Module) Status() (int, string, error) {
// kernelModules returns a list of all Modules that are currently loaded
// TODO just read from /proc/Modules
// TODO just read from /proc/modules
kernelModules := func() (Modules []string) {
cmd := exec.Command("/sbin/lsmod")
return chkutil.CommandColumnNoHeader(0, cmd)
}
Modules := kernelModules()
if tabular.StrIn(chk.name, Modules) {
modules := kernelModules()
if tabular.StrIn(chk.name, modules) {
return errutil.Success()
}
return errutil.GenericError("Module is not loaded", chk.name, Modules)
return errutil.GenericError("Module is not loaded", chk.name, modules)
}

/*
Expand All @@ -277,9 +278,9 @@ Description: Is this kernel parameter set?
Parameters:
- Name (string): Kernel parameter to check
Example parameters:
- TODO
- TODO
Depedencies:
- `/sbin/sysctl`
- `/sbin/sysctl`
*/

type KernelParameter struct{ name string }
Expand Down Expand Up @@ -317,12 +318,12 @@ func (chk KernelParameter) Status() (int, string, error) {
#### PHPConfig
Description: Does this PHP configuration variable have this value?
Parameters:
- Variable (string): PHP variable to check
- Value (string): Expected value
- Variable (string): PHP variable to check
- Value (string): Expected value
Example parameters:
- TODO
- TODO
Depedencies:
- `php`
- `php`
*/

type PHPConfig struct{ variable, value string }
Expand Down
6 changes: 3 additions & 3 deletions netstatus/netstatus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func TestCanConnect(t *testing.T) {
func TestGetHexPorts(t *testing.T) {
t.Parallel()
if len(GetHexPorts("tcp")) < 1 {
t.Error("len(GetHexPorts(tcp)) < 1")
t.Errorf("len(GetHexPorts('tcp')) = %s", len(GetHexPorts("tcp")))
} else if len(GetHexPorts("udp")) < 1 {
t.Error("len(GetHexPorts(udp)) < 1")
t.Logf("len(GetHexPorts('udp') = %s", len(GetHexPorts("udp")))
}
}

Expand All @@ -34,7 +34,7 @@ func TestOpenPorts(t *testing.T) {
for _, protocol := range [2]string{"tcp", "udp"} {
ports := OpenPorts(protocol)
if len(ports) < 1 {
t.Errorf("OpenPorts reported zero open ports for %s", protocol)
t.Logf("OpenPorts reported zero open ports for %s", protocol)
}
// test how many we can actually connect to as well (just FYI)
couldConnect := 0
Expand Down
2 changes: 1 addition & 1 deletion samples/misc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
{
"ID" : "module",
"Parameters" : ["btrfs"]
"Parameters" : ["bridge"]
}
]
}

0 comments on commit 95b9d08

Please sign in to comment.