diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 02ec150e..e239e054 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1633,6 +1633,7 @@ Perl: extensions: - .pl - .PL + - .cgi - .fcgi - .perl - .ph diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 97e7b511..7da2a415 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -447,6 +447,7 @@ ".dpr" ], "Perl": [ + ".cgi", ".fcgi", ".pl", ".pm", @@ -809,8 +810,8 @@ "exception.zep.php" ] }, - "tokens_total": 642012, - "languages_total": 879, + "tokens_total": 644723, + "languages_total": 881, "tokens": { "ABAP": { "*/**": 1, @@ -52315,35 +52316,35 @@ "package": 14, "App": 131, "Ack": 136, - ";": 1193, - "use": 83, - "warnings": 18, - "strict": 18, + ";": 1376, + "use": 88, + "warnings": 19, + "strict": 22, "File": 54, "Next": 27, "Plugin": 2, - "Basic": 10, + "Basic": 11, "head1": 36, "NAME": 6, - "-": 868, + "-": 1075, "A": 2, "container": 1, - "for": 83, + "for": 88, "functions": 2, - "the": 143, + "the": 153, "ack": 38, - "program": 6, + "program": 7, "VERSION": 15, "Version": 1, "cut": 28, "our": 34, "COPYRIGHT": 7, "BEGIN": 7, - "{": 1121, - "}": 1134, + "{": 1394, + "}": 1407, "fh": 28, "*STDOUT": 6, - "%": 78, + "%": 82, "types": 26, "type_wanted": 20, "mappings": 29, @@ -52354,8 +52355,8 @@ "is_cygwin": 6, "is_windows": 12, "Spec": 13, - "(": 925, - ")": 923, + "(": 1137, + ")": 1136, "Glob": 4, "Getopt": 6, "Long": 6, @@ -52368,11 +52369,11 @@ "_sgbak": 2, "_build": 2, "actionscript": 2, - "[": 159, + "[": 200, "qw": 35, - "as": 37, + "as": 40, "mxml": 2, - "]": 155, + "]": 196, "ada": 4, "adb": 2, "ads": 2, @@ -52386,7 +52387,7 @@ "Binary": 2, "files": 42, "defined": 54, - "by": 16, + "by": 19, "Perl": 9, "T": 2, "op": 2, @@ -52415,25 +52416,25 @@ "xsl": 2, "xslt": 2, "ent": 2, - "while": 31, - "my": 404, + "while": 33, + "my": 458, "type": 69, "exts": 6, "each": 14, - "if": 276, + "if": 322, "ref": 33, "ext": 14, - "@": 38, - "push": 30, - "_": 101, + "@": 54, + "push": 37, + "_": 104, "mk": 2, "mak": 2, - "not": 54, - "t": 18, - "p": 9, + "not": 56, + "t": 21, + "p": 10, "STDIN": 2, "O": 4, - "eq": 31, + "eq": 62, "/MSWin32/": 2, "quotemeta": 5, "catfile": 4, @@ -52441,37 +52442,37 @@ "If": 15, "you": 44, "want": 7, - "to": 95, + "to": 101, "know": 4, "about": 4, "F": 24, "": 13, "see": 5, - "file": 49, + "file": 57, "itself.": 3, "No": 4, - "user": 4, + "user": 5, "serviceable": 1, "parts": 1, "inside.": 1, - "is": 69, - "all": 23, - "that": 33, - "should": 6, + "is": 74, + "all": 28, + "that": 35, + "should": 8, "this.": 1, "FUNCTIONS": 1, "head2": 34, "read_ackrc": 4, "Reads": 1, "contents": 2, - "of": 64, + "of": 67, ".ackrc": 1, - "and": 85, + "and": 92, "returns": 4, "arguments.": 1, - "sub": 225, + "sub": 232, "@files": 12, - "ENV": 40, + "ENV": 41, "ACKRC": 2, "@dirs": 4, "HOME": 4, @@ -52480,55 +52481,55 @@ "grep": 17, "bsd_glob": 4, "GLOB_TILDE": 2, - "filename": 68, - "&&": 83, - "e": 20, - "open": 7, - "or": 49, + "filename": 72, + "&&": 84, + "e": 21, + "open": 10, + "or": 51, "die": 38, "@lines": 21, "/./": 2, - "/": 69, + "/": 82, "s*#/": 2, "<$fh>": 4, - "chomp": 3, - "close": 19, - "s/": 22, - "+": 120, + "chomp": 4, + "close": 22, + "s/": 28, + "+": 126, "//": 9, - "return": 157, + "return": 168, "get_command_line_options": 4, "Gets": 3, - "command": 14, - "line": 20, + "command": 16, + "line": 21, "arguments": 2, - "does": 10, + "does": 11, "specific": 2, "tweaking.": 1, "opt": 291, "pager": 19, "ACK_PAGER_COLOR": 7, - "||": 49, + "||": 52, "ACK_PAGER": 5, "getopt_specs": 6, "m": 17, "after_context": 16, "before_context": 18, - "shift": 165, + "shift": 170, "val": 26, "break": 14, - "c": 5, + "c": 6, "count": 23, "color": 38, "ACK_COLOR_MATCH": 5, "ACK_COLOR_FILENAME": 5, "ACK_COLOR_LINENO": 4, "column": 4, - "#": 99, + "#": 106, "ignore": 7, "this": 22, "option": 7, - "it": 28, + "it": 30, "handled": 2, "beforehand": 2, "f": 25, @@ -52538,14 +52539,14 @@ "heading": 18, "h": 6, "H": 6, - "i": 26, + "i": 27, "invert_file_match": 8, - "lines": 19, + "lines": 20, "l": 17, - "regex": 28, + "regex": 42, "n": 19, "o": 17, - "output": 36, + "output": 40, "undef": 17, "passthru": 9, "print0": 7, @@ -52554,15 +52555,15 @@ "smart_case": 3, "sort_files": 11, "u": 10, - "w": 4, + "w": 7, "remove_dir_sep": 7, "delete": 10, "print_version_statement": 2, - "exit": 16, + "exit": 19, "show_help": 3, - "@_": 43, + "@_": 45, "show_help_types": 2, - "require": 12, + "require": 13, "Pod": 4, "Usage": 4, "pod2usage": 2, @@ -52571,22 +52572,22 @@ "dummy": 2, "wanted": 4, "no//": 2, - "must": 5, - "be": 36, + "must": 7, + "be": 39, "later": 2, - "exists": 19, - "else": 53, + "exists": 31, + "else": 71, "qq": 18, "Unknown": 2, "unshift": 4, "@ARGV": 12, - "split": 13, + "split": 15, "ACK_OPTIONS": 5, "def_types_from_ARGV": 5, "filetypes_supported": 5, "parser": 12, "Parser": 4, - "new": 55, + "new": 56, "configure": 4, "getoptions": 4, "to_screen": 10, @@ -52596,27 +52597,27 @@ "Console": 2, "ANSI": 3, "key": 20, - "value": 12, + "value": 14, "<": 15, - "join": 5, + "join": 7, "map": 10, "@ret": 10, - "from": 19, + "from": 20, "warn": 22, "..": 7, "uniq": 4, "@uniq": 2, - "sort": 8, - "a": 85, + "sort": 9, + "a": 88, "<=>": 2, "b": 6, - "keys": 15, + "keys": 19, "numerical": 2, "occurs": 2, "only": 11, "once": 4, "Go": 1, - "through": 6, + "through": 10, "look": 2, "I": 68, "<--type-set>": 1, @@ -52624,14 +52625,14 @@ "bar": 3, "<--type-add>": 1, "xml=": 1, - ".": 125, + ".": 166, "Remove": 1, "them": 5, "add": 9, "supported": 1, "filetypes": 8, "i.e.": 2, - "into": 6, + "into": 8, "etc.": 3, "@typedef": 8, "td": 6, @@ -52639,12 +52640,12 @@ "Builtin": 4, "cannot": 4, "changed.": 4, - "ne": 9, + "ne": 11, "delete_type": 5, "Type": 2, - "exist": 4, + "exist": 5, "creating": 3, - "with": 26, + "with": 28, "...": 2, "unless": 39, "@exts": 8, @@ -52672,9 +52673,9 @@ "directory": 8, "any": 4, "ones": 1, - "we": 7, + "we": 9, "ignore.": 1, - "path": 28, + "path": 29, "This": 27, "removes": 1, "trailing": 1, @@ -52707,16 +52708,16 @@ "constant": 2, "TEXT": 16, "basename": 9, - ".*": 2, + ".*": 5, "is_searchable": 8, "lc_basename": 8, "lc": 5, - "r": 14, + "r": 18, "B": 76, "header": 17, "SHEBANG#!#!": 2, "ruby": 3, - "|": 28, + "|": 31, "lua": 2, "erl": 2, "hp": 2, @@ -52739,15 +52740,15 @@ "U": 2, "y": 8, "tr/": 2, - "x": 7, + "x": 12, "w/": 3, "nOo_/": 2, "_thpppt": 3, "_get_thpppt": 3, - "print": 35, + "print": 46, "_bar": 3, "<<": 10, - "&": 22, + "&": 27, "*I": 2, "g": 7, "#.": 6, @@ -52756,15 +52757,15 @@ "#I": 6, "#7": 4, "results.": 2, - "on": 25, - "when": 18, - "used": 12, + "on": 27, + "when": 19, + "used": 13, "interactively": 6, "no": 22, "Print": 6, "between": 4, "results": 8, - "different": 2, + "different": 3, "files.": 6, "group": 2, "Same": 8, @@ -52778,7 +52779,7 @@ "Windows": 4, "colour": 2, "COLOR": 6, - "match": 21, + "match": 24, "lineno": 2, "Set": 3, "filenames": 7, @@ -52804,7 +52805,7 @@ "invert": 2, "Print/search": 2, "handle": 3, - "do": 12, + "do": 16, "g/": 2, "G.": 2, "show": 3, @@ -52812,15 +52813,15 @@ "which": 7, "has.": 2, "inclusion/exclusion": 2, - "All": 4, + "All": 5, "searched": 5, "Ignores": 2, ".svn": 3, - "other": 5, + "other": 6, "ignored": 6, "directories": 9, "unrestricted": 2, - "name": 44, + "name": 60, "Add/Remove": 2, "dirs": 2, "R": 2, @@ -52850,12 +52851,12 @@ "res": 59, "next_text": 8, "has_lines": 4, - "scalar": 2, - "m/": 4, + "scalar": 3, + "m/": 12, "regex/": 9, "next": 9, "print_match_or_context": 13, - "elsif": 10, + "elsif": 26, "last": 17, "max": 12, "nmatches": 61, @@ -52869,7 +52870,7 @@ "match_start": 5, "match_end": 3, "Prints": 4, - "out": 2, + "out": 3, "context": 1, "around": 5, "match.": 3, @@ -52910,7 +52911,7 @@ "print_count0": 2, "filetypes_supported_set": 9, "True/False": 1, - "are": 25, + "are": 26, "print_files": 4, "iter": 23, "returned": 3, @@ -52922,10 +52923,10 @@ "<$ors>": 1, "<\"\\n\">": 1, "defines": 2, - "what": 14, + "what": 15, "filename.": 1, "print_files_with_matches": 4, - "where": 3, + "where": 4, "was": 2, "repo": 18, "Repository": 11, @@ -52952,7 +52953,7 @@ "EXPAND_FILENAMES_SCOPE": 4, "argv": 12, "attr": 6, - "foreach": 4, + "foreach": 13, "pattern": 10, "@results": 14, "didn": 2, @@ -52960,7 +52961,7 @@ "tried": 2, "load": 2, "GetAttributes": 2, - "end": 9, + "end": 10, "attributes": 4, "got": 2, "get_starting_points": 4, @@ -52968,7 +52969,7 @@ "@what": 14, "reslash": 4, "Assume": 2, - "current": 5, + "current": 6, "start_point": 4, "_match": 8, "target": 6, @@ -52983,7 +52984,7 @@ "is_interesting": 4, "descend_filter": 11, "error_handler": 5, - "msg": 4, + "msg": 5, "follow_symlinks": 6, "set_up_pager": 3, "Unable": 2, @@ -52996,7 +52997,7 @@ "code.": 2, "otherwise": 2, "handed": 1, - "in": 36, + "in": 40, "argument.": 1, "rc": 11, "LICENSE": 3, @@ -53013,6 +53014,236 @@ "License": 2, "v2.0.": 2, "End": 3, + "SHEBANG#!perl": 6, + "##": 79, + "configuration": 3, + "options": 8, + "BASE_DIR": 1, + "CONFIG_FILE": 2, + "Config": 1, + "location": 5, + "DEBUG_LOG_FILE": 2, + "Specify": 2, + "create": 4, + "log": 4, + "writable": 2, + "nagios": 3, + "DEBUGLEVEL": 3, + "Nothing": 1, + "Errors": 1, + "Warnings": 1, + "Debug": 1, + "DEBUGOUTPUT": 8, + "STDERR": 5, + "STDOUT": 1, + "cgi": 4, + "Global": 1, + "vars": 1, + "DEBUG_TIMESTAMP": 5, + "Find": 1, + "how": 2, + "run": 3, + "ARGV": 5, + "test": 1, + "errors": 4, + "console": 1, + "read_config": 4, + "abort": 23, + "parse": 3, + "performance": 2, + "data": 5, + "started": 1, + "parse_perfdata": 2, + "CGI": 10, + "script": 1, + "web": 9, + "browser": 1, + "run_as_cgi": 2, + "some": 2, + "help": 3, + "info": 1, + "logfile": 1, + "write": 5, + "blank": 2, + "wrote": 1, + "anything...": 1, + "debug": 39, + "Program": 1, + "called": 5, + "graph_name": 18, + "param": 10, + "graph_iteration": 6, + "config": 67, + "display": 2, + "index": 2, + "graphs": 3, + "display_htmltemplate": 3, + "graph": 4, + "Display": 3, + "HTML": 6, + "page": 1, + "generate": 1, + "call": 4, + "rrdtool_cmdline": 11, + ".join": 5, + "expand": 1, + "variables": 1, + "rrdarchive": 1, + "f/": 1, + "rrdarchive/g": 1, + "t_start": 4, + "t_start/g": 1, + "t_end": 4, + "e/": 1, + "t_end/g": 1, + "t_descr": 3, + "d/": 1, + "t_descr/g": 1, + "Call": 1, + "rrdtool": 3, + "probably": 1, + "fixed": 1, + "better": 1, + "way": 3, + "like": 14, + "exec": 1, + "template": 3, + "variable": 3, + "substitution": 1, + "stuff": 1, + "": 1, + "big": 2, + "regex..": 1, + "/my": 1, + "varname": 8, + "date": 3, + "time": 6, + "localtime": 2, + "code": 10, + "return_html": 4, + "gn": 2, + "return_html.": 2, + "escape": 1, + "slash": 1, + "since": 2, + "were": 2, + "inside": 1, + "an": 17, + "displaying": 1, + "actual": 1, + "images": 1, + "iteration_id": 2, + "unknown": 1, + "/eig": 1, + "thought": 1, + "would": 6, + "never": 2, + "Process": 1, + "incoming": 1, + "check": 3, + "plugin": 1, + "insert": 1, + "values": 7, + "rrd": 3, + "archives": 2, + "rrd_updates": 13, + "Provide": 1, + "more": 3, + "symbolic": 1, + "names": 3, + "same": 4, + "macros": 1, + "LASTCHECK": 1, + "HOSTNAME": 2, + "SERVICEDESCR": 2, + "SERVICESTATE": 1, + "OUTPUT": 2, + "PERFDATA": 2, + "host_and_descr_found": 3, + "Loop": 4, + "host_regexes": 1, + "host_regex": 5, + "service_description_regexes": 1, + "service_regex": 4, + "host_regex/i": 1, + "service_regex/i": 1, + "InsertValue": 1, + "host": 1, + "service_description": 1, + "insert_value": 10, + "regexes": 4, + "output/perfdata": 1, + "regex_string": 1, + "regex_string/": 2, + "Insert": 1, + "RRD": 3, + "calling": 1, + "may": 4, + "several": 1, + "archive": 9, + "rrdarchive_filename": 3, + "Create": 1, + "Archive": 1, + "according": 1, + "rrdarchive_filename.": 3, + "rrdtool_cmdline.": 1, + "Check": 1, + "wheter": 1, + "Assemle": 1, + "result": 3, + "Read": 1, + "CONFIG": 2, + "line_counter": 2, + "": 1, + "@args": 11, + "shellwords": 1, + "orig_confline": 1, + "args": 37, + "uc": 1, + "INSERTVALUE": 1, + "rrd_filename": 2, + "rrdcreatetemplate": 4, + "hostname_regex": 4, + "servicedescr_regex": 4, + "regex_template": 3, + "verify": 3, + "hostname": 2, + "service": 1, + "description": 2, + "s*": 1, + "#/": 1, + "comment": 1, + "row": 1, + "nuthin": 1, + "RRDToolPath": 1, + "PlotTemplate": 1, + "htmltemplate": 2, + "parameters..": 2, + "@params": 7, + "GraphTimeTemplate": 1, + "time_template": 2, + "@t_descr": 2, + "workaround": 1, + "string": 6, + "RRDCreateTemplate": 1, + "ValueRegexTemplate": 1, + "template_name": 3, + "@regexes": 2, + "perfdata": 1, + "regex_what": 2, + "dsa_name": 2, + "RRDARCHIVEPATH": 1, + "HTMLTemplatePath": 1, + "GraphIndexTemplate": 1, + "GRAPH": 1, + "rrdfilename": 1, + "graphtimetemplate": 1, + "plottemplate": 1, + "Write": 1, + "output/logging": 1, + "level": 3, + "timestamp": 1, + "msg.": 2, "SHEBANG#!#! perl": 4, "examples/benchmarks/fib.pl": 1, "Fibonacci": 2, @@ -53027,7 +53258,6 @@ "SEE": 4, "ALSO": 4, "": 1, - "SHEBANG#!perl": 5, "MAIN": 1, "main": 3, "env_is_usable": 3, @@ -53046,9 +53276,7 @@ "Resource": 5, "file_matching": 2, "check_regex": 2, - "like": 13, "finder": 1, - "options": 7, "FILE...": 1, "DIRECTORY...": 1, "designed": 1, @@ -53065,7 +53293,6 @@ "By": 2, "prints": 2, "also": 7, - "would": 5, "actually": 1, "let": 1, "take": 5, @@ -53079,7 +53306,6 @@ "symlinks": 1, "than": 5, "whatever": 1, - "were": 1, "specified": 3, "line.": 4, "default.": 2, @@ -53107,7 +53333,6 @@ "groups": 1, "with.": 1, "interactively.": 1, - "result": 1, "per": 1, "grep.": 2, "redirected.": 1, @@ -53121,14 +53346,12 @@ "searched.": 1, "<--help>": 1, "short": 1, - "help": 2, "statement.": 1, "<--ignore-case>": 1, "Ignore": 3, "case": 3, "strings.": 1, "applies": 3, - "regexes": 3, "<-g>": 5, "<-G>": 3, "options.": 4, @@ -53138,7 +53361,6 @@ "directories.": 2, "mason": 1, "users": 4, - "may": 3, "wish": 1, "include": 1, "<--ignore-dir=data>": 1, @@ -53185,7 +53407,6 @@ "": 2, "equivalent": 2, "specifying": 1, - "Specify": 1, "explicitly.": 1, "helpful": 2, "don": 2, @@ -53264,7 +53485,6 @@ "associates": 1, "Works": 1, "<--thpppt>": 1, - "Display": 1, "important": 1, "Bill": 1, "Cat": 1, @@ -53275,12 +53495,11 @@ "<--thpppppt>": 1, "important.": 1, "make": 3, - "perl": 8, + "perl": 9, "php": 2, "python": 1, "looks": 2, "location.": 1, - "variable": 1, "specifies": 1, "placed": 1, "front": 1, @@ -53334,7 +53553,6 @@ "both": 1, "understands": 1, "sequences.": 1, - "never": 1, "back": 4, "ACK": 2, "OTHER": 1, @@ -53359,7 +53577,6 @@ "Jackson": 1, "put": 1, "together": 2, - "an": 16, "": 1, "extension": 1, "": 1, @@ -53372,11 +53589,9 @@ "Code": 1, "greater": 1, "normal": 1, - "code": 8, "<$?=256>": 1, "": 1, "backticks.": 1, - "errors": 1, "used.": 1, "at": 4, "least": 1, @@ -53397,10 +53612,7 @@ "too.": 1, "there.": 1, "working": 1, - "big": 1, "codesets": 1, - "more": 2, - "create": 3, "tree": 2, "ideal": 1, "sending": 1, @@ -53419,7 +53631,6 @@ "": 1, "took": 1, "access": 2, - "log": 3, "scanned": 1, "twice.": 1, "aa.bb.cc.dd": 1, @@ -53465,7 +53676,6 @@ "metadata": 1, "wastes": 1, "lot": 1, - "time": 3, "those": 2, "well": 2, "returning": 1, @@ -53478,7 +53688,6 @@ "has": 3, "perfectly": 1, "good": 2, - "way": 2, "using": 5, "<-p>": 1, "<-n>": 1, @@ -53494,7 +53703,6 @@ "<.xyz>": 1, "already": 2, "program/package": 1, - "called": 4, "ack.": 2, "Yes": 1, "know.": 1, @@ -53594,7 +53802,6 @@ "seek": 4, "readline": 1, "nexted": 3, - "CGI": 6, "Fast": 3, "XML": 2, "Hash": 11, @@ -53614,21 +53821,18 @@ "Request": 11, "*STDERR": 1, "int": 2, - "ARGV": 2, "conv": 2, "use_attr": 1, "indent": 1, "xml_decl": 1, "tmpl_path": 2, "tmpl": 5, - "data": 3, "nick": 1, "parent": 5, "third_party": 1, "artist_name": 2, "venue": 2, "event": 2, - "date": 2, "zA": 1, "Z0": 1, "Content": 2, @@ -53650,7 +53854,6 @@ "": 3, "specification": 3, "interface": 1, - "web": 8, "servers": 2, "based": 2, "applications": 2, @@ -53658,7 +53861,6 @@ "supports": 1, "writing": 1, "portable": 1, - "run": 1, "various": 2, "methods": 4, "standalone": 1, @@ -53682,7 +53884,6 @@ "": 1, "root": 1, "application.": 1, - "write": 2, "own": 4, ".psgi": 7, "Writing": 2, @@ -53716,7 +53917,6 @@ "setting": 2, "wrapped": 1, "": 1, - "some": 1, "engine": 1, "fixes": 1, "uniform": 1, @@ -53728,7 +53928,6 @@ "override": 1, "providing": 2, "none": 1, - "call": 2, "MyApp": 1, "Thus": 1, "functionality": 1, @@ -53749,7 +53948,6 @@ "Catalyst.pm": 1, "library": 2, "software.": 1, - "same": 2, "Plack": 25, "_001": 1, "HTTP": 16, @@ -53817,13 +54015,11 @@ "query": 4, "flatten": 3, "uploads": 5, - "hostname": 1, "url_scheme": 1, "params": 1, "query_params": 1, "body_params": 1, "cookie": 6, - "param": 8, "get_all": 2, "upload": 13, "raw_uri": 1, @@ -53879,7 +54075,6 @@ "": 1, "provide": 1, "higher": 1, - "level": 1, "top": 1, "PSGI.": 1, "METHODS": 2, @@ -53893,9 +54088,7 @@ "noted": 1, "": 1, "passing": 1, - "values": 5, "accessor": 1, - "debug": 1, "set.": 1, "": 2, "request.": 1, @@ -53923,7 +54116,6 @@ "allow": 1, "modifying": 1, "@values": 1, - "@params": 1, "convenient": 1, "@fields": 1, "Creates": 2, @@ -53950,7 +54142,6 @@ "scalars": 1, "references": 1, "ARRAY": 1, - "parse": 1, "twice": 1, "efficiency.": 1, "DISPATCHING": 1, @@ -53962,7 +54153,6 @@ "": 1, "virtual": 1, "regardless": 1, - "how": 1, "mounted.": 1, "hosted": 1, "scripts": 1, @@ -53973,7 +54163,6 @@ "subclass": 1, "define": 1, "uri_for": 2, - "args": 3, "So": 1, "say": 1, "link": 1, @@ -53985,7 +54174,6 @@ "Cookie": 2, "handling": 1, "simplified": 1, - "string": 5, "encoding": 2, "decoding": 1, "totally": 1, @@ -54012,7 +54200,6 @@ "Accessor": 1, "status": 17, "Scalar": 2, - "location": 4, "redirect": 1, "url": 2, "clone": 1, @@ -54025,7 +54212,6 @@ "//g": 1, "CR": 1, "LF": 1, - "since": 1, "char": 1, "invalid": 1, "header_field_names": 1, @@ -54096,7 +54282,6 @@ "responsible": 1, "properly": 1, "": 1, - "names": 1, "their": 1, "corresponding": 1, "": 2, @@ -54113,7 +54298,11 @@ "formats": 1, "<+3M>": 1, "reference.": 1, - "AUTHOR": 1 + "AUTHOR": 1, + "Test": 2, + "Base": 1, + "__DATA__": 1, + "Strict": 1 }, "Perl6": { "token": 6, @@ -71077,7 +71266,7 @@ "Parrot Assembly": 6, "Parrot Internal Representation": 5, "Pascal": 30, - "Perl": 17979, + "Perl": 20690, "Perl6": 372, "Pike": 1835, "Pod": 658, @@ -71280,7 +71469,7 @@ "Parrot Assembly": 1, "Parrot Internal Representation": 1, "Pascal": 1, - "Perl": 15, + "Perl": 17, "Perl6": 3, "Pike": 2, "Pod": 1, @@ -71354,5 +71543,5 @@ "fish": 3, "wisp": 1 }, - "md5": "74cf3030ce69bf98dcb208636bb9486d" + "md5": "aa575c1bfc22b599f29c4d570b6c747d" } \ No newline at end of file diff --git a/samples/Perl/example.cgi b/samples/Perl/example.cgi new file mode 100755 index 00000000..eac1ef92 --- /dev/null +++ b/samples/Perl/example.cgi @@ -0,0 +1,447 @@ +#!/usr/bin/perl + +# v1.0 +# nagiostat, program to insert performance-data from Nagios into RRD-archives +# Copyright (C) 2004 Carl Bingel / Svensk IT konsult AB +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +use strict; + +## Basic configuration options +my $BASE_DIR = "/usr/share/nagiostat"; +my $CONFIG_FILE = "/etc/nagios/nagiostat.conf"; ## Config-file location +my $DEBUG_LOG_FILE = "/var/spool/nagiostat/debug.log"; ## Specify where to create log-file and what filename (must be writable by nagios-user!) +my $DEBUGLEVEL = 1; ## 0=Nothing, 1=Errors, 2=Warnings, 3=Debug +my $DEBUGOUTPUT = 0; ## 0=file, 1=STDERR, 2=STDOUT (for cgi) + +require 'shellwords.pl'; + +## Global vars +my $DEBUG_TIMESTAMP=0; + +## Find out how program is run +if( $ARGV[0] eq "-t") { ## -t = test configuration-file + print STDERR "nagiostat: Testing configuration-file..\n"; + $DEBUGLEVEL=3; + $DEBUGOUTPUT=1; ## output errors to console and not file + my $c = &read_config(); + abort(); +} elsif( $ARGV[0] eq "-p") { ## -p = parse performance-data (when started by nagios) + &parse_perfdata(); +} else { + if( exists $ENV{'GATEWAY_INTERFACE'}) { ## we are run as a CGI-script! + $DEBUGOUTPUT=2; ## output errors to web-browser + &run_as_cgi(); + } else { ## print some help-info + print STDERR "nagiostat: usage: + -t Test configuration-file + -p Parse/import performance-data (used when called from nagios) +"; + } +} + +abort(); + +sub abort { + ## logfile: write blank if we wrote anything... + if( $DEBUG_TIMESTAMP!=0) { + debug( 1, ""); + } + exit; +} + +## +## Program is called as CGI +## +sub run_as_cgi { + use CGI; + my $cgi = new CGI; + + my $graph_name = $cgi->param( "graph_name"); + my $graph_iteration = $cgi->param( "graph_iteration"); + + if( $graph_iteration eq "") { + print "Content-type: text/html\nExpires: 0\n\n"; + } else { + print "Content-type: image/gif\nExpires: 0\n\n"; + } + + my $config = read_config(); + + if( $graph_name eq "") { + ## + ## display index of graphs + ## + display_htmltemplate( $config->{'htmltemplatepath'}."/".$config->{'graphindextemplate'}, $graph_name, $config); + } else { ## display graph + if( ! exists $config->{'graphs'}->{$graph_name}) { + debug( 1, "ERROR: Graph '$graph_name' does not exist!"); + exit; + } elsif( $graph_iteration eq "") { + ## + ## Display HTML-page with all the graphs + ## + if( ! -r $config->{'htmltemplatepath'}."/".$config->{'graphs'}->{$graph_name}->{'htmltemplate'}) { + debug( 1, "ERROR: HTML-template '".($config->{'htmltemplatepath'}."/".$config->{'graphs'}->{$graph_name}->{'htmltemplate'})."' is not readable by effective userid!"); + exit; + } + display_htmltemplate( $config->{'htmltemplatepath'}."/".$config->{'graphs'}->{$graph_name}->{'htmltemplate'}, $graph_name, $config); + } else { + ## + ## generate graph (call 'rrdtool graph') + ## + my $rrdtool_cmdline = $config->{'rrdtoolpath'}." graph - ".join( " ", @{$config->{'plottemplates'}->{ $config->{'graphs'}->{$graph_name}->{'plottemplate'} } }); + + ## expand variables + my $rrdarchive = $config->{'rrdarchivepath'}."/".$config->{'graphs'}->{$graph_name}->{'rrdfilename'}; + $rrdtool_cmdline =~ s/\$f/$rrdarchive/g; + my $t_start = $config->{'graphtimetemplates'}->{ $config->{'graphs'}->{$graph_name}->{'graphtimetemplate'} }->[$graph_iteration]->{'starttime'}; + $rrdtool_cmdline =~ s/\$s/$t_start/g; + my $t_end = $config->{'graphtimetemplates'}->{ $config->{'graphs'}->{$graph_name}->{'graphtimetemplate'} }->[$graph_iteration]->{'endtime'}; + $rrdtool_cmdline =~ s/\$e/$t_end/g; + my $t_descr = $config->{'graphtimetemplates'}->{ $config->{'graphs'}->{$graph_name}->{'graphtimetemplate'} }->[$graph_iteration]->{'description'}; + $rrdtool_cmdline =~ s/\$d/$t_descr/g; + + ## Call rrdtool (should probably be fixed to call it in a better way, like exec) + print `$rrdtool_cmdline`; + } + + } + +} + +## Display HTML template (and do variable-substitution and other stuff) +## +sub display_htmltemplate { + my( $filename, $graph_name, $config) = @_; + + if( -r $filename) { + open( HTML, $filename); + while( ) { + ## All is a big regex.. :-) + s/\$(\w+)/my $t=sub { + my $varname = $_[0]; + if( $varname eq "GRAPHNAME") { ## return the name of the graph + if( $config->{'graphs'}->{$graph_name}->{'title'} ne "") { + return( $config->{'graphs'}->{$graph_name}->{'title'}); + } else { + return( "Graph ".$graph_name); + } + } elsif( $varname eq "CURRENTTIME") { ## return current date-time + return( localtime()); + } elsif( $varname eq "GRAPHINDEX" || $varname eq "GRAPHINDEX_ONEROW") { ## return HTML-code for index of the different graphs + my $return_html; + foreach my $gn ( sort keys %{$config->{'graphs'}}) { + $return_html.=(($varname eq "GRAPHINDEX")?"
  • ":""). + "".($config->{'graphs'}->{$gn}->{'title'})."<\/A>". # must escape slash since were inside an regex! + (($varname eq "GRAPHINDEX_ONEROW")?"  ":""); + } + return( $return_html); + } elsif( $varname eq "GRAPH_AUTOGENERATE") { ## return HTML-code for displaying the actual graph-images + my $iteration_id=0; + my $return_html; + foreach my $time ( @{ $config->{'graphtimetemplates'}->{ $config->{'graphs'}->{$graph_name}->{'graphtimetemplate'} } }) { + $return_html.="

    ".($time->{'description'})."
    "; + $iteration_id++; + } + return( $return_html); + } else { ## unknown variable + return( "##UNKNOWN-VARIABLE##"); + } + }; &$t($1)/eig; ## i thought that regex would never end! + print; + } + close( HTML); + } else { + print "ERROR: HTML-template '$filename' does not exist or is not readable by effective userid."; + } + +} + +## +## Process incoming performance-data (parse output from check-plugin and insert values into rrd-archives) +## +sub parse_perfdata { + + $DEBUG_TIMESTAMP=0; + + my $config = read_config(); + + my $rrd_updates; + + ## Provide more symbolic names (same names as the macros in nagios configuration-file) + + my( $LASTCHECK, $HOSTNAME, $SERVICEDESCR, $SERVICESTATE, $OUTPUT, $PERFDATA) = split( /\|!!\|/, $ARGV[1]); + debug( 3, "**INCOMING PERFDATA:\n LASTCHECK=$LASTCHECK\n HOSTNAME=$HOSTNAME\n SERVICEDESCR=\"$SERVICEDESCR\"\n SERVICESTATE=\"$SERVICESTATE\"\n OUTPUT=\"$OUTPUT\"\n PERFDATA=\"$PERFDATA\""); + + my $host_and_descr_found; + ## Loop through all host_regexes + foreach my $host_regex ( keys %{$config->{'regexes'}}) { + ## Loop through all service_description_regexes + foreach my $service_regex ( keys %{$config->{'regexes'}->{$host_regex}}) { + if( ($HOSTNAME =~ m/$host_regex/i) && ($SERVICEDESCR =~ m/$service_regex/i) ) { ## match! + $host_and_descr_found=1; + ## Loop through all InsertValue-lines with same host and service_description match + foreach my $insert_value ( @{$config->{'regexes'}->{$host_regex}->{$service_regex}} ) { + ## Loop through all regexes that should match values in the output/perfdata + foreach my $regex ( @{ $config->{'valueregextemplates'}->{$insert_value->{'regextemplate'}} }) { + my $regex_string = $regex->{'regex'}; + if( $regex->{'regex_what'} eq "output") { ## do regex on "output" + if( $OUTPUT =~ m/$regex_string/) { + debug( 3, " +VALUE: ".$1); + push( @{$rrd_updates->{$insert_value->{'rrdarchive'}}->{'value'}}, $1); + push( @{$rrd_updates->{$insert_value->{'rrdarchive'}}->{'dsaname'}}, $regex->{'dsaname'}); + $rrd_updates->{$insert_value->{'rrdarchive'}}->{'rrdcreatetemplate'} = $insert_value->{'rrdcreatetemplate'}; #$config->{'regexes'}->{$host_regex}->{$service_regex}->[0]->{'rrdcreatetemplate'}; + } else { + debug( 2, "**WARNING: No match for value with regex on output '$regex_string'."); + } + } else { ## do regex on "perfdata" + if( $PERFDATA =~ m/$regex_string/) { + debug( 3, " +VALUE: ".$1); + push( @{$rrd_updates->{$insert_value->{'rrdarchive'}}->{'value'}}, $1); + push( @{$rrd_updates->{$insert_value->{'rrdarchive'}}->{'dsaname'}}, $regex->{'dsaname'}); + $rrd_updates->{$insert_value->{'rrdarchive'}}->{'rrdcreatetemplate'} = $insert_value->{'rrdcreatetemplate'}; #$config->{'regexes'}->{$host_regex}->{$service_regex}->[0]->{'rrdcreatetemplate'}; + } else { + debug( 2, "**WARNING: No match for value with regex on perfdata '$regex_string'."); + } + } + } + } + + } + } + } + + if( !$host_and_descr_found) { + debug( 2, "**WARNING: Hostname and description didn't match any of the regexes in the config-file."); + } else { + ## + ## Insert the value into the RRD by calling the rrdtool (may be several rrd-archives) + ## + foreach my $archive ( keys %{$rrd_updates}) { + debug( 3, " =INSERT into '$archive': ".join( ",", @{$rrd_updates->{$archive}->{'value'}} )." DSA-names=".join( ",", @{$rrd_updates->{$archive}->{'dsaname'}}) ); + + my $rrdarchive_filename = $config->{'rrdarchivepath'}."/".$archive; + + ## Create RRD-Archive (according to template) if it does not exist + if( ! -e $rrdarchive_filename) { + my $rrdtool_cmdline = $config->{'rrdtoolpath'}." create ".$rrdarchive_filename." ".(join( " ", @{$config->{'rrdcreatetemplates'}->{$rrd_updates->{$archive}->{'rrdcreatetemplate'}}})); + debug( 2, "**CREATING: $rrdarchive_filename, cmdline='".$rrdtool_cmdline."'."); + `$rrdtool_cmdline`; + } + + ## Check if rrd-archive is writable + if( ! -w $rrdarchive_filename) { ## check wheter RRD-archive exists + debug( 1, "!!ERROR: RRD-archive '".$rrdarchive_filename."' does not exist or is not writable by effective UID."); abort(); + } + + ## Assemle command-line for rrdtool + my $rrdtool_cmdline = $config->{'rrdtoolpath'}." update ".$rrdarchive_filename. + " --template ".join( ":", @{$rrd_updates->{$archive}->{'dsaname'}}). + " $LASTCHECK:".join( ":", @{$rrd_updates->{$archive}->{'value'}}); + debug( 3, " !RRDCMDLINE: ".$rrdtool_cmdline); + my $result = `$rrdtool_cmdline`; + if( $result ne "") { + debug( 1, "!!RESULT: $result"); + } + } + } + +} + + + + +## +## Read config-file and check for errors +## +sub read_config { + my $config; + open( CONFIG, $CONFIG_FILE); + my( $line_counter); + while( ) { + $line_counter++; + chomp; + my( @args) = &shellwords( $_); + my $orig_confline = $_; + $args[0] = uc( $args[0]); + + if( $args[0] eq "INSERTVALUE") { ## INSERTVALUE-command + shift @args; + my( $rrd_filename, $rrdcreatetemplate, $hostname_regex, $servicedescr_regex, $regex_template) = @args; + + if( ! exists $config->{'rrdcreatetemplates'}->{$rrdcreatetemplate}) { + debug( 1, "!!ERROR: RRDCreateTemplate '$rrdcreatetemplate' is not defined but refered to in line $line_counter."); abort(); + } + if( $hostname_regex !~ m/^\/(.*)\/$/) { ## verify hostname regex + debug( 1, "!!ERROR: Hostname regex should be enclosed in slashes, i.e. /HOSTNAME/ and optionally enclosed in quotes if needed. Conf-line $line_counter."); abort(); + } else { + $hostname_regex = $1; + } + if( $servicedescr_regex !~ m/^\/(.*)\/$/) { ## verify service description regex + debug( 1, "!!ERROR: Service-description regex should be enclosed in slashes, i.e. /SERVICEDESCR/ and optionally enclosed in quotes if needed. Config-line $line_counter."); + abort(); + } else { + $servicedescr_regex = $1; + } + if( ! exists $config->{'valueregextemplates'}->{$regex_template}) { ## verify value-regex-template exists + debug( 1, "!!ERROR: VALUEREGEXTEMPLATE '$regex_template' is not defined on line $line_counter."); abort(); + } + push( @{$config->{'regexes'}->{$hostname_regex}->{$servicedescr_regex}}, { + 'rrdarchive' => $rrd_filename, + 'rrdcreatetemplate' => $rrdcreatetemplate, + 'regextemplate' => $regex_template + } ); + } elsif( $args[0] =~ m/^(\s*)#/ || $args[0] eq "") { ## comment or blank row + ## do nuthin + } elsif( $args[0] eq "RRDTOOLPATH") { ## RRDToolPath args: path + $config->{'rrdtoolpath'} = $args[1]; + } elsif( $args[0] eq "PLOTTEMPLATE") { ## PlotTemplate args: name,htmltemplate,parameters.. + shift @args; + my( $name, @params) = @args; + if( $name eq "") { + debug( 1, "!!ERROR: PLOTTEMPLATE-name must be specified on line $line_counter."); abort(); + } + if( exists $config->{'plottemplates'}->{$name}) { + debug( 1, "!!ERROR: PLOTTTEMPLATE-names must be uniqe. Duplicate name found on line: $line_counter."); abort(); + } + $config->{'plottemplates'}->{$name} = [ @params]; + } elsif( $args[0] eq "GRAPHTIMETEMPLATE") { ## GraphTimeTemplate args: name,parameters.. + shift @args; + my( $name, @params) = @args; + if( $name eq "") { + debug( 1, "!!ERROR: GRAPHTIMETEMPLATE-name must be specified on line $line_counter."); abort(); + } + if( exists $config->{'graphtimetemplates'}->{$name}) { + debug( 1, "!!ERROR: GRAPHTIMETEMPLATE-names must be uniqe. Duplicate name found on line: $line_counter."); abort(); + } + foreach my $time_template (@params) { + my( $t_start, $t_end, @t_descr) = split( /:/, $time_template); + my $t_descr = join( ":", @t_descr); # workaround if ':' is used in description-string + if( $t_start eq "" || $t_end eq "") { + debug( 1, "!!ERROR: GRAPHTIMETEMPLATE, each time-definition should be defined as '::' on line $line_counter."); + } + push( @{$config->{'graphtimetemplates'}->{$name}}, { + 'starttime' => $t_start, + 'endtime' => $t_end, + 'description' => $t_descr + }); + } + } elsif( $args[0] eq "RRDCREATETEMPLATE") { ## RRDCreateTemplate + shift @args; + my( $name, @params) = @args; + if( $name eq "") { + debug( 1, "!!ERROR: RRDCREATETEMPLATE-name must be specified on line $line_counter."); abort(); + } + if( exists $config->{'rrdcreatetemplates'}->{$name}) { + debug( 1, "!!ERROR: RRDCREATETEMPLATE-names must be uniq. Duplicate name found on line: $line_counter."); abort(); + } + $config->{'rrdcreatetemplates'}->{$name} = [ @params]; + } elsif( $args[0] eq "VALUEREGEXTEMPLATE") { ## ValueRegexTemplate + shift @args; + my( $template_name, @regexes) = @args; + if( $template_name eq "") { + debug( 1, "!!ERROR: VALUEREGEXTEMPLATE-name must be specified on line $line_counter."); abort(); + } + foreach my $r (@regexes) { + if( $r !~ m/^(output|perfdata):(\w+):\/(.*)\/$/) { + debug( 1, "!!ERROR: Value-regex should be formatted as 'output:dsaname:/regex/' or 'perfdata:dsaname:/regex/' depending on in which field to extract the data. The value should be within parantheses in the regex. Config-line $line_counter."); + abort(); + } else { + my( $regex_what, $dsa_name, $regex) = ( $1, $2, $3); + push( @{$config->{'valueregextemplates'}->{$template_name}}, { + 'regex_what' => $regex_what, + 'regex' => $regex, + 'dsaname' => $dsa_name + } ); + } + } + } elsif( $args[0] eq "RRDARCHIVEPATH") { ## RRDARCHIVEPATH + $config->{'rrdarchivepath'} = $args[1]; + } elsif( $args[0] eq "HTMLTEMPLATEPATH") { ## HTMLTemplatePath + $config->{'htmltemplatepath'} = $args[1]; + } elsif( $args[0] eq "GRAPHINDEXTEMPLATE") { ## GraphIndexTemplate + $config->{'graphindextemplate'} = $args[1]; + } elsif( $args[0] eq "GRAPH") { ## GRAPH args: name,rrdfilename,rrdcreatetemplate,graphtimetemplate,plottemplate,htmltemplate + if( $args[1] eq "") { + debug( 1, "!!ERROR: GRAPH-name must be specified on line $line_counter."); abort(); + } + if( ! exists $config->{'graphtimetemplates'}->{$args[3]}) { + debug( 1, "!!ERROR: Unknown GRAPHTIMETEMPLATE on line $line_counter."); abort(); + } + if( ! exists $config->{'plottemplates'}->{$args[4]}) { + debug( 1, "!!ERROR: Unknown PLOTTEMPLATE on line $line_counter."); abort(); + } + if( exists $config->{'graphs'}->{$args[1]}) { + debug( 1, "!!ERROR: Graphnames must be uniqe. Duplicate name found on line: $line_counter."); + abort(); + } else { + $config->{'graphs'}->{$args[1]} = { + 'graphname' => $args[1], + 'rrdfilename' => $args[2], + 'graphtimetemplate' => $args[3], + 'plottemplate' => $args[4], + 'htmltemplate' => $args[5], + 'title' => $args[6] + }; + } + } else { + debug( 1, "!!ERROR: Unknown config-file directive on line $line_counter: '".$args[0]."'"); + } + } + close( CONFIG); + + if( ! -x $config->{'rrdtoolpath'}) { + debug( 1, "!!ERROR: RRDTOOLPATH does not point to executable rrdtool-binary."); + abort(); + } + if( ! -x $config->{'rrdarchivepath'}) { + debug( 1, "!!ERROR: RRDARCHIVEPATH, '".($config->{'rrdarchivepath'})."' is not readable by effective userid."); abort(); + } + if( ! -x $config->{'htmltemplatepath'}) { + debug( 1, "!!ERROR: HTMLTEMPLATEPATH, '".($config->{'htmltemplatepath'})."' is not readable by effective userid."); abort(); + } + + return( $config); +} + + +## +## Write debug-output/logging +## +sub debug { + my( $level, $msg) = @_; + if( $DEBUGLEVEL >= $level) { + + ## write timestamp + if( !$DEBUG_TIMESTAMP) { + $DEBUG_TIMESTAMP=1; + debug( 1, scalar localtime()); + } + + ## write to file or STDERR + if( $DEBUGOUTPUT == 0) { + open( DEBUGOUTPUT, ">>".$DEBUG_LOG_FILE); + print DEBUGOUTPUT $msg."\n"; + close( DEBUGOUTPUT); + } elsif( $DEBUGOUTPUT == 2) { + print "

    $msg
    "; + } else { + print STDERR $msg."\n"; + } + + } +} diff --git a/samples/Perl/strict.t b/samples/Perl/strict.t new file mode 100644 index 00000000..04cea2f8 --- /dev/null +++ b/samples/Perl/strict.t @@ -0,0 +1,11 @@ +use Test::Base; + +__DATA__ +=== Strict Test + +--- perl strict +my $x = 5; +--- strict +use strict; +use warnings; +my $x = 5; \ No newline at end of file