See for the official Zabbix site.

Docs/specs/coding style

Jump to: navigation, search

General rules

  • Use tabs only for indentation. Tab width depends on the language:
    • Java, PHP, CSS, JavaScript - 4 characters
    • C, autotools, m4, Perl, SQL - 8 characters
  • There should be no trailing whitespace.
  • Use LF line endings only.
  • All text files should end with a single newline:
  • Unused code should not be commented out, but removed.
  • Comment text should be separated with a single space from the comment indicator.
  • Non-obvious code should be commented. Also, as a general rule, if at least one developer was puzzled about something, it should be commented as well.

  • All Zabbix developers are encouraged to read Deep C by Olve Maudal and Jon Jagger.

File names

  • The total length of the name and path of a file must be less than 83 symbols. Older tar implementations have a file length limit of 100 characters. Since 16 characters are reserved for the root folder (for example "zabbix-2.2.22rc2") and 1 for the directory separator that leaves 83 characters for other files.

You can use the following command to check if any file in the current directory exceeds this limitation:

find . | grep -v ".svn" | awk 'length > 85 {print $1,length-2}'

Or a version without grep/awk:

path_limit=83; path_limit=$[$path_limit+2]; while read path; do [[ ${#path} -gt $path_limit ]] && echo ${#path} $path; done < <(find ./ ! -wholename '*/.svn*')

Database rules

Database table and field names use underscores between words. For example, expand_macros. While old table and field names lack underscores, they will not be mass changed, but new tables and fields, and ones that have to be modified for other reasons, should use underscores.

Profile index key naming

Profile index keys (idx field in table profiles) should be prefixed with web. Main categories/namespaces are dot-separated. Lowercase only is used and words are separated with underscores: _. For example: web.hostinventories.filter_field_value

If a key may hold some entity and may be specified more than once, it is still named in singular (as that specific instance may contain one entity only). For example, web.dashconf.groups.groupid should be used (not web.dashconf.groups.groupids).

Language specific rules