<commit_before>// Sensu/Nagios check to monitor the delayed_job queue depth
//
// Copyright 2014 <NAME> <<EMAIL>>

package main

import (
	"database/sql"
	"flag"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"os"
	"strconv"
)

var exitCode int = 3
var count int

func codeToString() string {
	switch exitCode {
	case 0:
		return "OK"
	case 1:
		return "WARNING"
	case 2:
		return "CRITICAL"
	}
	return "UNKNOWN"
}

func done() {
	final(strconv.Itoa(count) + " queued jobs")
}

func final(outString string) {
	fmt.Println(codeToString() + ": " + outString)
	os.Exit(exitCode)
}

func main() {

	// Setup vars
	var dbname string
	var dbuser string
	var dbpassword string
	var debug bool
	var warning int
	var critical int

	// Parse command line options
	flag.StringVar(&dbname, "dbname", "", "database name")
	flag.StringVar(&dbuser, "dbuser", "root", "database username")
	flag.StringVar(&dbpassword, "dbpassword", "", "database password")
	flag.BoolVar(&debug, "debug", false, "debug mode")
	flag.IntVar(&warning, "warning", 5, "the warning threshold")
	flag.IntVar(&critical, "critical", 3, "the critical threshold")
	flag.Parse()

	// Print debug info
	if debug == true {
		fmt.Println("==============")
		fmt.Println("DEBUG INFO")
		fmt.Println("dbname:", dbname)
		fmt.Println("dbuser:", dbuser)
		fmt.Println("dbpassword:", <PASSWORD>)
		fmt.Println("warning:", warning)
		fmt.Println("critical:", critical)
		fmt.Println("==============")
	}

	// Run Query
	db, err := sql.Open("mysql", dbuser+"@"+dbpassword+"/"+dbname)
	if err != nil {
		final(err.Error())
	}
	defer db.Close()
<commit_msg>add dbhost option<commit_after>// Sensu/Nagios check to monitor the delayed_job queue depth
//
// Copyright 2014 <NAME> <<EMAIL>>

package main

import (
	"database/sql"
	"flag"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"os"
	"strconv"
)

var exitCode int = 3
var count int

func codeToString() string {
	switch exitCode {
	case 0:
		return "OK"
	case 1:
		return "WARNING"
	case 2:
		return "CRITICAL"
	}
	return "UNKNOWN"
}

func done() {
	final(strconv.Itoa(count) + " queued jobs")
}

func final(outString string) {
	fmt.Println(codeToString() + ": " + outString)
	os.Exit(exitCode)
}

func main() {

	// Setup vars
	var dbname string
	var dbuser string
	var dbpassword string
	var dbhost string
	var debug bool
	var warning int
	var critical int

	// Parse command line options
	flag.StringVar(&dbname, "dbname", "", "database name")
	flag.StringVar(&dbuser, "dbuser", "root", "database username")
	flag.StringVar(&dbpassword, "dbpassword", "", "database password")
	flag.StringVar(&dbhost, "dbhost", "", "database host")
	flag.BoolVar(&debug, "debug", false, "debug mode")
	flag.IntVar(&warning, "warning", 5, "warning threshold")
	flag.IntVar(&critical, "critical", 3, "critical threshold")
	flag.Parse()

	// Print debug info
	if debug == true {
		fmt.Println("==============")
		fmt.Println("DEBUG INFO")
		fmt.Println("dbname:", dbname)
		fmt.Println("dbuser:", dbuser)
		fmt.Println("dbpassword:", dbpassword)
		fmt.Println("dbhost:", dbhost)
		fmt.Println("warning:", warning)
		fmt.Println("critical:", critical)
		fmt.Println("==============")
	}

	// Run Query
	if dbpassword != "" {
		dbpassword = ":" + dbpassword
	}
	if dbhost != "" {
		dbhost = "@" + dbhost
	}
	db, err := sql.Open("mysql", dbuser+dbpassword+dbhost+"/"+dbname)
	if err != nil {
		final(err.Error())
	}
	defer db.Close()

{'fraction_non_alphanumeric': 0.1776798825256975, 'fraction_numerical': 0.005873715124816446, 'mean_word_length': 4.297045101088647, 'pattern_counts': {'":': 3, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5418088', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1209, 'n_words': 313}