summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-10-18 13:44:57 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-10-18 13:44:57 +0000
commit0bc8042afa40b292d2e46bf049f716e0aafdfd28 (patch)
tree527645af42492979f1a29649ccb96225579019dd /src
parentadc0cb63073a41e24bd22dcd80b5afef6c7de703 (diff)
downloadzabbix-0bc8042afa40b292d2e46bf049f716e0aafdfd28.tar.gz
zabbix-0bc8042afa40b292d2e46bf049f716e0aafdfd28.tar.xz
zabbix-0bc8042afa40b292d2e46bf049f716e0aafdfd28.zip
- added support of system.cpu.util[<idle|user|kernel|wait>] (Eugene)
- added support of net.listen.tcp[portdec] (Eugene) - changed system.uptime (Eugene) - changed net[listen_80] (Eugene) - changed net[listen_23] (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2198 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/libs/zbxsysinfo/solaris/Makefile.am2
-rwxr-xr-xsrc/libs/zbxsysinfo/solaris/SunOS5.9.c100
-rw-r--r--src/libs/zbxsysinfo/solaris/cpu.c373
-rw-r--r--src/libs/zbxsysinfo/solaris/diskio.c334
-rw-r--r--src/libs/zbxsysinfo/solaris/diskspace.c82
-rw-r--r--src/libs/zbxsysinfo/solaris/memory.c178
-rw-r--r--src/libs/zbxsysinfo/solaris/net.c416
-rw-r--r--src/libs/zbxsysinfo/solaris/solaris.c47
-rw-r--r--src/libs/zbxsysinfo/solaris/swap.c106
-rw-r--r--src/libs/zbxsysinfo/solaris/uptime.c32
10 files changed, 1133 insertions, 537 deletions
diff --git a/src/libs/zbxsysinfo/solaris/Makefile.am b/src/libs/zbxsysinfo/solaris/Makefile.am
index 17bd6d0c..94393287 100644
--- a/src/libs/zbxsysinfo/solaris/Makefile.am
+++ b/src/libs/zbxsysinfo/solaris/Makefile.am
@@ -1,6 +1,6 @@
SUBDIRS=
-libzbxsysinfo2_a_SOURCES=cpu.c diskio.c diskspace.c inodes.c kernel.c memory.c proc.c sensors.c swap.c uptime.c
+libzbxsysinfo2_a_SOURCES=cpu.c diskio.c diskspace.c inodes.c kernel.c memory.c net.c proc.c sensors.c swap.c uptime.c
lib_LIBRARIES=libzbxsysinfo2.a
libzbxsysinfo2_a_LIBADD = ../../zbxcommon/libzbxcommon.a ../../zbxcrypto/libzbxcrypto.a
diff --git a/src/libs/zbxsysinfo/solaris/SunOS5.9.c b/src/libs/zbxsysinfo/solaris/SunOS5.9.c
index b966eb79..64bac53c 100755
--- a/src/libs/zbxsysinfo/solaris/SunOS5.9.c
+++ b/src/libs/zbxsysinfo/solaris/SunOS5.9.c
@@ -47,6 +47,9 @@
#include "common.h"
#include "sysinfo.h"
+/*
+ * ADDED to /solaric/diskio.c
+ *
typedef struct busy_data
{
hrtime_t clock;
@@ -95,7 +98,11 @@ typedef struct disk_data
RBLOCKS_DATA rblocks;
WBLOCKS_DATA wblocks;
} DISK_DATA;
+*/
+/*
+ * ADDED to /solaric/net.c
+ *
typedef union value_overlay
{
union
@@ -139,9 +146,13 @@ typedef struct network_data
OPACKETS_DATA op;
} NETWORK_DATA;
-static DISK_DATA *disks;
-
static NETWORK_DATA *interfaces;
+*/
+
+/*
+ * ADDED to /solaric/diskio.c
+ *
+static DISK_DATA *disks;
static DISK_DATA *get_disk_data_record(const char *device)
{
@@ -178,7 +189,11 @@ static DISK_DATA *get_disk_data_record(const char *device)
return p;
}
+*/
+/*
+ * ADDED to /solaric/net.c
+ *
static NETWORK_DATA *get_net_data_record(const char *device)
{
NETWORK_DATA *p;
@@ -214,7 +229,11 @@ static NETWORK_DATA *get_net_data_record(const char *device)
return p;
}
+*/
+/*
+ * SKIPPED
+ *
static int PROCCNT(const char *cmd, const char *procname,double *value)
{
DIR *dir;
@@ -223,7 +242,7 @@ static int PROCCNT(const char *cmd, const char *procname,double *value)
char filename[MAX_STRING_LEN];
int fd;
-/* In the correct procfs.h, the structure name is psinfo_t */
+// In the correct procfs.h, the structure name is psinfo_t
psinfo_t psinfo;
int proccount=0;
@@ -269,7 +288,11 @@ static int PROCCNT(const char *cmd, const char *procname,double *value)
*value=(double)proccount;
return SYSINFO_RET_OK;
}
+*/
+/*
+ * ADDED to /solaric/diskio.c
+ *
static int get_disk_kstat_record(const char *name,
hrtime_t *crtime,
hrtime_t *snaptime,
@@ -509,7 +532,11 @@ static int DISKSVC(const char *cmd, const char *device, double *value)
return result;
}
+*/
+/*
+ * ADDED to /solaric/cpu.c
+ *
static int get_cpu_data(uint64_t *idle,
uint64_t *system,
uint64_t *user,
@@ -689,7 +716,11 @@ static int CPUIOWAIT(const char *cmd, const char *param,double *value)
return result;
}
+*/
+/*
+ * ADDED to /solaric/net.c
+ *
static int get_named_field(const char *name,
const char *field,
kstat_named_t *returned_data,
@@ -963,7 +994,11 @@ static int NETCOLLOUT(const char *cmd, const char *parameter,double *value)
return result;
}
+*/
+/*
+ * ADDED
+ *
int INODEFREE(const char *cmd, const char *mountPoint,double *value)
{
struct statvfs s;
@@ -976,7 +1011,11 @@ int INODEFREE(const char *cmd, const char *mountPoint,double *value)
*value=s.f_favail;
return SYSINFO_RET_OK;
}
+*/
+/*
+ * ADDED
+ *
int INODETOTAL(const char *cmd, const char *mountPoint,double *value)
{
struct statvfs s;
@@ -989,7 +1028,11 @@ int INODETOTAL(const char *cmd, const char *mountPoint,double *value)
*value=s.f_files;
return SYSINFO_RET_OK;
}
+*/
+/*
+ * ADDED
+ *
int DISKFREE(const char *cmd, const char *mountPoint,double *value)
{
struct statvfs s;
@@ -999,11 +1042,15 @@ int DISKFREE(const char *cmd, const char *mountPoint,double *value)
return SYSINFO_RET_FAIL;
}
-/* return s.f_bavail * (s.f_bsize / 1024.0);*/
+// return s.f_bavail * (s.f_bsize / 1024.0);
*value=s.f_bavail * (s.f_frsize / 1024.0);
return SYSINFO_RET_OK;
}
+*/
+/*
+ * ADDED
+ *
int DISKUSED(const char *cmd, const char *mountPoint,double *value)
{
struct statvfs s;
@@ -1013,11 +1060,15 @@ int DISKUSED(const char *cmd, const char *mountPoint,double *value)
return SYSINFO_RET_FAIL;
}
-/* return (s.f_blocks-s.f_bavail) * (s.f_bsize / 1024.0);*/
+// return (s.f_blocks-s.f_bavail) * (s.f_bsize / 1024.0);
*value=(s.f_blocks-s.f_bavail) * (s.f_frsize / 1024.0);
return SYSINFO_RET_OK;
}
+*/
+/*
+ * ADDED
+ *
int DISKTOTAL(const char *cmd, const char *mountPoint,double *value)
{
struct statvfs s;
@@ -1027,22 +1078,31 @@ int DISKTOTAL(const char *cmd, const char *mountPoint,double *value)
return SYSINFO_RET_FAIL;
}
-/* return s.f_blocks * (s.f_bsize / 1024.0);*/
+// return s.f_blocks * (s.f_bsize / 1024.0);
*value= s.f_blocks * (s.f_frsize / 1024.0);
return SYSINFO_RET_OK;
}
+*/
+/*
+ * ADDED
+ *
static int TOTALMEM(const char *cmd, const char *parameter,double *value)
{
*value=(double)sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGESIZE);
return SYSINFO_RET_OK;
}
+*/
+/*
+ * ADDED
+ *
static int FREEMEM(const char *cmd, const char *parameter,double *value)
{
*value=(double)sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE);
return SYSINFO_RET_OK;
}
+*/
/*
* ADDED
@@ -1080,6 +1140,9 @@ static int KERNEL_MAXPROC(const char *cmd, const char *parameter,double *value)
}
*/
+/*
+ * ADDED
+ *
static int UPTIME(const char *cmd, const char *parameter,double *value)
{
int result = SYSINFO_RET_FAIL;
@@ -1112,7 +1175,11 @@ static int UPTIME(const char *cmd, const char *parameter,double *value)
return result;
}
+*/
+/*
+ * ADDED
+ *
static int PROCLOAD(const char *cmd, const char *parameter,double *value)
{
double load[3];
@@ -1127,7 +1194,11 @@ static int PROCLOAD(const char *cmd, const char *parameter,double *value)
return SYSINFO_RET_FAIL;
}
}
+*/
+/*
+ * ADDED
+ *
static int PROCLOAD5(const char *cmd, const char *parameter,double *value)
{
double load[3];
@@ -1142,7 +1213,11 @@ static int PROCLOAD5(const char *cmd, const char *parameter,double *value)
return SYSINFO_RET_FAIL;
}
}
+*/
+/*
+ * ADDED
+ *
static int PROCLOAD15(const char *cmd, const char *parameter,double *value)
{
double load[3];
@@ -1157,7 +1232,11 @@ static int PROCLOAD15(const char *cmd, const char *parameter,double *value)
return SYSINFO_RET_FAIL;
}
}
+*/
+/*
+ * ADDED
+ *
static int get_swap_data(uint64_t *resv,
uint64_t *avail,
uint64_t *free)
@@ -1245,6 +1324,7 @@ int SWAPTOTAL(const char *cmd, const char *parameter,double *value)
return result;
}
+*/
/*
* ADDED
@@ -1324,6 +1404,9 @@ static int SWAPOUT(const char *cmd, const char *parameter,double *value)
}
*/
+/*
+ * SKIPPED
+ *
static int PROCCOUNT(const char *cmd, const char *parameter,double *value)
{
int result = SYSINFO_RET_FAIL;
@@ -1353,6 +1436,7 @@ static int PROCCOUNT(const char *cmd, const char *parameter,double *value)
return result;
}
+*/
/*
* ADDED
@@ -1453,6 +1537,9 @@ static int CSWITCHES(const char *cmd, const char *parameter,double *value)
}
*/
+/*
+ * ADDED to /solaris/net.c
+ *
static int TCP_LISTEN(const char *cmd, const char *parameter,double *value)
{
char command[MAX_STRING_LEN];
@@ -1463,6 +1550,7 @@ static int TCP_LISTEN(const char *cmd, const char *parameter,double *value)
return EXECUTE(NULL, command, value);
}
+*/
/*
* ADDED
diff --git a/src/libs/zbxsysinfo/solaris/cpu.c b/src/libs/zbxsysinfo/solaris/cpu.c
index 18f1f560..8fa3aab5 100644
--- a/src/libs/zbxsysinfo/solaris/cpu.c
+++ b/src/libs/zbxsysinfo/solaris/cpu.c
@@ -197,39 +197,112 @@ int SYSTEM_CPU_SYS15(const char *cmd, const char *param,double *value)
return get_stat("cpu[system15]",value);
}
-/* AIX CPU info */
-#ifdef HAVE_KNLIST_H
-static int getloadavg_kmem(double loadavg[], int nelem)
+static int get_cpu_data(unsigned long long *idle,
+ unsigned long long *system,
+ unsigned long long *user,
+ unsigned long long *iowait)
{
- struct nlist nl;
- int kmem, i;
- long avenrun[3];
-
- nl.n_name = "avenrun";
- nl.n_value = 0;
+ kstat_ctl_t *kc;
+ kstat_t *k;
+ cpu_stat_t *cpu;
+
+ int cpu_count = 0;
+
+ *idle = 0LL;
+ *system = 0LL;
+ *user = 0LL;
+ *iowait = 0LL;
- if(knlist(&nl, 1, sizeof(nl)))
- {
- return FAIL;
- }
- if((kmem = open("/dev/kmem", 0, 0)) <= 0)
+ kc = kstat_open();
+ if (kc)
+ {
+ k = kc->kc_chain;
+ while (k)
{
- return FAIL;
- }
+ if ((strncmp(k->ks_name, "cpu_stat", 8) == 0)
+ && (kstat_read(kc, k, NULL) != -1)
+ )
+ {
+ cpu = (cpu_stat_t *) k->ks_data;
- if(pread(kmem, avenrun, sizeof(avenrun), nl.n_value) <
- sizeof(avenrun))
- {
- return FAIL;
- }
+ *idle += cpu->cpu_sysinfo.cpu[CPU_IDLE];
+ *system += cpu->cpu_sysinfo.cpu[CPU_KERNEL];
+ *iowait += cpu->cpu_sysinfo.cpu[CPU_WAIT];
+ *user += cpu->cpu_sysinfo.cpu[CPU_USER];
+
+ cpu_count += 1;
+ }
+ k = k->ks_next;
+ }
+ kstat_close(kc);
+ }
+ return cpu_count;
+}
+
+#define CPU_I 0
+#define CPU_U 1
+#define CPU_K 2
+#define CPU_W 3
+
+int SYSTEM_CPU_UTILIZATION(const char *cmd, const char *param,double *value)
+{
+ unsigned long long cpu_val[4];
+ unsigned long long interval_size;
+
+ char cpu_info[MAX_STRING_LEN];
+
+ int info_id = 0;
+
+ int result = SYSINFO_RET_FAIL;
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
- for(i=0;i<nelem;i++)
+ if(get_param(param, 1, cpu_info, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+ else
+ {
+ strscpy(cpu_info, "idle");
+ }
+
+ if(strcmp(cpu_info,"idle") == 0)
+ {
+ info_id = CPU_I;
+ }
+ else if(strcmp(cpu_info,"user") == 0)
+ {
+ info_id = CPU_U;
+ }
+ else if(strcmp(cpu_info,"kernel") == 0)
+ {
+ info_id = CPU_K;
+ }
+ else if(strcmp(cpu_info,"wait") == 0)
+ {
+ info_id = CPU_W;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if (get_cpu_data(&cpu_val[CPU_I], &cpu_val[CPU_K], &cpu_val[CPU_U], &cpu_val[CPU_W]))
+ {
+ interval_size = cpu_val[CPU_I] + cpu_val[CPU_K] + cpu_val[CPU_U] + cpu_val[CPU_W];
+
+ if (interval_size > 0)
{
- loadavg[i] = (double) avenrun[i] / 65535;
- }
- return SUCCEED;
+ *value = (cpu_val[info_id] * 100.0)/interval_size;
+
+ result = SYSINFO_RET_OK;
+ }
+ }
+ return result;
}
-#endif
int SYSTEM_CPU_LOAD1(const char *cmd, const char *parameter,double *value)
{
@@ -246,57 +319,8 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *parameter,double *value)
return SYSINFO_RET_FAIL;
}
#else
-#ifdef HAVE_SYS_PSTAT_H
- struct pst_dynamic dyn;
-
- if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
- {
- *value=(double)dyn.psd_avg_1_min;
- return SYSINFO_RET_OK;
- }
-#else
-#ifdef HAVE_PROC_LOADAVG
- return getPROC("/proc/loadavg",1,1,value);
-#else
-#ifdef HAVE_KSTAT_H
- static kstat_ctl_t *kc = NULL;
- kstat_t *ks;
- kstat_named_t *kn;
-
- if (!kc && !(kc = kstat_open()))
- {
- return SYSINFO_RET_FAIL;
- }
- if (!(ks = kstat_lookup(kc, "unix", 0, "system_misc")) ||
- kstat_read(kc, ks, 0) == -1 ||
- !(kn = kstat_data_lookup(ks,"avenrun_1min")))
- {
- return SYSINFO_RET_FAIL;
- }
- *value=(double)kn->value.ul/256.0;
- return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_KNLIST_H
- double loadavg[3];
-
- if(getloadavg_kmem(loadavg,3) == FAIL)
- {
- return SYSINFO_RET_FAIL;
- }
-
- *value=loadavg[0];
- return SYSINFO_RET_OK;
-#else
return SYSINFO_RET_FAIL;
#endif
-#endif
-#endif
-#endif
-#endif
}
int SYSTEM_CPU_LOAD5(const char *cmd, const char *parameter,double *value)
@@ -314,135 +338,27 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *parameter,double *value)
return SYSINFO_RET_FAIL;
}
#else
-#ifdef HAVE_SYS_PSTAT_H
- struct pst_dynamic dyn;
+ return SYSINFO_RET_FAIL;
+#endif
+}
+
+int SYSTEM_CPU_LOAD15(const char *cmd, const char *parameter,double *value)
+{
+#ifdef HAVE_GETLOADAVG
+ double load[3];
- if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
+ if(getloadavg(load, 3))
{
- *value=(double)dyn.psd_avg_5_min;
+ *value=load[2];
return SYSINFO_RET_OK;
}
-#else
-#ifdef HAVE_PROC_LOADAVG
- return getPROC("/proc/loadavg",1,2,value);
-#else
-#ifdef HAVE_KSTAT_H
- static kstat_ctl_t *kc = NULL;
- kstat_t *ks;
- kstat_named_t *kn;
-
- if (!kc && !(kc = kstat_open()))
- {
- return SYSINFO_RET_FAIL;
- }
- if (!(ks = kstat_lookup(kc, "unix", 0, "system_misc")) ||
- kstat_read(kc, ks, 0) == -1 ||
- !(kn = kstat_data_lookup(ks,"avenrun_5min")))
+ else
{
- return SYSINFO_RET_FAIL;
+ return SYSINFO_RET_FAIL;
}
- *value=(double)kn->value.ul/256.0;
- return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_KNLIST_H
- double loadavg[3];
-
- if(getloadavg_kmem(loadavg,3) == FAIL)
- {
- return STSINFO_RET_FAIL;
- }
-
- *value=loadavg[1];
- return SYSINFO_RET_OK;
#else
return SYSINFO_RET_FAIL;
#endif
-#endif
-#endif
-#endif
-#endif
-}
-
-int SYSTEM_CPU_SWAPIN(const char *cmd, const char *parameter, double *value)
-{
- kstat_ctl_t *kc;
- kstat_t *k;
- cpu_stat_t *cpu;
-
- int cpu_count = 0;
- double swapin= 0.0;
-
- kc = kstat_open();
-
- if(kc != NULL)
- {
- k = kc->kc_chain;
- while (k != NULL)
- {
- if( (strncmp(k->ks_name, "cpu_stat", 8) == 0) &&
- (kstat_read(kc, k, NULL) != -1) )
- {
- cpu = (cpu_stat_t*) k->ks_data;
- /* uint_t swapin; // swapins */
- swapin += (double) cpu->cpu_vminfo.swapin;
- cpu_count += 1;
- }
- k = k->ks_next;
- }
- kstat_close(kc);
- }
-
- *value = swapin;
-
- if(cpu_count == 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- return SYSINFO_RET_OK;
-}
-
-int SYSTEM_CPU_SWAPOUT(const char *cmd, const char *parameter, double *value)
-{
- kstat_ctl_t *kc;
- kstat_t *k;
- cpu_stat_t *cpu;
-
- int cpu_count = 0;
- double swapout = 0.0;
-
- kc = kstat_open();
-
- if(kc != NULL)
- {
- k = kc->kc_chain;
- while (k != NULL)
- {
- if( (strncmp(k->ks_name, "cpu_stat", 8) == 0) &&
- (kstat_read(kc, k, NULL) != -1) )
- {
- cpu = (cpu_stat_t*) k->ks_data;
- /* uint_t swapout; // swapouts */
- swapout += (double) cpu->cpu_vminfo.swapout;
- cpu_count += 1;
- }
- k = k->ks_next;
- }
- kstat_close(kc);
- }
-
- *value = swapout;
-
- if(cpu_count == 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- return SYSINFO_RET_OK;
}
int SYSTEM_CPU_SWITCHES(const char *cmd, const char *parameter, double *value)
@@ -521,70 +437,3 @@ int SYSTEM_CPU_INTR(const char *cmd, const char *parameter, double *value)
return SYSINFO_RET_OK;
}
-int SYSTEM_CPU_LOAD15(const char *cmd, const char *parameter,double *value)
-{
-#ifdef HAVE_GETLOADAVG
- double load[3];
-
- if(getloadavg(load, 3))
- {
- *value=load[2];
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#else
-#ifdef HAVE_SYS_PSTAT_H
- struct pst_dynamic dyn;
-
- if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
- {
- *value=(double)dyn.psd_avg_15_min;
- return SYSINFO_RET_OK;
- }
-#else
-#ifdef HAVE_PROC_LOADAVG
- return getPROC("/proc/loadavg",1,3,value);
-#else
-#ifdef HAVE_KSTAT_H
- static kstat_ctl_t *kc = NULL;
- kstat_t *ks;
- kstat_named_t *kn;
-
- if (!kc && !(kc = kstat_open()))
- {
- return SYSINFO_RET_FAIL;
- }
- if (!(ks = kstat_lookup(kc, "unix", 0, "system_misc")) ||
- kstat_read(kc, ks, 0) == -1 ||
- !(kn = kstat_data_lookup(ks,"avenrun_15min")))
- {
- return SYSINFO_RET_FAIL;
- }
- *value=(double)kn->value.ul/256.0;
- return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_KNLIST_H
- double loadavg[3];
-
- if(getloadavg_kmem(loadavg,3) == FAIL)
- {
- return STSINFO_RET_FAIL;
- }
-
- *value=loadavg[2];
- return SYSINFO_RET_OK;
-#else
- return SYSINFO_RET_FAIL;
-#endif
-#endif
-#endif
-#endif
-#endif
-}
diff --git a/src/libs/zbxsysinfo/solaris/diskio.c b/src/libs/zbxsysinfo/solaris/diskio.c
index a030d6f9..42645f26 100644
--- a/src/libs/zbxsysinfo/solaris/diskio.c
+++ b/src/libs/zbxsysinfo/solaris/diskio.c
@@ -135,6 +135,340 @@
#include "common.h"
#include "sysinfo.h"
+#if 0
+
+/* !!! don't work on solaris !!!
+ !!! missing 'hda' field in kstat !!! */
+
+typedef struct busy_data
+{
+ hrtime_t clock;
+ hrtime_t rtime;
+} BUSY_DATA;
+
+typedef struct svc_time_data
+{
+ hrtime_t rtime;
+ uint_t reads;
+ uint_t writes;
+} SVC_TIME_DATA;
+
+typedef struct read_ios_data
+{
+ hrtime_t clock;
+ uint_t reads;
+} READ_IOS_DATA;
+
+typedef struct write_ios_data
+{
+ hrtime_t clock;
+ uint_t writes;
+} WRITE_IOS_DATA;
+
+typedef struct rblocks_data
+{
+ hrtime_t clock;
+ u_longlong_t nread;
+} RBLOCKS_DATA;
+
+typedef struct wblocks_data
+{
+ hrtime_t clock;
+ u_longlong_t nwritten;
+} WBLOCKS_DATA;
+
+typedef struct disk_data
+{
+ struct disk_data *next;
+ char *name;
+ BUSY_DATA busy;
+ SVC_TIME_DATA svc;
+ READ_IOS_DATA reads;
+ WRITE_IOS_DATA writes;
+ RBLOCKS_DATA rblocks;
+ WBLOCKS_DATA wblocks;
+} DISK_DATA;
+
+static DISK_DATA *disks;
+
+static DISK_DATA *get_disk_data_record(const char *device)
+{
+ DISK_DATA *p;
+
+ p = disks;
+
+ while ((p) && (strcmp(p->name, device) != 0))
+ p = p->next;
+
+ if (p == (DISK_DATA *) NULL)
+ {
+ p = (DISK_DATA *) calloc(1, sizeof(DISK_DATA));
+
+ if (p)
+ {
+ p->name = strdup(device);
+
+ if (p->name)
+ {
+ p->next = disks;
+
+ disks = p;
+ }
+
+ else
+ {
+ free(p);
+
+ p = NULL;
+ }
+ }
+ }
+
+ return p;
+}
+
+static int get_disk_kstat_record(const char *name,
+ hrtime_t *crtime,
+ hrtime_t *snaptime,
+ kstat_io_t *returned_data)
+{
+ int result = SYSINFO_RET_FAIL;
+ kstat_ctl_t *kc;
+
+ kc = kstat_open();
+
+ if (kc)
+ {
+ kstat_t *kt;
+
+ kt = kstat_lookup(kc, NULL, -1, (char *) name);
+
+ if (kt)
+ {
+ if ( (kt->ks_type == KSTAT_TYPE_IO)
+ && (kstat_read(kc, kt, returned_data) != -1)
+ )
+ {
+ *crtime = kt->ks_crtime;
+ *snaptime = kt->ks_snaptime;
+ result = SYSINFO_RET_OK;
+ }
+ }
+
+ kstat_close(kc);
+ }
+
+ return result;
+}
+
+int DISKREADOPS(const char *cmd, const char *device,double *value)
+{
+ int result = SYSINFO_RET_FAIL;
+ DISK_DATA *p;
+
+ p = get_disk_data_record(device);
+
+ if (p)
+ {
+ hrtime_t crtime, snaptime;
+ kstat_io_t kio;
+
+ result = get_disk_kstat_record(device, &crtime, &snaptime, &kio);
+
+ if (result == SYSINFO_RET_OK)
+ {
+ int interval_seconds;
+
+ interval_seconds = (snaptime - p->reads.clock) / 1000000000;
+
+ if (interval_seconds > 0)
+ *value = (kio.reads - p->reads.reads) / interval_seconds;
+
+ else
+ *value = 0.0;
+
+ p->reads.clock = snaptime;
+
+ p->reads.reads = kio.reads;
+ }
+ }
+
+ return result;
+}
+
+static int DISKREADBLOCKS(const char *cmd, const char *device,double *value)
+{
+ int result = SYSINFO_RET_FAIL;
+ DISK_DATA *p;
+
+ p = get_disk_data_record(device);
+
+ if (p)
+ {
+ hrtime_t crtime, snaptime;
+ kstat_io_t kio;
+
+ result = get_disk_kstat_record(device, &crtime, &snaptime, &kio);
+
+ if (result == SYSINFO_RET_OK)
+ {
+ int interval_seconds;
+
+ interval_seconds = (snaptime - p->rblocks.clock) / 1000000000;
+
+ if (interval_seconds > 0)
+ *value = ((kio.nread - p->rblocks.nread) / 1024.0) / interval_seconds;
+
+ else
+ *value = 0.0;
+
+ p->rblocks.clock = snaptime;
+
+ p->rblocks.nread = kio.nread;
+ }
+ }
+
+ return result;
+}
+
+static int DISKWRITEOPS(const char *cmd, const char *device,double *value)
+{
+ int result = SYSINFO_RET_FAIL;
+ DISK_DATA *p;
+
+ p = get_disk_data_record(device);
+
+ if (p)
+ {
+ hrtime_t crtime, snaptime;
+ kstat_io_t kio;
+
+ result = get_disk_kstat_record(device, &crtime, &snaptime, &kio);
+
+ if (result == SYSINFO_RET_OK)
+ {
+ int interval_seconds;
+
+ interval_seconds = (snaptime - p->writes.clock) / 1000000000;
+
+ if (interval_seconds > 0)
+ *value = (kio.writes - p->writes.writes) / interval_seconds;
+
+ else
+ *value = 0.0;
+
+ p->writes.clock = snaptime;
+
+ p->writes.writes = kio.writes;
+ }
+ }
+
+ return result;
+}
+
+static int DISKWRITEBLOCKS(const char *cmd, const char *device,double *value)
+{
+ int result = SYSINFO_RET_FAIL;
+ DISK_DATA *p;
+
+ p = get_disk_data_record(device);
+
+ if (p)
+ {
+ hrtime_t crtime, snaptime;
+ kstat_io_t kio;
+
+ result = get_disk_kstat_record(device, &crtime, &snaptime, &kio);
+
+ if (result == SYSINFO_RET_OK)
+ {
+ int interval_seconds;
+
+ interval_seconds = (snaptime - p->wblocks.clock) / 1000000000;
+
+ if (interval_seconds > 0)
+ *value = ((kio.nwritten - p->wblocks.nwritten) / 1024.0) / interval_seconds;
+
+ else
+ *value = 0.0;
+
+ p->wblocks.clock = snaptime;
+
+ p->wblocks.nwritten = kio.nwritten;
+ }
+ }
+
+ return result;
+}
+
+static int DISKBUSY(const char *cmd, const char *device, double *value)
+{
+ int result = SYSINFO_RET_FAIL;
+ DISK_DATA *p;
+
+ p = get_disk_data_record(device);
+
+ if (p)
+ {
+ hrtime_t crtime, snaptime;
+ kstat_io_t kio;
+
+ result = get_disk_kstat_record(device, &crtime, &snaptime, &kio);
+
+ if (result == SYSINFO_RET_OK)
+ {
+ if (snaptime > p->busy.clock)
+ *value = ((kio.rtime - p->busy.rtime) * 100.0) / (snaptime - p->busy.clock);
+
+ else
+ *value = 0.0;
+
+ p->busy.clock = snaptime;
+
+ p->busy.rtime = kio.rtime;
+ }
+ }
+
+ return result;
+}
+
+static int DISKSVC(const char *cmd, const char *device, double *value)
+{
+ int result = SYSINFO_RET_FAIL;
+ DISK_DATA *p;
+
+ p = get_disk_data_record(device);
+
+ if (p)
+ {
+ hrtime_t crtime, snaptime;
+ kstat_io_t kio;
+
+ result = get_disk_kstat_record(device, &crtime, &snaptime, &kio);
+
+ if (result == SYSINFO_RET_OK)
+ {
+ unsigned long ios;
+
+ ios = (kio.reads - p->svc.reads) + (kio.writes - p->svc.writes);
+
+ if (ios > 0)
+ *value = ((kio.rtime - p->svc.rtime)/ios)/1000000.0;
+
+ else
+ *value = 0.0;
+
+ p->svc.writes = kio.writes;
+ p->svc.reads = kio.reads;
+ p->svc.rtime = kio.rtime;
+ }
+ }
+
+ return result;
+}
+
+#endif
+
int DISKREADOPS1(const char *cmd, const char *device,double *value)
{
char key[MAX_STRING_LEN];
diff --git a/src/libs/zbxsysinfo/solaris/diskspace.c b/src/libs/zbxsysinfo/solaris/diskspace.c
index 49351916..0eae3c15 100644
--- a/src/libs/zbxsysinfo/solaris/diskspace.c
+++ b/src/libs/zbxsysinfo/solaris/diskspace.c
@@ -197,33 +197,6 @@ int VFS_FS_FREE(const char *cmd, const char *mountPoint,double *value)
*value=s.f_bavail * (s.f_frsize / 1024.0);
return SYSINFO_RET_OK;
#else
- struct statfs s;
- long blocks_used;
- long blocks_percent_used;
-
- if ( statfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( s.f_blocks > 0 ) {
- blocks_used = s.f_blocks - s.f_bfree;
- blocks_percent_used = (long)
- (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
-
-/* printf(
- "%7.0f %7.0f %7.0f %5ld%% %s\n"
- ,s.f_blocks * (s.f_bsize / 1024.0)
- ,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)
- ,s.f_bavail * (s.f_bsize / 1024.0)
- ,blocks_percent_used
- ,mountPoint);
-*/
- *value=s.f_bavail * (s.f_bsize / 1024.0);
- return SYSINFO_RET_OK;
-
- }
-
return SYSINFO_RET_FAIL;
#endif
}
@@ -242,33 +215,6 @@ int VFS_FS_USED(const char *cmd, const char *mountPoint,double *value)
*value=(s.f_blocks-s.f_bavail) * (s.f_frsize / 1024.0);
return SYSINFO_RET_OK;
#else
- struct statfs s;
- long blocks_used;
- long blocks_percent_used;
-
- if ( statfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( s.f_blocks > 0 ) {
- blocks_used = s.f_blocks - s.f_bfree;
- blocks_percent_used = (long)
- (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
-
-/* printf(
- "%7.0f %7.0f %7.0f %5ld%% %s\n"
- ,s.f_blocks * (s.f_bsize / 1024.0)
- ,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)
- ,s.f_bavail * (s.f_bsize / 1024.0)
- ,blocks_percent_used
- ,mountPoint);
-*/
- *value=blocks_used * (s.f_bsize / 1024.0);
- return SYSINFO_RET_OK;
-
- }
-
return SYSINFO_RET_FAIL;
#endif
}
@@ -287,33 +233,7 @@ int VFS_FS_TOTAL(const char *cmd, const char *mountPoint,double *value)
*value= s.f_blocks * (s.f_frsize / 1024.0);
return SYSINFO_RET_OK;
#else
- struct statfs s;
- long blocks_used;
- long blocks_percent_used;
-
- if ( statfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( s.f_blocks > 0 ) {
- blocks_used = s.f_blocks - s.f_bfree;
- blocks_percent_used = (long)
- (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
-
-/* printf(
- "%7.0f %7.0f %7.0f %5ld%% %s\n"
- ,s.f_blocks * (s.f_bsize / 1024.0)
- ,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)
- ,s.f_bavail * (s.f_bsize / 1024.0)
- ,blocks_percent_used
- ,mountPoint);
-*/
- *value=s.f_blocks * (s.f_bsize / 1024.0);
- return SYSINFO_RET_OK;
-
- }
-
return SYSINFO_RET_FAIL;
#endif
}
+
diff --git a/src/libs/zbxsysinfo/solaris/memory.c b/src/libs/zbxsysinfo/solaris/memory.c
index 21461a80..95eceb75 100644
--- a/src/libs/zbxsysinfo/solaris/memory.c
+++ b/src/libs/zbxsysinfo/solaris/memory.c
@@ -233,198 +233,20 @@ int VM_MEMORY_SHARED(const char *cmd, const char *parameter,double *value)
int VM_MEMORY_TOTAL(const char *cmd, const char *parameter,double *value)
{
-/* Solaris */
#ifdef HAVE_UNISTD_SYSCONF
*value=(double)sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGESIZE);
return SYSINFO_RET_OK;
#else
-#ifdef HAVE_SYS_PSTAT_H
- struct pst_static pst;
- long page;
-
- if(pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
- {
- /* Get page size */
- page = pst.page_size;
- /* Total physical memory in bytes */
- *value=(double)page*pst.physical_memory;
- return SYSINFO_RET_OK;
- }
-#else
-#ifdef HAVE_SYSINFO_TOTALRAM
- struct sysinfo info;
-
- if( 0 == sysinfo(&info))
- {
-#ifdef HAVE_SYSINFO_MEM_UNIT
- *value=(double)info.totalram * (double)info.mem_unit;
-#else
- *value=(double)info.totalram;
-#endif
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#else
-#ifdef HAVE_SYS_VMMETER_VMTOTAL
- int mib[2],len;
- struct vmtotal v;
-
- len=sizeof(struct vmtotal);
- mib[0]=CTL_VM;
- mib[1]=VM_METER;
-
- sysctl(mib,2,&v,&len,NULL,0);
-
- *value=(double)(v.t_rm<<2);
- return SYSINFO_RET_OK;
-#else
-#ifdef HAVE_SYS_SYSCTL_H
- static int mib[] = { CTL_HW, HW_PHYSMEM };
- size_t len;
- unsigned int memory;
- int ret;
-
- len=sizeof(memory);
-
- if(0==sysctl(mib,2,&memory,&len,NULL,0))
- {
- *value=(double)memory;
- ret=SYSINFO_RET_OK;
- }
- else
- {
- ret=SYSINFO_RET_FAIL;
- }
- return ret;
-#else
return SYSINFO_RET_FAIL;
#endif
-#endif
-#endif
-#endif
-#endif
}
int VM_MEMORY_FREE(const char *cmd, const char *parameter,double *value)
{
-/* Solaris */
#ifdef HAVE_UNISTD_SYSCONF
*value=(double)sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE);
return SYSINFO_RET_OK;
#else
-#ifdef HAVE_SYS_PSTAT_H
- struct pst_static pst;
- struct pst_dynamic dyn;
- long page;
-
- if(pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
- {
- /* Get page size */
- page = pst.page_size;
-/* return pst.physical_memory;*/
-
- if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
- {
- return SYSINFO_RET_FAIL;
- }
- else
- {
-/* cout<<"total virtual memory allocated is " << dyn.psd_vm << "
- pages, " << dyn.psd_vm * page << " bytes" << endl;
- cout<<"active virtual memory is " << dyn.psd_avm <<" pages, " <<
- dyn.psd_avm * page << " bytes" << endl;
- cout<<"total real memory is " << dyn.psd_rm << " pages, " <<
- dyn.psd_rm * page << " bytes" << endl;
- cout<<"active real memory is " << dyn.psd_arm << " pages, " <<
- dyn.psd_arm * page << " bytes" << endl;
- cout<<"free memory is " << dyn.psd_free << " pages, " <<
-*/
- /* Free memory in bytes */
-
- *value=(double)dyn.psd_free * page;
- return SYSINFO_RET_OK;
- }
- }
-#else
-#ifdef HAVE_SYSINFO_FREERAM
- struct sysinfo info;
-
- if( 0 == sysinfo(&info))
- {
-#ifdef HAVE_SYSINFO_MEM_UNIT
- *value=(double)info.freeram * (double)info.mem_unit;
-#else
- *value=(double)info.freeram;
-#endif
- return SYSINFO_RET_OK;
- }
- else
- {
- return SYSINFO_RET_FAIL;
- }
-#else
-#ifdef HAVE_SYS_VMMETER_VMTOTAL
- int mib[2],len;
- struct vmtotal v;
-
- len=sizeof(struct vmtotal);
- mib[0]=CTL_VM;
- mib[1]=VM_METER;
-
- sysctl(mib,2,&v,&len,NULL,0);
-
- *value=(double)(v.t_free<<2);
- return SYSINFO_RET_OK;
-#else
-/* OS/X */
-#ifdef HAVE_MACH_HOST_INFO_H
- vm_statistics_data_t page_info;
- vm_size_t pagesize;
- mach_msg_type_number_t count;
- kern_return_t kret;
- int ret;
-
- pagesize = 0;
- kret = host_page_size (mach_host_self(), &pagesize);
-
- count = HOST_VM_INFO_COUNT;
- kret = host_statistics (mach_host_self(), HOST_VM_INFO,
- (host_info_t)&page_info, &count);
- if (kret == KERN_SUCCESS)
- {
- double pw, pa, pi, pf, pu;
-
- pw = (double)page_info.wire_count*pagesize;
- pa = (double)page_info.active_count*pagesize;
- pi = (double)page_info.inactive_count*pagesize;
- pf = (double)page_info.free_count*pagesize;
-
- pu = pw+pa+pi;
-
- *value=(double)pf;
- ret = SYSINFO_RET_OK;
- }
- else
- {
- ret = SYSINFO_RET_FAIL;
- }
- return ret;
-#else
return SYSINFO_RET_FAIL;
#endif
-#endif
-#endif
-#endif
-#endif
}
diff --git a/src/libs/zbxsysinfo/solaris/net.c b/src/libs/zbxsysinfo/solaris/net.c
new file mode 100644
index 00000000..b28961db
--- /dev/null
+++ b/src/libs/zbxsysinfo/solaris/net.c
@@ -0,0 +1,416 @@
+/*
+ * ** ZABBIX
+ * ** Copyright (C) 2000-2005 SIA Zabbix
+ * **
+ * ** 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * **/
+
+#include "config.h"
+
+#include <errno.h>
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#ifdef HAVE_PWD_H
+# include <pwd.h>
+#endif
+
+/* Definitions of uint32_t under OS/X */
+#ifdef HAVE_STDINT_H
+ #include <stdint.h>
+#endif
+#ifdef HAVE_STRINGS_H
+ #include <strings.h>
+#endif
+#ifdef HAVE_FCNTL_H
+ #include <fcntl.h>
+#endif
+#ifdef HAVE_DIRENT_H
+ #include <dirent.h>
+#endif
+/* Linux */
+#ifdef HAVE_SYS_VFS_H
+ #include <sys/vfs.h>
+#endif
+#ifdef HAVE_SYS_SYSINFO_H
+ #include <sys/sysinfo.h>
+#endif
+/* Solaris */
+#ifdef HAVE_SYS_STATVFS_H
+ #include <sys/statvfs.h>
+#endif
+
+#ifdef HAVE_SYS_PROC_H
+# include <sys/proc.h>
+#endif
+/* Solaris */
+#ifdef HAVE_SYS_PROCFS_H
+/* This is needed to access the correct procfs.h definitions */
+ #define _STRUCTURED_PROC 1
+ #include <sys/procfs.h>
+#endif
+#ifdef HAVE_SYS_LOADAVG_H
+ #include <sys/loadavg.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+ #include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+ #include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+ #include <arpa/inet.h>
+#endif
+/* OpenBSD/Solaris */
+#ifdef HAVE_SYS_PARAM_H
+ #include <sys/param.h>
+#endif
+
+#ifdef HAVE_SYS_MOUNT_H
+ #include <sys/mount.h>
+#endif
+
+/* Solaris */
+#ifdef HAVE_SYS_SWAP_H
+ #include <sys/swap.h>
+#endif
+
+#ifdef HAVE_SYS_SYSCALL_H
+ #include <sys/syscall.h>
+#endif
+
+#ifdef HAVE_KSTAT_H
+ #include <kstat.h>
+#endif
+
+#ifdef HAVE_LDAP
+ #include <ldap.h>
+#endif
+
+#include "common.h"
+#include "sysinfo.h"
+
+/*
+#define FDI(f, m) fprintf(stderr, "DEBUG INFO: " f "\n" , m) // show debug info to stderr
+#define SDI(m) FDI("%s", m) // string info
+#define IDI(i) FDI("%i", i) // integer info
+*/
+
+#if 0
+
+/* !!! don't work on solaris !!!
+ !!! missing 'lo' field in kstat !!! */
+
+typedef union value_overlay
+{
+ union
+ {
+ uint64_t ui64;
+ uint32_t ui32;
+ } u;
+} VALUE_OVERLAY;
+
+typedef struct rbytes_data
+{
+ hrtime_t clock;
+ VALUE_OVERLAY rbytes;
+} RBYTES_DATA;
+
+typedef struct obytes_data
+{
+ hrtime_t clock;
+ VALUE_OVERLAY obytes;
+} OBYTES_DATA;
+
+typedef struct rpackets_data
+{
+ hrtime_t clock;
+ VALUE_OVERLAY rpackets;
+} RPACKETS_DATA;
+
+typedef struct opackets_data
+{
+ hrtime_t clock;
+ VALUE_OVERLAY opackets;
+} OPACKETS_DATA;
+
+typedef struct network_data
+{
+ struct network_data *next;
+ char *name;
+ RBYTES_DATA rb;
+ OBYTES_DATA ob;
+ RPACKETS_DATA rp;
+ OPACKETS_DATA op;
+} NETWORK_DATA;
+
+static NETWORK_DATA *interfaces;
+
+static NETWORK_DATA *get_net_data_record(const char *device)
+{
+ NETWORK_DATA *p;
+
+ p = interfaces;
+
+ while ((p) && (strcmp(p->name, device) != 0))
+ p = p->next;
+
+ if (p == (NETWORK_DATA *) NULL)
+ {
+ p = (NETWORK_DATA *) calloc(1, sizeof(NETWORK_DATA));
+ if (p)
+ {
+ p->name = strdup(device);
+ if (p->name)
+ {
+ p->next = interfaces;
+ interfaces = p;
+ }
+ else
+ {
+ free(p);
+ p = NULL;
+ }
+ }
+ }
+ return p;
+}
+
+static int get_named_field(
+ const char *name,
+ const char *field,
+ kstat_named_t *returned_data,
+ hrtime_t *snaptime
+ )
+{
+ int result = SYSINFO_RET_FAIL;
+
+ kstat_ctl_t *kc;
+ kstat_t *kp;
+ kstat_named_t *kn;
+
+ kc = kstat_open();
+ if (kc)
+ {
+ kp = kstat_lookup(kc, NULL, -1, name);
+ if ((kp) && (kstat_read(kc, kp, 0) != -1))
+ {
+ kn = (kstat_named_t*) kstat_data_lookup(kp, field);
+ *snaptime = kp->ks_snaptime;
+ *returned_data = *kn;
+ result = SYSINFO_RET_OK;
+ }
+ kstat_close(kc);
+ }
+ return result;
+}
+
+int NET_IN_LOAD(const char *cmd, const char *parameter,double *value)
+{
+ int result = SYSINFO_RET_FAIL;
+ NETWORK_DATA *p;
+ kstat_named_t kn;
+ hrtime_t snaptime;
+ int interval_seconds;
+
+ p = get_net_data_record(parameter);
+ if(p)
+ {
+ result = get_named_field(parameter, "rbytes64", &kn, &snaptime);
+ if (result == SYSINFO_RET_OK)
+ {
+ interval_seconds = (snaptime - p->rb.clock) / 1000000000;
+ *value = (double) (kn.value.ui64 - p->rb.rbytes.u.ui64) / interval_seconds;
+ p->rb.rbytes.u.ui64 = kn.value.ui64;
+ p->rb.clock = snaptime;
+ }
+ else
+ {
+ result = get_named_field(parameter, "rbytes", &kn, &snaptime);
+ if (result == SYSINFO_RET_OK)
+ {
+ interval_seconds = (snaptime - p->rb.clock) / 1000000000;
+ *value = (double) (kn.value.ui32 - p->rb.rbytes.u.ui32) / interval_seconds;
+ p->rb.rbytes.u.ui32 = kn.value.ui32;
+ p->rb.clock = snaptime;
+ }
+ }
+ }
+ return result;
+}
+
+int NET_IN_PACKETS(const char *cmd, const char *parameter,double *value)
+{
+ int result = SYSINFO_RET_FAIL;
+ NETWORK_DATA *p;
+ int interval_seconds;
+ kstat_named_t kn;
+ hrtime_t snaptime;
+
+ p = get_net_data_record(parameter);
+ if(p)
+ {
+ result = get_named_field(parameter, "ipackets64", &kn, &snaptime);
+ if (result == SYSINFO_RET_OK)
+ {
+ interval_seconds = (snaptime - p->rp.clock) / 1000000000;
+ *value = (double) (kn.value.ui64 - p->rp.rpackets.u.ui64) / interval_seconds;
+ p->rp.rpackets.u.ui64 = kn.value.ui64;
+ p->rp.clock = snaptime;
+ }
+ else
+ {
+ result = get_named_field(parameter, "ipacket", &kn, &snaptime);
+ if (result == SYSINFO_RET_OK)
+ {
+ interval_seconds = (snaptime - p->rp.clock) / 1000000000;
+ *value = (double) (kn.value.ui32 - p->rp.rpackets.u.ui32) / interval_seconds;
+ p->rp.rpackets.u.ui32 = kn.value.ui32;
+ p->rp.clock = snaptime;
+ }
+ }
+ }
+ return result;
+}
+
+int NET_IN_ERRORS(const char *cmd, const char *parameter,double *value)
+{
+ int result;
+ kstat_named_t kn;
+ hrtime_t snaptime;
+
+ result = get_named_field(parameter, "ierrors", &kn, &snaptime);
+
+ if (result == SYSINFO_RET_OK)
+ *value = (double) kn.value.ui32;
+
+ return result;
+}
+
+int NET_OUT_LOAD(const char *cmd, const char *parameter,double *value)
+{
+ int result = SYSINFO_RET_FAIL;
+ NETWORK_DATA *p;
+ kstat_named_t kn;
+ hrtime_t snaptime;
+ int interval_seconds;
+
+ p = get_net_data_record(parameter);
+ if (p)
+ {
+ result = get_named_field(parameter, "obytes64", &kn, &snaptime);
+
+ if (result == SYSINFO_RET_OK)
+ {
+ interval_seconds = (snaptime - p->ob.clock) / 1000000000;
+ *value = (double) (kn.value.ui64 - p->ob.obytes.u.ui64) / interval_seconds;
+ p->ob.obytes.u.ui64 = kn.value.ui64;
+ p->ob.clock = snaptime;
+ }
+ else
+ {
+ result = get_named_field(parameter, "obytes", &kn, &snaptime);
+ if (result == SYSINFO_RET_OK)
+ {
+ interval_seconds = (snaptime - p->ob.clock) / 1000000000;
+ *value = (double) (kn.value.ui32 - p->ob.obytes.u.ui32) / interval_seconds;
+ p->ob.obytes.u.ui32 = kn.value.ui32;
+ p->ob.clock = snaptime;
+ }
+ }
+ }
+ return result;
+}
+
+int NET_OUT_PACKETS(const char *cmd, const char *parameter,double *value)
+{
+ int result = SYSINFO_RET_FAIL;
+ NETWORK_DATA *p;
+ kstat_named_t kn;
+ hrtime_t snaptime;
+ int interval_seconds;
+
+ p = get_net_data_record(parameter);
+ if (p)
+ {
+ result = get_named_field(parameter, "opackets64", &kn, &snaptime);
+ if (result == SYSINFO_RET_OK)
+ {
+ interval_seconds = (snaptime - p->op.clock) / 1000000000;
+ *value = (double) (kn.value.ui64 - p->op.opackets.u.ui64) / interval_seconds;
+ p->op.opackets.u.ui64 = kn.value.ui64;
+ p->op.clock = snaptime;
+ }
+ else
+ {
+ result = get_named_field(parameter, "opacket", &kn, &snaptime);
+ if (result == SYSINFO_RET_OK)
+ {
+ interval_seconds = (snaptime - p->op.clock) / 1000000000;
+ *value = (double) (kn.value.ui32 - p->op.opackets.u.ui32) / interval_seconds;
+ p->op.opackets.u.ui32 = kn.value.ui32;
+ p->op.clock = snaptime;
+ }
+ }
+ }
+ return result;
+}
+
+int NET_OUT_ERRORS(const char *cmd, const char *parameter,double *value)
+{
+ int result;
+ kstat_named_t kn;
+ hrtime_t snaptime;
+
+ result = get_named_field(parameter, "oerrors", &kn, &snaptime);
+
+ if (result == SYSINFO_RET_OK)
+ *value = (double) kn.value.ui32;
+
+ return result;
+}
+
+int NET_COLLISIONS(const char *cmd, const char *parameter,double *value)
+{
+ int result;
+ kstat_named_t kn;
+ hrtime_t snaptime;
+
+ result = get_named_field(parameter, "collisions", &kn, &snaptime);
+
+ if (result == SYSINFO_RET_OK)
+ *value = (double) kn.value.ui32;
+
+ return result;
+}
+
+#endif
+
+int NET_TCP_LISTEN(const char *cmd, const char *parameter,double *value)
+{
+ char command[MAX_STRING_LEN];
+
+ memset(command, '\0', sizeof(command));
+
+ snprintf(command, sizeof(command)-1, "netstat -an | grep '*.%s' | wc -l", parameter);
+
+ return EXECUTE(NULL, command, value);
+}
+
diff --git a/src/libs/zbxsysinfo/solaris/solaris.c b/src/libs/zbxsysinfo/solaris/solaris.c
index cadd243f..a733998a 100644
--- a/src/libs/zbxsysinfo/solaris/solaris.c
+++ b/src/libs/zbxsysinfo/solaris/solaris.c
@@ -76,6 +76,10 @@ int NET_IF_OBYTES1(const char *cmd, const char *parameter,double *value);
int NET_IF_OBYTES5(const char *cmd, const char *parameter,double *value);
int NET_IF_OBYTES15(const char *cmd, const char *parameter,double *value);
+int NET_TCP_LISTEN(const char *cmd, const char *parameter,double *value);
+
+int TCP_LISTEN(const char *cmd, const char *porthex,double *value);
+
int DISKREADOPS1(const char *cmd, const char *parameter,double *value);
int DISKREADOPS5(const char *cmd, const char *parameter,double *value);
int DISKREADOPS15(const char *cmd, const char *parameter,double *value);
@@ -88,6 +92,7 @@ int DISKWRITEOPS15(const char *cmd, const char *parameter,double *value);
int DISKWRITEBLKS1(const char *cmd, const char *parameter,double *value);
int DISKWRITEBLKS5(const char *cmd, const char *parameter,double *value);
int DISKWRITEBLKS15(const char *cmd, const char *parameter,double *value);
+
int AGENT_PING(const char *cmd, const char *parameter,double *value);
int VM_MEMORY_SHARED(const char *cmd, const char *parameter,double *value);
int VM_MEMORY_TOTAL(const char *cmd, const char *parameter,double *value);
@@ -102,6 +107,7 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *parameter,double *value);
int SYSTEM_CPU_LOAD15(const char *cmd, const char *parameter,double *value);
int SYSTEM_CPU_INTR(const char *cmd, const char *parameter, double *value);
int SYSTEM_CPU_SWITCHES(const char *cmd, const char *parameter, double *value);
+int SYSTEM_CPU_UTILIZATION(const char *cmd, const char *param,double *value);
int SENSOR_TEMP1(const char *cmd, const char *parameter,double *value);
int SENSOR_TEMP2(const char *cmd, const char *parameter,double *value);
@@ -118,8 +124,6 @@ int SYSTEM_UPTIME(const char *cmd, const char *parameter,double *value);
int SYSTEM_SWAP_FREE(const char *cmd, const char *parameter,double *value);
int SYSTEM_SWAP_TOTAL(const char *cmd, const char *parameter,double *value);
-int TCP_LISTEN(const char *cmd, const char *porthex,double *value);
-
int EXECUTE(const char *cmd, const char *command,double *value);
int EXECUTE_STR(const char *cmd, const char *command, const char *parameter, char **value);
int AGENT_VERSION(const char *cmd, const char *command,char **value);
@@ -238,12 +242,35 @@ COMMAND parameters_specific[]=
{"system.cpu.user5" ,SYSTEM_CPU_USER5, 0, 0},
{"system.cpu.user15" ,SYSTEM_CPU_USER15, 0, 0},
+ {"system.cpu.util[*]" ,SYSTEM_CPU_UTILIZATION, 0, "idle"},
+
{"net.if.ibytes1[*]" ,NET_IF_IBYTES1, 0, "lo"},
{"net.if.ibytes5[*]" ,NET_IF_IBYTES5, 0, "lo"},
{"net.if.ibytes15[*]" ,NET_IF_IBYTES15, 0, "lo"},
{"net.if.obytes1[*]" ,NET_IF_OBYTES1, 0, "lo"},
{"net.if.obytes5[*]" ,NET_IF_OBYTES5, 0, "lo"},
{"net.if.obytes15[*]" ,NET_IF_OBYTES15, 0, "lo"},
+
+ {"net.listen.tcp[*]" ,NET_TCP_LISTEN, 0, "80"},
+
+/* {"tcp_count" ,EXECUTE, 0, "netstat -tn|grep EST|wc -l"}, */
+
+ {"net[listen_23]" ,NET_TCP_LISTEN, 0, "23"},
+ {"net[listen_80]" ,NET_TCP_LISTEN, 0, "80"},
+
+/****************************************
+ Don't work, see solaris/net.c
+
+ {"net.in.load[*]" ,NET_IN_LOAD, 0, "lo"},
+ {"net.in.pack[*]" ,NET_IN_PACKETS, 0, "lo"},
+ {"net.in.err[*]" ,NET_IN_ERRORS, 0, "lo"},
+
+ {"net.out.load[*]" ,NET_OUT_LOAD, 0, "lo"},
+ {"net.out.pack[*]" ,NET_OUT_PACKETS, 0, "lo"},
+ {"net.out.err[*]" ,NET_OUT_ERRORS, 0, "lo"},
+
+ {"net.out.coll[*]" ,NET_COLLISIONS, 0, "lo"},
+***************************************/
{"disk_read_ops1[*]" ,DISKREADOPS1, 0, "hda"},
{"disk_read_ops5[*]" ,DISKREADOPS5, 0, "hda"},
@@ -261,6 +288,17 @@ COMMAND parameters_specific[]=
{"disk_write_blks5[*]" ,DISKWRITEBLKS5, 0, "hda"},
{"disk_write_blks15[*]" ,DISKWRITEBLKS15, 0, "hda"},
+/****************************************
+ Don't work, see solaris/diskio.c
+
+ {"disk_read_ops[*]" ,DISKREADOPS, 0, "hda"},
+ {"disk_read_kbs[*]" ,DISKREADBLOCKS, 0, "hda"},
+ {"disk_write_ops[*]" ,DISKWRITEOPS, 0, "hda"},
+ {"disk_write_kbs[*]" ,DISKWRITEBLOCKS, 0, "hda"},
+ {"disk_busy[*]" ,DISKBUSY, 0, "hda"},
+ {"disk_svc[*]" ,DISKSVC, 0, "hda"},
+***************************************/
+
{"sensor[temp1]" ,SENSOR_TEMP1, 0, 0},
{"sensor[temp2]" ,SENSOR_TEMP2, 0, 0},
{"sensor[temp3]" ,SENSOR_TEMP3, 0, 0},
@@ -312,11 +350,6 @@ COMMAND parameters_specific[]=
#endif
-/* {"tcp_count" ,EXECUTE, 0, "netstat -tn|grep EST|wc -l"}, */
-
- {"net[listen_23]" ,TCP_LISTEN, 0, "0017"},
- {"net[listen_80]" ,TCP_LISTEN, 0, "0050"},
-
{"check_port[*]" ,CHECK_PORT, 0, "80"},
{"check_service[*]" ,CHECK_SERVICE, 0, "ssh,127.0.0.1,22"},
diff --git a/src/libs/zbxsysinfo/solaris/swap.c b/src/libs/zbxsysinfo/solaris/swap.c
index 52b209a8..15970dd3 100644
--- a/src/libs/zbxsysinfo/solaris/swap.c
+++ b/src/libs/zbxsysinfo/solaris/swap.c
@@ -137,14 +137,18 @@
#include "md5.h"
+
+#if 1
+
/* Solaris. */
+
#ifndef HAVE_SYSINFO_FREESWAP
#ifdef HAVE_SYS_SWAP_SWAPTABLE
void get_swapinfo(double *total, double *fr)
{
register int cnt, i, page_size;
/* Support for >2Gb */
-/* register int t, f;*/
+/* register int t, f; */
double t, f;
struct swaptable *swt;
struct swapent *ste;
@@ -166,7 +170,7 @@ void get_swapinfo(double *total, double *fr)
swt->swt_n = cnt;
/* fill in ste_path pointers: we don't care about the paths, so we
-point them all to the same buffer */
+ point them all to the same buffer */
ste = &(swt->swt_ent[0]);
i = cnt;
while (--i >= 0)
@@ -236,6 +240,8 @@ int SYSTEM_SWAP_FREE(const char *cmd, const char *parameter,double *value)
#endif
}
+
+
int SYSTEM_SWAP_TOTAL(const char *cmd, const char *parameter,double *value)
{
#ifdef HAVE_SYSINFO_TOTALSWAP
@@ -268,6 +274,102 @@ int SYSTEM_SWAP_TOTAL(const char *cmd, const char *parameter,double *value)
#endif
#endif
}
+#endif
+
+#if 0
+static int get_swap_data(
+ uint64_t *resv,
+ uint64_t *avail,
+ uint64_t *free
+ )
+{
+ kstat_ctl_t *kc;
+ kstat_t *ksp;
+ vminfo_t *vm;
+
+ uint64_t oresv;
+ uint64_t ofree;
+ uint64_t oavail;
+
+ int result = SYSINFO_RET_FAIL;
+ int i;
+
+ kc = kstat_open();
+ if (kc)
+ {
+ ksp = kstat_lookup(kc, "unix", 0, "vminfo");
+ if ((ksp) && (kstat_read(kc, ksp, NULL) != -1))
+ {
+ vm = (vminfo_t *) ksp->ks_data;
+#if 0
+ *resv = vm->swap_resv;
+ *free = vm->swap_free;
+ *avail = vm->swap_avail;
+
+ result = SYSINFO_RET_OK;
+#else
+ oresv = vm->swap_resv;
+ ofree = vm->swap_free;
+ oavail = vm->swap_avail;
+
+ for (i = 0; i < 12; i++)
+ {
+ usleep(100000);
+ if (kstat_read(kc, ksp, NULL) != -1)
+ {
+ vm = (vminfo_t *) ksp->ks_data;
+ if ((oresv != vm->swap_resv) || (ofree != vm->swap_free) || (oavail != vm->swap_avail))
+ {
+ *resv = vm->swap_resv - oresv;
+ *free = vm->swap_free - ofree;
+ *avail = vm->swap_avail - oavail;
+
+ result = SYSINFO_RET_OK;
+ break;
+ }
+ }
+ }
+#endif
+ }
+ kstat_close(kc);
+ }
+ return result;
+}
+
+int SYSTEM_SWAP_FREE(const char *cmd, const char *param, double *value)
+{
+ int result;
+ uint64_t resv = 0;
+ uint64_t avail =0;
+ uint64_t free = 0;
+
+ result = get_swap_data(&resv, &avail, &free);
+
+ if (result == SYSINFO_RET_OK)
+ {
+ *value = free * sysconf(_SC_PAGESIZE);
+ }
+ return result;
+}
+
+int SYSTEM_SWAP_TOTAL(const char *cmd, const char *param, double *value)
+{
+ int result;
+ uint64_t resv = 0;
+ uint64_t avail =0;
+ uint64_t free = 0;
+ uint64_t swap_total_bytes = 0;
+
+ result = get_swap_data(&resv, &avail, &free);
+
+ if (result == SYSINFO_RET_OK)
+ {
+ swap_total_bytes = (resv + avail) * sysconf(_SC_PAGESIZE);
+ *value = (double) swap_total_bytes;
+ }
+ return result;
+}
+#endif
#define DO_SWP_IN 1
#define DO_PG_IN 2
diff --git a/src/libs/zbxsysinfo/solaris/uptime.c b/src/libs/zbxsysinfo/solaris/uptime.c
index 9455bef2..d739dc26 100644
--- a/src/libs/zbxsysinfo/solaris/uptime.c
+++ b/src/libs/zbxsysinfo/solaris/uptime.c
@@ -135,6 +135,36 @@
#include "common.h"
#include "sysinfo.h"
+#if 1
+int SYSTEM_UPTIME(const char *cmd, const char *param,double *value)
+{
+ kstat_ctl_t *kc;
+ kstat_t *kp;
+ kstat_named_t *kn;
+
+ time_t now;
+
+ int result = SYSINFO_RET_FAIL;
+
+ kc = kstat_open();
+
+ if (kc)
+ {
+ kp = kstat_lookup(kc, "unix", 0, "system_misc");
+ if ((kp) && (kstat_read(kc, kp, 0) != -1))
+ {
+ kn = (kstat_named_t*) kstat_data_lookup(kp, "boot_time");
+ time(&now);
+ *value=difftime(now, (time_t) kn->value.ul);
+ result = SYSINFO_RET_OK;
+ }
+ kstat_close(kc);
+ }
+ return result;
+}
+#endif
+
+#if 0
int SYSTEM_UPTIME(const char *cmd, const char *parameter,double *value)
{
#ifdef HAVE_SYSINFO_UPTIME
@@ -215,3 +245,5 @@ int SYSTEM_UPTIME(const char *cmd, const char *parameter,double *value)
#endif
#endif
}
+#endif
+