summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d8577e1)
raw | patch | inline | side by side (parent: d8577e1)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Tue, 17 Jun 2008 14:19:17 +0000 (14:19 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Tue, 17 Jun 2008 14:19:17 +0000 (14:19 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2012 f882894a-f735-0410-b71e-b25c423dba1c
plugins-root/pst3.c | patch | blob | history |
diff --git a/plugins-root/pst3.c b/plugins-root/pst3.c
index ee1d180e0a12566104f4c348dbfb8659508bd763..641a9b86bf8368cddfe80413f2f8da3437aa5e13 100644 (file)
--- a/plugins-root/pst3.c
+++ b/plugins-root/pst3.c
* Prototypes
*/
-static int output_info(struct proc *proc_kvm, psinfo_t procinfo,char **proc_argv);
-static psinfo_t get_procinfo(struct proc *proc);
-static int HandleProc(struct proc *proc);
+static void output_info(struct proc *proc_kvm,char **proc_argv);
+static void HandleProc(struct proc *proc);
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
-static int HandleProc(struct proc *proc)
+static void HandleProc(struct proc *proc)
{
struct pid pid;
struct user *user;
- psinfo_t procinfo;
- char **proc_argv = 0;
+ char **proc_argv = NULL;
if(kvm_kread(kd, (unsigned long) proc->p_pidp, (char *) &pid, sizeof pid) == -1) {
perror("kvm_read error");
user = kvm_getu(kd, proc);
if(kvm_getcmd(kd, proc, user, &proc_argv, NULL) == -1) {
- return FAIL;
+ return;
+ }
+
+ if(proc_argv == NULL) {
+ return;
}
- procinfo = get_procinfo(proc);
- return output_info(proc, procinfo, proc_argv);
+ output_info(proc, proc_argv);
+ free(proc_argv);
}
-static psinfo_t get_procinfo(struct proc *proc)
+static void output_info(struct proc *proc_kvm, char **proc_argv)
{
char procpath[MAX_PATH];
psinfo_t procinfo;
int fd, len;
+ char *procname;
+ int i;
- sprintf(procpath, "/proc/%d/psinfo", proc->p_pidp->pid_id);
+ sprintf(procpath, "/proc/%d/psinfo", proc_kvm->p_pidp->pid_id);
if ((fd = open(procpath, O_RDONLY)) >= 0)
{
if ((len = read(fd, &procinfo, sizeof(procinfo))) != sizeof(procinfo))
{
- fprintf(stderr,"%s: Read error of psingo structure (%d)\n", procpath, len);
+ fprintf(stderr,"%s: Read error of psinfo structure (%d)\n", procpath, len);
exit(2);
}
close(fd);
}
- return procinfo;
-
-}
-
-static int output_info(struct proc *proc_kvm, psinfo_t procinfo, char **proc_argv)
-{
- char *procname;
- int i;
if((procname = strrchr(proc_argv[0], '/')) != NULL)
procname++;
@@ -216,7 +212,5 @@ static int output_info(struct proc *proc_kvm, psinfo_t procinfo, char **proc_arg
}
printf("\n");
-
- return OK;
}