diff options
author | Chris Buechler <cmb@pfsense.org> | 2013-01-22 17:16:34 -0800 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2013-01-22 17:16:34 -0800 |
commit | 57dbd5d29393789f2b078213ab8ec3546bc44a1b (patch) | |
tree | 9df1ce9491d013ec70739e32ad6b9fbffa0bb7f6 /config | |
parent | 05dd30063ea497b34bd0e1899ed975ed382cdf80 (diff) | |
parent | 6571eef8d831715e6a1e8d66801f7e77cb641084 (diff) | |
download | pfsense-packages-57dbd5d29393789f2b078213ab8ec3546bc44a1b.tar.gz pfsense-packages-57dbd5d29393789f2b078213ab8ec3546bc44a1b.tar.bz2 pfsense-packages-57dbd5d29393789f2b078213ab8ec3546bc44a1b.zip |
Merge pull request #355 from dbaio/master
New beta packages: Zabbix-2 Agent and Zabbix-2 Proxy
Diffstat (limited to 'config')
-rw-r--r-- | config/zabbix2-agent/zabbix2-agent.xml | 258 | ||||
-rw-r--r-- | config/zabbix2-proxy/zabbix2-proxy.xml | 254 |
2 files changed, 512 insertions, 0 deletions
diff --git a/config/zabbix2-agent/zabbix2-agent.xml b/config/zabbix2-agent/zabbix2-agent.xml new file mode 100644 index 00000000..6d83a0bd --- /dev/null +++ b/config/zabbix2-agent/zabbix2-agent.xml @@ -0,0 +1,258 @@ +<?xml version="1.0" encoding="utf-8"?> +<packagegui> + <name>zabbixagent</name> + <title>Services: Zabbix-2 Agent</title> + <category>Monitoring</category> + <version>0.3</version> + <addedit_string>Zabbix Agent has been created/modified.</addedit_string> + <delete_string>Zabbix Agent has been deleted.</delete_string> + <restart_command>/usr/local/etc/rc.d/zabbix2_agentd.sh restart</restart_command> + <menu> + <name>Zabbix-2 Agent</name> + <tooltiptext>Setup Zabbix Agent specific settings</tooltiptext> + <section>Services</section> + <url>/pkg_edit.php?xml=zabbix2-agent.xml&id=0</url> + </menu> + <service> + <name>zabbix_agentd</name> + <rcfile>zabbix2_agentd.sh</rcfile> + <executable>zabbix_agentd</executable> + <description>Zabbix Agent runs on a host being monitored. The agent provides host's performance and availability information for Zabbix Server.</description> + </service> + <tabs> + <tab> + <text>Settings</text> + <url>/pkg_edit.php?xml=zabbix2-agent.xml&id=0</url> + <active /> + </tab> + </tabs> + <fields> + <field> + <fielddescr>Server</fielddescr> + <fieldname>server</fieldname> + <description>List of comma delimited IP addresses (or hostnames) of ZABBIX servers</description> + <value>127.0.0.1</value> + <type>input</type> + <size>60</size> + <required>true</required> + </field> + <field> + <fielddescr>Server Active</fielddescr> + <fieldname>serveractive</fieldname> + <description>List of comma delimited IP:port (or hostname:port) pairs of Zabbix servers for active checks</description> + <value>127.0.0.1</value> + <type>input</type> + <size>60</size> + <required>true</required> + </field> + <field> + <fielddescr>Hostname</fielddescr> + <fieldname>hostname</fieldname> + <description>Unique hostname. Required for active checks and must match hostname as configured on the Zabbix server (case sensitive).</description> + <value>localhost</value> + <type>input</type> + <size>60</size> + <required>true</required> + </field> + <field> + <fielddescr>Listen IP</fielddescr> + <fieldname>listenip</fieldname> + <value>0.0.0.0</value> + <type>input</type> + <size>60</size> + <required>true</required> + <description>Listen IP for connections from the server (generally 0.0.0.0 for all interfaces)</description> + </field> + <field> + <fielddescr>Listen Port</fielddescr> + <fieldname>listenport</fieldname> + <value>10050</value> + <type>input</type> + <size>60</size> + <required>true</required> + <description>Listen port for connections from the server (generally 10050)</description> + </field> + <field> + <fielddescr>Refresh Active Checks</fielddescr> + <fieldname>refreshactchecks</fieldname> + <value>120</value> + <type>input</type> + <size>60</size> + <required>false</required> + <description>The agent will refresh list of active checks once per 120 (default) seconds.</description> + </field> + <field> + <fielddescr>Timeout</fielddescr> + <fieldname>timeout</fieldname> + <value>3</value> + <type>input</type> + <size>60</size> + <required>true</required> + <description>Timeout (default 3). Do not spend more that Timeout seconds on getting requested value (1-255). The agent does not kill timeouted User Parameters processes!</description> + </field> + <field> + <fielddescr>Disable active checks</fielddescr> + <fieldname>disableactive</fieldname> + <type>checkbox</type> + <description>The agent will work only in passive mode listening for server. (generally net set)</description> + </field> + <field> + <fielddescr>Disable passive checks</fielddescr> + <fieldname>disablepassive</fieldname> + <type>checkbox</type> + <description>The agent will not listen on any TCP port. Only active checks will be processed. (generally not set)</description> + </field> + <field> + <fielddescr>User Parameters</fielddescr> + <fieldname>userparams</fieldname> + <encoding>base64</encoding> + <value></value> + <type>textarea</type> + <rows>5</rows> + <cols>50</cols> + <required>false</required> + <description>User-defined parameter to monitor. There can be several user-defined parameters. Value has form, example: UserParameter=users,who|wc -l</description> + </field> + </fields> + <custom_php_install_command> + <![CDATA[ + global $config, $g; + + $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); + switch ($pfs_version) { + case "1.2": + case "2.0": + define('ZABBIX_AGENT_BASE','/usr/local'); + break; + default: + define('ZABBIX_AGENT_BASE', '/usr/pbi/zabbix2-agent-' . php_uname("m")); + } + + mwexec("mkdir -p /var/log/zabbix2/"); + mwexec("mkdir -p /var/run/zabbix2/"); + + conf_mount_rw(); + + /* create a few directories and ensure the sample files are in place */ + exec("/bin/mkdir -p " . ZABBIX_AGENT_BASE . "/etc/zabbix2"); + exec("/bin/mkdir -p /var/log/zabbix2"); + exec("/bin/mkdir -p /var/run/zabbix2"); + + exec("/bin/rm -f " . ZABBIX_AGENT_BASE . "/etc/rc.d/zabbix2_agentd"); + + $start = "/bin/mkdir -p /var/log/zabbix2\n"; + $start .= "/usr/sbin/chown -R zabbix:zabbix /var/log/zabbix2\n"; + + $start .= "/bin/mkdir -p /var/run/zabbix2\n"; + $start .= "/usr/sbin/chown -R zabbix:zabbix /var/run/zabbix2\n"; + + $start .= "echo \"Starting Zabbix Agent\"...\n"; + + /* start zabbix agent */ + $start .= ZABBIX_AGENT_BASE . "/sbin/zabbix_agentd\n"; + + $stop = "echo \"Stopping Zabbix Agent\"\n"; + $stop .= "/usr/bin/killall zabbix_agentd\n"; + /* write out rc.d start/stop file */ + write_rcfile(array( + "file" => "zabbix2_agentd.sh", + "start" => "{$start}", + "restart" => "$stop\n" . "sleep 5\n" . "{$start}", + "stop" => "$stop" + ) + ); + + conf_mount_ro(); + ]]> + </custom_php_install_command> + <custom_php_command_before_form></custom_php_command_before_form> + <custom_php_after_head_command></custom_php_after_head_command> + <custom_php_after_form_command></custom_php_after_form_command> + <custom_php_validation_command> + <![CDATA[ + global $_POST; + $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); + switch ($pfs_version) { + case "1.2": + case "2.0": + define('ZABBIX_AGENT_BASE','/usr/local'); + break; + default: + define('ZABBIX_AGENT_BASE', '/usr/pbi/zabbix2-agent-' . php_uname("m")); + } + + $ListenIP=$_POST['listenip']; + if (!preg_match("/^(?:\d{1,3}\.){3}\d{1,3}$/", $ListenIP)) { + $input_errors[]='Listen IP is not ip-adress.'; + } + + $ListenPort=$_POST['listenport']; + if (!preg_match("/^\d+$/", $ListenPort)) { + $input_errors[]='Listen Port is not numeric.'; + } + + $RefreshActiveChecks=$_POST['refreshactchecks']; + if (!preg_match("/^\d+$/", $RefreshActiveChecks)) { + $input_errors[]='Refresh Active Checks is not numeric.'; + } + + $Timeout=$_POST['timeout']; + if (!preg_match("/^\d+$/", $Timeout)) { + $input_errors[]='Timeout is not numeric.'; + } + ]]> + </custom_php_validation_command> + <custom_add_php_command></custom_add_php_command> + <custom_php_resync_config_command> + <![CDATA[ + conf_mount_rw(); + global $config; + global $g; + + $Server=$config['installedpackages']['zabbixagent']['config'][0]['server']; + $ServerActive=$config['installedpackages']['zabbixagent']['config'][0]['serveractive']; + $Hostname=$config['installedpackages']['zabbixagent']['config'][0]['hostname']; + $ListenIP=$config['installedpackages']['zabbixagent']['config'][0]['listenip']; + $ListenPort=$config['installedpackages']['zabbixagent']['config'][0]['listenport']; + $RefreshActChecks=$config['installedpackages']['zabbixagent']['config'][0]['refreshactchecks']; + $Timeout=$config['installedpackages']['zabbixagent']['config'][0]['timeout']; + $DisableActive=$config['installedpackages']['zabbixagent']['config'][0]['disableactive']; + $DisablePassive=$config['installedpackages']['zabbixagent']['config'][0]['disablepassive']; + $UserParams=base64_decode($config['installedpackages']['zabbixagent']['config'][0]['userparams']); + + $conf = "Server=$Server\n"; + $conf .= "ServerActive=$ServerActive\n"; + $conf .= "Hostname=$Hostname\n"; + $conf .= "ListenIP=$ListenIP\n"; + $conf .= "ListenPort=$ListenPort\n"; + $conf .= "StartAgents=5\n"; + $conf .= "RefreshActiveChecks=$RefreshActChecks\n"; + $conf .= "DebugLevel=3\n"; + $conf .= "PidFile=/var/run/zabbix2/zabbix2_agentd.pid\n"; + $conf .= "LogFile=/var/log/zabbix2/zabbix2_agentd.log\n"; + $conf .= "LogFileSize=1\n"; + $conf .= "Timeout=$Timeout\n"; + if (isset($DisableActive) && ($DisableActive == "on")) { + $conf .= "DisableActive=1\n"; + } + if (isset($DisablePassive) && ($DisablePassive == "on")) { + $conf .= "DisablePassive=1\n"; + } + $conf .= "$UserParams\n"; + + file_put_contents(ZABBIX_AGENT_BASE . "/etc/zabbix2/zabbix_agentd.conf", $conf); + conf_mount_ro(); + + ]]> + </custom_php_resync_config_command> + <custom_php_deinstall_command> + <![CDATA[ + exec("/usr/bin/killall zabbix_agentd"); + + exec("/bin/rm " . ZABBIX_AGENT_BASE . "/etc/rc.d/zabbix2_agentd.sh"); + + exec("/bin/rm -r /var/log/zabbix2/"); + exec("/bin/rm -r /var/run/zabbix2/"); + ]]> + </custom_php_deinstall_command> +</packagegui> diff --git a/config/zabbix2-proxy/zabbix2-proxy.xml b/config/zabbix2-proxy/zabbix2-proxy.xml new file mode 100644 index 00000000..7575fbc9 --- /dev/null +++ b/config/zabbix2-proxy/zabbix2-proxy.xml @@ -0,0 +1,254 @@ +<?xml version="1.0" encoding="utf-8"?> +<packagegui> + <name>zabbixproxy</name> + <title>Services: Zabbix-2 Proxy</title> + <category>Monitoring</category> + <version>0.3</version> + <addedit_string>Zabbix Proxy has been created/modified.</addedit_string> + <delete_string>Zabbix Proxy has been deleted.</delete_string> + <restart_command>/usr/local/etc/rc.d/zabbix2_proxy.sh restart</restart_command> + <menu> + <name>Zabbix-2 Proxy</name> + <tooltiptext>Setup Zabbix Proxy specific settings</tooltiptext> + <section>Services</section> + <url>/pkg_edit.php?xml=zabbix2-proxy.xml&id=0</url> + </menu> + <service> + <name>zabbix-proxy</name> + <rcfile>zabbix2_proxy.sh</rcfile> + <executable>zabbix_proxy</executable> + <description>Zabbix proxy is a process which collects performance and availability data from one or more monitored devices and sends the information to a Zabbix server</description> + </service> + <tabs> + <tab> + <text>Settings</text> + <url>/pkg_edit.php?xml=zabbix2-proxy.xml&id=0</url> + <active /> + </tab> + </tabs> + <fields> + <field> + <fielddescr>Server</fielddescr> + <fieldname>server</fieldname> + <description>List of comma delimited IP addresses (or hostnames) of ZABBIX servers</description> + <default_value>127.0.0.1</default_value> + <type>input</type> + <size>100</size> + <required>true</required> + </field> + <field> + <fielddescr>Server Port</fielddescr> + <fieldname>serverport</fieldname> + <description>Port of Zabbix trapper on Zabbix server. default value 10051</description> + <value>10051</value> + <default_value>10051</default_value> + <type>input</type> + <size>6</size> + <required>true</required> + </field> + <field> + <fielddescr>Hostname</fielddescr> + <fieldname>hostname</fieldname> + <description>Unique, case-sensitive proxy name. Make sure the proxy name is known to the server</description> + <default_value>localhost</default_value> + <type>input</type> + <size>100</size> + <required>true</required> + </field> + <field> + <fielddescr>Active Mode</fielddescr> + <fieldname>activemode</fieldname> + <description>Check to run Zabbix proxy in active mode (default)</description> + <default_value>on</default_value> + <type>checkbox</type> + <required>true</required> + </field> + <field> + <fielddescr>Config Frequency</fielddescr> + <fieldname>configfrequency</fieldname> + <description>How often the proxy retrieves configuration data from the Zabbix server in seconds. Ignored if the proxy runs in passive mode.</description> + <default_value>3600</default_value> + <type>input</type> + <size>10</size> + <required>true</required> + </field> + </fields> + <custom_php_install_command> + <![CDATA[ + global $config, $g; + + $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); + switch ($pfs_version) { + case "1.2": + case "2.0": + define('ZABBIX_PROXY_BASE', '/usr/local'); + break; + case "2.1": + define('ZABBIX_PROXY_BASE', '/usr/local'); + break; + default: + define('ZABBIX_PROXY_BASE', '/usr/pbi/zabbix2-proxy-' . php_uname("m")); + } + + mwexec("mkdir -p /var/log/zabbix2/"); + mwexec("mkdir -p /var/run/zabbix2/"); + mwexec("mkdir -p /var/db/zabbix2/"); + + conf_mount_rw(); + + /* create a few directories and ensure the sample files are in place */ + exec("/bin/mkdir -p " . ZABBIX_PROXY_BASE . "/etc/zabbix2"); + exec("/bin/mkdir -p /var/log/zabbix2"); + exec("/bin/mkdir -p /var/run/zabbix2"); + exec("/bin/mkdir -p /var/db/zabbix2"); + + exec("/bin/rm -f " . ZABBIX_PROXY_BASE . "/etc/rc.d/zabbix2_proxy"); + + $start = "/bin/mkdir -p /var/log/zabbix2\n"; + $start .= "/usr/sbin/chown -R zabbix:zabbix /var/log/zabbix2\n"; + + $start .= "/bin/mkdir -p /var/run/zabbix2\n"; + $start .= "/usr/sbin/chown -R zabbix:zabbix /var/run/zabbix2\n"; + + $start .= "/bin/mkdir -p /var/db/zabbix2\n"; + $start .= "/usr/sbin/chown -R zabbix:zabbix /var/db/zabbix2\n"; + + $start .= "echo \"Starting Zabbix Proxy\"...\n"; + + /* start zabbix proxy */ + $start .= ZABBIX_PROXY_BASE . "/sbin/zabbix_proxy\n"; + + $stop = "echo \"Stopping Zabbix Proxy\"\n"; + $stop .= "/usr/bin/killall zabbix_proxy\n"; + /* write out rc.d start/stop file */ + write_rcfile(array( + "file" => "zabbix2_proxy.sh", + "start" => "{$start}", + "restart" => "$stop\n" . "sleep 5\n" . "{$start}", + "stop" => "$stop" + ) + ); + + conf_mount_ro(); + ]]> + </custom_php_install_command> + <custom_php_command_before_form></custom_php_command_before_form> + <custom_php_after_head_command></custom_php_after_head_command> + <custom_php_after_form_command></custom_php_after_form_command> + <custom_php_validation_command> + <![CDATA[ + global $_POST; + + $ServerPort=$_POST['serverport']; + if (!preg_match("/^\d+$/", $ServerPort)) { + $input_errors[]='Server Port is not numeric.'; + } + + $ConfigFrequency=$_POST['configfrequency']; + if (!preg_match("/^\d+$/", $ConfigFrequency)) { + $input_errors[]='Config Frequency is not numeric.'; + } + ]]> + </custom_php_validation_command> + <custom_add_php_command></custom_add_php_command> + <custom_php_resync_config_command> + <![CDATA[ + conf_mount_rw(); + global $config, $g; + + $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); + switch ($pfs_version) { + case "1.2": + case "2.0": + define('ZABBIX_PROXY_BASE', '/usr/local'); + break; + default: + define('ZABBIX_PROXY_BASE', '/usr/pbi/zabbix2-proxy-' . php_uname("m")); + } + + $zabbixproxy_config = $config['installedpackages']['zabbixproxy']['config'][0]; + + $Server=$zabbixproxy_config['server']; + $ServerPort=$zabbixproxy_config['serverport']; + $Hostname=$zabbixproxy_config['hostname']; + $ListenPort=$zabbixproxy_config['listenport']; + $ConfigFrequency=$zabbixproxy_config['configfrequency']; + if(isset($zabbixproxy_config['activemode'])) { + $Mode="0"; /* active */ + } else { + $Mode="1"; /* passive */ + } + + $conf = "Server=$Server\n"; + $conf .= "ServerPort=$ServerPort\n"; + $conf .= "Hostname=$Hostname\n"; + $conf .= "PidFile=/var/run/zabbix2/zabbix2_proxy.pid\n"; + $conf .= "DBName=/var/db/zabbix2/proxy.db\n"; + $conf .= "LogFile=/var/log/zabbix2/zabbix_proxy.log\n"; + $conf .= "ConfigFrequency=$ConfigFrequency\n"; + $conf .= "FpingLocation=/usr/local/sbin/fping\n"; + /* there's currently no fping6 (IPv6) dependency in the package, but if there was, the binary would likely also be in /usr/local/sbin */ + $conf .= "Fping6Location=/usr/local/sbin/fping6\n"; + $conf .= "ProxyMode=$Mode\n"; + + file_put_contents(ZABBIX_PROXY_BASE . "/etc/zabbix2/zabbix_proxy.conf", $conf); + + $want_sysctls = array( + 'kern.ipc.shmall' => '2097152', + 'kern.ipc.shmmax' => '2147483648', + 'kern.ipc.semmsl' => '250' + ); + $sysctls = array(); + if (file_exists("/etc/sysctl.conf")) { + $sc = file_get_contents("/etc/sysctl.conf"); + $sc = explode("\n", $sc); + foreach ($sc as $num => $line) { + list($sysctl, $val) = explode("=", $line, 2); + if (array_key_exists($sysctl, $want_sysctls) || empty($sysctl)) + unset($sc[$num]); + } + } + foreach ($want_sysctls as $ws => $wv) { + $sc[] = "{$ws}={$wv}"; + exec("/sbin/sysctl {$ws}={$wv}"); + } + file_put_contents("/etc/sysctl.conf", implode("\n", $sc) . "\n"); + + $want_tunables = array( + 'kern.ipc.semopm' => '100', + 'kern.ipc.semmni' => '128', + 'kern.ipc.semmns' => '32000', + 'kern.ipc.shmmni' => '4096' + ); + $tunables = array(); + if (file_exists("/boot/loader.conf")) { + $lt = file_get_contents("/boot/loader.conf"); + $lt = explode("\n", $lt); + foreach ($lt as $num => $line) { + list($tunable, $val) = explode("=", $line, 2); + if (array_key_exists($tunable, $want_tunables) || empty($tunable)) + unset($lt[$num]); + } + } + foreach ($want_tunables as $wt => $wv) { + $lt[] = "{$wt}={$wv}"; + } + file_put_contents("/boot/loader.conf", implode("\n", $lt) . "\n"); + chmod("/var/log/zabbix2", 0755); + chmod("/var/run/zabbix2", 0755); + conf_mount_ro(); + + ]]> + </custom_php_resync_config_command> + <custom_php_deinstall_command> + <![CDATA[ + exec("kill `cat /var/run/zabbix2/zabbix2_proxy.pid`"); + + exec("/bin/rm " . ZABBIX_PROXY_BASE . "/etc/rc.d/zabbix2_proxy.sh"); + + exec("/bin/rm -r /var/log/zabbix2/"); + exec("/bin/rm -r /var/run/zabbix2/"); + exec("/bin/rm -r /var/db/zabbix2/"); + ]]> + </custom_php_deinstall_command> +</packagegui> |